Documentation ¶
Overview ¶
Package font provides an easy interface for creating font faces to provide to the gfx package. It may include more in the future.
Index ¶
- Variables
- func Bold(fontSize float32) (font.Face, error)
- func Default(fontSize float32) (font.Face, error)
- func Italic(fontSize float32) (font.Face, error)
- func NewBitmapFace(filepath, glyphHints string) (font.Face, error)
- func NewTTFFace(filepath string, size float32) (font.Face, error)
- type BitmapFace
- func (face BitmapFace) Close() error
- func (face BitmapFace) Glyph(dot fixed.Point26_6, r rune) (dr image.Rectangle, mask image.Image, maskp image.Point, advance fixed.Int26_6, ...)
- func (face BitmapFace) GlyphAdvance(r rune) (advance fixed.Int26_6, ok bool)
- func (face BitmapFace) GlyphBounds(r rune) (bounds fixed.Rectangle26_6, advance fixed.Int26_6, ok bool)
- func (face BitmapFace) Kern(r0, r1 rune) fixed.Int26_6
- func (face BitmapFace) Metrics() font.Metrics
- type Face
Constants ¶
This section is empty.
Variables ¶
var ( // ASCII is a set of all ASCII runes. These runes are codepoints from 32 to 127 inclusive. ASCII []rune // Latin is a set of all the Latin runes Latin []rune )
Functions ¶
func NewBitmapFace ¶
NewBitmapFace will load up an image font face for creating a font in graphics
Types ¶
type BitmapFace ¶
type BitmapFace struct {
// contains filtered or unexported fields
}
BitmapFace holds data for a bitmap font face to satisfy the font.Face interface
func (BitmapFace) Glyph ¶
func (face BitmapFace) Glyph(dot fixed.Point26_6, r rune) (dr image.Rectangle, mask image.Image, maskp image.Point, advance fixed.Int26_6, ok bool)
Glyph returns the draw.DrawMask parameters (dr, mask, maskp) to draw r's glyph at the sub-pixel destination location dot, and that glyph's advance width.
It returns !ok if the face does not contain a glyph for r.
The contents of the mask image returned by one Glyph call may change after the next Glyph call. Callers that want to cache the mask must make a copy.
func (BitmapFace) GlyphAdvance ¶
func (face BitmapFace) GlyphAdvance(r rune) (advance fixed.Int26_6, ok bool)
GlyphAdvance returns the advance width of r's glyph.
It returns !ok if the face does not contain a glyph for r.
func (BitmapFace) GlyphBounds ¶
func (face BitmapFace) GlyphBounds(r rune) (bounds fixed.Rectangle26_6, advance fixed.Int26_6, ok bool)
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 equal -bounds.Min.Y and +bounds.Max.Y. A visual depiction of what these metrics are is at https://developer.apple.com/library/mac/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyph_metrics_2x.png
func (BitmapFace) Kern ¶
func (face BitmapFace) Kern(r0, r1 rune) fixed.Int26_6
Kern returns the horizontal adjustment for the kerning pair (r0, r1). A positive kern means to move the glyphs further apart.
func (BitmapFace) Metrics ¶
func (face BitmapFace) Metrics() font.Metrics
Metrics returns the metrics for this Face.