Skip to content

Commit d8b858d

Browse files
committed
Round scale to nearest 26.6 fixed point.
With this change, the computation of the scale factor becomes identical across the freetype and truetype packages, removing deviations in the font metrics that are derived from scale. The rounding computation is newer; it was introduced when the truetype.Face type was added in commit 6deea24. Fixes #85.
1 parent e2365df commit d8b858d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CONTRIBUTORS

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
# Please keep the list sorted.
2828

2929
Andrew Gerrand <[email protected]>
30+
Dmitri Shuralyov <[email protected]>
3031
3132
Maksim Kochkin <[email protected]>
3233
Michael Fogleman <[email protected]>

freetype.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func (c *Context) DrawString(s string, p fixed.Point26_6) (fixed.Point26_6, erro
260260
// recalc recalculates scale and bounds values from the font size, screen
261261
// resolution and font metrics, and invalidates the glyph cache.
262262
func (c *Context) recalc() {
263-
c.scale = fixed.Int26_6(c.fontSize * c.dpi * (64.0 / 72.0))
263+
c.scale = fixed.Int26_6(0.5 + (c.fontSize * c.dpi * 64 / 72))
264264
if c.f == nil {
265265
c.r.SetBounds(0, 0)
266266
} else {

0 commit comments

Comments
 (0)