Skip to main content

Module font_source

Module font_source 

Source
Expand description

Turning app-declared font families into parsed faces.

FontFamily::FileBacked and FontFamily::LoadedTypeface name faces by file rather than by a name inside the font, so something has to read those files and hand the bytes to the rasterizer. That is this module: it parses each face exactly once, at registration, and produces an immutable SoftwareTextFontSet that measurement and rasterization then share.

Nothing here runs per frame or per string. A registry is built at startup, consumed into a font set, and the font set is cloned (it is Arc-backed) into every measurer and rasterizer that needs it.

Fonts that are not files on disk come in through SoftwareTextFontRegistry::register_face_reader or SoftwareTextFontRegistry::register_face_bytes: an APK asset opened with AndroidApp::asset_manager(), or anything cranpose-assets resolved out of a desktop bundle. cranpose-assets is a filesystem path resolver, so it covers bundles but not APK entries, which are not filesystem paths.

Structs§

SoftwareTextFontRegistry
Parsed app-supplied faces, on their way to a SoftwareTextFontSet.

Enums§

FontLoadError
Why an app-supplied face could not be registered.

Constants§

ANDROID_SYSTEM_FONT_DIR
Directory Android keeps its system font files in.
DEFAULT_SYSTEM_FAMILY_WEIGHTS
The weights SoftwareTextFontRegistry::register_system_family registers when an app does not name its own: Compose’s Regular/Medium/Bold set.

Functions§

system_font_file
The file a platform backs family with at weight, if one is present.