bitmapfont

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Char

type Char struct {
	Id       uint8   // The character id.
	X        float32 // The left position of the character image in the texture.
	Y        float32 // The top position of the character image in the texture.
	Width    float32 // The width of the character image in the texture.
	Height   float32 // The height of the character image in the texture.
	Xoffset  float32 // How much the current position should be offset when copying the image from the texture to the screen.
	Yoffset  float32 // How much the current position should be offset when copying the image from the texture to the screen.
	Xadvance float32 // How much the current position should be advanced after drawing the character.
	Page     int     //	The texture page where the character image is found.
	Channel  int     //	The texture channel where the character image is found (1 = blue, 2 = green, 4 = red, 8 = alpha, 15 = all channels).
	Letter   string  // The letter is represents
}

This tag describes on character in the font. There is one for each included character in the font.

type Common

type Common struct {
	LineHeight float32 // This is the distance in pixels between each line of text.
	Base       int     // The number of pixels from the absolute top of the line to the base of the characters.
	ScaleW     float32 // The width of the texture, normally used to scale the x pos of the character image.
	ScaleH     float32 // The height of the texture, normally used to scale the y pos of the character image.
	Pages      int     // The number of texture pages included in the font.
	Packed     int     // Set to 1 if the monochrome characters have been packed into each of the texture channels. In this case alphaChnl describes what is stored in each channel.
	AlphaChnl  int     // Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one.
	RedChnl    int     // Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one.
	GreenChnl  int     // Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one.
	BlueChnl   int     // Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one.
}

This tag holds information common to all characters.

type Font

type Font struct {
	Common Common
	// contains filtered or unexported fields
}

func NewFont

func NewFont() *Font

func (*Font) AmountBetween

func (f *Font) AmountBetween(left, right uint8) float32

func (*Font) Base

func (f *Font) Base() float32

func (*Font) CharAt

func (f *Font) CharAt(c uint8) Char

func (*Font) LineHeight

func (f *Font) LineHeight() float32

func (*Font) Scales

func (f *Font) Scales() (float32, float32)

func (*Font) String

func (f *Font) String() string

type Info

type Info struct {
	Face     string // This is the name of the true type font.
	Size     int    // The size of the true type font.
	Bld      bool   // The font is bold.
	Italic   bool   // The font is italic.
	Charset  string // The name of the OEM charset used (when not unicode).
	Unicode  bool   // Set to 1 if it is the unicode charset.
	StretchH int    // The font height stretch in percentage. 100% means no stretch.
	Smooth   bool   // Set to 1 if smoothing was turned on.
	AA       int    // The supersampling level used. 1 means no supersampling was used.
	Padding  []int  // The padding for each character (up, right, down, left).
	Spacing  []int  // The spacing for each character (horizontal, vertical).
	Outline  int    // The outline thickness for the characters.
}

This tag holds information on how the font was generated.

type Kerning

type Kerning struct {
	First  uint8   // The first character id.
	Second uint8   // The second character id.
	Amount float32 // How much the x position should be adjusted when drawing the second character immediately following the first.
}

The kerning information is used to adjust the distance between certain characters, e.g. some characters should be placed closer to each other than others.

type Page

type Page struct {
	Id   int    // The page id.
	File string // The texture file name.
}

This tag gives the name of a texture file. There is one for each page in the font.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

func NewReader added in v0.2.0

func NewReader() Reader

func (*Reader) Read

func (r *Reader) Read(filename string) (*Font, error)

type Text

type Text struct {
	Text   string
	X      float32 // center x-coordinate
	Y      float32 // center y-coordinate
	Width  float32 // text must fit into this width
	Height float32 // text must fit into this height
	Font   *Font
}

func NewText

func NewText(text string, x, y, width, height float32, font *Font) Text

NewText return a new Text value for rendering a (multiline) string using a Font inside a 2d box.

func (Text) Render

func (t Text) Render(callback func([]TextureVertex))

Render calls a function with 4 TextureVertex values per character. http://www.glprogramming.com/red/chapter09.html http://www.angelcode.com/products/bmfont/doc/render_text.html

type TextureVertex

type TextureVertex struct {
	S, T float32 // texture coordinates
	X, Y float32 // position coordinates
}

TextureVertex captures one corner of a character to render.

Jump to

Keyboard shortcuts

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