fonts

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFace

func GetFace(gc *draw2dimg.GraphicContext, fontData draw2d.FontData, size float64) font.Face

func GetGlyphWidth

func GetGlyphWidth(tf TypeFace, char rune) float64

func GetTextHeight

func GetTextHeight(tf TypeFace, text string) (float64, float64)

func GetTextWidth

func GetTextWidth(tf TypeFace, text string) float64

func SetFont

func SetFont(gc *draw2dimg.GraphicContext, typeFace TypeFace)

Types

type FaceMetrics

type FaceMetrics struct {
	Ascent     float64
	Descent    float64
	Height     float64
	XHeight    float64
	CapHeight  float64
	CaretSlope image.Point
}

type GlyphBounds

type GlyphBounds struct {
	BlX float64
	BlY float64
	TlX float64
	TlY float64
	TrX float64
	TrY float64
	BrX float64
	BrY float64
}

func GetGlyphBounds

func GetGlyphBounds(tf TypeFace, char rune) GlyphBounds

type GlyphMetrics

type GlyphMetrics struct {
	Ascent       float64
	Descent      float64
	BearingLeft  float64
	BearingRight float64
	Advance      float64
}

func GetGlyphMetrics

func GetGlyphMetrics(tf TypeFace, char rune) GlyphMetrics

GlyphBounds returns the bounding box of r's glyph, drawn at a dot equal to the origin, and that glyph's advance width.

It returns !ok if the face does not contain a glyph for r.

The glyph's ascent and descent are equal to -bounds.Min.Y and +bounds.Max.Y. The glyph's left-side and right-side bearings are equal to bounds.Min.X and advance-bounds.Max.X. A visual depiction of what these metrics are is at https://developer.apple.com/library/archive/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyphterms_2x.png

type MyFontCache

type MyFontCache map[string]*truetype.Font

func (MyFontCache) Load

func (fc MyFontCache) Load(fd draw2d.FontData) (*truetype.Font, error)

func (MyFontCache) Store

func (fc MyFontCache) Store(fd draw2d.FontData, font *truetype.Font)

type TypeFace

type TypeFace struct {
	Name                  string
	Size                  float64
	Color                 color.RGBA
	BackgroundColor       color.RGBA
	BackgroundStrokeStyle draw2d.StrokeStyle
	FontData              draw2d.FontData
	Spacing               float64
	Face                  font.Face
	StrokeStyle           draw2d.StrokeStyle
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL