Documentation
¶
Overview ¶
Package font reads font programs and returns glyph outlines and metrics. It knows nothing about PDF: a font is bytes in, outlines out.
Index ¶
- Variables
- func AddFontDir(dir string)
- func BidiLevels(text []rune, base int) []byte
- func BidiMirror(r rune) rune
- func BidiOrder(levels []byte) []int
- func Encoding(name string) *[256]string
- func IndexForName(name string) int
- func MacGlyphName(i int) string
- func MacRomanCode(r rune) int
- func NeedsBidi(s string) bool
- func NeedsShaping(s string) bool
- func RuneForName(name string) rune
- func StandardEncoding() *[256]string
- func StandardName(name string, serif, fixed, symbolic, bold, italic bool) string
- func StandardWidth(font, glyph string) float64
- func Upright(r rune) bool
- type Font
- func (f *Font) Advance(gid int) float32
- func (f *Font) BuiltinEncoding() *[256]string
- func (f *Font) DebugLayout() string
- func (f *Font) GIDForMacCode(code uint32) int
- func (f *Font) GIDForName(name string) int
- func (f *Font) GIDForRune(r rune) int
- func (f *Font) GIDForSymbolCode(code uint32) int
- func (f *Font) GlyphName(gid int) string
- func (f *Font) GlyphPath(gid int) *raster.Path
- func (f *Font) HasCmap() bool
- func (f *Font) HasGlyphNames() bool
- func (f *Font) NumGlyphs() int
- func (f *Font) Shape(text []rune, rtl bool) []Glyph
- func (f *Font) Shaped() bool
- type Glyph
- type Kind
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalid means the font program is damaged past use. ErrInvalid = errors.New("font: invalid font") // ErrUnsupported means the format is known but not handled. ErrUnsupported = errors.New("font: unsupported font") )
Errors returned by this package.
Functions ¶
func AddFontDir ¶
func AddFontDir(dir string)
AddFontDir adds a directory to the system font search. It must be called before the first look-up.
func BidiLevels ¶
BidiLevels is the UAX #9 embedding level of every character of one paragraph. base is 0 for left to right, 1 for right to left, negative to take it from the text.
func BidiMirror ¶
BidiMirror is the mirrored form rule L4 draws for r, or r when it has none.
func IndexForName ¶
IndexForName reads the gXX, GXX, glyphXX and cidXX conventions, which name a glyph by its number rather than by what it looks like.
func MacGlyphName ¶
MacGlyphName is the name of the glyph at index i of the standard Macintosh ordering.
func MacRomanCode ¶
MacRomanCode returns the MacRoman code of a character, or -1.
func NeedsShaping ¶
NeedsShaping reports text a font has to lay out itself.
func RuneForName ¶
RuneForName resolves a glyph name to a character through the Adobe Glyph List and the conventions that stand in for it: uniXXXX, uXXXX, a suffix after a dot, and a single character name.
func StandardEncoding ¶
func StandardEncoding() *[256]string
StandardEncoding is the encoding a simple font falls back to.
func StandardName ¶
StandardName maps a font name onto one of the fourteen, using the flags of the font descriptor to choose when the name says nothing. It returns "" for a name that cannot be resolved, which is never: Helvetica is last.
func StandardWidth ¶
StandardWidth returns the advance a base-14 font gives a glyph name, in units of a thousandth of an em, or -1.
Types ¶
type Font ¶
type Font struct {
Kind Kind
// Name is the name the program gives itself.
Name string
// Family is the family the program belongs to.
Family string
// Weight is the usWeightClass, 400 by default, and Italic whether it is slanted.
Weight int
Italic bool
// UnitsPerEm is the glyph space of a TrueType font.
UnitsPerEm int
// Matrix maps glyph space to text space, where one unit is the font size.
Matrix raster.Matrix
// Ascent and Descent are the em box extents above and below the baseline, in text space.
Ascent, Descent float32
// XHeight, SubOffset and SuperOffset are SFNT metrics in text space, zero when absent.
XHeight, SubOffset, SuperOffset float32
// CID is true for a CID keyed CFF font.
CID bool
// contains filtered or unexported fields
}
Font is a font program.
func Standard ¶
Standard returns one of the fourteen fonts by its canonical name, or nil. One Font is kept per name and shared by every document that asks for it, which is what makes the base fourteen cost their glyph outlines once for the life of the process rather than once a document.
func SystemFont ¶
SystemFont returns the face nearest a weight and slant the machine has for a family, or nil.
func (*Font) BuiltinEncoding ¶
BuiltinEncoding returns the code to glyph name table the program carries, or nil.
func (*Font) DebugLayout ¶
DebugLayout reports what the layout tables of a font hold.
func (*Font) GIDForMacCode ¶
GIDForMacCode looks a byte code up in a (1,0) Mac Roman character map.
func (*Font) GIDForName ¶
GIDForName returns the glyph with a name, or -1.
func (*Font) GIDForRune ¶
GIDForRune looks a Unicode value up in the font's character map, or -1.
func (*Font) GIDForSymbolCode ¶
GIDForSymbolCode looks a byte code up in a (3,0) symbol character map.
func (*Font) GlyphPath ¶
GlyphPath returns the outline of a glyph in glyph space, owned by the font. A CID keyed CFF is addressed by CID.
func (*Font) HasGlyphNames ¶
HasGlyphNames reports whether the program names its glyphs.
Source Files
¶
- arabic_tables.go
- bidi.go
- bidi_tables.go
- brotli.go
- brotli_tables.go
- cff.go
- cffstrings_tables.go
- charstring.go
- decomp_tables.go
- encoding.go
- encodings_tables.go
- font.go
- glyf.go
- glyphlist_tables.go
- gpos.go
- gsub.go
- indic.go
- indic_tables.go
- macnames_tables.go
- mark_tables.go
- metrics_tables.go
- otlayout.go
- otmatch.go
- script.go
- sfnt.go
- shape.go
- stdfonts.go
- stdfonts_tables.go
- system.go
- t1charstring.go
- type1.go
- vertical.go
- vertical_tables.go
- woff.go
- woff2.go