Werner LEMBERG writes:
> I'm trying to determine the nominal width of monospaced fonts, in > pixels, that is the normal horizontal advance of rendered glyphs > when FT_FACE_FLAG_FIXED_WIDTH is set. This is not sufficient information. Are you interested in the *linear* (i.e., unhinted) advance width or the hinted one? The former can be a fractional pixel value, while the latter is always returned as full pixels for TrueType fonts.[*]
I'm looking for a metric that corresponds to what I get after an FT_Load_Glyph(), and looking at face->glyph->advance.[xy], for monospaced Truetype fonts like Liberation Mono. I'm trying to answer the following question: here's a monospaced font where, hopefully, all glyphs have the same advance.x for rendering. Can I obtain this value without actually rendering each glyph and seeing what I get.
> I thought, at first, to look at face->size->metrics.max_advance, but > if I do that I find that it's always several pixels more than what I > eventually get after FT_LOAD_RENDERing each glyph, and computing > face->glyph->advance.x >> 6. This might be due to hinting.
I was seeing differences that were more than two pixels. I would think that hinting-related differences would not translate to more than a pixel's worth of a difference.
> For example, using Liberation Mono: with a height of 16 pixels, I > get 11 in metrics.max_advance, but the actual advance width, based > on advance.x, is 10. With a height of 21 pixels, I get a > max_advance of 15, and the actual advance based on advance.x is 13. > Is it possible to get the advance width, of fixed width fonts, > without actually rendering some sample glyphs and seeing what it is? If hinting is involved, no. Exception: The font contains an `hdmx' table that lists advance widths for some ppem value.
That pretty much answers my question. In the interim, I am using a heuristic approach of loading a sample set of glyphs from each face, and averaging out their advance. So far, this gives me a metric that ends up working out correctly, I was just wondering if I reinvented some wheel, somewhere. Seemed like a basic font property that gets shouted from the rooftops. Thanks.
_______________________________________________ Freetype mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/freetype
