How to show Turkish characters on an ofxLabel?

How can I display Turkish characters on an ofxLabel under Android, is it supported?I worked on it but couldn’t be successfull, while displaying a text on ofxLabel it omits Turkish characters.

gui.add(label1.setup("abcçdegğhıijkl","234",375,250));

This code doesn’t work as expected, it omits characters ğ and ı.
Using:

string str;
ofUTF8Insert(str,0,'a');
ofUTF8Insert(str,0,'ı');

If I use like this compiler gives an error:

Error:(44, 21) error: character too large for enclosing character literal type(for 'ı' character)

If I use:
ofUTF8Insert(str,0,L’a’);

ofUTF8Insert(str,1,L'ı');

or
ofUTF8Insert(str,1,U'ı');

and


label1.setName(str);

It compiles but on my Android phone it omits Turkish character ‘ı’.

I am using Openframeworks 0.10.0 for Android using Android Studio under Windows.

the default font in ofxGui doesn’t support unicode, you need to setup the gui using a font that has been setup with whatever alphabet you are using first by using ofxBaseGui::loadFont

1 Like

Thanks for your answer.

I put some .ttf files into bin\data directory and then
I tried:


gui.loadFont("Turkish Courier New.ttf",28,true,true); 
gui.setup("panel");
label1.loadFont("Turkish Courier New.ttf",28,true,true);
gui.add(label1.setup("abcçdegğhıijkl","234",375,250));

or

If I use:

string str;
ofUTF8Insert(str,0,L’a’);
ofUTF8Insert(str,1,L'ı');`
label1.setName(str);

It still omits Turkish characters ı,ğ,ş, I tried it with some other fonts too: ARIALUNI.ttf, Roboto-Black.ttf, adlery-pro.blockletter.ttf .

For example adlery-pro.blockletter.ttf supports 513 characters including Turkish characters too but none of the fonts I tried worked for Turkish characters,though writing style changes using different fonts.

you need to use the version that gets an ofTruetypeFontSettings object to setup a font with a custom alphabet.

https://openframeworks.cc//documentation/ofxGui/ofxBaseGui/#!show_loadFont

you can find more info on how to setup that object in this blog post: https://blog.openframeworks.cc/post/173122543219/utf8-support

1 Like

Thanks for your answer.

I’ve looked at the blog page link you gave and a few other openframeworks webpages.On a different website I find Turkish characters ı,ğ,ş were supported in Unicode Latin Extended Additional.

I tried:

ofTrueTypeFont setting("ARIALUNI.TTF",24);
setting.addRanges(ofAlphabet::Latin);

or

setting.addRange(ofUnicode::Latin);
setting.addRange(ofUnicode::LatinExtendedAdditional);
setting.addRange(ofUnicode::Latin1Supplement);

gui.loadFont(setting);
gui.add(label1.setup("abcçdegğhıijkl","234",375,250));
 label1.loadFont(setting);

I tried similar things and combinations.Just using:

setting.addRange(ofUnicode::LatinExtendedAdditional);

cause no display of text maybe there was/is a problem with ofUnicode::LatinExtendedAdditional.

In the end, I found a thread related to Turkish characters under Openframeworks 0.10.0(the version which I am currently using:

0.10.0 Release candidate 4https://forum.openframeworks.cc/t/0-10-0-release-candidate-4/29423/

There a user named Alp suggests a quick fix for Turkish characters problem,I tried it and it worked :slight_smile:
"

Alp wrote:
May '18
I tried to include unicode characters as follows;

> ofTrueTypeFontSettings settings("verdana.ttf", 14);
> settings.addRanges(ofAlphabet::Latin);
> settings.contours=true;
> settings.antialiased=true;

I can’t display “ğ,Ğ,ı,İ,şŞ”. I’ve just add the following line (LatinA chars range) to ofTrueTypeFont.h

static const range LatinA;
And, to ofTrueTypeFont.cpp

> const ofUnicode::range ofUnicode::LatinA {0x0100,0x017F};
> const std::initializer_list<ofUnicode::range> ofAlphabet::Latin {
>     ofUnicode::Latin1Supplement,
>     ofUnicode::LatinExtendedAdditional,
>     ofUnicode::LatinA
> };

Now, Latin alphabet includes full Turkish language character set.
"

So now using something like:

setting.addRange(ofUnicode::LatinA);
setting.addRange(ofUnicode::Latin1Supplement);

works.

I wonder if ofxaddons now support Unicode too, like ofxImGui or ofxDatGui.

oh i see, this is fixed already in later versions but great you got it working