Some fonts not rendered correctly in Linux


#1

Hello!

My application uses the font “Unit Rounded OT” converted to a true type font. This font is rendered correctly in Windows but not in Linux. If the glyph is somehow “round” in the lower right, Juce draws an edge instead. At the most extreme, this effect can be seen with the “8”, but it’s also visible with a “0”, “9”, “S”, …
As I found, the problem is the handling of the start point of a contour returned by the freetype library. I changed the code of “addGlyph” in “juce_linux_Fonts.cpp” to the following:

[code]…
for (int p = startPoint; p <= endPoint; p++)
{
const float x = CONVERTX (points[p]);
const float y = CONVERTY (points[p]);

            if (p == startPoint)
            {
                if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_Conic)
                {
                    float x2 = CONVERTX (points [endPoint]);
                    float y2 = CONVERTY (points [endPoint]);

                    if (FT_CURVE_TAG (tags[endPoint]) == FT_Curve_Tag_On)
                    {
                        destShape.startNewSubPath (x2, y2);
                    }
                    else
                    {
                        destShape.startNewSubPath ((x + x2) * 0.5f, (y + y2) * 0.5f);
                    }
                }
                else
                {
                    destShape.startNewSubPath (x, y);
                }
            }
            if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_On)
            {
                if (p != startPoint)
                {
                    destShape.lineTo (x, y);
                }
            }
            else if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_Conic)
            {


[/code]

The font mentioned above works now, and other fonts don’t seem to be disturbed.
I found that solution for the handling of the first point of a contour in the implementation of the freetype-internal function “Decompose_Curve”.

Best Regards,
Andreas


#2

Ah, right. Thanks very much for tracking that down!

But you didn’t mean to remove the “else” at this line, did you?

} else if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_On) {


#3

Yes, I meant to remove the “else” on that line. Instead I added

                    if (p != startPoint)

to that case. The removal of the “else” is necessary, because if the first point is a conic, that conic has to be added to the path.
A cubic as first point would not be handled correctly now, but freetype should not return a cubic as first point. But to be sure, this should be checked probably.


#4

Oh yes, sorry, I didn’t notice your “p != startPoint” line. Ok, I’ll do a fix and check it in. Thanks!