More FreeType experiments


#1

Hi Everyone,

I had a go at trying to get more out of FreeType font rendering by having freetype render instead of Juce. it works, but there are some problems.

The first problem is that I am rendering the FT glyph every time! Yes, this is crazy and, as you can imagine isn’t fast. Actually, it’s a lot slower than Juce rendering. So, my question is how are you supposed to do this efficiently. Let me explain;

Currently, I have Juce perform the layout and it gives me a bunch of `PositionGlyph’s. These have non-integer pixel coordinates (which it should). In order to render the glyph correctly at the sun-pixel offset, i have to translate and render the outline to a bitmap, like this:

[code] error = FT_Load_Char (face, c, FT_LOAD_NO_HINTING);

        error = !error && FT_Get_Glyph( face->glyph, &glyph );  
        error = !error && FT_Glyph_To_Bitmap(&glyph,
                                             lcd ?
                                           FT_RENDER_MODE_LCD: 
                                             FT_RENDER_MODE_NORMAL,
                                             &offset, 1);

[/code]

I pass in the subpixel `offset’ for the glyph. This works and I get the correct results. HOWEVER, each glyph image depends on the subpixel value, which varies from 0 to 63. Am i expected to cache 64 glyph images per character, because that sounds like a lot! Obviously, just caching one pixel aligned image per character does not give the result - or is there something i’m missing here.

The other thing, as you can see from my code above, is that i had a shot at LCD rendering. As you know, you have to enable this in the freetype lib due to patents (as an aside, is there a non-patented option at all?). The result is terrible! the color fringes are too bright and, actually, the freetype docs admit this. I wanted to enable to LCD filter `FT_Library_SetLcdFilter’ but this appears absent from TheVinn’s amalgamation. Any suggestions here before i give up on it.

Otherwise, i can reveal the results are almost pixel identical to the Juce rendering.


#2

You can re-amalgamate FreeType yourself using the Amalgams repository in my GitHub.


#3

ok, thanks. I’ll give it a go.


#4

got it and it works. thanks.

add this to FreeTypeAmalgamTemplate.h

and this to FreeTypeAmalgamTemplate.c