UTF8 support
In 0.10.0 there’s (finally) full support for UTF8 both as utilities to manipulate strings but also in ofTruetypefont.
String manipulation
Some of this utilities where already introduced in 0.9.0 but there’s some more now and the API has been cleaned to make it more consistent.
All this functions start as ofUTF8* and if you want to do something with text which might have characters other than ascci, because UTF8 has variable length characters you should be using this functions instead of the corresponding string methods. for example instead of doing:
str.insert(pos, chr);
to insert a character you should be using:
ofUTF8Insert(str, pos, chr)
or when creating a string from keypresses:
ofUTF8Append(str, key);
there’s also ofUTF8Substring, ofUTF8ToString and ofUTF8Length
Also to iterate over a string don’t iterate over it’s characters but use:
for(uint32_t & c: ofUTF8Iterator(str)){
}
ofTrueTypeFont alphabets
To load a true type font in 0.10 you can now do:
ofTrueTypeFontSettings settings("EmojiSymbols-Regular.ttf", 64);
settings.antialiased = true;
settings.dpi = 72;
settings.direction = OF_TTF_LEFT_TO_RIGHT;
settings.addRanges(ofAlphabet::Emoji);
ttf.load(settings);
...
ttf.drawString("🍱 🍲 🍳 🍴 🍵 🍶 🍷 🍸 🍹 🍺", 20, 100);
which looks like:

Or:
ofTrueTypeFontSettings settings("Noto Sans CJK JP", 32);
settings.antialiased = true;
settings.dpi = 72;
settings.direction = OF_TTF_LEFT_TO_RIGHT;
settings.addRanges(ofAlphabet::Japanese);
ttf.load(settings);
...
ttf.drawString(
"色はにほへど 散りぬるを\n\
我が世たれぞ 常ならむ\n\
有為の奥山 今日越えて\n\
浅き夢見じ 酔ひもせず", 20, 60);

This one using a font installed in the system by it’s name.
You can setup a font with any unicode range and it’ll preload those characters in a texture so it’s faster to draw them.
Instead of having to figure out each unicode range there’s a set of predefined alphabets that you can pass to addRanges, right now:
ofAlphabet::Emoji;
ofAlphabet::Japanese;
ofAlphabet::Chinese;
ofAlphabet::Korean;
ofAlphabet::Arabic;
ofAlphabet::Devanagari;
ofAlphabet::Latin;
ofAlphabet::Greek;
ofAlphabet::Cyrillic;
Let us know if any of them is wrong or you want us to add any that is missing!
There’s still one thing that is not working yet, ligatures, some alphabets like arabic join some combinations of characters, that’s still not working but there’s tools that you can use to reshape the text and paste it into you OF code (like: http://mpcabd.xyz/python-arabic-text-reshaper/). We’ll try to figure this one out for next release
Arturo
ps: Thanks to Hiroshi Matoba for his help with the Japanese example and figuring out a couple of missing characters in the Japanese alphabet