Blog by Max Ammann

Unicode: Mess with characters and fonts.

Can you see this symbol? 🔊 Nice, this means you have a good set of fonts and a good browser. Mostly easy so view a good part of the Unicode Character Set. But when it comes to support these in your own programs it can be a hassle to render these.

The FreeType library supports rending basically every character but still, it can be quite complicated if you’re not into the encoding of strings. First you’ll want to set the charset FreeType should use if it isn’t already specified in the font file by using FT_Select_Charmap(face, FT_ENCODING_UNICODE). You can also get some information about the charset tables in your font or set the one you want to use.

FreeType supports quite a bunch of charsets (I’m not sure why FreeType calls it’s charsets encodings, as encodings are something very different):

Charset
FT_ENCODING_NONE
FT_ENCODING_UNICODE
FT_ENCODING_MS_SYMBOL
FT_ENCODING_ADOBE_LATIN_1
FT_ENCODING_OLD_LATIN_2
FT_ENCODING_SJIS
FT_ENCODING_GB2312
FT_ENCODING_BIG5
FT_ENCODING_WANSUNG
FT_ENCODING_JOHAB
FT_ENCODING_ADOBE_STANDARD
FT_ENCODING_ADOBE_EXPERT
FT_ENCODING_ADOBE_CUSTOM
FT_ENCODING_APPLE_ROMAN

FT_ENCODING_UNICODE is probably the one you want to use. Also, if you want won’t be able to include the 🔊 character like this:

1
NEW_STRING("🔊");

or:

1
NEW_WSTRING(L"🔊");

You’ll have to do something like this to be sure that it works on every system:

1
2
unsigned long speaker = 0x1F50A;
NEW_LONG_STRING(&speaker);

Now let’s find a font which supports the following characters: 🔊 (0x1F50A), ☁ (0x2601) and ⏰ (0x23F0)

Symbola

The only font which supports all three characters I’ve found.

Google Noto

Awesome font by Google. Supported ☁ and ⏰. But didn’t support 🔊. Probably because it’s beyond 0xFFFF.

Arial Unicode

Should have been working, but didn’t.

Do you have Questions? Send an E-Mail to max@maxammann.org