Skip to content

package kaiju_font

import "kaiju/rendering/loaders/kaiju_font"

Types

Atlas

struct

type Atlas struct {
    Width  int32 `json:"width"`
    Height int32 `json:"height"`
}

FontData

struct

type FontData struct {
    Glyphs  []Glyph   `json:"glyphs"`
    Atlas   Atlas     `json:"atlas"`
    Metrics Metrics   `json:"metrics"`
    Kerning []Kerning `json:"kerning"`
}

Glyph

struct

type Glyph struct {
    Unicode     int     `json:"unicode"`
    Advance     float32 `json:"advance"`
    PlaneBounds Rect    `json:"planeBounds"`
    AtlasBounds Rect    `json:"atlasBounds"`
}

KaijuFont

struct

type KaijuFont struct {
    Details FontData
    PNG     []byte
}

KaijuFont is a base primitive representing a single font including each character's details along with the MSDF PNG image. Typically this structure is generated when importing a font into the engine using a function like [font_to_msdf.ProcessTTF]. From this point, it is typically serialized and stored into the content database. When reading a font from the content database, it will return a KaijuFont.

Deserialize

func Deserialize(data []byte) (KaijuFont, error)

Deserialize will construct a KaijuFont from the given array of bytes. This deserialization uses the built-in gob.Decoder

KaijuFont.Serialize

func (f *KaijuFont) Serialize() ([]byte, error)

Serialize will convert a KaijuFont into a byte array for saving to the database or later use. This serialization uses the built-in gob.Encoder

Kerning

struct

type Kerning struct {
    Unicode1 int32   `json:"unicode1"`
    Unicode2 int32   `json:"unicode2"`
    Advance  float32 `json:"advance"`
}

Metrics

struct

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"`
}

Rect

struct

type Rect struct {
    Left   float32 `json:"left"`
    Top    float32 `json:"top"`
    Right  float32 `json:"right"`
    Bottom float32 `json:"bottom"`
}