FontLoader class

Registry for font files used in pure Dart text rendering.

Since pure_ui runs outside of Flutter, there is no system font registry. Use FontLoader to register TTF/OTF font files by family name before rendering text with ParagraphBuilder.

Example:

// Register from raw bytes
final bytes = File('/path/to/Roboto-Regular.ttf').readAsBytesSync();
FontLoader.load('Roboto', bytes);

// Register from a file path
FontLoader.loadFromFile('Roboto', '/path/to/Roboto-Bold.ttf',
  weight: FontWeight.bold);

// Then use in paragraph building
final builder = ParagraphBuilder(ParagraphStyle(fontFamily: 'Roboto'));
builder.addText('Hello');

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

families Set<String>
Returns all registered font family names.
no setter

Static Methods

clear() → void
Removes all registered fonts.
getFont(String family, {FontWeight weight = FontWeight.normal, FontStyle style = FontStyle.normal}) Uint8List?
Returns the font bytes for the given family, weight, and style.
hasFamily(String family) bool
Whether any font variant is registered for the given family name.
load(String family, Uint8List bytes, {FontWeight weight = FontWeight.normal, FontStyle style = FontStyle.normal}) → void
Registers a font from raw bytes.
loadFromFile(String family, String filePath, {FontWeight weight = FontWeight.normal, FontStyle style = FontStyle.normal}) → void
Registers a font from a file path.