Aperture UI
Content development

Fonts

Loading fonts with @font-face, system and bundled fonts, fallback, GPU vector glyph rendering and the glyph atlas in Aperture UI.

Aperture UI has its own text stack and does not use the platform's. Skribidi, a text library built on HarfBuzz, SheenBidi and libunibreak, shapes runs (including complex scripts such as Arabic, CJK and Indic), applies the Unicode bidirectional algorithm and wraps text when it is given a width. In inline layout, the break opportunities come from ICU's Unicode line-break (UAX #14) iterator. Fonts come from your content, from a bundled fallback set and, on Windows, from the system.

Two Ways to Draw Glyphs

Shaped glyphs reach your renderer by one of two routes. The backend you use must handle the route that is on. Rendering backends has the details.

GPU vector glyph rendering is the default. The engine hands the GPU each glyph's outline as curve data, and the pixel shader works out coverage for every pixel. Because it draws from outlines, it needs no bitmap per font size. Color emoji in COLRv1 fonts take this route too. The backend has to upload the curve buffers and run the matching shader code.

The glyph atlas is the other route. Glyphs are rasterized on the CPU into atlas pages that the backend uploads as textures, and text is drawn from them. A host turns it on for all text with FontEngineBridge::SetVectorGlyphRenderingEnabled(false), and the Unreal plugin has a setting for it. Color emoji that exist only as bitmaps, such as those in CBDT or sbix fonts, always use the atlas, even while vector rendering is on.

Loading Fonts via @font-face

The standard CSS @font-face rule is supported:

@font-face {
  font-family: "GameDisplay";
  src: url("fonts/game-display.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "GameDisplay";
  src: url("fonts/game-display-bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
}

body {
  font-family: "GameDisplay", sans-serif;
}
  • Paths. url() resolves against the stylesheet and loads through IAPCFileSystem, so it must stay inside the roots described in File system.
  • A src list is a fallback chain. The engine tries the url() candidates in order and the first file that loads wins. WOFF2 candidates are tried last. A local() source is not looked up on the system: a rule whose src holds only local() registers nothing, so list a url().
  • Weights and styles. Give each weight and each style its own font file, in its own @font-face rule with the same font-family. The engine chooses between the faces of a family by the weight, style and width that each font file reports about itself. It reads the font-weight and font-style descriptors but does not use them to pick a face, so a regular file declared font-weight: 700 is not treated as the bold face. A bold request then draws synthesized bold from it, where Chrome would use the file as it is. The engine synthesizes bold when a bold weight is requested, and oblique when italic is requested, and the face it chose is neither. font-synthesis: none turns that off.
  • unicode-range. It restricts what a face covers and is applied, so a font stack falls through to the next family for the characters outside the range.
  • A fixed number of families. The engine keeps a fixed pool of custom font families. All weights and styles of one family name share a single entry. Once the pool is used up, further families fall back to the generic sans-serif, so declare the families a screen uses and not every font your game owns.

Supported font formats

FormatStatus
TrueType (.ttf)Supported
OpenType (.otf)Supported
WOFFSupported. Decompressed when the font loads.
WOFF2Supported. Decoded when the font loads. A test page checks that a WOFF2 web font sets the width of text.
Embedded OpenType (.eot)Not supported

For shipping games, prefer TTF or OTF. WOFF and WOFF2 give a smaller download, but Aperture UI loads from your local asset pipeline, so the size benefit does not apply, and the engine has to decompress the file before it can use it.

System Fonts

Named system-font resolution is only implemented on Windows. There the engine registers common system fonts by their CSS names when the files exist under C:/Windows/Fonts: Arial, Helvetica, Verdana, Tahoma, Segoe UI, Times New Roman, Times, Georgia, Courier New and Consolas, with their bold and italic faces. The generic keywords map to them: sans-serif to Arial, serif to Times New Roman, monospace to Consolas and system-ui to Segoe UI.

On every other platform, including consoles, there is no system font lookup. serif and monospace fall back to the bundled sans-serif, and a named family such as Arial is not found. On consoles, there are no OS font directories: every font your UI uses must be bundled with your game.

For portability, do not rely on system fonts. Bundle the fonts you need, on every platform.

The Bundled Fallback Set

Every build configuration loads a default fallback set from the package's data/Base/Fonts folder: an IBM Plex Sans family, fonts for several other scripts, and emoji fonts. Copy data/ next to your executable (see Requirements) or the engine logs that text may not render. This set is a fallback, not a design font.

Font Fallback

For each character, the shaper tries the families in your font-family list in order, then the other registered faces that cover it. If nothing covers a script, the engine on Windows loads a system font for that script from a fixed list under C:/Windows/Fonts, once per script. Elsewhere there is no such step, and the character draws as the font's missing-glyph box (.notdef). Bundle a broad-coverage family (Noto Sans or similar) for every script you ship, and add a CJK font after your Latin ones:

body {
  font-family: "GameDisplay", "NotoSansCJK", sans-serif;
}

The Font Atlas

On the atlas route, glyphs live in a GPU texture. It starts at a fixed size, grows in height only up to a fixed ceiling, and evicts glyphs that have not been used for a while. There is no public API to size it, and its limits are a hardcoded part of the engine, not something application code can raise. The atlas fills faster when:

  • You ship CJK languages (Chinese, Japanese, Korean), where the glyph count is large
  • You use many distinct font sizes, since each size produces different glyphs
  • You use multiple font-family values in the same view

Under pressure the atlas has to evict glyphs and rasterize them again when they return, which costs time. The vector route has no atlas for outline glyphs. Fewer distinct sizes and families keep either route cheaper. See Rendering performance.

Internationalization

Unicode shaping is handled by Skribidi, not ICU. ICU is used elsewhere in Aperture UI: for the JavaScript engine's Intl support, which is what resources/v8_icudtl.dat is loaded for, for the break opportunities in inline layout, and for charset detection in IAPCFileSystem::FileCharset. It plays no part in font shaping or the bidirectional algorithm.

Complex scripts such as Arabic, Devanagari, Tamil, Thai and Khmer shape correctly when the font has the OpenType tables the script needs. Bundle a font with the required Unicode ranges. The Noto Sans family is a safe default for broad coverage. CJK ideographs draw from the font's glyphs, and mixed Latin and CJK content walks the fallback list above. Localization covers right-to-left text, the lang attribute and the Intl data files.

document.fonts

document.fonts exists so that libraries that probe it do not throw, but it does not report real font state. status is always "loaded", ready is a resolved promise, check() always returns true and load() resolves at once with an empty array. Do not use it to detect whether a font loaded. Look at the engine log, or render a test string and measure it.

Troubleshooting

SymptomLikely cause
Boxes (.notdef) where characters should beNo registered font covers the character. Add one to the family list or bundle it.
Arabic or Indic letters drawn but not joinedThe font lacks the OpenType tables for the script
serif or monospace look like sans-serifNot on Windows, so only the bundled sans-serif exists
A named family such as Arial is ignoredNot on Windows, or the font file is missing. Declare it with @font-face.
Bold or italic looks faked or slantedThe family has no font file that reports that weight or style, so the engine synthesizes it. Add a real file in its own @font-face rule, or set font-synthesis: none.
A font does not loadThe path failed containment or the file is missing. Turn on the engine log.
A font declared only with local() is missinglocal() is not looked up. Declare a url().
Text stutters on the atlas routeThe atlas may be under pressure. Cut sizes, families or character sets.
Text differs slightly from ChromeA different text engine draws it. Layout geometry is what the tests compare.

Upgrading to 26.08.0.1

This release corrects inline kerning, font metrics and input text/caret alignment. Recheck text against bundled fonts; older compensating CSS offsets may now be wrong. Test fallback characters, mixed sizes, adjacent inline spans and localized controls. Update font rendering data and shaders from the same SDK package.

On this page