Skip to content

Commit

Permalink
Round scale to nearest 26.6 fixed point.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dmitshur committed Oct 24, 2021
1 parent e2365df commit d8b858d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# Please keep the list sorted.

Andrew Gerrand <[email protected]>
Dmitri Shuralyov <[email protected]>
Jeff R. Allen <[email protected]> <[email protected]>
Maksim Kochkin <[email protected]>
Michael Fogleman <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion freetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (c *Context) DrawString(s string, p fixed.Point26_6) (fixed.Point26_6, erro
// recalc recalculates scale and bounds values from the font size, screen
// resolution and font metrics, and invalidates the glyph cache.
func (c *Context) recalc() {
c.scale = fixed.Int26_6(c.fontSize * c.dpi * (64.0 / 72.0))
c.scale = fixed.Int26_6(0.5 + (c.fontSize * c.dpi * 64 / 72))
if c.f == nil {
c.r.SetBounds(0, 0)
} else {
Expand Down

0 comments on commit d8b858d

Please sign in to comment.