Documentation ¶
Index ¶
- func CalculateTextSize(text string, font Font, fontSize float32) f32.Vec2
- func LoadTrueType(r io.Reader, lc TTFConfig) (*fontAtlas, error)
- func Pow2Image(src image.Image) image.Image
- func Wrap(font Font, text string, wrap, fontSize float32) (n int, lines string)
- type Direction
- type Directional
- type Disposer
- type Font
- type Glyph
- type Point
- type TTFConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadTrueType ¶
LoadTrueType loads a truetype fontAtlas from the given stream and applies the given fontAtlas scale in points.
The low and high values determine the lower and upper rune limits we should load for this Font. For standard ASCII this would be:32, 127.
func Pow2Image ¶
Pow2Image returns the given image, scaled to the smallest power-of-two dimensions larger or equal to the input dimensions. It preserves the image format and contents.
This is useful if an image is to be used as an OpenGL Texture. These often require image data to have power-of-two dimensions.
Types ¶
type Direction ¶
type Direction uint8
Direction represents the direction in which strings should be rendered.
type Directional ¶
type Directional interface {
Direction() Direction
}
type Font ¶
type Font interface { Tex2D() (uint16, *bk.Texture2D) Glyph(rune rune) (g Glyph, ok bool) Bounds() (gw, gh float32) Frame(rune rune) (x1, y1, x2, y2 float32) }
Font provides all the information needed to render a Rune.
Tex2D returns the low-level bk-texture. Glyph returns the matrix of rune. Bounds returns the largest width and height for any of the glyphs in the fontAtlas. SizeOf measure the text and returns the width and height.
func LoadBitmap ¶
LoadBitmap loads a bitmap (raster) fontAtlas from the given sprite sheet and config files. It is optionally scaled by the given scale factor.
A scale factor of 1 retains the original size. A factor of 2 doubles the fontAtlas size, etc. A scale factor of 0 is not valid and will default to 1.
Supported image formats are 32-bit RGBA as PNG, JPEG.
type Glyph ¶
type Glyph struct { Rune rune X float32 Y float32 Width float32 Height float32 XOffset float32 YOffset float32 Advance int }
A Glyph describes metrics for a single Font glyph. These indicate which area of a given image contains the glyph data and how the glyph should be spaced in a rendered string.
Advance determines the distance to the next glyph. This is used to properly align non-monospaced fonts.