Some fonts not rendered correctly in Linux

For Linux specific issues

Some fonts not rendered correctly in Linux

Postby andreas » Tue Apr 22, 2008 1:58 pm

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: Select all
...
            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)
                {
...


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
andreas
JUCE Geek
 
Posts: 37
Joined: Fri Oct 05, 2007 10:17 am

Postby jules » Tue Apr 22, 2008 2:06 pm

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

But you didn't mean to remove the "else" at this line, did you?

Code: Select all
                }
                else if (FT_CURVE_TAG (tags[p]) == FT_Curve_Tag_On)
                {
User avatar
jules
Fearless Leader
 
Posts: 17189
Joined: Mon Sep 06, 2004 9:03 am
Location: London, UK

Postby andreas » Tue Apr 22, 2008 2:18 pm

Yes, I meant to remove the "else" on that line. Instead I added
Code: Select all
                    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.
andreas
JUCE Geek
 
Posts: 37
Joined: Fri Oct 05, 2007 10:17 am

Postby jules » Tue Apr 22, 2008 2:32 pm

Oh yes, sorry, I didn't notice your "p != startPoint" line. Ok, I'll do a fix and check it in. Thanks!
User avatar
jules
Fearless Leader
 
Posts: 17189
Joined: Mon Sep 06, 2004 9:03 am
Location: London, UK


Return to Linux

Who is online

Users browsing this forum: Heritrix [Crawler] and 1 guest