Change Register parameter

This commit is contained in:
Laurent Le Goff 2012-04-17 10:18:26 +02:00
parent 51a750535c
commit 489c6261be

View file

@ -37,11 +37,7 @@ type FontData struct {
Style FontStyle Style FontStyle
} }
func RegisterFont(fontfilename string, font *truetype.Font) { func fontFileName(fontData FontData) string {
fonts[fontfilename] = font
}
func GetFont(fontData FontData) *truetype.Font {
fontFileName := fontData.Name fontFileName := fontData.Name
switch fontData.Family { switch fontData.Family {
case FontFamilySans: case FontFamilySans:
@ -61,6 +57,15 @@ func GetFont(fontData FontData) *truetype.Font {
fontFileName += "i" fontFileName += "i"
} }
fontFileName += ".ttf" fontFileName += ".ttf"
return fontFileName
}
func RegisterFont(fontData FontData, font *truetype.Font) {
fonts[fontFileName(fontData)] = font
}
func GetFont(fontData FontData) *truetype.Font {
fontFileName := fontFileName(fontData)
font := fonts[fontFileName] font := fonts[fontFileName]
if font != nil { if font != nil {
return font return font