Documentation ¶
Index ¶
- Constants
- func LoadHeadTable(ld *loader.Loader, buffer []byte) (tables.Head, []byte, error)
- func LoadHmtx(ld *loader.Loader, numGlyphs int) (*tables.Hhea, tables.Hmtx, error)
- type AATStateTable
- type Face
- func (f *Face) FontHExtents() (api.FontExtents, bool)
- func (f *Face) FontVExtents() (api.FontExtents, bool)
- func (f *Face) GlyphData(gid GID) api.GlyphData
- func (f *Face) GlyphExtents(glyph GID) (api.GlyphExtents, bool)
- func (f *Face) GlyphVOrigin(glyph GID) (x, y int32, found bool)
- func (f *Face) HorizontalAdvance(gid GID) float32
- func (f *Face) LineMetric(metric api.LineMetric) float32
- func (face *Face) SetVariations(variations []Variation)
- func (f *Face) VerticalAdvance(gid GID) float32
- type Feature
- type Font
- func (font *Font) BitmapSizes() []api.BitmapSize
- func (f *Font) GetGlyphContourPoint(glyph GID, pointIndex uint16) (x, y int32, ok bool)
- func (f *Font) GlyphHOrigin(GID) (x, y int32, found bool)
- func (f *Font) GlyphName(glyph GID) string
- func (f *Font) HasVerticalMetrics() bool
- func (f *Font) NominalGlyph(ch rune) (GID, bool)
- func (f *Font) NormalizeVariations(coords []float32) []VarCoord
- func (f *Font) Upem() uint16
- func (f *Font) VariationGlyph(ch, varSelector rune) (GID, bool)
- type GID
- type GPOS
- type GPOSLookup
- type GSUB
- type GSUBLookup
- type Kern0
- type Kern1
- type Kern2
- type Kern3
- type Kern4
- type Kern6
- type KernSubtable
- type Kernx
- type Layout
- type LookupOptions
- type Morx
- type MorxChain
- type MorxContextualSubtable
- type MorxInsertionSubtable
- type MorxLigatureSubtable
- type MorxNonContextualSubtable
- type MorxRearrangementSubtable
- type MorxSubtable
- type Script
- type SimpleKerns
- type Tag
- type VarCoord
- type Variation
Constants ¶
const UseMarkFilteringSet = 1 << 4
Variables ¶
This section is empty.
Functions ¶
func LoadHeadTable ¶
LoadHeadTable loads the table corresponding to the 'head' tag. If a 'bhed' Apple table is present, it replaces the 'head' one.
'buffer' may be provided to reduce allocations; the return Head is guaranteed not to retain any reference on 'buffer'. If 'buffer' is nil or has not enough capacity, a new slice is allocated (and returned).
Types ¶
type AATStateTable ¶
type AATStateTable struct {
// contains filtered or unexported fields
}
AATStateTable supports both regular and extended AAT state machines
func (*AATStateTable) GetClass ¶
func (st *AATStateTable) GetClass(glyph GID) uint16
GetClass return the class for the given glyph, with the correct default value.
func (*AATStateTable) GetEntry ¶
func (st *AATStateTable) GetEntry(state, class uint16) tables.AATStateEntry
GetEntry return the entry for the given state and class, and handle invalid values (by returning an empty entry).
type Face ¶
type Face struct { *Font // Coords are the current variable coordinates, expressed in normalized units. // It is empty for non variable fonts. // Use `SetVariations` to convert from design (user) space units. Coords []tables.Coord // Horizontal and vertical pixels-per-em (ppem), used to select bitmap sizes. XPpem, YPpem uint16 }
Face is a font with user-provided settings. It is a lightweight wrapper around *Font, NOT safe for concurrent use.
func (*Face) FontHExtents ¶
func (f *Face) FontHExtents() (api.FontExtents, bool)
FontHExtents returns the extents of the font for horizontal text, or false it not available, in font units.
func (*Face) FontVExtents ¶
func (f *Face) FontVExtents() (api.FontExtents, bool)
FontVExtents is the same as `FontHExtents`, but for vertical text.
func (*Face) GlyphExtents ¶
func (f *Face) GlyphExtents(glyph GID) (api.GlyphExtents, bool)
func (*Face) HorizontalAdvance ¶
func (*Face) LineMetric ¶
func (f *Face) LineMetric(metric api.LineMetric) float32
LineMetric returns the metric identified by `metric` (in fonts units).
func (*Face) SetVariations ¶
SetVariations applies a list of font-variation settings to a font, defaulting to the values given in the `fvar` table. Note that passing an empty slice will instead remove the coordinates.
func (*Face) VerticalAdvance ¶
type Font ¶
type Font struct { // Cmap is the 'cmap' table Cmap api.Cmap GDEF tables.GDEF // An absent table has a nil GlyphClassDef Trak tables.Trak Ankr tables.Ankr Feat tables.Feat Ltag tables.Ltag Morx Morx Kern Kernx Kerx Kernx GSUB GSUB // An absent table has a nil slice of lookups GPOS GPOS // An absent table has a nil slice of lookups // contains filtered or unexported fields }
Font represents one Opentype font file (or one sub font of a collection). It is an educated view of the underlying font file, optimized for quick access to information required by text layout engines.
All its methods are read-only and a *Font object is thus safe for concurrent use.
func NewFont ¶
NewFont loads all the font tables, sanitizing them. An error is returned only when required tables 'cmap', 'head', 'maxp' are invalid (or missing). More control on errors is available by using package tables.
func (*Font) BitmapSizes ¶
func (font *Font) BitmapSizes() []api.BitmapSize
BitmapSizes returns the size of bitmap glyphs present in the font.
func (*Font) GetGlyphContourPoint ¶
func (*Font) GlyphName ¶
GlyphName returns the name of the given glyph, or an empty string if the glyph is invalid or has no name.
func (*Font) HasVerticalMetrics ¶
HasVerticalMetrics returns true if a the 'vmtx' table is present. If not, client should avoid calls to [VerticalAdvance], which will returns a defaut value.
func (*Font) NominalGlyph ¶
NominalGlyph returns the glyph used to represent the given rune, or false if not found. Note that it only looks into the cmap, without taking account substitutions nor variation selectors.
func (*Font) NormalizeVariations ¶
NormalizeVariations normalize the given design-space coordinates. The minimum and maximum values for the axis are mapped to the interval [-1,1], with the default axis value mapped to 0.
Any additional scaling defined in the face's `avar` table is also applied, as described at https://docs.microsoft.com/en-us/typography/opentype/spec/avar.
This method panics if `coords` has not the correct length, that is the number of axis inf 'fvar'.
type GPOS ¶
type GPOS struct { Layout Lookups []GPOSLookup }
type GPOSLookup ¶
type GPOSLookup struct { LookupOptions Subtables []tables.GPOSLookup }
type GSUB ¶
type GSUB struct { Layout Lookups []GSUBLookup }
type GSUBLookup ¶
type GSUBLookup struct { LookupOptions Subtables []tables.GSUBLookup }
type Kern0 ¶
type Kern0 []tables.Kernx0Record
type Kern1 ¶
type Kern1 struct { Values []int16 // After successful parsing, may be safely indexed by AATStateEntry.AsKernxIndex() from `Machine` Machine AATStateTable }
type Kern4 ¶
type Kern4 struct { Anchors tables.KerxAnchors Machine AATStateTable // contains filtered or unexported fields }
type KernSubtable ¶
type KernSubtable struct { Data interface { // contains filtered or unexported methods } // IsExtended [true] for AAT `kerx` subtables, false for 'kern' subtables IsExtended bool // 0 for scalar values TupleCount int // contains filtered or unexported fields }
KernSubtable represents a 'kern' or 'kerx' subtable.
func (KernSubtable) IsBackwards ¶
func (k KernSubtable) IsBackwards() bool
IsBackwards returns true if state-table based should process the glyphs backwards.
func (KernSubtable) IsCrossStream ¶
func (k KernSubtable) IsCrossStream() bool
IsCrossStream returns true if the subtable has cross-stream kerning values.
func (KernSubtable) IsHorizontal ¶
func (k KernSubtable) IsHorizontal() bool
IsHorizontal returns true if the subtable has horizontal kerning values.
func (KernSubtable) IsVariation ¶
func (k KernSubtable) IsVariation() bool
IsVariation returns true if the subtable has variation kerning values.
type Kernx ¶
type Kernx []KernSubtable
Kernx represents a 'kern' or 'kerx' kerning table. It supports both Microsoft and Apple formats.
type Layout ¶
type Layout struct { Scripts []Script Features []Feature FeatureVariations []tables.FeatureVariationRecord }
shared between GSUB and GPOS
func (*Layout) FindFeatureIndex ¶
FindFeatureIndex fetches the index for a given feature tag in the GSUB or GPOS table. Returns false if not found
func (*Layout) FindScript ¶
FindScript looks for [script] and return its index into the Scripts slice, or -1 if the tag is not found.
func (*Layout) FindVariationIndex ¶
FindVariationIndex returns the first feature variation matching the specified variation coordinates, as an index in the `FeatureVariations` field. It returns `-1` if not found.
type LookupOptions ¶
type LookupOptions struct { // Lookup qualifiers. Flag uint16 // Index (base 0) into GDEF mark glyph sets structure, // meaningfull only if UseMarkFilteringSet is set. MarkFilteringSet uint16 }
func (LookupOptions) Props ¶
func (lo LookupOptions) Props() uint32
Props returns a 32-bit integer where the lower 16-bit is `Flag` and the higher 16-bit is `MarkFilteringSet` if the lookup uses one.
type MorxChain ¶
type MorxChain struct { Features []tables.AATFeature Subtables []MorxSubtable DefaultFlags uint32 }
type MorxContextualSubtable ¶
type MorxContextualSubtable struct { Substitutions []tables.AATLookup Machine AATStateTable }
type MorxInsertionSubtable ¶
type MorxInsertionSubtable struct { // After successul parsing, this array may be safely // indexed by the indexes and counts from Machine entries. Insertions []GID Machine AATStateTable }
type MorxLigatureSubtable ¶
type MorxLigatureSubtable struct { LigatureAction []uint32 Components []uint16 Ligatures []GID Machine AATStateTable }
type MorxRearrangementSubtable ¶
type MorxRearrangementSubtable AATStateTable
type MorxSubtable ¶
type SimpleKerns ¶
type SimpleKerns interface { // KernPair return the kern value for the given pair, or zero. // The value is expressed in glyph units and // is negative when glyphs should be closer. KernPair(left, right GID) int16 }
SimpleKerns store a compact form of the kerning values, which is restricted to (one direction) kerning pairs. It is only implemented by Kern0, Kern2, Kern3 and Kern6, where Kern1 and Kern4 requires a state machine to be interpreted.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
interpreter
Package psinterpreter implement a Postscript interpreter required to parse .CFF files, and Type1 and Type2 Charstrings.
|
Package psinterpreter implement a Postscript interpreter required to parse .CFF files, and Type1 and Type2 Charstrings. |