Merge pull request #146 from piotrkowalczuk/get-font-name-proper-font-size-serialization
GetFontName serialize font size properly thanks @piotrkowalczuk
This commit is contained in:
commit
f52c8a71af
4 changed files with 11 additions and 13 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -21,3 +21,5 @@ _test*
|
|||
**/core*[0-9]
|
||||
.private
|
||||
|
||||
go.sum
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Loading…
Reference in a new issue