Repository navigation
v0.8.0
This release loads fonts in WOFF, WOFF2 and EOT, and reads the strings of the name table of a font (D45).
go get github.com/xo/okage@v0.8.0Fonts in a web format
svg.FontDatabase.LoadFontData loads a font in one of these formats:
| Format | What okage does |
|---|---|
| TrueType, OpenType, or a collection of them | Loads the bytes as they are, as before |
| WOFF 1.0 | Inflates each table and writes a TrueType or OpenType file |
| WOFF2 | Decompresses the tables with brotli and reverses the transforms of the tables glyf, loca and hmtx. A WOFF2 collection gives each of its faces |
| EOT | Removes the header, and reverses the XOR of the font data when the header sets it |
FaceData gives the converted bytes. An EOT file that uses MicroType Express compression does not load. LoadFontsFS, LoadSystemFonts and LoadUserFonts still load only .ttf, .ttc, .otf and .otc files, as fontdb does.
svg.ConvertFontData gives the TrueType or OpenType bytes of such a font, for a program that needs the bytes and not a database. Its errors wrap the new sentinel errors okage.ErrFontData, for malformed data, and okage.ErrFontUnsupported, for data in another format.
The brotli decoder is a copy of the one of github.com/dsnet/compress, in internal/brotli, under its BSD-3-Clause license. okage still has no new dependency. The decoder adds about 460 KB to a program that uses svg.
The name table
svg.FontDatabase.FaceName(id, nameID) returns the string of a name ID of the name table of a face, such as 4 for the full name, 5 for the version and 19 for the sample text. It takes the record in English (United States) first.