> I'm aware that when drawing text, all glyphs should be aligned on a
> single baseline.  The example I've given does not do this; it aligns
> the text on different font's baseline, causing the inconsistent
> look.

This is what I told you in the very beginning: Your logic to position
the glyphs vertically is flawed; you actually don't align them
correctly – somewhere, you are not using the correct vertical offsets.
I suggest that you check the FreeType demo programs for some guidance.

  https://gitlab.freedesktop.org/freetype/freetype-demos

> When I'm talking about "aligning the baselines", I'm referring to
> choosing a suitable baseline from different fonts. I use the term
> "baseline" loosely as when rendering text from top to bottom, the
> ascent value is used.

Why not position the baseline for all fonts at position y=0?

> Initially, I plan to calculate a global baseline from all the fonts
> by averaging their respective baselines. Another way is to pick the
> "lowest" baseline (as in the highest ascent value) as the global
> baseline. I'm unsure of what strategy to use, so I'm curious about
> what approach do other applications use to solve this problem.

If I understand you correctly, we have an XY problem here.  The real
issue seems not to be the alignment on a baseline but rather how to
compute the global bounding box of a text string that comprises
different fonts.  The answer to that was given repeatedly on the
mailing list: If you need a bounding box correct to the pixel and you
do hinting, you have to make FreeType compute all glyphs, store them
somewhere, *then* walk over all individual bounding boxes and take the
maximum dimensions to get the global one.  Finally, you can render the
glyphs with the correct offsets.


    Werner

Reply via email to