diff --git a/.gitignore b/.gitignore index 3527a30..ec763e1 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ _test* **/core*[0-9] .private +go.sum + diff --git a/draw2dbase/stack_gc.go b/draw2dbase/stack_gc.go index 77622bb..7f53511 100644 --- a/draw2dbase/stack_gc.go +++ b/draw2dbase/stack_gc.go @@ -41,6 +41,13 @@ type ContextStack struct { Previous *ContextStack } +// GetFontName gets the current FontData with fontSize as a string +func (cs *ContextStack) GetFontName() string { + fontData := cs.FontData + return fmt.Sprintf("%s:%d:%d:%9.2f", fontData.Name, fontData.Family, fontData.Style, cs.FontSize) +} + + /** * Create a new Graphic context from an image */ @@ -198,6 +205,5 @@ func (gc *StackGraphicContext) Restore() { } func (gc *StackGraphicContext) GetFontName() string { - fontData := gc.Current.FontData - return fmt.Sprintf("%s:%d:%d:%d", fontData.Name, fontData.Family, fontData.Style, gc.Current.FontSize) + return gc.Current.GetFontName() } diff --git a/draw2dsvg/gc.go b/draw2dsvg/gc.go index 30fba26..806b664 100644 --- a/draw2dsvg/gc.go +++ b/draw2dsvg/gc.go @@ -4,8 +4,7 @@ package draw2dsvg import ( - "fmt" - "github.com/golang/freetype/truetype" + "github.com/golang/freetype/truetype" "github.com/llgcode/draw2d" "github.com/llgcode/draw2d/draw2dbase" "golang.org/x/image/font" @@ -401,12 +400,3 @@ func (gc *GraphicContext) drawGlyph(glyph truetype.Index, dx, dy float64) error func (gc *GraphicContext) recalc() { gc.Current.Scale = gc.Current.FontSize * float64(gc.DPI) * (64.0 / 72.0) } - -/////////////////////////////////////// -// TODO implement following methods (or remove if not neccesary) - -// GetFontName gets the current FontData with fontSize as a string -func (gc *GraphicContext) GetFontName() string { - fontData := gc.Current.FontData - return fmt.Sprintf("%s:%d:%d:%d", fontData.Name, fontData.Family, fontData.Style, gc.Current.FontSize) -} diff --git a/output/samples/geometry.png b/output/samples/geometry.png index b46ec89..d05da1b 100644 Binary files a/output/samples/geometry.png and b/output/samples/geometry.png differ