Documentation
¶
Overview ¶
Package bmf implements BMF .fnt file parsing and serialization. It supports only version 3 of the binary format. For more information see http://www.angelcode.com/products/bmfont/doc/file_format.html
Index ¶
- Constants
- Variables
- func LookupCharset(charsetEnum int) (name string, found bool)
- func LookupCharsetValue(charset string) (value int, found bool)
- func SerializeBinary(fnt *Font, dst io.Writer) error
- func SerializeText(fnt *Font, dst io.Writer) error
- type BinBool
- type BinaryParseError
- type BlockType
- type Channel
- type ChannelData
- type Char
- type Common
- type Font
- type Info
- type Kerning
- type Padding
- type Page
- type Spacing
- type TextParseError
Constants ¶
const SupportedVersion = 3
SupportedVersion of the binary format
Variables ¶
var CharsetTable = map[int]string{
186: "Baltic",
77: "Mac",
204: "Russian",
238: "EastEurope",
222: "Thai",
163: "Vietnamese",
162: "Turkish",
161: "Greek",
178: "Arabic",
177: "Hebrew",
130: "Johab",
255: "Oem",
136: "ChineseBig5",
134: "GB2312",
129: "Hangul",
128: "ShiftJIS",
2: "Symbol",
1: "Default",
0: "Ansi",
}
CharsetTable enumerates known charset values source https://docs.microsoft.com/en-us/previous-versions/windows/desktop/bb322881(v=vs.85)
Functions ¶
func LookupCharset ¶ added in v1.0.1
LookupCharset gets the name of a charset or value as a decimal string when not found
func LookupCharsetValue ¶ added in v1.1.0
LookupCharsetValue gets the enum value of a charset or converts a a decimal string to a number
func SerializeBinary ¶ added in v1.1.0
SerializeBinary serializes a bmf font definition in binary format.
Types ¶
type BinBool ¶
type BinBool bool
BinBool represents a boolean as 0 or 1
type BinaryParseError ¶
BinaryParseError contains info about where and why a parsing error occurred
func (BinaryParseError) Error ¶
func (e BinaryParseError) Error() string
func (BinaryParseError) Unwrap ¶ added in v1.1.0
func (e BinaryParseError) Unwrap() error
type ChannelData ¶
type ChannelData int
ChannelData specifies the type of data that a color channel holds
const ( Glyph ChannelData = iota Outline GlyphAndOutline Zero One )
Channel data types
type Char ¶
type Char struct {
Id rune `xml:"id,attr"`
X int `xml:"x,attr"`
Y int `xml:"y,attr"`
Width int `xml:"width,attr"`
Height int `xml:"height,attr"`
XOffset int `xml:"xoffset,attr"`
YOffset int `xml:"yoffset,attr"`
XAdvance int `xml:"xadvance,attr"`
Page int `xml:"page,attr"`
Channel Channel `xml:"chnl,attr"`
}
Char describes on character in the font. There is one for each included character in the font.
type Common ¶
type Common struct {
LineHeight int `xml:"lineHeight,attr"`
Base int `xml:"base,attr"`
ScaleW int `xml:"scaleW,attr"`
ScaleH int `xml:"scaleH,attr"`
Pages int `xml:"pages,attr"`
Packed BinBool `xml:"packed,attr"`
AlphaChannel ChannelData `xml:"alphaChnl,attr"`
RedChannel ChannelData `xml:"redChnl,attr"`
GreenChannel ChannelData `xml:"greenChnl,attr"`
BlueChannel ChannelData `xml:"blueChnl,attr"`
}
Common holds information common to all characters.
type Font ¶
type Font struct {
Info Info `xml:"info"`
Common Common `xml:"common"`
Pages []Page `xml:"pages>page"`
Chars []Char `xml:"chars>char"`
Kernings []Kerning `xml:"kernings>kerning"`
}
Font defines an AngelCode Bitmap Font
func ParseBinary ¶
ParseBinary parses a bmf font definition in binary format. For more information see http://www.angelcode.com/products/bmfont/doc/file_format.html#bin
func (Font) MarshalXML ¶
MarshalXML converts a Font struct to XML
type Info ¶
type Info struct {
Face string `xml:"face,attr"`
Size int `xml:"size,attr"`
Bold BinBool `xml:"bold,attr"`
Italic BinBool `xml:"italic,attr"`
Charset string `xml:"charset,attr"`
Unicode BinBool `xml:"unicode,attr"`
StretchH int `xml:"stretchH,attr"`
Smooth BinBool `xml:"smooth,attr"`
AA int `xml:"aa,attr"`
Padding Padding `xml:"padding,attr"`
Spacing Spacing `xml:"spacing,attr"`
Outline int `xml:"outline,attr"`
}
Info holds information on how the font was generated
type Kerning ¶
type Kerning struct {
First rune `xml:"first,attr"`
Second rune `xml:"second,attr"`
Amount int `xml:"amount,attr"`
}
Kerning specifies the distance between specific character pairs
type Padding ¶
Padding specifies the padding for each character in pixels See https://www.angelcode.com/products/bmfont/doc/export_options.html
func (Padding) MarshalXMLAttr ¶
MarshalXMLAttr converts to format <up>,<right>,<down>,<left>
type Page ¶
Page references a bitmap image that contains the glyphs. A font can contain multiple glyph pages.
type Spacing ¶
Spacing specifies the spacing for each character in pixels See https://www.angelcode.com/products/bmfont/doc/export_options.html
func (Spacing) MarshalXMLAttr ¶
MarshalXMLAttr converts to format <horizontal>,<vertical>
type TextParseError ¶
TextParseError contains info about where and why a parsing error occurred
func (TextParseError) Error ¶
func (e TextParseError) Error() string
func (TextParseError) Unwrap ¶
func (e TextParseError) Unwrap() error