Font rendering without VFlib

Hi together

It seems vFlib and its Freetype library are not maintained anymore and i think the library is too big for what i need it. Is there an alternative to render a "clean" text without vFlib and its freetype font features?

I can live with the current JUCE text rendering if the text is BOLD, but it looks a bit blurry if i use the normal font style. The components itself look good with some cheating (using floating numbers for positions to avoid the mix of blurry rounded corners and clean straight lines).

Is it possible to use OpenGL and render the GUI 2 or 4 times bigger and let the graphic card scale it down with some hardware accelerated high quality resampling? Does juce offer a feature like this out of the box?

Think this would be the way to go, especially if we do not want use images for the GUI design anymore.

Any ideas are welcome.
 

 

Is it possible to use OpenGL and render the GUI 2 or 4 times bigger and let the graphic card scale it down with some hardware accelerated high quality resampling? Does juce offer a feature like this out of the box?

Think this would be the way to go, especially if we do not want use images for the GUI design anymore.

Huh? No, you're totally misunderstanding the whole thing.

The accuracy of the juce font/path rendering is already perfect - messing around with bitmaps will only produce a worse result. What you want is font hinting, which is totally different. The fonts aren't "blurry" because there's a error in the code - they look like that because that's exactly what the result would be if you rendered them at a huge scale and then scaled it down perfectly.

And did you see that I've changed the gamma used for rendering recently? It's now pretty much identical to the OSX native rendering, apart from hinting.

I believe the terms of the MIT license allow you to extract vf_freetype out of VFLib and use it standalone (as long as you retain the notices).

You'd need to include vf_FreeTypeFaces.h and FreeTypeAmalgam\FreeTypeAmalgam.h and you might need to hack vf_freetype.c so the path to FreeTypeAmalgam\FreeTypeAmalgam.c is OK.

This'd probably be a good one to make into a standalone module.

Ok, is see. Thanks for pointing me into the right direction. I will try the latest tip. I think the OSX font rendering is good enough for me, otherwise i will try font hinting.

 

Thanks for the tip. Sounds like a possible "easy" solution to get font hinting without a lot effort.

..ok, but there is no hinting in the software renderer - that's the whole reason for all this moaning, and why vinnie did the FT stuff!

I just wanted to avoid you going down a blind alley by thinking it was some kind of rendering error.

Thanks for the additional information. The difference with the latest tip is not big, but it improves the readability and looks better. Think there is currently no need for hinting as long as i render "Bold" text.

 

 

It worked and i was able to include the freetype library. Thanks a lot for this! But it seems that i'm using the library the wrong way and FreeTypeFaces always returns nullptr. After i had no success with a serialized font i tried following simple example:

Typeface::Ptr typeface = FreeTypeFaces::createTypefaceForFont(Font(11, 0));

Shouldn't that return a hinted typeface for the default font? Any help is welcome.

Assuming you've read and followed all the instructions in vf_FreeTypeFaces.h, then another thing to do is try to serialise a different font. I found that some fonts didn't load properly and I couldn't track down why they failed. However I found that I could sometimes fix the problem by using the webfont generator at Font Squirrel to optimise a problematic font.

I haven't actually tried using FreeTypeFaces for the default font, so I'll refrain from commenting on that for now.

Thanks for the fast reply. I will try some other standard fonts and maybe use Font Squirrel for the special ones if that does not work.

It worked :) Thanks for your help. I serialized the font with the JUCE serializer instead of using the ttf file directly as binary ressource.

Good news!

Hi, I'm trying too to make it work, however FT_New_Memory_Face in FreeTypeFace::openMemoryFace never returns without error. I've tried a few ttf fonts, also ones created via fontsquirrrel. Can you specify more exactly how you serialized the font, and then used that font with freetype ?

Thanks

/Rob

The FontSquirrel thing is a last resort. The thing Patrick mentioned about using the JUCE serializer is really important. Use BinaryBuilder from the JUCE extras folder. For example (from the command prompt in Windows):

BinaryBuilder.exe MyFontDirectory MyDestinationDirectory myFontClass fontname*.ttf

This will scan MyFontDirectory for all files that match fontname*.ttf and serialise them into MyDestinationDirectory\myFontClass.h/.cpp. Hope this helps!

No, not really :) I already import all assets I need into a zip which then is incorporated into the binary with BinaryBuilder. However, what I missed was that when adding the typeface from memory, the memory needs to be persistent, i.e. the freetype stuff doesn't keep a copy of the data. With the raw data created with BinaryBuilder it's not a problem, but with my construct I need to cache the extracted memory... :)

I was able to get very clean hinted text in windows now, but it does not look the same on OSX (Arial.ttf). The text on OSX looks a bit more blurry as on windows and not all letters are hinted.

Did someone notice a similar behavior and was able to fix it? Any ideas are welcome.

Edit: I'm using Vinn's code snipped for the Look and Feel modification.

@jules: no images :)

 

Edit2: It seems that the hinting works if i use justification::left. justfication::center kills the hinting. I just do not understand why it works on windows.