I am using allegro to print text onto the screen, which I have had no problems with. But I am unable to print a `£' sign. When try to print a string with a `£' sign in it, then nothing happens, as if I never called al_draw_text.
I have tried a number of fonts, as I wondered if it was just that the font I used didn't have the symbol. None of them worked, so I figured it must be something else.
Could anyone help me?
I see DejaVuSans.ttf (distributed with A5) has a pound sign, maybe you forgot something else, such as al_init_ttf_addon()?
I noticed this too, last night. Using Allegro 5.07, Code::Blocks & Mingw. I tried with Arial.ttf but couldn't get it working, so decided to leave it for now.
Strange, this prog stops printing the entire string when it gets to the pound sign.
pepsi@fractal:/home/prog/gui 05:24 AM $ tail r.c { fprintf(stderr,"Couldn't load font\n"); return 1; } al_draw_text(DejaVuSans28font, al_map_rgb(255,255,255), 0.0,0.0,0,"pound sign -> £ <- pound sign"); al_flip_display(); al_rest(10.0); return 0; }
[EDIT]
I can get it to appear in ex_ttf.c
{"name":"606501","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/e\/9ece7ec2cbdf15047945ca18d7c0133e.png","w":652,"h":508,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/e\/9ece7ec2cbdf15047945ca18d7c0133e"}
but I can't see what's different about the ttf code.
[EDIT 2]
When I look at ex_ttf.c with the joe editor, it shows uppercase 'A's among the weird characters, but the test code doesn't show that. The kwrite editor I normally use now won't even move the cursor when I open the test code, it's like it's locked up.
[EDIT 3]
I finally got it to work by using a hex editor on the source file
{"name":"606502","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/1\/21388d0651c192891e5a3962535870f3.png","w":246,"h":84,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/1\/21388d0651c192891e5a3962535870f3"}
[EDIT 5]
And now when I copy the code off this post, and save it and compile, it doesn't work. Fuck it, I'm going back to ASCII!
It's simple. Your files have to be in UTF8 encoding.
Thanks guys.
For anyone else who comes across this post and is using Microsoft Visual Studios, you can change the file encoding by opening the file, and going to File > Advanced Save Options. Then under Encoding, select a UTF-8 encoding. The only one I could find was "Unicode (UTF-8 without signature - Codepage 65001".
Your files have to be in UTF8 encoding.
Been there, done that, that's what was making kwrite lock up. Kate wasn't any better really. And I can't (or rather don't know how) to create symbols such as the sterling pound sign directly from the keyboard, and I don't know how far I can trust the clipboard either.
[EDIT]
pepsi@fractal:/home/prog/ttf_crap 06:57 AM $ file *.c common.c: ASCII C program text ex8.c: UTF-8 Unicode English text ex_ttf.c: UTF-8 Unicode C program text r.c: ISO-8859 C program text r3.c: empty r4.c: UTF-8 Unicode C program text
Both r.c and ex_ttf.c show the pound sign correctly as they are right now.
But the source is weird, this is an altered line in ex_ttf.c viewed in gvim.
{"name":"606503","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/9\/49800a3a20abdea26687c504ae04bb78.png","w":752,"h":31,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/9\/49800a3a20abdea26687c504ae04bb78"}
KWrite and Kate most likely will use UTF8 by default already, so no need to change anything.
Look at that image I pasted into my previous post.
Well, geany, gedit and vim are all UTF8 by default here. So I was quite sure all Linux editors are.
Well I can't get it to work, OTOH, I'm an obnoxious American who has no need for UTF-8.
I just downloaded Kate here, I think it's encoding is broken - once a file is not UTF8 it will never convert it back for me. If you use any one of the editors I mentioned (and convert the file to UTF8) does it work for you?
If you use any other editor (and convert the file to UTF8) does it work for you?
Not for me. I selected "Settings"|"Configure Editor"| "Open/Save"|"Encoding" to UTF-8 in both Kate and Kwrite and it still doesn't work. I'm working on an input box for an A5 gui, and might post an example in a week to see if accented characters are accepted. Maybe it's something to do with xfce displaying characters incorrectly? Shooting blind, as it were.
I've had kate convert just fine for me. Just recently too with some stuff at work. Someone decided to use special unicode quote/apostrophe marks rather than normal ones.
I tried doing it with Tools->Encoding, which doesn't seem to work.
Works fine for me. What version of kate do you have?
I re-opened the altered ex_ttf.c with kwrite, and the line was "yýþæö£" (copy paste directly), when I clicked Tools->Encoding->Unicode->UTF-8 and selected UTF-8 it shows "yýþæö£".
[EDIT]
Kate version 3.5.5, Kwrite version Version 4.5.5
Ouch. Those are bout a year old, maybe closer to two years old. I'm on 3.8.4. Each minor (3.x) is generally released with each minor (4.x) KDE release, which happens every 6 months, and 4.9 is almost out.
I just got the ex_ttf.c program to display two consecutive pound signs by using the character mapper to find out the code in octal.
al_draw_textf(ex.f3, green, 50, 300, 0, "%s", "yýþæö£\302\243");