Made Recalc public (recalc->Recalc)

This commit is contained in:
redstarcoder 2016-10-25 14:48:01 -04:00
parent 8c94f068e3
commit fde8c4dad0
3 changed files with 6 additions and 3 deletions

View file

@ -29,7 +29,6 @@ func loadCurrentFont(gc draw2d.GraphicContext) (*truetype.Font, error) {
} }
gc.SetFont(font) gc.SetFont(font)
gc.SetFontSize(gc.GetFontSize()) gc.SetFontSize(gc.GetFontSize())
recalc(gc)
return font, nil return font, nil
} }
@ -116,9 +115,9 @@ func GetStringBounds(gc draw2d.GraphicContext, s string) (left, top, right, bott
return left, top, right, bottom return left, top, right, bottom
} }
// recalc recalculates scale and bounds values from the font size, screen // Recalc recalculates scale and bounds values from the font size, screen
// resolution and font metrics, and invalidates the glyph cache. // resolution and font metrics, and invalidates the glyph cache.
func recalc(gc draw2d.GraphicContext) { func Recalc(gc draw2d.GraphicContext) {
gc.SetScale(gc.GetFontSize() * float64(gc.GetDPI()) * (64.0 / 72.0)) gc.SetScale(gc.GetFontSize() * float64(gc.GetDPI()) * (64.0 / 72.0))
} }

View file

@ -173,6 +173,7 @@ func (gc *GraphicContext) StrokeStringAt(text string, x, y float64) (width float
func (gc *GraphicContext) SetDPI(dpi int) { func (gc *GraphicContext) SetDPI(dpi int) {
gc.DPI = dpi gc.DPI = dpi
draw2dbase.Recalc(gc)
} }
func (gc *GraphicContext) GetDPI() int { func (gc *GraphicContext) GetDPI() int {
@ -182,6 +183,7 @@ func (gc *GraphicContext) GetDPI() int {
// SetFontSize sets the font size in points (as in ``a 12 point font''). // SetFontSize sets the font size in points (as in ``a 12 point font'').
func (gc *GraphicContext) SetFontSize(fontSize float64) { func (gc *GraphicContext) SetFontSize(fontSize float64) {
gc.Current.FontSize = fontSize gc.Current.FontSize = fontSize
draw2dbase.Recalc(gc)
} }
//TODO //TODO

View file

@ -145,6 +145,7 @@ func (gc *GraphicContext) StrokeStringAt(text string, x, y float64) (cursor floa
func (gc *GraphicContext) SetDPI(dpi int) { func (gc *GraphicContext) SetDPI(dpi int) {
gc.DPI = dpi gc.DPI = dpi
draw2dbase.Recalc(gc)
} }
func (gc *GraphicContext) GetDPI() int { func (gc *GraphicContext) GetDPI() int {
@ -154,6 +155,7 @@ func (gc *GraphicContext) GetDPI() int {
// SetFontSize sets the font size in points (as in ``a 12 point font''). // SetFontSize sets the font size in points (as in ``a 12 point font'').
func (gc *GraphicContext) SetFontSize(fontSize float64) { func (gc *GraphicContext) SetFontSize(fontSize float64) {
gc.Current.FontSize = fontSize gc.Current.FontSize = fontSize
draw2dbase.Recalc(gc)
} }
func (gc *GraphicContext) paint(rasterizer *raster.Rasterizer, color color.Color) { func (gc *GraphicContext) paint(rasterizer *raster.Rasterizer, color color.Color) {