Documentation
¶
Index ¶
- type Alignment
- type Flags
- type FontFace
- type Glyph
- type GlyphID
- type LazyFace
- type Parameters
- type Range
- type RuneRange
- type Shaper
- func (l *Shaper) Bitmaps(gs []Glyph) op.CallOp
- func (l *Shaper) Layout(params Parameters, txt io.Reader)
- func (l *Shaper) LayoutString(params Parameters, str string)
- func (l *Shaper) NextGlyph() (_ Glyph, ok bool)
- func (l *Shaper) ReleaseLayoutBuffers()
- func (l *Shaper) ResetLayoutCache()
- func (l *Shaper) Shape(gs []Glyph) clip.PathSpec
- type ShaperOption
- type WrapPolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Glyph ¶
type Glyph struct {
ID GlyphID
X fixed.Int26_6
Y int32
Advance fixed.Int26_6
Ascent fixed.Int26_6
Descent fixed.Int26_6
Offset fixed.Point26_6
Bounds fixed.Rectangle26_6
// Runes is the number of runes represented by the glyph. It can
// exceed 65535 on the truncator glyph, which accounts for every
// rune hidden by truncation, so it must not be narrower than 32 bits.
Runes uint32
Flags Flags
}
type LazyFace ¶ added in v1.4.0
type LazyFace struct {
Typeface giofont.Typeface
Ranges []RuneRange
Match func(giofont.Font) bool
Load func() (FontFace, error)
}
LazyFace describes a font face that is parsed on first use instead of when the Shaper is built. Ranges lists the runes the face is expected to serve; the face is parsed the first time one of them is shaped, or when a rune turns out to be covered by no already-loaded face.
Match, when non-nil, additionally loads the face the first time a layout requests a matching font. This defers faces whose trigger is a style rather than a codepoint — an italic or heavy-weight variant loads on the first layout asking for that aspect, not at startup. A face with Match set and no Ranges is loaded only by its Match (or by the missing-coverage fallback, which always loads everything before giving up on a rune).
Typeface must be the family name the parsed face reports, so that family queries naming it behave the same before and after loading.
type Parameters ¶
type RuneRange ¶ added in v1.4.0
type RuneRange struct {
Lo, Hi rune
}
RuneRange is an inclusive range of runes.
type Shaper ¶
type Shaper struct {
// contains filtered or unexported fields
}
func NewShaper ¶
func NewShaper(options ...ShaperOption) *Shaper
func (*Shaper) LayoutString ¶
func (l *Shaper) LayoutString(params Parameters, str string)
func (*Shaper) ReleaseLayoutBuffers ¶ added in v1.1.0
func (l *Shaper) ReleaseLayoutBuffers()
ReleaseLayoutBuffers drops the per-shape document held inside the shaper after the last NextGlyph call. The next Layout/LayoutString call repopulates from scratch, so this is safe to invoke from the caller (e.g. the editor) once it has copied the glyphs it needs into its own index. For multi-MB texts this frees hundreds of MB that otherwise sit in Shaper.txt until the next shape.
func (*Shaper) ResetLayoutCache ¶ added in v1.1.0
func (l *Shaper) ResetLayoutCache()
ResetLayoutCache drops cached paragraph layouts. Useful when an editor is about to switch wrap modes or when a large text replaces the current one, so the document/glyph data captured for previous (text, width) keys can be reclaimed by the GC instead of waiting for LRU eviction.
type ShaperOption ¶
type ShaperOption func(*Shaper)
func NoSystemFonts ¶
func NoSystemFonts() ShaperOption
func WithCollection ¶
func WithCollection(collection []FontFace) ShaperOption
func WithLazyCollection ¶ added in v1.4.0
func WithLazyCollection(collection []LazyFace) ShaperOption
WithLazyCollection registers faces that are parsed on demand. They rank after the faces given to WithCollection, as if they had been appended to that collection.
func WithoutLigatures ¶ added in v1.4.2
func WithoutLigatures(typefaces ...giofont.Typeface) ShaperOption
type WrapPolicy ¶
type WrapPolicy uint8
const ( WrapHeuristically WrapPolicy = iota WrapWords WrapGraphemes )