font

package
v0.0.0-...-4c1a193 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2019 License: MIT Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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 Bold

func Bold(fontSize float32) (font.Face, error)

Bold will return an bold font face with the request font size

func Default

func Default(fontSize float32) (font.Face, error)

Default will return an regular font face with the request font size

func Italic

func Italic(fontSize float32) (font.Face, error)

Italic will return an italic font face with the request font size

func NewBitmapFace

func NewBitmapFace(filepath, glyphHints string) (font.Face, error)

NewBitmapFace will load up an image font face for creating a font in graphics

func NewTTFFace

func NewTTFFace(filepath string, size float32) (font.Face, error)

NewTTFFace will load up a ttf 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) Close

func (face BitmapFace) Close() error

Close to satisfy 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.

type Face

type Face font.Face

Face just an alias so you don't ahve to import multople packages named font

Jump to

Keyboard shortcuts

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