Property definitions

gamnit $ BMFont :: defaultinit
# BMFont description, parsed with `Text::parse_bmfont` or loaded as a `BMFontAsset`
#
# This class flattens all the `info` and `common` data.
class BMFont

	# ---
	# info part
	#
	# How the font was generated.

	# Name of the source true type font
	var face: Text

	# Size of the source true type font
	var size: Float

	# Is the font bold?
	var bold: Bool

	# Is the font italic?
	var italic: Bool

	# Does the font uses the Unicode charset?
	var unicode: Bool

	# Padding for each character
	#
	# In the format `up,right,down,left`
	var padding: String

	# Spacing for each character
	#
	# In the format `horizontal,vertical`.
	var spacing: String

	# ---
	# common part
	#
	# Information common to all characters

	# Distance in pixels between each line of text
	var line_height: Float

	# Pixels from the top of the line to the base of the characters
	var base: Float

	# Width of the texture
	var scale_w: Float

	# Height of the texture
	var scale_h: Float

	# Textures
	var pages = new Map[String, TextureAsset]

	# Characters in the font
	var chars = new Map[Char, BMFontChar]

	# Distance between certain characters
	var kernings = new HashMap2[Char, Char, Float]

	# Additional distance between `prev_char` and `char`
	fun kerning(prev_char: nullable Char, char: Char): Float
	do
		if prev_char == null then return 0.0
		return kernings[prev_char, char] or else 0.0
	end

	redef fun to_s do return "<{class_name} {face} at {size} pt, "+
	                         "{pages.length} pages, {chars.length} chars>"

	# TODO
	#
	# # From info
	# charset
	# stretchH
	# smooth
	# aa
	# outline
	#
	# # From common
	# packed
	# alphaChnl
	# redChnl
	# greenChnl
	# blueChnl
end
lib/gamnit/bmfont.nit:29,1--115,3