ConvertFont
ceramic.ConvertFont (Class)
Implements: ConvertField
Converter for BitmapFont fields in fragments and data serialization.
This converter handles BitmapFont instances by storing and loading them using asset names. During deserialization, fonts are loaded from the asset system asynchronously. The default font is handled as a special case to avoid unnecessary loading.
Instance Members
Convert a font asset name to a BitmapFont instance.
Special handling:
- If the name matches the default font, returns it immediately
- Otherwise loads the font asset asynchronously
- Returns null if the asset name is null or loading fails
Name | Type | Description |
---|---|---|
instance |
Entity | The entity that will use this font |
field |
String | The name of the field being converted |
assets |
Assets | Assets instance used to load the font |
basic |
String | The font asset name to load |
done |
Function | Callback invoked with the loaded BitmapFont instance |
fieldToBasic(instance: Entity, field: String, value: BitmapFont): String
Convert a BitmapFont instance to its asset name for serialization.
Name | Type | Description |
---|---|---|
instance |
Entity | The entity that owns this font |
field |
String | The name of the field being converted |
value |
BitmapFont | The BitmapFont instance to convert |
Returns | Description |
---|---|
String | The font's asset name, or null if the font or its asset is null |
new(): Void
Create a new font converter instance.