Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » fonts in 5.0.1 vs. 5.0.5

This thread is locked; no one can reply to it. rss feed Print
fonts in 5.0.1 vs. 5.0.5
APrince
Member #12,698
March 2011

Hi I tried to migrate from 5.0.1 to 5.0.5 but someting strange happened to all the texts...

{"name":"fonts.PNG","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/f\/4f443151664dbff0c3979634c779182a.png","w":492,"h":65,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/f\/4f443151664dbff0c3979634c779182a"}fonts.PNG

//The 5.0.5 and 5.0.1 labels are not drawn by the program i just labeled the image...

In the left part, the version label seems to be kind of too shrunk whereas the right side seems to be a bit scaled in 5.0.5. I read the changes from 5.0.1 to 5.0.5 but haven't found one, that would correspond to this problem. What have I possibly done wrong?

Thanks.

Peter Wang
Member #23
April 2000

Are you sure it's the same version of FreeType? There could be differences there.

Otherwise please provide a short test program with the associated font file.

APrince
Member #12,698
March 2011

Well I downloaded Windows binaries so I didn't have to care about freetype at all... Anyway I will make a short demo and post it here.

//edit: So here is the code:

#SelectExpand
1bool as_al_init(int display_width, int display_height, ALLEGRO_DISPLAY** display, ALLEGRO_EVENT_QUEUE** event_queue){ 2 if (!al_init()){ 3 std::cerr << "Failed to initialize allegro!" << std::endl; 4 return false; 5 } 6 if (!al_install_mouse()){ 7 std::cerr << "Failed to install mouse!" << std::endl; 8 return false; 9 } 10 if (!al_install_keyboard()){ 11 std::cerr << "Failed to install keyboard!" << std::endl; 12 return false; 13 } 14 if (!display) return false; 15 //al_set_new_display_flags(ALLEGRO_OPENGL); 16 al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST); 17 al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST); 18 if (!(*display = al_create_display(display_width,display_height))){ 19 return false; 20 } 21 22 if (!event_queue) {al_destroy_display(*display); return false;} 23 if (!(*event_queue = al_create_event_queue())){ 24 al_destroy_display(*display); 25 std::cerr << "Failed to create event queue!" << std::endl; 26 return false; 27 } 28 if (!(al_init_image_addon())){ 29 std::cerr << "Failed to initialize image addon." << std::endl; 30 al_destroy_display(*display); 31 return false; 32 } 33 if (!(al_init_primitives_addon())){ 34 std::cerr << "Failed to initialize primitives addon." << std::endl; 35 al_destroy_display(*display); 36 return false; 37 } 38 al_init_font_addon(); 39 if (!(al_init_ttf_addon())){ 40 std::cerr << "Failed to initialize ttf addon." << std::endl; 41 al_destroy_display(*display); 42 return false; 43 } 44 45 return true; 46} 47 48void as_al_cleanUp(ALLEGRO_DISPLAY* display, ALLEGRO_EVENT_QUEUE* event_queue){ 49 if (event_queue) al_destroy_event_queue(event_queue); 50 if (display) al_destroy_display(display); 51 al_shutdown_ttf_addon(); 52 al_shutdown_font_addon(); 53 al_shutdown_primitives_addon(); 54 al_shutdown_image_addon(); 55 al_uninstall_keyboard(); 56 al_uninstall_mouse(); 57 al_uninstall_system(); //all allegro shutdowns have to go before this one... 58} 59 60int main(int argc, char* argv[]) 61{ 62 ALLEGRO_DISPLAY* display = NULL; 63 ALLEGRO_EVENT_QUEUE* event_queue = NULL; 64 65 if (!as_al_init(640, 480, &display, &event_queue)) return 1; 66 ALLEGRO_FONT* font = al_load_ttf_font("titilliumtext25l001.ttf", 12, 0); 67 68 al_clear_to_color(al_map_rgb(0,0,0)); 69 70 al_draw_text(font, al_map_rgb(255,255,255), 20,2,0, "0.9851"); 71 72 al_flip_display(); 73 74 Sleep(10000); 75 76 as_al_cleanUp(display, event_queue); 77 return 0; 78}

And here are the results:
5.0.1
501.png
5.0.5
505.png

//edit: So I suppose that the problem is caused by the fact, that provided Windows binaries have been built with different version of freetype, right? That's unfortunate I'd say, because the 5.0.5 version seems a bit defective.

Peter Wang
Member #23
April 2000

I tested on Linux with 5.01 and 5.0.5. The results are bit-identical. So it's probably a difference in how the Windows binaries were made. Michał might know.

PS. Next time, provide the whole source. Don't make it hard for testers.

APrince
Member #12,698
March 2011

You mean "whole" as with includes as well? All right...

Michał Cichoń
Member #11,736
March 2010

I'm syncing from time to time dependencies. Yes, I did updated FreeType to newer version. I can update again and artifact may just dissapear.

I will try.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

APrince
Member #12,698
March 2011

Thank's a lot...

Michał Cichoń
Member #11,736
March 2010

I found a reason. From version ~2.4.5 FreeType auto hinter is enabled by default, that affect rendering of some fonts. Exactly your case.

In order to fix that FT_LOAD_NO_AUTOHINT should be specified while rendering glyph. That mean some flag should be added to TTF addon, which inform FT that we want or do not want auto hinter.

One way or another that will require new binaries unless you're linking Allegro statically. In that very case you may just use FreeType from 5.0.1 package and you will get properly hinted font.

Edit:
Appropriate changes was committed to Allegro 5.1 branch and should be merged down to 5.0.6 version.

If you want I may prepare a build for you, just tell me what toolchain are you using.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

Trent Gamblin
Member #261
April 2000
avatar

Michal, is you're preparing a binary, could you include the D3D multisampling fix I committed today? The OP asked me when a new release would be coming for that fix. Only if you're already going to be building binaries, might as well kill two birds... :D

APrince
Member #12,698
March 2011

That would be so perfect, that I don't even dare to hope for it... :-D

Trent Gamblin
Member #261
April 2000
avatar

Don't forget to mention your toolchain :P.

APrince
Member #12,698
March 2011

Well... I had to google the term up.

I hope that I get it correctly... So I use Visual Studio 2010 for everything and I link Allegro binaries (the ones from Michał) dynamically (because I was not able to build it statically even after reading a lot of threads here concerning the topic).

Michał Cichoń
Member #11,736
March 2010

Trent, on what branch yours changes are?

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

Trent Gamblin
Member #261
April 2000
avatar

My changes are still only in the 5.1 branch. Revision 15286.

Peter Wang
Member #23
April 2000

I'll commit the 5.0.6 backported changes later today or tomorrow, after some testing in Windows.

Michał Cichoń
Member #11,736
March 2010

I will do a build when 5.0.6 will be ready.

Peter is already merging changes to 5.0.6 branch.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

APrince
Member #12,698
March 2011

Thanks...

GullRaDriel
Member #3,861
September 2003
avatar

I like when things get fixed :-)

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

APrince
Member #12,698
March 2011

So how's it going?

Michał Cichoń
Member #11,736
March 2010

Build is ready: http://www.allegro.cc/forums/thread/609685/949007#target

To solve your issue, use FT_LOAD_NO_AUTOHINT flag to load font.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

APrince
Member #12,698
March 2011

Thank's a lot... I'll try tomorrow.

//edit: I suppose you meant ALLEGRO_TTF_NO_AUTOHINT, but i figured out that much... :-) Works perfectly. Thank's very much.

Michał Cichoń
Member #11,736
March 2010

Yes, my mistake.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

Go to: