Hinting when font size ~= 1

14 views
Skip to first unread message

paul....@gmail.com

unread,
May 29, 2022, 9:55:35 AMMay 29
to skia-discuss
Hi all

Right now, hinting needs to be disabled if font sizes are down near 1 or so.  Otherwise this happens:


Ideally, Skia (or FreeType) would hint based on the final rendered size of the font - not just the value in SkFont.setSize().

If we have no prior knowldge of what the scale will be, we are left with the choice of disabling hinting entirely, or coming up with an algorithm that enables hinting based on a combination of font size and canvas scale.

Is this a bug?  Does the Skia team consider it a bug? 

Paul

Ben Wagner

unread,
May 31, 2022, 8:28:00 AMMay 31
to skia-d...@googlegroups.com
There are a few issues on the Skia side here, but probably the
opposite of what you might expect. The first is that if one does this
Skia should draw the (probably) heavily hinted outlines scaled up
instead of drawing the glyphs at a calculated larger size. This would
look really ugly but would be more correct (and there are historical
reasons why this is difficult to fix right now). The second issue is
that "drawString", "drawSimpleText", etc exist at all. These are toy
routines for labels and such in tests, and should not be used in any
actual product if they can be avoided. Skia really only draws placed
glyphs. For text shaping and producing placed glyphs you'll want to
look into SkParagraph or SkShaper. You might be able to get away with
"drawString" and such if you directly control both the strings and the
exact font data used (not displaying any user entered strings).

Now that being said, if you want scalable text then hinting isn't
going to work well in general. The point of hinting is to trade glyph
shape (linear scaling) for legibility (mostly contrast). In addition
to turning off hinting you'll also want to ensure subpixel
positioning, linear metrics, no baseline snapping, and no embedded
bitmaps (all these set on SkFont).
Reply all
Reply to author
Forward
0 new messages