Documentation ¶
Index ¶
- func HBSubset(src []byte, cutset map[rune]struct{}) ([]byte, error)
- func HBSubsetC(src []byte, charset map[rune]struct{}) ([]byte, error)
- func HBSubsetPath(path string, cutset map[rune]struct{}) ([]byte, error)
- func TTFSubset(f *sfnt.Font, src []byte, cutset map[rune]struct{}) ([]byte, error)
- type BasicSubsetter
- type HarfBuzzCGoSubsetter
- type HarfBuzzSubsetter
- type TableTag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HBSubset ¶
HBSubset returns the source bytes of a font containing only the characters included in the cutset. For this function to work, the HarfBuzz hb-subsettool must be installed. The HBSubset func may handle edge cases that the TTFSubset func does not. hb-subset has a mature, well-tested API and is capable of handling more font formats than TTFSubset. However, this approach requires os/exec, so it might not be suitable for all environments.
func HBSubsetC ¶
HBSubsetC calls functions in libharfbuzz and libharfbuzz-subset via CGo and returns the source bytes of a font containing only the characters included in the cutset. In order for this function to work, CGo must be enabled, HarfBuzz v>=2.9.0 must be installed on your system, and `hbsubsetc` must be passed to the Go compiler as a build tag.
func HBSubsetPath ¶
HBSubset returns the source bytes of a font containing only the characters included in the cutset. The path parameter represents the path of the source font. This function has the same limitations as HBSubset.
func TTFSubset ¶
TTFSubset is something of a poor man's subsetting function. It works - for TrueType fonts with 'glyf' tables only - by zeroing out the outlines of all glyphs not corresponding to or directly referenced by f's glyphs for the runes in cutset, truncating f's glyf and loca tables, and then writing only the required tables to the returned byte slice. The final subset font contains cmap, glyf, head, hhea, hmtx, loca, and maxp tables. The glyph indices are not affected. src should be a copy of the source bytes for f.
Types ¶
type BasicSubsetter ¶
type BasicSubsetter struct {
// contains filtered or unexported fields
}
type HarfBuzzCGoSubsetter ¶
type HarfBuzzCGoSubsetter struct {
// contains filtered or unexported fields
}
type HarfBuzzSubsetter ¶
type HarfBuzzSubsetter struct {
// contains filtered or unexported fields
}
type TableTag ¶
type TableTag uint32
const ( Cmap TableTag = 'c'<<24 | 'm'<<16 | 'a'<<8 | 'p' Glyf TableTag = 'g'<<24 | 'l'<<16 | 'y'<<8 | 'f' Head TableTag = 'h'<<24 | 'e'<<16 | 'a'<<8 | 'd' Hhea TableTag = 'h'<<24 | 'h'<<16 | 'e'<<8 | 'a' Hmtx TableTag = 'h'<<24 | 'm'<<16 | 't'<<8 | 'x' Loca TableTag = 'l'<<24 | 'o'<<16 | 'c'<<8 | 'a' Maxp TableTag = 'm'<<24 | 'a'<<16 | 'x'<<8 | 'p' )