Documentation
¶
Overview ¶
Package font provides high-quality font rendering with texture atlas
Index ¶
- func ColorToRGBA(c math.Color) color.RGBA
- func EmbeddedFontData() []byte
- func FontCoverageScore(ttfData []byte, probes []rune) (int, error)
- func ValidateFontData(ttfData []byte) error
- type Font
- func (f *Font) Ascent() float32
- func (f *Font) Delete()
- func (f *Font) Descent() float32
- func (f *Font) Fallbacks() []*Font
- func (f *Font) ForEachGlyph(fn func(r rune, g *GlyphInfo))
- func (f *Font) GetGlyph(r rune) (*GlyphInfo, bool)
- func (f *Font) Glyphs() map[rune]*GlyphInfo
- func (f *Font) HasRune(r rune) bool
- func (f *Font) LetterSpacing() float32
- func (f *Font) LineHeight() float32
- func (f *Font) MeasureText(text string) (float32, float32)
- func (f *Font) ResolveGlyph(r rune) (*Font, *GlyphInfo, bool)
- func (f *Font) RuneAdvance(r rune) float32
- func (f *Font) SetFallbacks(fallbacks ...*Font)
- func (f *Font) SyncGPU()
- func (f *Font) TextWidth(text string) float32
- func (f *Font) Texture() uint32
- type FontStyle
- type GlyphInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorToRGBA ¶
ColorToRGBA converts Color to color.RGBA
func EmbeddedFontData ¶
func EmbeddedFontData() []byte
EmbeddedFontData returns the embedded default font data (Noto Sans CJK Regular). It covers Latin, CJK Unified Ideographs (Chinese, Japanese, Korean), Kana, and Hangul. Returns nil if the font file was not embedded at build time.
func FontCoverageScore ¶
FontCoverageScore counts how many probe runes a font contains.
func ValidateFontData ¶
ValidateFontData verifies that font data is supported by the opentype parser.
Types ¶
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
Font represents a font with texture atlas
func NewFontStyled ¶
NewFontStyled creates a new font with style options (bold/italic). It supports TTF, OTF, TTC, and OTC font formats.
func (*Font) Descent ¶
Descent returns the descent (positive value indicating pixels below baseline).
func (*Font) ForEachGlyph ¶
ForEachGlyph calls fn for each cached glyph while holding the read lock. Prefer this over Glyphs() for non-debug iteration (no map copy).
func (*Font) Glyphs ¶
Glyphs returns a copy of the glyph map (for debugging only). For production iteration use ForEachGlyph instead.
func (*Font) LetterSpacing ¶
LetterSpacing returns the extra spacing inserted after each glyph.
func (*Font) MeasureText ¶
MeasureText returns width and height of text
func (*Font) ResolveGlyph ¶
ResolveGlyph returns the font atlas and glyph used to draw a rune, including fallbacks.
func (*Font) RuneAdvance ¶
RuneAdvance returns a rune's advance including configured letter spacing.
func (*Font) SetFallbacks ¶
SetFallbacks replaces the fallback fonts used when a rune is missing.
func (*Font) SyncGPU ¶
func (f *Font) SyncGPU()
SyncGPU ensures the GPU texture is up to date with the CPU atlas. Must be called with a current GL context (e.g. inside Render/BeginFrame).