Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » TTF and ASCII

Credits go to Kirr for helping out!
This thread is locked; no one can reply to it. rss feed Print
TTF and ASCII
Wagner Soares
Member #9,011
September 2007
avatar

I want to use TTF in Allegro, and need ASCII support at the same time (characters like á, ã, ç).
I tried Glyph Keeper with gk_create_allegro_font(rend), but I get a very low frame rate. Other functions doesn't seem to work with those ASCII characters.
Alfont at http://chernsha.sitesled.com/ doesn't work to compile.
With FudgeFont at http://fudgefont.sourceforge.net/, when I type mingw32-make -f SConstruct I get this error:

SConstruct:4: *** missing separator. Stop.

So what should I do!?!?!
unfortunelly I really need that some fonts used in my game must be TTF, and must support some ASCII characters.

and I forgot something, I used set_uformat ( U_ASCII ) whith glyph keeper and nothing changed.

thanx anyway, and sorry if I wrote anything wrong, cause I'm brazilian!!

gnolam
Member #2,030
March 2002
avatar

Quote:

I want to use TTF in Allegro, and need ASCII support at the same time (characters like á, ã, ç).

Those aren't ASCII (the ASCII extensions are a mess of incompatible code pages). You want U_UTF8, not U_ASCII.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Wagner Soares
Member #9,011
September 2007
avatar

I tried U_UTF8, and I get a ^ in place of those chars.

I didn't understand what u meant with "the ASCII extensions are a mess of incompatible code pages". :P

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

I tried U_UTF8, and I get a ^ in place of those chars.

That means allegro couldn't find the char in the font. Make sure your font has them, and in the right place.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Wagner Soares
Member #9,011
September 2007
avatar

Quote:

That means allegro couldn't find the char in the font. Make sure your font has them, and in the right place.

I wasn't using BITMAP fonts, I was using glyph keeper, and loading a TTF (Monotype Corsiva).
with the glyph textout functions, those chars turn into a ^, but when I use gk_create_allegro_font(rend), set_uformat(U_ASCII) and Allegro textout functions, all chars appear normally for the cost of performance.

glyph keeper has other function (gk_create_allegro_bitmap_font_for_range) but with that, the application stops to respond.

So I'm asking for alternative ways to use TTF (not image fonts) in my project, and support those chars.

I was thinking about make my own BITMAP fonts and functions, but I don't want to lose performance.

Kirr
Member #5,060
September 2004
avatar

Hi Wagner. Can you post a short program that demonstrates low performance with Glyph Keeper? Glyph Keeper is all about performance. If it works slowly it is probably because you are not using glyph cache, or because you render translucent text onto a 8-bit bitmap, or some other problem like this.. Do Glyph Keeper examples also work slowly for you? Especially the benchmark? Please post more information and I'll try to help. :)

--
"Go to the NW of Stonemarket Plaza to the Blue Glyph Keeper Library door and enter."
- Lunabean's Thief Deadly Shadows Walkthrough, day eight

Wagner Soares
Member #9,011
September 2007
avatar

GLYPH_FACE *face;
GLYPH_REND *rend;
FONT *mtcorsva;

face = gk_load_face_from_file("MTCORSVA.ttf", 0);
rend = gk_create_renderer(face, 0);
mtcorsva = gk_create_allegro_font(rend);

and when I use mtcorsva with:

textprintf ( Tela, mtcorsva, 10, 10, makecol(255, 255, 255), "(áãç FPS: %d", Fps);

or

textout ( Tela, mtcorsva, "Testando acentos com Glyph Keeper áãç", 10, 30, makecol(255,255,255) );

I get a consederable drop at the game speed, but only if I use FONT *mtcorsva with Allegro functions.
Glyph functions Work great, but don't show those chars that I need (áãçâ and others like that).

Kirr
Member #5,060
September 2004
avatar

Please try this:

GLYPH_FACE *face;
GLYPH_REND *rend;
GLYPH_KEEP *keep;
FONT *mtcorsva;

keep = gk_create_keeper(0,1*1024*1024);
face = gk_load_face_from_file("MTCORSVA.ttf", 0);
rend = gk_create_renderer(face, keep);
mtcorsva = gk_create_allegro_font(rend);

and tell me if it helped.

Also, Glyph Keeper certainly supports "áãçâ and others like that", you just have to use one of the Unicode Transformation Formats for your text for them to work. (UTF-8 or UTF-16).

Use any Unicode text editor to save your text in such format. Allegro Unicode routines can be useful too. This way you are getting one step closer to writing an internationalizable program. :)

--
"Go to the NW of Stonemarket Plaza to the Blue Glyph Keeper Library door and enter."
- Lunabean's Thief Deadly Shadows Walkthrough, day eight

Wagner Soares
Member #9,011
September 2007
avatar

thanx, this solves the problem, but I didn't understand how. ;D
and I found something about UTF-8 in Code::Blocks and now it's able to show all chars that I write.

I have one last question, glyph keeper has textout function like textprintf from Allegro, if I want to print a variable.
if not no prob, glyph keeper is great!!
thanx again!

Kirr
Member #5,060
September 2004
avatar

Glad that it worked. :) Now you are caching the glyphs instead of rendering them every time you need them.

Quote:

I have one last question, glyph keeper has textout function like textprintf from Allegro, if I want to print a variable.

No Glyph Keeper does not have such function. You can use sprintf (or better snprintf) to format your text.

--
"Go to the NW of Stonemarket Plaza to the Blue Glyph Keeper Library door and enter."
- Lunabean's Thief Deadly Shadows Walkthrough, day eight

Go to: