Documentation ¶
Overview ¶
Package truetype provides support for OpenType and TrueType font formats, used in PDF.
It is largely influenced by github.com/ConradIrwin/font, golang.org/x/image/font/sfnt, and FreeType2.
Package truetype provides support for OpenType and TrueType font formats, used in PDF.
It is largely influenced by github.com/ConradIrwin/font and golang.org/x/image/font/sfnt, and FreeType2.
Index ¶
- Constants
- Variables
- func Float1616ToUint(f Float1616) uint32
- func Load(file fonts.Resource) (fonts.Faces, error)
- func ScanFont(file fonts.Resource) ([]fonts.FontDescriptor, error)
- func SetVariations(face FaceVariable, variations []Variation)
- type AATAnchor
- type AATFeature
- type AATFeatureName
- type AATFeatureSelector
- type AATSettingName
- type AATStateEntry
- type AATStateTable
- type CaretValue
- type CaretValueFormat1
- type CaretValueFormat2
- type CaretValueFormat3
- type ChainedSequenceRule
- type Class
- type Cmap
- type CmapID
- type CmapIter
- type CmapSubtable
- type ConditionFormat1
- type Coverage
- type CoverageList
- type CoverageRange
- type CoverageRanges
- type DeviceHinting
- type DeviceTable
- type DeviceVariation
- type FaceVariable
- type Feature
- type FeatureRecord
- type FeatureSubstitution
- type FeatureVariation
- type Float1616
- type Font
- func (font *Font) Cmap() (fonts.Cmap, fonts.CmapEncoding)
- func (f *Font) FontHExtents() (fonts.FontExtents, bool)
- func (f *Font) FontVExtents() (fonts.FontExtents, bool)
- func (f *Font) GetGlyphContourPoint(glyph fonts.GID, pointIndex uint16) (x, y int32, ok bool)
- func (f *Font) GlyphData(gid GID, xPpem, yPpem uint16) fonts.GlyphData
- func (f *Font) GlyphExtents(glyph GID, xPpem, yPpem uint16) (fonts.GlyphExtents, bool)
- func (f *Font) GlyphHOrigin(GID) (x, y int32, found bool)
- func (f *Font) GlyphName(glyph GID) string
- func (f *Font) GlyphVOrigin(glyph GID) (x, y int32, found bool)
- func (f *Font) HorizontalAdvance(gid GID) float32
- func (font *Font) IsGraphite() (*Font, bool)
- func (font *Font) LayoutTables() LayoutTables
- func (f *Font) LineMetric(metric fonts.LineMetric) (float32, bool)
- func (font *Font) LoadBitmaps() []fonts.BitmapSize
- func (font *Font) LoadSummary() (fonts.FontSummary, error)
- func (f *Font) NominalGlyph(ch rune) (GID, bool)
- func (f *Font) NormalizeVariations(coords []float32) []float32
- func (font *Font) PoscriptName() string
- func (font *Font) PostscriptInfo() (fonts.PSInfo, bool)
- func (font *Font) SetVarCoordinates(coords []float32)
- func (f *Font) Upem() uint16
- func (font *Font) VarCoordinates() []float32
- func (f *Font) VariationGlyph(ch, varSelector rune) (GID, bool)
- func (f *Font) Variations() TableFvar
- func (f *Font) VerticalAdvance(gid GID) float32
- type FontParser
- func (pr *FontParser) AnkrTable(numGlyphs int) (TableAnkr, error)
- func (pr *FontParser) CmapTable() (TableCmap, error)
- func (pr *FontParser) FeatTable() (TableFeat, error)
- func (pr *FontParser) GDEFTable(nbAxis int) (TableGDEF, error)
- func (pr *FontParser) GPOSTable() (TableGPOS, error)
- func (pr *FontParser) GSUBTable() (TableGSUB, error)
- func (pr *FontParser) GetRawTable(tag Tag) ([]byte, error)
- func (pr *FontParser) GlyfTable(numGlyphs int, locationIndexFormat int16) (TableGlyf, error)
- func (pr *FontParser) HasTable(tag Tag) bool
- func (pr *FontParser) HheaTable() (*TableHVhea, error)
- func (pr *FontParser) HtmxTable(numGlyphs int) (TableHVmtx, error)
- func (pr *FontParser) KernTable(numGlyphs int) (TableKernx, error)
- func (pr *FontParser) KerxTable(numGlyphs int) (TableKernx, error)
- func (pr *FontParser) LoadGraphiteTables() (gr GraphiteTables, err error)
- func (pr *FontParser) MorxTable(numGlyphs int) (TableMorx, error)
- func (pr *FontParser) NumGlyphs() (int, error)
- func (pr *FontParser) OS2Table() (*TableOS2, error)
- func (pr *FontParser) PostTable(numGlyphs int) (TablePost, error)
- func (pr *FontParser) TrakTable() (TableTrak, error)
- func (pr *FontParser) VheaTable() (*TableHVhea, error)
- func (pr *FontParser) VtmxTable(numGlyphs int) (TableHVmtx, error)
- type GID
- type GPOSAnchor
- type GPOSAnchorFormat1
- type GPOSAnchorFormat2
- type GPOSAnchorFormat3
- type GPOSChainedContext1
- type GPOSChainedContext2
- type GPOSChainedContext3
- type GPOSContext1
- type GPOSContext2
- type GPOSContext3
- type GPOSCursive1
- type GPOSMark
- type GPOSMarkToBase1
- type GPOSMarkToLigature1
- type GPOSMarkToMark1
- type GPOSPair1
- type GPOSPair2
- type GPOSPairSet
- type GPOSPairValueRecord
- type GPOSSingle1
- type GPOSSingle2
- type GPOSSubtable
- type GPOSType
- type GPOSValueFormat
- type GPOSValueRecord
- type GSUBAlternate1
- type GSUBChainedContext1
- type GSUBChainedContext2
- type GSUBChainedContext3
- type GSUBContext1
- type GSUBContext2
- type GSUBContext3
- type GSUBLigature1
- type GSUBMultiple1
- type GSUBReverseChainedContext1
- type GSUBSingle1
- type GSUBSingle2
- type GSUBSubtable
- type GSUBType
- type GlyphData
- type GlyphNames
- type GlyphProps
- type GraphiteTables
- type ItemVariationData
- type Kern0
- type Kern1
- type Kern2
- type Kern3
- type KernSubtable
- type KerningPair
- type Kerx4
- type Kerx6
- type KerxAnchor
- type KerxAnchorAnchor
- type KerxAnchorControl
- type KerxAnchorCoordinates
- type LangSys
- type LayoutTables
- type LigatureCaretList
- type LigatureGlyph
- type LookupChainedContext1
- type LookupChainedContext2
- type LookupChainedContext3
- type LookupContext1
- type LookupContext2
- type LookupContext3
- type LookupFlag
- type LookupGPOS
- type LookupGSUB
- type LookupOptions
- type Metric
- type MortxSubtable
- type MorxChain
- type MorxContextualSubtable
- type MorxInsertionSubtable
- type MorxLigatureSubtable
- type MorxNonContextualSubtable
- type MorxRearrangementSubtable
- type MorxSubtableType
- type NameEntry
- type NameID
- type PlatformEncodingID
- type PlatformID
- type PlatformLanguageID
- type Script
- type SequenceLookup
- type SequenceRule
- type SimpleKerns
- type TableAnkr
- type TableCmap
- type TableFeat
- type TableFvar
- type TableGDEF
- type TableGPOS
- type TableGSUB
- type TableGlyf
- type TableHVhea
- type TableHVmtx
- type TableHead
- type TableKernx
- type TableLayout
- type TableMorx
- type TableMvar
- type TableName
- type TableOS2
- type TableOS2Version0
- type TableOS2Version1
- type TableOS2Version4
- type TablePost
- type TableTrak
- type Tag
- type TrackEntry
- type TrakData
- type VarAxis
- type VarInstance
- type VarValueRecord
- type Variation
- type VariationRegion
- type VariationStore
- type VariationStoreIndex
Constants ¶
const ( Kerx1Push = 0x8000 // If set, push this glyph on the kerning stack. Kerx1DontAdvance = 0x4000 // If set, don't advance to the next glyph before going to the new state. Kerx1Reset = 0x2000 // If set, reset the kerning data (clear the stack) Kern1Offset = 0x3FFF // Byte offset from beginning of subtable to the value table for the glyphs on the kerning stack. )
Kernx1 state entry flags
const ( /* If set, make the current glyph the first * glyph to be rearranged. */ MRMarkFirst = 0x8000 /* If set, don't advance to the next glyph * before going to the new state. This means * that the glyph index doesn't change, even * if the glyph at that index has changed. */ MRDontAdvance = 0x4000 /* If set, make the current glyph the last * glyph to be rearranged. */ MRMarkLast = 0x2000 /* These bits are reserved and should be set to 0. */ MRReserved = 0x1FF0 /* The type of rearrangement specified. */ MRVerb = 0x000F )
MorxRearrangement flags
const ( MCSetMark = 0x8000 /* If set, make the current glyph the marked glyph. */ /* If set, don't advance to the next glyph before * going to the new state. */ MCDontAdvance = 0x4000 MCReserved = 0x3FFF /* These bits are reserved and should be set to 0. */ )
MorxContextualSubtable flags
const ( /* Push this glyph onto the component stack for * eventual processing. */ MLSetComponent = 0x8000 /* Leave the glyph pointer at this glyph for the next iteration. */ MLDontAdvance = 0x4000 MLPerformAction = 0x2000 // Use the ligActionIndex to process a ligature group. /* Byte offset from beginning of subtable to the * ligature action list. This value must be a * multiple of 4. */ MLOffset = 0x3FFF /* This is the last action in the list. This also * implies storage. */ MLActionLast = 1 << 31 /* Store the ligature at the current cumulated index * in the ligature table in place of the marked * (i.e. currently-popped) glyph. */ MLActionStore = 1 << 30 /* A 30-bit value which is sign-extended to 32-bits * and added to the glyph ID, resulting in an index * into the component table. */ MLActionOffset = 0x3FFFFFFF )
MorxLigatureSubtable flags
const ( // If set, mark the current glyph. MISetMark = 0x8000 // If set, don't advance to the next glyph before // going to the new state. This does not mean // that the glyph pointed to is the same one as // before. If you've made insertions immediately // downstream of the current glyph, the next glyph // processed would in fact be the first one // inserted. MIDontAdvance = 0x4000 // If set, and the currentInsertList is nonzero, // then the specified glyph list will be inserted // as a kashida-like insertion, either before or // after the current glyph (depending on the state // of the currentInsertBefore flag). If clear, and // the currentInsertList is nonzero, then the // specified glyph list will be inserted as a // split-vowel-like insertion, either before or // after the current glyph (depending on the state // of the currentInsertBefore flag). MICurrentIsKashidaLike = 0x2000 // If set, and the markedInsertList is nonzero, // then the specified glyph list will be inserted // as a kashida-like insertion, either before or // after the marked glyph (depending on the state // of the markedInsertBefore flag). If clear, and // the markedInsertList is nonzero, then the // specified glyph list will be inserted as a // split-vowel-like insertion, either before or // after the marked glyph (depending on the state // of the markedInsertBefore flag). MIMarkedIsKashidaLike = 0x1000 // If set, specifies that insertions are to be made // to the left of the current glyph. If clear, // they're made to the right of the current glyph. MICurrentInsertBefore = 0x0800 // If set, specifies that insertions are to be // made to the left of the marked glyph. If clear, // they're made to the right of the marked glyph. MIMarkedInsertBefore = 0x0400 // This 5-bit field is treated as a count of the // number of glyphs to insert at the current // position. Since zero means no insertions, the // largest number of insertions at any given // current location is 31 glyphs. MICurrentInsertCount = 0x3E0 // This 5-bit field is treated as a count of the // number of glyphs to insert at the marked // position. Since zero means no insertions, the // largest number of insertions at any given // marked location is 31 glyphs. MIMarkedInsertCount = 0x001F )
MorxInsertionSubtable flags
const ( PEUnicodeDefault = PlatformEncodingID(0) PEUnicodeBMP = PlatformEncodingID(3) PEUnicodeFull = PlatformEncodingID(4) PEUnicodeFull13 = PlatformEncodingID(6) PEMacRoman = PEUnicodeDefault PEMicrosoftSymbolCs = PlatformEncodingID(0) PEMicrosoftUnicodeCs = PlatformEncodingID(1) PEMicrosoftUcs4 = PlatformEncodingID(10) )
const ( PLMacEnglish = PlatformLanguageID(0) PLUnicodeDefault = PlatformLanguageID(0) PLMicrosoftEnglish = PlatformLanguageID(0x0409) )
Variables ¶
var ( // TagPNG identifies bitmap glyph with png format TagPNG = MustNewTag("png ") // TagTIFF identifies bitmap glyph with tiff format TagTIFF = MustNewTag("tiff") // TagJPG identifies bitmap glyph with jpg format TagJPG = MustNewTag("jpg ") )
var ( // TagGpos represents the 'GPOS' table, which contains Glyph Positioning features TagGpos = MustNewTag("GPOS") // TagGsub represents the 'GSUB' table, which contains Glyph Substitution features TagGsub = MustNewTag("GSUB") // TagGdef represents the 'GDEF' table, which contains various Glyph Definitions TagGdef = MustNewTag("GDEF") TagSilf = MustNewTag("Silf") TagPrep = MustNewTag("prep") // TypeTrueType is the first four bytes of an OpenType file containing a TrueType font TypeTrueType = Tag(0x00010000) // TypeAppleTrueType is the first four bytes of an OpenType file containing a TrueType font // (specifically one designed for Apple products, it's recommended to use TypeTrueType instead) TypeAppleTrueType = MustNewTag("true") // TypePostScript1 is the first four bytes of an OpenType file containing a PostScript Type 1 font TypePostScript1 = MustNewTag("typ1") // TypeOpenType is the first four bytes of an OpenType file containing a PostScript Type 2 font // as specified by OpenType TypeOpenType = MustNewTag("OTTO") // SignatureWOFF is the magic number at the start of a WOFF file. SignatureWOFF = MustNewTag("wOFF") )
Functions ¶
func Float1616ToUint ¶ added in v0.0.10
func Load ¶ added in v0.0.8
Load implements fonts.FontLoader. For collection font files (.ttc, .otc), multiple fonts may be returned.
func ScanFont ¶ added in v0.0.6
func ScanFont(file fonts.Resource) ([]fonts.FontDescriptor, error)
ScanFont lazily parse `file` to extract a summary of the font(s). Collections are supported.
func SetVariations ¶ added in v0.0.2
func SetVariations(face FaceVariable, variations []Variation)
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.
Types ¶
type AATAnchor ¶
type AATAnchor struct {
X, Y int16
}
AATAnchor is a point within the coordinate space of a given glyph independent of the control points used to render the glyph
type AATFeature ¶
type AATFeatureName ¶
type AATFeatureName struct { Settings []AATSettingName Feature uint16 Flags uint16 NameIndex NameID }
func (*AATFeatureName) GetSelectorInfos ¶
func (feature *AATFeatureName) GetSelectorInfos() ([]AATFeatureSelector, uint16)
GetSelectorInfos fetches a list of the selectors available for the feature, and the default index. It the later equals 0xFFFF, then the feature type is non-exclusive. Otherwise, it is the index of the selector that is selected by default.
func (*AATFeatureName) IsExclusive ¶
func (feature *AATFeatureName) IsExclusive() bool
IsExclusive returns true if the feature settings are mutually exclusive.
type AATFeatureSelector ¶
type AATFeatureSelector struct { Name NameID // selector's name identifier Enable uint16 // value to turn the selector on Disable uint16 // value to turn the selector off }
AATFeatureSelector represents a setting for an AAT feature type.
type AATSettingName ¶
type AATStateEntry ¶
type AATStateEntry struct { NewState uint16 Flags uint16 // Table specific. // contains filtered or unexported fields }
AATStateEntry is the shared type for entries in a state table. See the various AsXXX methods to exploit its content.
func (AATStateEntry) AsKernxIndex ¶
func (e AATStateEntry) AsKernxIndex() uint16
AsKernxIndex reads the internal data for entries in 'kern/x' subtable format 1. An entry with no index returns 0xFFFF
func (AATStateEntry) AsMorxContextual ¶
func (e AATStateEntry) AsMorxContextual() (markIndex, currentIndex uint16)
AsMorxContextual reads the internal data for entries in morx contextual subtable. The returned indexes use 0xFFFF as empty value.
func (AATStateEntry) AsMorxInsertion ¶
func (e AATStateEntry) AsMorxInsertion() (currentIndex, markedIndex uint16)
AsMorxInsertion reads the internal data for entries in morx insertion subtable. The returned indexes use 0xFFFF as empty value.
func (AATStateEntry) AsMorxLigature ¶
func (e AATStateEntry) AsMorxLigature() (ligActionIndex uint16)
AsMorxLigature reads the internal data for entries in morx ligature subtable.
type AATStateTable ¶
type AATStateTable struct {
// contains filtered or unexported fields
}
AATStateTable is an extended state table.
func (*AATStateTable) GetClass ¶
func (t *AATStateTable) GetClass(glyph GID) uint16
GetClass return the class for the given glyph, with the correct default value.
func (AATStateTable) GetEntry ¶
func (t AATStateTable) GetEntry(state, class uint16) AATStateEntry
GetEntry return the entry for the given state and class, and handle invalid values (by returning an empty entry).
type CaretValue ¶ added in v0.0.2
type CaretValue interface {
// contains filtered or unexported methods
}
CaretValue is either CaretValueFormat1, CaretValueFormat2 or CaretValueFormat3.
type CaretValueFormat1 ¶ added in v0.0.2
type CaretValueFormat1 int16 // X or Y value, in design units
type CaretValueFormat2 ¶ added in v0.0.2
type CaretValueFormat2 uint16
type CaretValueFormat3 ¶ added in v0.0.2
type CaretValueFormat3 struct { Device DeviceTable Coordinate int16 // X or Y value, in design units }
type ChainedSequenceRule ¶
type ChainedSequenceRule struct { SequenceRule Backtrack []uint16 Lookahead []uint16 }
type Class ¶
type Class interface { // ClassID returns the class ID for the provided glyph. Returns (0, false) // for glyphs not covered by this class. ClassID(GID) (uint32, bool) // GlyphSize returns the number of glyphs covered. GlyphSize() int // Extent returns the maximum class ID + 1. This is the length // required for an array to be indexed by the class values. Extent() int }
Class group glyph indices. Conceptually it is a map[GID]uint32, but it may be implemented more efficiently.
type CmapID ¶
type CmapID struct { Platform PlatformID Encoding PlatformEncodingID }
CmapID groups the platform and encoding of a Cmap subtable.
func (CmapID) IsSymbolic ¶
IsSymbolic returns `true` for the special case of a symbolic cmap, for which the codepoints are not interpreted as Unicode.
type CmapSubtable ¶
type ConditionFormat1 ¶
type Coverage ¶
type Coverage interface { // Index returns the index of the provided glyph, or // `false` if the glyph is not covered by this lookup. // Note: this method is injective: two distincts, covered glyphs are mapped // to distincts tables. Index(GID) (int, bool) // Size return the number of glyphs covered. For non empty Coverages, it is also // 1 + (maximum index returned) Size() int }
Coverage specifies all the glyphs affected by a substitution or positioning operation described in a subtable. Conceptually is it a []GlyphIndex, but it may be implemented for efficiently. See the concrete types `CoverageList` and `CoverageRanges`.
type CoverageList ¶
type CoverageList []GID
CoverageList is a coverage with format 1. The glyphs are sorted in ascending order.
func (CoverageList) Size ¶
func (cl CoverageList) Size() int
type CoverageRange ¶
CoverageRange store a range of indexes, starting from StartCoverage. For example, for the glyphs 12,13,14,15, and the indexes 7,8,9,10, the CoverageRange would be {12, 15, 7}.
type CoverageRanges ¶
type CoverageRanges []CoverageRange
CoverageRanges is a coverage with format 2. Ranges are non-overlapping. The following GlyphIDs/index pairs are stored as follows:
glyphs: 130, 131, 132, 133, 134, 135, 137 indexes: 0, 1, 2, 3, 4, 5, 6 ranges: {130, 135, 0} {137, 137, 6}
StartCoverage is used to calculate the index without counting the length of the preceeding ranges
func (CoverageRanges) Size ¶
func (cr CoverageRanges) Size() int
type DeviceHinting ¶ added in v0.0.2
type DeviceTable ¶ added in v0.0.2
type DeviceTable interface {
// contains filtered or unexported methods
}
DeviceTable is either an GPOSDeviceHinting for standard fonts, or a GPOSDeviceVariation for variable fonts.
type DeviceVariation ¶ added in v0.0.2
type DeviceVariation VariationStoreIndex
type FaceVariable ¶ added in v0.0.2
type FaceVariable interface { // Variations returns the variations for the font, // or an empty table for non-variable fonts. Variations() TableFvar // SetVarCoordinates apply the normalized coordinates values. // Use `NormalizeVariations` to convert from design space units. // See also `SetVariations`. SetVarCoordinates(coords []float32) // VarCoordinates returns the current variable coordinates, // in normalized units. VarCoordinates() []float32 // NormalizeVariations should 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. // This should be a no-op for non-variable fonts. NormalizeVariations(coords []float32) []float32 }
FaceVariable is an extension interface supporting Opentype variable fonts. See the `Variations` method to check if a font is actually variable.
type Feature ¶
type Feature struct { LookupIndices []uint16 // contains filtered or unexported fields }
Feature represents a glyph substitution or glyph positioning features.
type FeatureRecord ¶
FeatureRecord associate a tag with a feature
type FeatureSubstitution ¶
type FeatureVariation ¶
type FeatureVariation struct { ConditionSet []ConditionFormat1 FeatureSubstitutions []FeatureSubstitution }
type Float1616 ¶ added in v0.0.10
type Float1616 = float32
Float1616 is a float32, represented in fixed 16.16 format in font files.
func Float1616FromUint ¶ added in v0.0.10
type Font ¶
type Font struct { Names TableName Glyf TableGlyf Hmtx TableHVmtx OS2 *TableOS2 // optional // graphite font, optionnal Graphite *GraphiteTables Head TableHead // NumGlyphs exposes the number of glyph indexes present in the font, // as exposed in the 'maxp' table. NumGlyphs int // TODO: check usage // Type represents the kind of glyphs in this font. // It is one of TypeTrueType, TypeTrueTypeApple, TypePostScript1, TypeOpenType Type Tag // HasHint is true if the font has a prep table. HasHint bool // contains filtered or unexported fields }
Font represents a SFNT font, which is the underlying representation found in .otf and .ttf files. SFNT is a container format, which contains a number of tables identified by Tags. Depending on the type of glyphs embedded in the file which tables will exist. In particular, there's a big different between TrueType glyphs (usually .ttf) and CFF/PostScript Type 2 glyphs (usually .otf)
func Parse ¶
Parse parses an OpenType or TrueType file and returns a Font. See Loader for support for collections, and FontParser for more control over table loading.
func (*Font) FontHExtents ¶ added in v0.0.2
func (f *Font) FontHExtents() (fonts.FontExtents, bool)
func (*Font) FontVExtents ¶ added in v0.0.2
func (f *Font) FontVExtents() (fonts.FontExtents, bool)
func (*Font) GetGlyphContourPoint ¶ added in v0.0.2
func (*Font) GlyphExtents ¶ added in v0.0.2
func (*Font) GlyphHOrigin ¶ added in v0.0.2
func (*Font) GlyphVOrigin ¶ added in v0.0.2
func (*Font) HorizontalAdvance ¶ added in v0.0.2
func (*Font) IsGraphite ¶
Returns true if the font has Graphite capabilities, but does not check if the tables are actually valid.
func (*Font) LayoutTables ¶
func (font *Font) LayoutTables() LayoutTables
LayoutTables returns the valid advanced layout tables. When parsing yields an error, it is ignored and an empty table is returned. See the individual methods for more control over error handling.
func (*Font) LineMetric ¶ added in v0.0.2
func (f *Font) LineMetric(metric fonts.LineMetric) (float32, bool)
func (*Font) LoadBitmaps ¶ added in v0.0.2
func (font *Font) LoadBitmaps() []fonts.BitmapSize
LoadBitmaps checks for the various bitmaps table and returns the first valid
func (*Font) LoadSummary ¶
func (font *Font) LoadSummary() (fonts.FontSummary, error)
func (*Font) NormalizeVariations ¶ added in v0.0.2
Normalizes 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
func (*Font) PoscriptName ¶
PoscriptName returns the optional PoscriptName of the font
func (*Font) SetVarCoordinates ¶ added in v0.0.2
func (*Font) VarCoordinates ¶ added in v0.0.2
func (*Font) VariationGlyph ¶ added in v0.0.2
func (*Font) Variations ¶ added in v0.0.2
func (*Font) VerticalAdvance ¶ added in v0.0.2
type FontParser ¶ added in v0.0.5
type FontParser struct { Type Tag // contains filtered or unexported fields }
FontParser serves as an intermediate when reading font files. Most of the time, the Parse and Loader.Load functions are enough, but `FontParser` may be used on its own when more control over table loading is needed.
func NewFontParser ¶ added in v0.0.5
func NewFontParser(file fonts.Resource) (*FontParser, error)
NewFontParser reads the `file` header and returns a parser. `file` will be used to parse tables, and should not be close.
func NewFontParsers ¶ added in v0.0.5
func NewFontParsers(file fonts.Resource) ([]*FontParser, error)
NewFontParsers is the same as `NewFontParser`, but supports collections.
func (*FontParser) AnkrTable ¶ added in v0.0.5
func (pr *FontParser) AnkrTable(numGlyphs int) (TableAnkr, error)
AnkrTable parse the AAT 'ankr' table.
func (*FontParser) CmapTable ¶ added in v0.0.6
func (pr *FontParser) CmapTable() (TableCmap, error)
func (*FontParser) FeatTable ¶ added in v0.0.5
func (pr *FontParser) FeatTable() (TableFeat, error)
FeatTable parse the AAT 'feat' table.
func (*FontParser) GDEFTable ¶ added in v0.0.5
func (pr *FontParser) GDEFTable(nbAxis int) (TableGDEF, error)
GDEFTable returns the Glyph Definition table identified with the 'GDEF' tag.
func (*FontParser) GPOSTable ¶ added in v0.0.5
func (pr *FontParser) GPOSTable() (TableGPOS, error)
GPOSTable returns the Glyph Positioning table identified with the 'GPOS' tag.
func (*FontParser) GSUBTable ¶ added in v0.0.5
func (pr *FontParser) GSUBTable() (TableGSUB, error)
GSUBTable returns the Glyph Substitution table identified with the 'GSUB' tag.
func (*FontParser) GetRawTable ¶ added in v0.0.5
func (pr *FontParser) GetRawTable(tag Tag) ([]byte, error)
GetRawTable returns the binary content of the given table, or an error if not found. Note that many tables are already interpreted by this package, see the various XXXTable().
func (*FontParser) GlyfTable ¶ added in v0.0.5
func (pr *FontParser) GlyfTable(numGlyphs int, locationIndexFormat int16) (TableGlyf, error)
GlyfTable parse the 'glyf' table. Note that glyphs may be defined in various format (like CFF or bitmaps), and stored in other tables. `locationIndexFormat` is found in the 'head' table.
func (*FontParser) HasTable ¶ added in v0.0.5
func (pr *FontParser) HasTable(tag Tag) bool
HasTable returns `true` is the font has the given table.
func (*FontParser) HheaTable ¶ added in v0.0.5
func (pr *FontParser) HheaTable() (*TableHVhea, error)
func (*FontParser) HtmxTable ¶ added in v0.0.5
func (pr *FontParser) HtmxTable(numGlyphs int) (TableHVmtx, error)
HtmxTable returns the glyphs horizontal metrics (array of size numGlyphs), expressed in fonts units.
func (*FontParser) KernTable ¶ added in v0.0.5
func (pr *FontParser) KernTable(numGlyphs int) (TableKernx, error)
KernTable parses and returns the 'kern' table.
func (*FontParser) KerxTable ¶ added in v0.0.5
func (pr *FontParser) KerxTable(numGlyphs int) (TableKernx, error)
KerxTable parse the AAT 'kerx' table.
func (*FontParser) LoadGraphiteTables ¶ added in v0.0.5
func (pr *FontParser) LoadGraphiteTables() (gr GraphiteTables, err error)
LoadGraphiteTables returns the raw tables required for Graphite engine support. See the package graphite for how to interpret these tables.
func (*FontParser) MorxTable ¶ added in v0.0.5
func (pr *FontParser) MorxTable(numGlyphs int) (TableMorx, error)
MorxTable parse the AAT 'morx' table.
func (*FontParser) NumGlyphs ¶ added in v0.0.5
func (pr *FontParser) NumGlyphs() (int, error)
NumGlyphs parses the 'maxp' table to find the number of glyphs in the font.
func (*FontParser) OS2Table ¶ added in v0.0.5
func (pr *FontParser) OS2Table() (*TableOS2, error)
func (*FontParser) PostTable ¶ added in v0.0.5
func (pr *FontParser) PostTable(numGlyphs int) (TablePost, error)
PostTable returns the Post table names
func (*FontParser) TrakTable ¶ added in v0.0.5
func (pr *FontParser) TrakTable() (TableTrak, error)
TrakTable parse the AAT 'trak' table.
func (*FontParser) VheaTable ¶ added in v0.0.5
func (pr *FontParser) VheaTable() (*TableHVhea, error)
func (*FontParser) VtmxTable ¶ added in v0.0.5
func (pr *FontParser) VtmxTable(numGlyphs int) (TableHVmtx, error)
VtmxTable returns the glyphs vertical metrics (array of size numGlyphs), expressed in fonts units.
type GPOSAnchor ¶
type GPOSAnchor interface {
// contains filtered or unexported methods
}
type GPOSAnchorFormat1 ¶
type GPOSAnchorFormat1 struct {
X, Y int16 // in design units
}
type GPOSAnchorFormat2 ¶
type GPOSAnchorFormat2 struct { GPOSAnchorFormat1 AnchorPoint uint16 }
type GPOSAnchorFormat3 ¶
type GPOSAnchorFormat3 struct {
XDevice, YDevice DeviceTable // may be null
GPOSAnchorFormat1
}
type GPOSChainedContext1 ¶
type GPOSChainedContext1 LookupChainedContext1
func (GPOSChainedContext1) Type ¶
func (GPOSChainedContext1) Type() GPOSType
type GPOSChainedContext2 ¶
type GPOSChainedContext2 LookupChainedContext2
func (GPOSChainedContext2) Type ¶
func (GPOSChainedContext2) Type() GPOSType
type GPOSChainedContext3 ¶
type GPOSChainedContext3 LookupChainedContext3
func (GPOSChainedContext3) Type ¶
func (GPOSChainedContext3) Type() GPOSType
type GPOSContext1 ¶
type GPOSContext1 LookupContext1
func (GPOSContext1) Type ¶
func (GPOSContext1) Type() GPOSType
type GPOSContext2 ¶
type GPOSContext2 LookupContext2
func (GPOSContext2) Type ¶
func (GPOSContext2) Type() GPOSType
type GPOSContext3 ¶
type GPOSContext3 LookupContext3
func (GPOSContext3) Type ¶
func (GPOSContext3) Type() GPOSType
type GPOSCursive1 ¶
type GPOSCursive1 [][2]GPOSAnchor // entry, exit (may be null)
GPOSCursive1 has, after successul parsing, the length of its associated coverage
func (GPOSCursive1) Type ¶
func (GPOSCursive1) Type() GPOSType
type GPOSMark ¶
type GPOSMark struct { Anchor GPOSAnchor ClassValue uint16 }
type GPOSMarkToBase1 ¶
type GPOSMarkToBase1 struct { BaseCoverage Coverage // same length as the associated Coverage, marks can't be nil Marks []GPOSMark // one set for each index in `BaseCoverage`, each with same length // anchors may be nil Bases [][]GPOSAnchor }
func (GPOSMarkToBase1) Type ¶
func (GPOSMarkToBase1) Type() GPOSType
type GPOSMarkToLigature1 ¶
type GPOSMarkToLigature1 struct { LigatureCoverage Coverage Marks []GPOSMark // marks can't be nil Ligatures [][][]GPOSAnchor // one set for each index in `LigatureCoverage` }
func (GPOSMarkToLigature1) Type ¶
func (GPOSMarkToLigature1) Type() GPOSType
type GPOSMarkToMark1 ¶
type GPOSMarkToMark1 struct { Mark2Coverage Coverage Marks1 []GPOSMark Marks2 [][]GPOSAnchor // one set for each index in `Mark2Coverage`, each with same length }
func (GPOSMarkToMark1) Type ¶
func (GPOSMarkToMark1) Type() GPOSType
type GPOSPair1 ¶
type GPOSPair1 struct { // After successul parsing, has one set for each glyph in the coverage Values []GPOSPairSet Formats [2]GPOSValueFormat // first, second }
type GPOSPair2 ¶
type GPOSPair2 struct {
First, Second Class
// Positionning for first and second glyphs.
// After successful parsing, it has size First.Extent() x Second.Extent()
Values [][][2]GPOSValueRecord
Formats [2]GPOSValueFormat // first, second
}
type GPOSPairSet ¶
type GPOSPairSet []GPOSPairValueRecord
GPOSPairSet is sorted according to the `SecondGlyph` field
func (GPOSPairSet) FindGlyph ¶
func (ps GPOSPairSet) FindGlyph(secondGlyph GID) *GPOSPairValueRecord
FindGlyph performs a binary search in the list, returning the record for `secondGlyph`, or `nil` if not found.
type GPOSPairValueRecord ¶
type GPOSPairValueRecord struct { Pos [2]GPOSValueRecord // Positioning data for first and second glyphs SecondGlyph GID // Glyph ID of second glyph in the pair }
type GPOSSingle1 ¶
type GPOSSingle1 struct { Value GPOSValueRecord Format GPOSValueFormat }
func (GPOSSingle1) Type ¶
func (GPOSSingle1) Type() GPOSType
type GPOSSingle2 ¶
type GPOSSingle2 struct { // After successful parsing, has same length as associated coverage. Values []GPOSValueRecord Format GPOSValueFormat }
func (GPOSSingle2) Type ¶
func (GPOSSingle2) Type() GPOSType
type GPOSSubtable ¶
type GPOSSubtable struct { // For GPOSChained - Format 3, its the coverage of the first input. Coverage Coverage Data interface{ Type() GPOSType } }
GPOSSubtable is one of the subtables of a GPOS lookup.
type GPOSType ¶
type GPOSType uint16
GPOSType identifies the kind of lookup format, for GPOS tables.
const ( GPOSSingle GPOSType = 1 + iota // Adjust position of a single glyph GPOSPair // Adjust position of a pair of glyphs GPOSCursive // Attach cursive glyphs GPOSMarkToBase // Attach a combining mark to a base glyph GPOSMarkToLigature // Attach a combining mark to a ligature GPOSMarkToMark // Attach a combining mark to another mark GPOSContext // Position one or more glyphs in context GPOSChained // Position one or more glyphs in chained context )
type GPOSValueFormat ¶
type GPOSValueFormat uint16
GPOSValueFormat is a mask indicating which field are set in a GPOSValueRecord. It is often shared between many records.
const ( XPlacement GPOSValueFormat = 1 << iota /* Includes horizontal adjustment for placement */ YPlacement /* Includes vertical adjustment for placement */ XAdvance /* Includes horizontal adjustment for advance */ YAdvance /* Includes vertical adjustment for advance */ XPlaDevice /* Includes horizontal Device table for placement */ YPlaDevice /* Includes vertical Device table for placement */ XAdvDevice /* Includes horizontal Device table for advance */ YAdvDevice /* Includes vertical Device table for advance */ // Mask for having any Device table Devices = XPlaDevice | YPlaDevice | XAdvDevice | YAdvDevice )
type GPOSValueRecord ¶
type GPOSValueRecord struct { XPlaDevice DeviceTable // Device table for horizontal placement (may be nil) YPlaDevice DeviceTable // Device table for vertical placement (may be nil) XAdvDevice DeviceTable // Device table for horizontal advance (may be nil) YAdvDevice DeviceTable // Device table for vertical advance (may be nil) // format gposValueFormat XPlacement int16 // Horizontal adjustment for placement--in design units YPlacement int16 // Vertical adjustment for placement--in design units XAdvance int16 // Horizontal adjustment for advance--in design units (only used for horizontal writing) YAdvance int16 // Vertical adjustment for advance--in design units (only used for vertical writing) }
type GSUBAlternate1 ¶
type GSUBAlternate1 [][]GID
func (GSUBAlternate1) Type ¶
func (GSUBAlternate1) Type() GSUBType
type GSUBChainedContext1 ¶
type GSUBChainedContext1 LookupChainedContext1
func (GSUBChainedContext1) Type ¶
func (GSUBChainedContext1) Type() GSUBType
type GSUBChainedContext2 ¶
type GSUBChainedContext2 LookupChainedContext2
func (GSUBChainedContext2) Type ¶
func (GSUBChainedContext2) Type() GSUBType
type GSUBChainedContext3 ¶
type GSUBChainedContext3 LookupChainedContext3
func (GSUBChainedContext3) Type ¶
func (GSUBChainedContext3) Type() GSUBType
type GSUBContext1 ¶
type GSUBContext1 LookupContext1
func (GSUBContext1) Type ¶
func (GSUBContext1) Type() GSUBType
type GSUBContext2 ¶
type GSUBContext2 LookupContext2
func (GSUBContext2) Type ¶
func (GSUBContext2) Type() GSUBType
type GSUBContext3 ¶
type GSUBContext3 LookupContext3
func (GSUBContext3) Type ¶
func (GSUBContext3) Type() GSUBType
type GSUBLigature1 ¶
type GSUBLigature1 [][]LigatureGlyph
GSUBLigature1 stores one ligature set per glyph in the coverage.
func (GSUBLigature1) Type ¶
func (GSUBLigature1) Type() GSUBType
type GSUBMultiple1 ¶
type GSUBMultiple1 [][]GID
func (GSUBMultiple1) Type ¶
func (GSUBMultiple1) Type() GSUBType
type GSUBReverseChainedContext1 ¶
type GSUBReverseChainedContext1 struct { Backtrack []Coverage Lookahead []Coverage Substitutes []GID }
func (GSUBReverseChainedContext1) Type ¶
func (GSUBReverseChainedContext1) Type() GSUBType
type GSUBSingle1 ¶
type GSUBSingle1 int16
GSUBSingle1 is a Single Substitution Format 1, expressed as a delta from the coverage.
func (GSUBSingle1) Type ¶
func (GSUBSingle1) Type() GSUBType
type GSUBSingle2 ¶
type GSUBSingle2 []GID
GSUBSingle2 is a Single Substitution Format 2, expressed as substitutes
func (GSUBSingle2) Type ¶
func (GSUBSingle2) Type() GSUBType
type GSUBSubtable ¶
type GSUBSubtable struct { // For SubChaining - Format 3, its the coverage of the first input. Coverage Coverage Data interface{ Type() GSUBType } }
GSUBSubtable is one of the subtables of a GSUB lookup.
type GSUBType ¶
type GSUBType uint16
GSUBType identifies the kind of lookup format, for GSUB tables.
const ( GSUBSingle GSUBType = 1 + iota // Single (format 1.1 1.2) Replace one glyph with one glyph GSUBMultiple // Multiple (format 2.1) Replace one glyph with more than one glyph GSUBAlternate // Alternate (format 3.1) Replace one glyph with one of many glyphs GSUBLigature // Ligature (format 4.1) Replace multiple glyphs with one glyph GSUBContext // Context (format 5.1 5.2 5.3) Replace one or more glyphs in context GSUBChaining // Chaining Context (format 6.1 6.2 6.3) Replace one or more glyphs in chained context GSUBReverse // Reverse chaining context single (format 8.1) )
type GlyphData ¶
type GlyphData struct {
Xmin, Ymin, Xmax, Ymax int16
// contains filtered or unexported fields
}
type GlyphNames ¶
type GlyphNames interface { // GlyphName return the postscript name of a // glyph, or an empty string if it not found GlyphName(x GID) string }
GlyphNames stores the names of a 'post' table.
type GlyphProps ¶
type GlyphProps = uint16
GlyphProps is a 16-bit integer where the lower 8-bit have bits representing glyph class, and high 8-bit the mark attachment type (if any).
const ( BaseGlyph GlyphProps = 1 << (iota + 1) Ligature Mark )
type GraphiteTables ¶ added in v0.0.5
type GraphiteTables struct {
Sill, Feat, Gloc, Glat, Silf []byte
}
type ItemVariationData ¶
type Kern0 ¶
type Kern0 []KerningPair
type Kern1 ¶
type Kern1 struct { Values []int16 // After successful parsing, may be safely indexed by AATStateEntry.AsKernxIndex() from `Machine` Machine AATStateTable }
type Kern3 ¶
type Kern3 struct {
// contains filtered or unexported fields
}
Kern3 is the Apple kerning subtable format 3
type KernSubtable ¶
type KernSubtable struct { Data interface { // contains filtered or unexported methods } IsExtended bool // `true` for AAT `kerx` subtables TupleCount int // 0 for scalar values // contains filtered or unexported fields }
KernSubtable contains kerning information. Some formats provides an easy lookup method: see SimpleKerns. Others require a state machine to interpret it.
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 KerningPair ¶
type Kerx4 ¶
type Kerx4 struct { Anchors []KerxAnchor Machine AATStateTable // contains filtered or unexported fields }
type KerxAnchor ¶
type KerxAnchor interface {
// contains filtered or unexported methods
}
type KerxAnchorAnchor ¶
type KerxAnchorAnchor struct {
Mark, Current uint16
}
type KerxAnchorControl ¶
type KerxAnchorControl struct {
Mark, Current uint16
}
type KerxAnchorCoordinates ¶
type KerxAnchorCoordinates struct {
MarkX, MarkY, CurrentX, CurrentY int16
}
type LangSys ¶
type LangSys struct { // Features contains the index of the features for this language, // relative to the Features slice of the table Features []uint16 // Index of a feature required for this language system. // If no required features, default to 0xFFFF RequiredFeatureIndex uint16 Tag Tag }
LangSys represents the language system for a script.
type LayoutTables ¶
type LayoutTables struct { GDEF TableGDEF // An absent table has a nil Class Trak TableTrak Ankr TableAnkr Feat TableFeat Morx TableMorx Kern TableKernx Kerx TableKernx GSUB TableGSUB // An absent table has a nil slice of lookups GPOS TableGPOS // An absent table has a nil slice of lookups }
LayoutTables exposes advanced layout tables. All the fields are optionnals.
type LigatureCaretList ¶ added in v0.0.2
type LigatureCaretList struct { Coverage Coverage LigCarets [][]CaretValue // once successfully parsed, has same length as Coverage.Size() }
type LigatureGlyph ¶
type LigatureGlyph struct { // Glyphs composing the ligature, starting after the // implicit first glyph, given in the coverage of the // SubstitutionLigature table Components []uint16 // Output ligature glyph Glyph GID }
func (LigatureGlyph) Matches ¶
func (l LigatureGlyph) Matches(glyphsFromSecond []GID) bool
Matches tests if the ligature should be applied on `glyphsFromSecond`, which starts from the second glyph.
type LookupChainedContext1 ¶
type LookupChainedContext1 [][]ChainedSequenceRule
type LookupChainedContext2 ¶
type LookupChainedContext2 struct { BacktrackClass Class InputClass Class LookaheadClass Class SequenceSets [][]ChainedSequenceRule }
type LookupChainedContext3 ¶
type LookupChainedContext3 struct { Backtrack []Coverage Input []Coverage Lookahead []Coverage SequenceLookups []SequenceLookup }
type LookupContext1 ¶
type LookupContext1 [][]SequenceRule
type LookupContext2 ¶
type LookupContext2 struct { Class Class SequenceSets [][]SequenceRule }
type LookupContext3 ¶
type LookupContext3 struct { Coverages []Coverage SequenceLookups []SequenceLookup }
type LookupFlag ¶
type LookupFlag = uint16
const ( // This bit relates only to the correct processing of // the cursive attachment lookup type (GPOS lookup type 3). // When this bit is set, the last glyph in a given sequence to // which the cursive attachment lookup is applied, will be positioned on the baseline. RightToLeft LookupFlag = 1 << iota IgnoreBaseGlyphs // If set, skips over base glyphs IgnoreLigatures // If set, skips over ligatures IgnoreMarks // If set, skips over all combining marks // If set, indicates that the lookup table structure // is followed by a MarkFilteringSet field. // The layout engine skips over all mark glyphs not in the mark filtering set indicated. UseMarkFilteringSet Reserved LookupFlag = 0x00E0 // For future use (Set to zero) // If not zero, skips over all marks of attachment // type different from specified. MarkAttachmentType LookupFlag = 0xFF00 )
type LookupGPOS ¶
type LookupGPOS struct { // After successful parsing, it is a non empty array // with all subtables of the same `GPOSType`. Subtables []GPOSSubtable Type GPOSType LookupOptions }
LookupGPOS is a lookup for GPOS tables.
type LookupGSUB ¶
type LookupGSUB struct { // After successful parsing, all subtables have the `GSUBType`. Subtables []GSUBSubtable LookupOptions Type GSUBType }
LookupGSUB is a lookup for GSUB tables.
type LookupOptions ¶
type LookupOptions struct { Flag LookupFlag // Lookup qualifiers. // Index (base 0) into GDEF mark glyph sets structure, // meaningfull only if UseMarkFilteringSet is set. MarkFilteringSet uint16 // TODO: sanitize with gdef }
func (LookupOptions) Props ¶
func (l 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 MortxSubtable ¶
type MortxSubtable struct { Data interface{ Type() MorxSubtableType } Coverage uint8 // high byte of the coverage flag Flags uint32 // Mask identifying which subtable this is. }
type MorxChain ¶
type MorxChain struct { Features []AATFeature Subtables []MortxSubtable DefaultFlags uint32 }
type MorxContextualSubtable ¶
type MorxContextualSubtable struct { Substitutions []Class Machine AATStateTable }
func (MorxContextualSubtable) Type ¶
func (MorxContextualSubtable) Type() MorxSubtableType
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 }
func (MorxInsertionSubtable) Type ¶
func (MorxInsertionSubtable) Type() MorxSubtableType
type MorxLigatureSubtable ¶
type MorxLigatureSubtable struct { LigatureAction []uint32 Component []uint16 Ligatures []GID Machine AATStateTable }
func (MorxLigatureSubtable) Type ¶
func (MorxLigatureSubtable) Type() MorxSubtableType
type MorxNonContextualSubtable ¶
type MorxNonContextualSubtable struct {
Class // the lookup value is interpreted as a GlyphIndex
}
func (MorxNonContextualSubtable) Type ¶
func (MorxNonContextualSubtable) Type() MorxSubtableType
type MorxRearrangementSubtable ¶
type MorxRearrangementSubtable AATStateTable
MorxRearrangementSubtable is a 'morx' subtable format 0.
func (MorxRearrangementSubtable) Type ¶
func (MorxRearrangementSubtable) Type() MorxSubtableType
type MorxSubtableType ¶
type MorxSubtableType uint8
MorxSubtableType indicates the kind of 'morx' subtable. See the constants.
const ( MorxRearrangement MorxSubtableType = iota MorxContextual MorxLigature MorxNonContextual MorxInsertion )
type NameEntry ¶
type NameEntry struct { Value []byte // raw value of the name PlatformID PlatformID EncodingID PlatformEncodingID LanguageID PlatformLanguageID NameID NameID }
type NameID ¶
type NameID uint16
NameID is the ID for entries in the font table.
const ( NameCopyrightNotice NameID = iota NameFontFamily NameFontSubfamily NameUniqueIdentifier NameFull NameVersion NamePostscript NameTrademark NameManufacturer NameDesigner NameDescription NameVendorURL NameDesignerURL NameLicenseDescription NameLicenseURL NamePreferredFamily // or Typographic Family NamePreferredSubfamily // or Typographic Subfamily NameCompatibleFull NameSampleText NamePostscriptCID NameWWSFamily NameWWSSubfamily NameLightBackgroundPalette NameDarkBackgroundPalette )
type PlatformEncodingID ¶
type PlatformEncodingID uint16
PlatformEncodingID represents the platform specific id for entries in the name table. The most common values are provided as constants.
type PlatformID ¶
type PlatformID uint16
PlatformID represents the platform id for entries in the name table.
const ( PlatformUnicode PlatformID = iota PlatformMac PlatformIso /* deprecated */ PlatformMicrosoft PlatformCustom PlatformAdobe /* artificial */ )
func (PlatformID) String ¶
func (p PlatformID) String() string
String returns an idenfying string for each platform or "Platform X" for unknown values.
type PlatformLanguageID ¶
type PlatformLanguageID uint16
PlatformLanguageID represents the language used by an entry in the name table, the three most common values are provided as constants.
type Script ¶
Script represents a single script (i.e "latn" (Latin), "cyrl" (Cyrillic), etc).
func (Script) FindLanguage ¶
FindLanguage looks for `language` and return its index into the Languages slice, or -1 if the tag is not found.
func (Script) GetLangSys ¶
GetLangSys return the language at `index`. It `index` is out of range (for example with 0xFFFF), it returns `DefaultLanguage` (which may be empty)
type SequenceLookup ¶
type SequenceLookup struct { InputIndex uint16 // Index (zero-based) into the input glyph sequence LookupIndex uint16 // Index (zero-based) into the LookupList }
SequenceLookup is used to specify an action (a nested lookup) to be applied to a glyph at a particular sequence position within the input sequence.
type SequenceRule ¶
type SequenceRule struct { // Starts with the second glyph // For format1, it is interpreted as GlyphIndex, for format 2, as ClassID Input []uint16 Lookups []SequenceLookup }
SequenceRule is used in Context format 1 and 2
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. It is not implemented by complex AAT kerning subtables.
type TableCmap ¶
type TableCmap struct { Cmaps []CmapSubtable // contains filtered or unexported fields }
TableCmap defines the mapping of character codes to the glyph index values used in the font. It may contain more than one subtable, in order to support more than one character encoding scheme.
func (TableCmap) BestEncoding ¶
func (t TableCmap) BestEncoding() (Cmap, fonts.CmapEncoding)
BestEncoding returns the widest encoding supported. For valid fonts, the returned cmap won't be nil.
func (*TableCmap) FindSubtable ¶
FindSubtable returns the cmap for the given platform and encoding, or nil if not found.
type TableFeat ¶
type TableFeat []AATFeatureName
func (TableFeat) GetFeature ¶
func (t TableFeat) GetFeature(feature uint16) *AATFeatureName
GetFeature performs a binary seach into the names, using `Feature` as key, returning `nil` if not found.
type TableFvar ¶
type TableFvar struct { Axis []VarAxis Instances []VarInstance // contains the default instance }
func (*TableFvar) GetDesignCoords ¶
GetDesignCoords updates the design coordinates, with the given pairs of axis/value. It will panic if `designCoords` has not the length expected by the table, that is the number of axis.
func (*TableFvar) GetDesignCoordsDefault ¶
GetDesignCoordsDefault returns the design coordinates corresponding to the given pairs of axis/value. The default value of the axis is used when not specified in the variations.
func (TableFvar) IsDefaultInstance ¶
func (fvar TableFvar) IsDefaultInstance(it VarInstance) bool
IsDefaultInstance returns `true` is `instance` has the same coordinates as the default instance.
type TableGDEF ¶
type TableGDEF struct { // Identify the class of the glyph: // 1: Base glyph, single character, spacing glyph // 2: Ligature glyph (multiple character, spacing glyph) // 3: Mark glyph (non-spacing combining glyph) // 4: Component glyph (part of single character, spacing glyph) // May be nil Class Class // Class to which a mark glyph may belong (may be nil) MarkAttach Class MarkGlyphSet []Coverage // used in GSUB and GPOS lookups to filter which marks in a string are considered or ignored VariationStore VariationStore // for variable fonts, may be empty LigatureCaretList LigatureCaretList // optional }
func (*TableGDEF) GetGlyphProps ¶
func (t *TableGDEF) GetGlyphProps(glyph GID) GlyphProps
GetGlyphProps return a summary of the glyph properties.
type TableGPOS ¶
type TableGPOS struct { Lookups []LookupGPOS TableLayout }
TableGPOS provides precise control over glyph placement for sophisticated text layout and rendering in each script and language system that a font supports.
type TableGSUB ¶
type TableGSUB struct { Lookups []LookupGSUB TableLayout }
TableGSUB is the Glyph Substitution (GSUB) table. It provides data for substition of glyphs for appropriate rendering of scripts, such as cursively-connecting forms in Arabic script, or for advanced typographic effects, such as ligatures.
type TableHVhea ¶
type TableHVhea struct { Ascent int16 // typoAscent in version 1.1 Descent int16 // typoDescent in version 1.1 LineGap int16 // typoLineGap in version 1.1 AdvanceMax uint16 MinFirstSideBearing int16 // left/top MinSecondSideBearing int16 // right/bottom MaxExtent int16 CaretSlopeRise int16 CaretSlopeRun int16 CaretOffset int16 // contains filtered or unexported fields }
TableHVhea exposes global metrics for horizontal or vertical writting.
type TableHVmtx ¶
type TableHVmtx []Metric // with length numGlyphs
type TableHead ¶
type TableHead struct { Created longdatetime Updated longdatetime FontRevision uint32 UnitsPerEm uint16 Flags uint16 XMin int16 YMin int16 XMax int16 YMax int16 MacStyle uint16 LowestRecPPEM uint16 FontDirection int16 // contains filtered or unexported fields }
TableHead contains critical information about the rest of the font. https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6head.html https://docs.microsoft.com/fr-fr/typography/opentype/spec/head
func (*TableHead) ExpectedChecksum ¶
ExpectedChecksum is the checksum that the file should have had.
type TableKernx ¶
type TableKernx []KernSubtable
TableKernx represents a 'kern' or 'kerx' kerning table. It supports both Microsoft and Apple formats.
type TableLayout ¶
type TableLayout struct { Scripts []Script Features []FeatureRecord FeatureVariations []FeatureVariation // contains filtered or unexported fields }
TableLayout represents the common layout table used by GPOS and GSUB. The Features field contains all the features for this layout. However, the script and language determines which feature is used.
See https://www.microsoft.com/typography/otspec/chapter2.htm#organization See https://www.microsoft.com/typography/otspec/GPOS.htm See https://www.microsoft.com/typography/otspec/GSUB.htm
func (*TableLayout) FindFeatureIndex ¶ added in v0.0.2
func (t *TableLayout) FindFeatureIndex(featureTag Tag) (uint16, bool)
FindFeatureIndex fetches the index for a given feature tag in the specified face's GSUB table or GPOS table. Returns false if not found
func (*TableLayout) FindScript ¶
func (t *TableLayout) FindScript(script Tag) int
FindScript looks for `script` and return its index into the Scripts slice, or -1 if the tag is not found.
func (*TableLayout) FindVariationIndex ¶
func (t *TableLayout) FindVariationIndex(coords []float32) int
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 TableMvar ¶
type TableMvar struct { Values []VarValueRecord // sorted by tag Store VariationStore }
type TableName ¶
type TableName []NameEntry
TableName represents the OpenType 'name' table. This contains human-readable meta-data about the font, for example the Author and Copyright. https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html
func (TableName) SelectEntry ¶
SelectEntry return the entry for `name` or nil if not found.
type TableOS2 ¶
type TableOS2 struct { TableOS2Version4 UsLowerPointSize uint16 UsUpperPointSize uint16 }
type TableOS2Version0 ¶
type TableOS2Version0 struct { Version uint16 XAvgCharWidth uint16 USWeightClass uint16 USWidthClass uint16 FSType uint16 YSubscriptXSize int16 YSubscriptYSize int16 YSubscriptXOffset int16 YSubscriptYOffset int16 YSuperscriptXSize int16 YSuperscriptYSize int16 YSuperscriptXOffset int16 YSuperscriptYOffset int16 YStrikeoutSize int16 YStrikeoutPosition int16 SFamilyClass int16 Panose [10]byte UlCharRange [4]uint32 AchVendID Tag FsSelection uint16 USFirstCharIndex uint16 USLastCharIndex uint16 STypoAscender int16 STypoDescender int16 STypoLineGap int16 UsWinAscent uint16 UsWinDescent uint16 }
type TableOS2Version1 ¶
type TableOS2Version1 struct { TableOS2Version0 UlCodePageRange1 uint32 UlCodePageRange2 uint32 }
type TableOS2Version4 ¶
type TableOS2Version4 struct { TableOS2Version1 SxHeigh int16 SCapHeight int16 UsDefaultChar uint16 UsBreakChar uint16 UsMaxContext uint16 }
TableOS2Version4 is the OS2 format for versions 2,3 and 4
type TablePost ¶ added in v0.0.5
type TablePost struct { // Names stores the glyph names. It may be nil. Names GlyphNames // ItalicAngle in counter-clockwise degrees from the vertical. Zero for // upright text, negative for text that leans to the right (forward). ItalicAngle float64 // Version of the version tag of the "post" table. Version uint32 // UnderlinePosition is the suggested distance of the top of the // underline from the baseline (negative values indicate below baseline). UnderlinePosition int16 // Suggested values for the underline thickness. UnderlineThickness int16 // IsFixedPitch indicates that the font is not proportionally spaced // (i.e. monospaced). IsFixedPitch bool }
TablePost represents an information stored in the PostScript font section.
type Tag ¶
type Tag uint32
Tag represents an open-type name. These are technically uint32's, but are usually displayed in ASCII as they are all acronyms. See https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6.html#Overview
func MustNewTag ¶
MustNewTag gives you the Tag corresponding to the acronym. This function will panic if the string passed in is not 4 bytes long.
type TrackEntry ¶
type TrakData ¶
type TrakData struct { Entries []TrackEntry Sizes []float32 }
type VarAxis ¶
type VarAxis struct { Tag Tag // Tag identifying the design variation for the axis. Minimum Float1616 // mininum value on the variation axis that the font covers Default Float1616 // default position on the axis Maximum Float1616 // maximum value on the variation axis that the font covers // contains filtered or unexported fields }
type VarInstance ¶
type VarValueRecord ¶
type VarValueRecord struct { Tag Tag Index VariationStoreIndex }
type VariationRegion ¶
type VariationRegion [3]float32
VariationRegion stores start, peek, end coordinates.
type VariationStore ¶
type VariationStore struct { Regions [][]VariationRegion // for each region, for each axis Datas []ItemVariationData }
VariationStore store variation data. After successful parsing, every region indexes in `Datas` elements are valid, that is, can safely be used as index into `Regions`.
func (VariationStore) GetDelta ¶
func (store VariationStore) GetDelta(index VariationStoreIndex, coords []float32) float32
GetDelta uses the variation store and the selected instance coordinates to compute the value at `index`.
type VariationStoreIndex ¶
type VariationStoreIndex struct {
DeltaSetOuter, DeltaSetInner uint16
}
VariationStoreIndex reference an item in the variation store
Source Files ¶
- aat_state.go
- aat_table_ankr.go
- aat_table_feat.go
- aat_table_kerx.go
- aat_table_mortx.go
- aat_table_trak.go
- bitmaps.go
- bitmaps_edbt_cbdt.go
- bitmaps_sbix.go
- descriptor.go
- font.go
- metrics.go
- parse_collection.go
- parse_otf.go
- parse_woff.go
- parser.go
- rd.go
- rd_outlines.go
- table.go
- table_cmap.go
- table_common.go
- table_gdef.go
- table_glyf.go
- table_gpos.go
- table_gsub.go
- table_head.go
- table_htmx.go
- table_hvhea.go
- table_kern.go
- table_layout.go
- table_name.go
- table_os2.go
- table_post.go
- table_post_data.go
- table_svg.go
- table_var.go
- table_vorg.go
- typedefs.go
- utils.go
- variations.go