Documentation
¶
Index ¶
- func CollectionIndex(data []byte, name string) (int, error)
- func DefaultCFFFontPath() (string, error)
- func DefaultFontPath() (string, error)
- func IsGlyphFormatControl(r rune) bool
- func RasterizerVersion() string
- type Bounds
- type CompositeComponent
- type CompositeGlyph
- type Decoder
- type DecoderSet
- type Face
- func (f *Face) CacheKey() uint64
- func (f *Face) CapHeight() int16
- func (f *Face) Close() error
- func (f *Face) Glyph(glyphID uint16) (*Glyph, error)
- func (f *Face) GlyphBounds(glyphID uint16) (Bounds, error)
- func (f *Face) GlyphIndex(r rune) uint16
- func (f *Face) GlyphKerning(left, right uint16) int
- func (f *Face) HorizontalMetrics(glyphID uint16) (LongHorMetric, error)
- func (f *Face) Italic() *Face
- func (f *Face) Outline(glyphID uint16) (*Outline, error)
- func (f *Face) RasterizeGlyph(glyphID uint16, pixelsPerEm float64) (*GlyphBitmap, error)
- func (f *Face) RasterizeGlyphAt(glyphID uint16, pixelsPerEm float64, phaseX, phaseY uint8) (*GlyphBitmap, error)
- func (f *Face) ResolveGlyph(r rune) (*Face, uint16)
- func (f *Face) UseFallback(face *Face)
- func (f *Face) UseSystemFallback()
- func (f *Face) XHeight() int16
- type FaceOptions
- type FormatDecoder
- type Glyph
- type GlyphBitmap
- type Head
- type Hhea
- type Int26_6
- type LCDColor
- type LongHorMetric
- type Maxp
- type Metrics
- type NoDecoder
- type Outline
- type OutlineContour
- type OutlinePoint
- type Point
- type Point26_6
- type PositionedGlyph
- type SFNTDecoder
- type ScaledFace
- func (f *ScaledFace) Close() error
- func (f *ScaledFace) Glyph(dot Point26_6, r rune) (image.Rectangle, image.Image, image.Point, Int26_6, bool)
- func (f *ScaledFace) GlyphAdvance(r rune) (Int26_6, bool)
- func (f *ScaledFace) GlyphBounds(r rune) (image.Rectangle, Int26_6, bool)
- func (f *ScaledFace) GlyphLCD(r rune, phaseX uint8) (image.Rectangle, *image.RGBA, Int26_6, bool)
- func (f *ScaledFace) GlyphOutline(r rune) (*Outline, Int26_6, bool)
- func (f *ScaledFace) Kern(left, right rune) Int26_6
- func (f *ScaledFace) Metrics() Metrics
- type SimpleGlyph
- type SystemFont
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCFFFontPath ¶
func DefaultFontPath ¶
func IsGlyphFormatControl ¶
IsGlyphFormatControl identifies joiners, variation selectors and emoji tags. They remain in the source text for selection but have no standalone ink or advance.
func RasterizerVersion ¶
func RasterizerVersion() string
RasterizerVersion identifies the built-in pure Go rasterizer in visual reports. It does not require cgo or a system font library.
Types ¶
type CompositeComponent ¶
type CompositeGlyph ¶
type CompositeGlyph struct {
Components []CompositeComponent
Instructions []byte
}
type DecoderSet ¶
type DecoderSet[A, B FormatDecoder] struct{}
DecoderSet is a compile-time font format collection. It performs no runtime registration and does not allocate while selecting a decoder.
func (DecoderSet[A, B]) DecodeFont ¶
func (DecoderSet[A, B]) DecodeFont(data []byte, path string) (*Face, error)
type Face ¶
type Face struct {
Cmap cmap
Kern kernTable
SFNT *sfnt
CFF *cffFont
Glyf []byte
Data []byte
Loca []uint32
Metrics []LongHorMetric
Hhea Hhea
Head Head
Maxp Maxp
// contains filtered or unexported fields
}
func LoadDefault ¶
func (*Face) CapHeight ¶
CapHeight returns the cap-height metric in font units, using H for fonts without the optional OS/2 metric. It does not rasterize a glyph.
func (*Face) Close ¶
Close releases the file or memory backing owned by the face. Callers must stop using the face and any scaled faces created from it before closing it.
func (*Face) GlyphBounds ¶
GlyphBounds reads TrueType ink bounds without decoding or retaining contours.
func (*Face) GlyphIndex ¶
func (*Face) GlyphKerning ¶
GlyphKerning returns horizontal advance adjustment in font design units. GPOS kern lookups take precedence over the legacy kern table.
func (*Face) HorizontalMetrics ¶
func (f *Face) HorizontalMetrics(glyphID uint16) (LongHorMetric, error)
func (*Face) Italic ¶
Italic returns a shared synthetic oblique face, or the original face if it already contains italic glyphs. The source must remain open while it is used. Font tables and metrics are shared; raster and outline caches are independent.
func (*Face) RasterizeGlyph ¶
func (f *Face) RasterizeGlyph(glyphID uint16, pixelsPerEm float64) (*GlyphBitmap, error)
func (*Face) RasterizeGlyphAt ¶
func (f *Face) RasterizeGlyphAt(glyphID uint16, pixelsPerEm float64, phaseX, phaseY uint8) (*GlyphBitmap, error)
RasterizeGlyphAt samples a glyph at a quarter-pixel device-space origin. The sixteen possible phases bound cache growth independently of positions.
func (*Face) ResolveGlyph ¶
ResolveGlyph returns both the owning face and its local glyph ID. If every candidate is missing the character, it returns this face's .notdef glyph. System fallback faces are shared; callers must not modify or close them.
func (*Face) UseFallback ¶
UseFallback sets a shared face to consult for missing glyphs before system fallback. Configure it before measuring or rendering. The caller owns the fallback and must keep it open while this face is in use.
func (*Face) UseSystemFallback ¶
func (f *Face) UseSystemFallback()
UseSystemFallback enables lazy, shared system glyph fallback. Configure the face before measuring or rendering it; raw glyph-ID APIs remain face-local. Closing this face does not close the shared fallback faces.
type FaceOptions ¶
type FormatDecoder ¶
type FormatDecoder interface {
MatchesFont([]byte, string) bool
DecodeFont([]byte, string) (*Face, error)
}
FormatDecoder handles one font path extension in DecoderSet.
type Glyph ¶
type Glyph struct {
Simple *SimpleGlyph
Composite *CompositeGlyph
Bounds Bounds
GlyphID uint16
NumberOfContours int16
}
type GlyphBitmap ¶
type LCDColor ¶
type LCDColor uint16
LCDColor identifies Skia's eight canonical foreground intensities per channel. Coverage correction depends on foreground color, not background. Quantization bounds glyph-cache variants to 512 colors.
func GrayColorFromRGB ¶
GrayColorFromRGB selects Skia's A8 luminance bucket without prematurely quantizing the individual foreground channels.
func LCDColorFromRGB ¶
func (LCDColor) PreblendGray ¶
PreblendGray applies coverage gamma without LCD's five-bit quantization.
func (LCDColor) PreblendLCD ¶
PreblendLCD converts raw RGB coverage into the mask used by the existing component blend passes. Alpha remains opaque. Grayscale masks are unchanged.
type LongHorMetric ¶
type Outline ¶
type Outline struct {
Contours []OutlineContour
Bounds Bounds
}
type OutlineContour ¶
type OutlineContour []OutlinePoint
type OutlinePoint ¶
type PositionedGlyph ¶
PositionedGlyph carries a glyph's authored position in logical pixels. PenX is the pen origin; X includes the glyph's left side bearing.
type SFNTDecoder ¶
type SFNTDecoder struct{}
SFNTDecoder handles TTF, OTF, and TTC fonts in the core parser.
func (SFNTDecoder) DecodeFont ¶
func (SFNTDecoder) DecodeFont(data []byte, _ string) (*Face, error)
func (SFNTDecoder) MatchesFont ¶
func (SFNTDecoder) MatchesFont(data []byte, path string) bool
type ScaledFace ¶
type ScaledFace struct {
// contains filtered or unexported fields
}
func NewFace ¶
func NewFace(face *Face, opts *FaceOptions) (*ScaledFace, error)
func (*ScaledFace) Close ¶
func (f *ScaledFace) Close() error
func (*ScaledFace) GlyphAdvance ¶
func (f *ScaledFace) GlyphAdvance(r rune) (Int26_6, bool)
func (*ScaledFace) GlyphBounds ¶
GlyphBounds matches Glyph at the pixel origin without rasterizing a bitmap.
func (*ScaledFace) GlyphLCD ¶
GlyphLCD produces raw RGB coverage using Skia's four-sample LCD filter. Atlas users apply foreground preblend and retain the resulting bitmap.
func (*ScaledFace) GlyphOutline ¶
func (f *ScaledFace) GlyphOutline(r rune) (*Outline, Int26_6, bool)
func (*ScaledFace) Kern ¶
func (f *ScaledFace) Kern(left, right rune) Int26_6
func (*ScaledFace) Metrics ¶
func (f *ScaledFace) Metrics() Metrics
type SimpleGlyph ¶
type SystemFont ¶
type SystemFont struct {
Family string
Path string
Index int
Weight int
Italic bool
Monospace bool
}
SystemFont identifies one installed face, including its index in a collection. Listing faces reads metadata only; Load parses the selected face on demand.
func SystemFonts ¶
func SystemFonts() ([]SystemFont, error)
SystemFonts returns the process-cached installed font list. Callers must not modify the returned slice. Fonts installed later become available on restart.
func (SystemFont) Load ¶
func (f SystemFont) Load() (*Face, error)
Source Files
¶
- cff.go
- cmap.go
- collection.go
- color.go
- decoder.go
- face.go
- fallback.go
- fixed.go
- font_file.go
- font_file_unix.go
- glyf.go
- gpos.go
- head.go
- hhea.go
- hmtx.go
- italic.go
- kern.go
- lcd.go
- lcd_gamma.go
- loader.go
- loca.go
- maxp.go
- outline.go
- positioned_glyph.go
- raster_scratch.go
- rasterizer.go
- rasterizer_version.go
- scaled_face.go
- sfnt.go
- system.go
- system_linux.go
- system_list.go
- system_mobile.go