Documentation ¶
Overview ¶
Package graphite Graphite implements a "smart font" system developed specifically to handle the complexities of lesser-known languages of the world.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FeatureValue ¶
FeatureValue specifies a value for a given feature.
type FeaturesValue ¶
type FeaturesValue []FeatureValue
FeaturesValue are sorted by Id
func (FeaturesValue) FindFeature ¶
func (feats FeaturesValue) FindFeature(id Tag) *FeatureValue
FindFeature return the feature for the given tag, or nil.
type FontOptions ¶
type FontOptions struct {
// contains filtered or unexported fields
}
FontOptions allows to specify a scale to get position in user units rather than in font units.
func NewFontOptions ¶
func NewFontOptions(ppem uint16, face *GraphiteFace) *FontOptions
NewFontOptions builds options from the given points per em.
type GraphiteFace ¶
type GraphiteFace struct { fonts.FaceMetrics // contains filtered or unexported fields }
GraphiteFace contains the specific OpenType tables used by the Graphite engine. It also wraps the common OpenType metrics record.
func LoadGraphite ¶
func LoadGraphite(font *truetype.Font) (*GraphiteFace, error)
LoadGraphite read graphite tables from the given OpenType font. It returns an error if the tables are invalid or if the font is not a graphite font.
func (*GraphiteFace) FeaturesForLang ¶
func (f *GraphiteFace) FeaturesForLang(lang Tag) FeaturesValue
FeaturesForLang selects the features and values for the given language, or the default ones if the language is not found.
func (*GraphiteFace) Shape ¶
func (face *GraphiteFace) Shape(font *FontOptions, text []rune, script Tag, features FeaturesValue, dir int8) *Segment
Shape process the given `text` and applies the graphite tables found in the font, returning a shaped segment of text. `font` is optional: if given, the positions are scaled; otherwise they are expressed in font units. If `features` is nil, the default features from the `Sill` table are used. Note that this not the same as passing an empty slice, which would desactivate any feature. `script` is optional and may help to select the correct `Silf` subtable. `dir` sets the direction of the text.
type Segment ¶
type Segment struct { // Start of the segment (may be nil for empty segments) First *Slot // Advance of the whole segment Advance Position // Number of slots (output characters). // Since slots may be added or deleted during shaping, // it may differ from the number of characters ot the text input. // It could be directly computed by walking the linked list but is cached // for performance reasons. NumGlyphs int // contains filtered or unexported fields }
Segment represents a line of text. It is used internally during shaping and returned as the result of the operation.
type Slot ¶
type Slot struct { // Next is the next slot along the segment (that is the next element in the linked list). // It is nil at the end of the segment. Next *Slot // Each slot is associated with a range of characters in the input slice, // delimited by [Before, After]. // Before is also the index of the position of the cursor before this slot. // After is also the index of the position of the cursor after this slot. Before, After int // Offset ot the glyph from the start of the segment. Position Position // Glyph advance for this glyph as adjusted for kerning Advance Position // contains filtered or unexported fields }
Slot represents one glyph in a shaped line of text. Slots are created from the input string, but may also be added or removed by the shaping process.
func (*Slot) CanInsertBefore ¶
CanInsertBefore returns whether text may be inserted before this glyph.
This indicates whether a cursor can be put before this slot. It applies to base glyphs that have no parent as well as attached glyphs that have the .insert attribute explicitly set to true. This is the primary mechanism for identifying contiguous sequences of base plus diacritics.