Advertisement
  1. Web Design
  2. Web Typography
Webdesign

The Future of Web Typography: CSS Fonts Level 4

Web fonts helped to breathe life into designs, helping us avoid the system defaults so widely used during the early days of web design. With so many options available today, we as have plenty of tricks up our sleeves in order to serve and style custom fonts. Level 4 of the CSS Fonts Module outlines more intriguing options you will love, including some exciting properties such as font-min/max-size. This article won’t uncover every last crumb of level 4, but will highlight the interesting parts still in their infancy. The adventure starts now!

The Status Quo

Currently we sit between two levels of specs. On one side we have level 3; a spec that has been at “Candidate Recommendation” since October 2013. Looking ahead we have level 4; a spec that has been resting at “Working Draft” since July 2017. If you’re in need of a reminder regarding the order of W3C specification stages, let’s take a moment to review them:

  1. Working Draft (WD): Published for review by the community, including W3C Members, the public, and other technical organizations. Does not represent a consensus of the Working Group nor imply any endorsement by W3C.
  2. Candidate Recommendation (CR): Widely reviewed and ready for implementation. Doesn’t imply endorsement by W3C. Signals to the wider community that it’s time to carry out a final review.
  3. Proposed Recommendation (PR): A mature technical report sent to the W3C Advisory Committee for final endorsement.
  4. W3C Recommendation (REC): Receives endorsement from W3C Members and the Director. Recommends wide deployment of specification guidelines.

Now that we understand the specification stages let’s dive into the guts of level 4 and bring to light some of the known and documented features new to this module.

Fonts Module Level 4

Parts of level 3 that become standardized will be ported into level 4, but level 4 will also include its own unique additions. Sections such as Font Variations, Font Rendering Controls, Color Font Support, Basic Font Properties and Font Resources will contain brand-new items many developers will find useful.

Basic Font Properties

The particular font face rendered is determined by the font-family and other font properties that apply to a given element, such as font-weight and font-style for example. This structure allows settings to vary independently of each other and what encompasses Basic Font Properties. So what’s planned for this group?

📌  font-min-size and font-max-size

Out of everything outlined in level 4, these two properties are my favorite because both will permit an element’s font-size to become “clamped” between the values supplied. This is certainly super awesome news for responsive design fans. The values can be an absolute size, a relative size or length percentage.

There isn’t any documentation at this time that notes how the browser’s resize event triggers either property, and if you’re looking to experiment with this feature using the experimental web platform features flag in Chrome you’re out of luck.

Font Resources

The majority of items outlined in this section help to control aspects that pertain to fetching, referencing and displaying the font-family of your choosing.

📌  font-display

This property determines how a font face is displayed, based on if and when it’s been downloaded and ready to use by the browser. It’s also intended for use within your @font-face or @font-feature-values declaration.

  • auto: The font display policy is user-agent-defined (i.e. the browser) unless defined within CSS explicitly.
  • block: Gives the font face a short block period (3s is recommended in most cases) and an infinite swap period.
  • swap: Gives the font face a 0s block period and an infinite swap period.
  • fallback: Gives the font face an extremely small block period (100ms or less is recommended in most cases) and a short swap period (3s is recommended in most cases).
  • optional: Gives the font face an extremely small block period (100ms or less is recommended in most cases) and a 0s swap period.

For anyone paying close attention to web font performance and who is busy on a daily basis debating FOUT or FOIT, then this property will make you extremely pleased.

📌  @font-feature-values

When font-display is omitted in a @font-face rule, the user agent uses the font-display value set via @font-feature-values for the relevant font-family if one is set, otherwise it defaults to font-display: auto. See previous explanation regarding font-display values.

The ruleset is perfect for cases when a font is served via a third-party and you don’t have control over the @font-face rules, but are still able to set a default font-display policy for the provided font-family. This is good news for those building sites with non-stop third party action.

While still new and somewhat vague, I can only assume in order to control a particular font-family display behavior, the developer must use the font-family property within this ruleset in order to target the desired font. Again, this is only an assumption on my part and not factual by any means.

Font Variations

This section is 100% new and specific to level 4. Most of the features currently documented pertain to the sizing and settings of each font face.

📌  font-optical-setting

This property is used in order to maintain stylistic traits and improve readability at different optical sizes. With digital type we have the ability to scale a font to any size, but this doesn’t take into account the appearance of type at these varying sizes.

“Text that is rendered at different sizes often benefits from slightly different visual representations. For example, to aid reading at small text sizes, strokes are often thicker with larger serifs. Larger text often has a more delicate figure with more contrast between thicker and thinner strokes.” ~ Level 4 Working Draft
  • auto: The user agent may modify the shape of glyphs based on the font-size and the pixel density of the screen. For OpenType and TrueType fonts using font variations, this is often done by using the opsz font variation.
  • none: The user agent must not modify the shape of glyphs for optical size.

📌  font-variation-settings

This property provides low-level control over OpenType or TrueType font variations. It is intended as a way of providing access to font variations that aren’t widely used, but are needed for a particular use case.

  • normal: Text is laid out using default settings.
  • <string> <number>: When rendering text, the list of OpenType axis names is passed to the text layout engine to enable or disable font features. Each setting is always a <string> of 4 ASCII characters, followed by a <number> indicating the axis value. If the <string> has more or fewer characters or contains characters outside the U+20 - U+7E code point range, the whole property is invalid. The <number> can be fractional or negative.

The string value used in the code above is known as the four letter axis name that describes the feature you desire to vary, along with the variation value typically ranging from 0-1, but can also be negative values where required. The variations allowed will always depend on the font face chosen.

Color Font Support

Color Fonts are brand-new to level 4 and allow font files to describe not just the contours describing edges of glyphs, but also the colors present inside the glyphs. Why would you want to use any of these features? I suggest reading this article by Grace Fussell to get up to speed:

📌  font-palette

Many color font file formats allow colors within glyphs to be parameterized. In these fonts, colors are referenced by index when describing the geometry of each glyph. These indices are resolved within a current active palette using a lookup table present inside the font. However, many fonts contain multiple palettes, each containing a set of complementary colors chosen by the font designer to provide pleasing visual results. Developers can define a palette by using the @font-palette-values rule mentioned in the next section.

📌  @font-palette-values

This represents a palette of colors used in a font. It defines a color palette and associates that color palette with a specific font. This allows a web author to select arbitrary colors to use inside a color font rather than being limited to the preexisting palettes inside font files

📌  font-presentation

This property allows web authors to select whether emoji presentation or text presentation is used for certain emoji code points. A huge win for emoji fanatics 😎

Conclusion

There are certainly plenty of exciting new features coming down the pipeline for web fonts and I encourage you to start experimenting with your favorites as they become available. If you have a particular favorite from level 4 or even level 3 let us know in the comments including any opinions you may have regarding the features we’ve discussed.

I also suggest that developers to look into the css-font-loading spec if loading performance is something you care deeply about. You can monitor support as adoption is fairly decent across browser vendors. Enjoy the new era of web fonts and happy coding!

Advertisement
Advertisement
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.