I am running into inconsistencies with how glyphs are spaced in some situations.
I am using DirectWrite with a IDWriteFontFace
and using the GetGlyphIndices
with GetDesignGlyphMetrics
to get the metrics of the glyphs so I can take each glyph, store it as an image, then reconstruct the whole string using the glyph information (advance, lsb, rsb, etc). I am rendering each glyph using ID2D1RenderTarget.DrawTextLayout
with WIC bitmaps. While 99% of tests I have done seem to work, I am running into inconsistent spacing and I have no idea what is causing it. Maybe someone can shed some light, but I am not sure where to start.
From my basic interpretation the font layout is composed of rendering the glyphs as lsb + width, and then the place to put the next character is called the advance and the advance width is composed of lsb, glyph width, rsb.
I am using this Zapfino font, because it seems fairly complex and a good metric to test if things are rendering correctly.
So here are some rendering comparisons line by line:
correct render: Here are two different strings left and right, correctly rendered through paint.net
my render: I include the advance placements (red) and the starting position (yellow). On the left, we have World! rendered, and the orld! is correctly placed, but the distance between W and o is too large now compared to the correct rendering.
On the right side we have Hold! rendered and for the most part is consistent with the paint.net render.
I overlap both to give a better idea of comparison. I align the left of the orld! so you can see that atleast that part is consistent, it's the W is off. Right side is almost identical.
Paint.net shows the cursor position in what I assume is the advance. You can see that the advance placement, the o is right on top of it. But with o on the right side, you can see it has distance from advance to the o. When rendering the o at the front (5), next to a different character, or by itself, it still has that distance. I believe (appearance wise) it's the LSB that seems to shrink?
orld! rendered with paint.net with the cursor. You can see the o is intersecting the advance. Some other examples, We has the same problem as Wo, shrunk LSB, but for instance in Wi, the glyph has proper distance from the advance, like it would be on its own.
What is this effect called where it shrinks the LSB or moves the placement of the glyph depending on characters? How can I detect such behavior through glyph data?