Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtlasMeta ¶
type AtlasMeta struct { // Type is the atlas mask type. It must be "mtsdf". Type string `json:"type"` // DistanceRange is number of pixels over which the signed distance // field goes from fully opaque to fully transparent. DistanceRange float32 `json:"distanceRange"` // Size is the number of pixels in the sprite sheet per EM unit. Size float32 `json:"size"` // Width is the width of the sprite sheet in pixels. // It should be a power of 2. Width int `json:"width"` // Height is the height of the sprite sheet in pixels. // It should be a power of 2. Height int `json:"height"` // YOrigin is the side of the image that corresponds to y = 0. // It must be "bottom". YOrigin string `json:"yOrigin"` }
AtlasMeta holds data about the generated texture sheet.
type Bounds ¶
type Bounds struct { Left float32 `json:"left"` Bottom float32 `json:"bottom"` Right float32 `json:"right"` Top float32 `json:"top"` }
Bounds is the bounds of a rectangle.
type Font ¶
type Font struct { Metrics Metrics // contains filtered or unexported fields }
func New ¶
NewFont prepares a font atlas for rendering.
These files are generated using msdf-atlas gen, which is available from https://github.com/Chlumsky/msdf-atlas-gen
An example of a command to generate an atlas:
msdf-atlas-gen -font /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf \ -fontname "DejaVu Sans" -charset charset.txt -emrange 0.2 \ -potr -type mtsdf -format png -imageout text.png -json text.json
func NewMulti ¶
func NewMulti(sheet *gfx.Sheet, atlas *MultiAtlas) []*Font
NewFonts prepares multiple font atlases for rendering.
The input to this function is what msdf-atlas-gen creates when passed the `-and` argument.
See NewFont for an example of a command that generates a single-font atlas.
func (*Font) DrawBorder ¶
type Glyph ¶
type Glyph struct { Unicode rune `json:"unicode"` Advance float32 `json:"advance"` Plane *Bounds `json:"planeBounds,omitempty"` Atlas *Bounds `json:"atlasBounds,omitempty"` }
Glyph holds data about one glyph in the font atlas.
type KerningPair ¶
type KerningPair struct { Unicode1 rune `json:"unicode1"` Unicode2 rune `json:"unicode2"` Advance float32 `json:"advance"` }
KerningPair holds data about the distance between specific characters when they are rendered next to each other.
type Metrics ¶
type Metrics struct { EmSize float32 `json:"emSize"` LineHeight float32 `json:"lineHeight"` Ascender float32 `json:"ascender"` Descender float32 `json:"descender"` UnderlineY float32 `json:"underlineY"` UnderlineThickness float32 `json:"underlineThickness"` }
Metrics holds data about the font itself.