[HarfBuzz] hb-view
Adam Twardoch (List)
list.adam at twardoch.com
Thu Apr 21 15:21:07 PDT 2011
On 11-04-21 23:49, Behdad Esfahbod wrote:
> That's a bit trickier than you'd imagine. I've done this before for a client.
> The only way I can get really scalable text is to get the glyphs set for a
> nominal size, convert to outlines using cairo, and scale the outline.
Sure that it's not a 100% "secure" method, especially for small sizes.
But if you measure at a reasonably large size (I'd say equal to the UPM
size, so you really get your total measurements in font units :) ), then
the little rounding "errors" can actually be even USEFUL. I mean, if you
declare something like --text-width=200, and I get 212 rendered, then I
know that the hinting is producing such and such overhead vs. perfectly
linear scaling. That is USEFUL information.
> Right. I'm still undecided whether I want this in a separate tool (that
> wouldn't link to cairo) or in hb-view. Perhaps I add it as you suggest (with
> format="xml" and format="js" or format="json" perhaps), and see how it goes.
An "hb-report" tool could be more sophisticated -- on the other hand,
you could as well put it in hb-view now. I mean, if you're fancy, you
could add config checks for Cairo etc., and if it's not available, the
tool would just not support some "backends". I don't know how one does
it, because I still have not quite understood how compiling and linking,
and how static and dynamic libraries work :D
Oh, for the report formats, I'd also like to see, if possible the UPM
size of the font. The reason why I'm asking for the UPM size to be
reported is that I've realized at some point that doing scaled
measurements where the ppem size = UPM size gives you the 1 pixel = 1
font unit information. So you can render two glyphs, one time with the
"kern" feature enabled, and one time with the kern feature disabled,
compare the pixel widths of the bitmaps and know right away what kerning
value there is. So for complex positioning rules, this can be a handy
way to run various kinds of tests. Alternatively, the tool could just
default to --font-size=UPM size if --font-size is not specified. Sure,
it would produce huge images, but I think that actually is a reasonable
default, rather than something arbitrary, say, 24.
Of course there are tons of other tools that expose the font's UPM size
because it's trivial, but in case of hb-view, that could actually make
sense for the sake of completeness.
And, a record for each shaped glyph should of course have five entries:
(glyph ID, x-position, y-position, x-advance, y-advance).
Best,
Adam
--
May success attend your efforts,
-- Adam Twardoch
(Remove "list." from e-mail address to contact me directly.)
More information about the HarfBuzz
mailing list