Properties
Static cache
cache: boolean = false
Static loaders
loaders: any = []
Static path
path: string = "/font/"
Static version
version: number = 0
Methods
Static getFont
- getFont(name: string): Font
Static isLoaded
- isLoaded(name: string): boolean
-
Parameters
Returns boolean
Static load
- load(target: any, fonts: string[]): void
-
Parameters
-
target: any
-
fonts: string[]
Returns void
Static loadFont
- loadFont(fontName: string, loader: any): void
-
Parameters
-
fontName: string
-
loader: any
Returns void
Fetches font files via AJAX request, and parses the font into glyphs, and stores it. Local storage is optionally used for caching.
Font files store font data, grouped by categories:
0
= Font properties:0|property name|property value
1
= Glyph SVG shape data:1|?|?|SVGPath data
2
= Kerning spacing:2|?|?|?
3
= Ligatures:3
Each line in a category of data is delineated with pipe characters "|".
Partial example:
0|id|Abel-Regular 0|family|Abel 1|33|428|M250 434h-72l-55 1000h182zM137 0v154h154v-154h-154z 1|34|645|M225 993h-51l-51 441h153zM471 993h-51l-51 441h153z 2|34|197|123 2|47|100|102 3
This class should be split into FontLoader (AJAX fetch), FontParser (deserialisation), and probably a FontStorage class.