Made Recalc public (recalc->Recalc)
This commit is contained in:
parent
8c94f068e3
commit
fde8c4dad0
3 changed files with 6 additions and 3 deletions
|
@ -29,7 +29,6 @@ func loadCurrentFont(gc draw2d.GraphicContext) (*truetype.Font, error) {
|
|||
}
|
||||
gc.SetFont(font)
|
||||
gc.SetFontSize(gc.GetFontSize())
|
||||
recalc(gc)
|
||||
return font, nil
|
||||
}
|
||||
|
||||
|
@ -116,9 +115,9 @@ func GetStringBounds(gc draw2d.GraphicContext, s string) (left, top, right, bott
|
|||
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.
|
||||
func recalc(gc draw2d.GraphicContext) {
|
||||
func Recalc(gc draw2d.GraphicContext) {
|
||||
gc.SetScale(gc.GetFontSize() * float64(gc.GetDPI()) * (64.0 / 72.0))
|
||||
}
|
||||
|
||||
|
|
|
@ -173,6 +173,7 @@ func (gc *GraphicContext) StrokeStringAt(text string, x, y float64) (width float
|
|||
|
||||
func (gc *GraphicContext) SetDPI(dpi int) {
|
||||
gc.DPI = dpi
|
||||
draw2dbase.Recalc(gc)
|
||||
}
|
||||
|
||||
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'').
|
||||
func (gc *GraphicContext) SetFontSize(fontSize float64) {
|
||||
gc.Current.FontSize = fontSize
|
||||
draw2dbase.Recalc(gc)
|
||||
}
|
||||
|
||||
//TODO
|
||||
|
|
|
@ -145,6 +145,7 @@ func (gc *GraphicContext) StrokeStringAt(text string, x, y float64) (cursor floa
|
|||
|
||||
func (gc *GraphicContext) SetDPI(dpi int) {
|
||||
gc.DPI = dpi
|
||||
draw2dbase.Recalc(gc)
|
||||
}
|
||||
|
||||
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'').
|
||||
func (gc *GraphicContext) SetFontSize(fontSize float64) {
|
||||
gc.Current.FontSize = fontSize
|
||||
draw2dbase.Recalc(gc)
|
||||
}
|
||||
|
||||
func (gc *GraphicContext) paint(rasterizer *raster.Rasterizer, color color.Color) {
|
||||
|
|
Loading…
Reference in a new issue