From 489c6261be91d2603a328904cdf0e1b5b9327719 Mon Sep 17 00:00:00 2001 From: Laurent Le Goff Date: Tue, 17 Apr 2012 10:18:26 +0200 Subject: [PATCH] Change Register parameter --- draw2d/font.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/draw2d/font.go b/draw2d/font.go index 8385629..a0e7650 100644 --- a/draw2d/font.go +++ b/draw2d/font.go @@ -37,11 +37,7 @@ type FontData struct { Style FontStyle } -func RegisterFont(fontfilename string, font *truetype.Font) { - fonts[fontfilename] = font -} - -func GetFont(fontData FontData) *truetype.Font { +func fontFileName(fontData FontData) string { fontFileName := fontData.Name switch fontData.Family { case FontFamilySans: @@ -61,6 +57,15 @@ func GetFont(fontData FontData) *truetype.Font { fontFileName += "i" } 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] if font != nil { return font