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 (*Font) AmountBetween ¶
func (*Font) LineHeight ¶
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 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 ¶
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.