ofTrueTypeFont and full character set

#1

Hi why ofTrueTypeFont do not draw character as œ ?

this character is in the true type font (https://www.dafont.com/fr/kg-ten-thousand-reasons.font), full character set option is on …

Any advice ? ii it an issue ?

Cheers
Sebastien

#2

you need to load the needed character ranges.
I don’t know which range includes that one but to do so use the following

ofTrueTypeFontSettings settings("font.ttf", size);
// add the ranges that you need.
settings.addRanges(ofAlphabet::Emoji);
settings.addRanges(ofAlphabet::Japanese);
settings.addRanges(ofAlphabet::Chinese);
settings.addRanges(ofAlphabet::Korean);
settings.addRanges(ofAlphabet::Arabic);
settings.addRanges(ofAlphabet::Devanagari);
settings.addRanges(ofAlphabet::Latin);
settings.addRanges(ofAlphabet::Greek);
settings.addRanges(ofAlphabet::Cyrillic);
     
font.load(settings); // font is an instance of ofTrueTypeFont

You could also load just the particular range of characters.
use any of the following:

settings.addRange(ofUnicode::Space);
settings.addRange(ofUnicode::IdeographicSpace);
settings.addRange(ofUnicode::Latin);
settings.addRange(ofUnicode::Latin1Supplement);
settings.addRange(ofUnicode::LatinA);
settings.addRange(ofUnicode::Greek);
settings.addRange(ofUnicode::Cyrillic);
settings.addRange(ofUnicode::Arabic);
settings.addRange(ofUnicode::ArabicSupplement);
settings.addRange(ofUnicode::ArabicExtendedA);
settings.addRange(ofUnicode::Devanagari);
settings.addRange(ofUnicode::HangulJamo);
settings.addRange(ofUnicode::VedicExtensions);
settings.addRange(ofUnicode::LatinExtendedAdditional);
settings.addRange(ofUnicode::GreekExtended);
settings.addRange(ofUnicode::GeneralPunctuation);
settings.addRange(ofUnicode::SuperAndSubScripts);
settings.addRange(ofUnicode::CurrencySymbols);
settings.addRange(ofUnicode::LetterLikeSymbols);
settings.addRange(ofUnicode::NumberForms);
settings.addRange(ofUnicode::Arrows);
settings.addRange(ofUnicode::MathOperators);
settings.addRange(ofUnicode::MiscTechnical);
settings.addRange(ofUnicode::BoxDrawing);
settings.addRange(ofUnicode::BlockElement);
settings.addRange(ofUnicode::GeometricShapes);
settings.addRange(ofUnicode::MiscSymbols);
settings.addRange(ofUnicode::Dingbats);
settings.addRange(ofUnicode::Hiragana);
settings.addRange(ofUnicode::Katakana);
settings.addRange(ofUnicode::HangulCompatJamo);
settings.addRange(ofUnicode::KatakanaPhoneticExtensions);
settings.addRange(ofUnicode::CJKLettersAndMonths);
settings.addRange(ofUnicode::CJKUnified);
settings.addRange(ofUnicode::DevanagariExtended);
settings.addRange(ofUnicode::HangulExtendedA);
settings.addRange(ofUnicode::HangulSyllables);
settings.addRange(ofUnicode::HangulExtendedB);
settings.addRange(ofUnicode::AlphabeticPresentationForms);
settings.addRange(ofUnicode::ArabicPresFormsA);
settings.addRange(ofUnicode::ArabicPresFormsB);
settings.addRange(ofUnicode::KatakanaHalfAndFullwidthForms);
settings.addRange(ofUnicode::KanaSupplement);
settings.addRange(ofUnicode::RumiNumericalSymbols);
settings.addRange(ofUnicode::ArabicMath);
settings.addRange(ofUnicode::MiscSymbolsAndPictographs);
settings.addRange(ofUnicode::Emoticons);
settings.addRange(ofUnicode::TransportAndMap);
settings.addRange(ofUnicode::EnclosedCharacters);
settings.addRange(ofUnicode::Uncategorized);
settings.addRange(ofUnicode::AdditionalEmoticons);
settings.addRange(ofUnicode::AdditionalTransportAndMap);

The default range is ofUnicode::Latin1Supplement (added automatically).

Check http://jrgraphix.net/research/unicode_blocks.php for a reference to these ranges

hope this helps

2 Likes
[Solved] Displaying special characters with ofTrueTypeFont
#3

Thanks. That makes sense to me,
but I can not find the class ofTrueTypeFontSettings even it is in OF documentation.

is it OF.10.0 feature ? Could you tell me more ?

Sebastien

#4

Yes, it is a v0.10 feature. it is a really simple class, it is mostly a data holder.

#5

At this time, my project is a 0.9.8 project, and I don’t really want to change now (because of some addons maybe not compatible, project nearly finished and i don’t want surprises)

I tried to convert my project to OF10, but ofxBullet seems no more compatible, is there a way to add special characters in OF0.9.8 ?

Bests

#6

in my opinion, it is an issue because extented characters as Ù or ç are availables…

#7

this is pretty much what is supported until 0.9.8:

https://cs.stanford.edu/people/miles/iso8859.html

anything not in that table except for a couple of symbols we were pulling manually won’t be rendered

You could try to bring the new ofTrueTypeFont in 0.10 to 0.9.8 but it has dependencies with glm so it won’t work right away

#8

Yeah,

œ is in Latin A supplement, but ç and Ù are not.
I tried to put the new ofTrueTypeFont, I had to stop because of some ofGetRenderer() faults that I don’t get.

I switch into a rough replacement œ -> oe … not proud of it

#10

Hi ! I´ve been facing the same issue, i´ve already tryed what @roymacdonald posted.

Im only trying to put latin special characters wich are áéíóú.

This is my code :


	ofTrueTypeFontSettings settings(fontpath, 24);
	//settings.
	// add the ranges that you need.
	//settings.addRanges(ofAlphabet::Emoji);
	//settings.addRanges(ofAlphabet::Japanese);
	//settings.addRanges(ofAlphabet::Chinese);
	//settings.addRanges(ofAlphabet::Korean);
	//settings.addRanges(ofAlphabet::Arabic);
	//settings.addRanges(ofAlphabet::Devanagari);
	settings.addRanges(ofAlphabet::Latin);
	//settings.addRanges(ofAlphabet::Greek);
	//settings.addRanges(ofAlphabet::Cyrillic);
	P.load(settings);

As you can see im using Arial font wich has the special characters.

#11

it should works correctly with 0.10.1 since this commit

#12

@Julian_Puppo, were you able to get those characters?

#13

Actually no , Im facing the same issue.

Im using 0.10.1.

My font is arialbd wich has the special characters.

What else can I try?

I´ve tryed using all other alphabets as well to see is they are working, but they are also not working.

And some alphabets are making my code crash.

This are the alphabets that i´ve tryed :

//--------------------------------------------------------------
void ofApp::setup(){
	ofSetWindowShape(600, 600);
	string fontpath = "arial.ttf";
	ofTrueTypeFontSettings settings(fontpath, 40);

	settings.antialiased = true;
	settings.addRange(ofUnicode::CJKUnified);
	settings.addRanges(ofAlphabet::Latin);
	//settings.addRanges(ofAlphabet::Emoji); //This one makes my soft crash
	settings.addRanges(ofAlphabet::Japanese);
	settings.addRanges(ofAlphabet::Chinese);
	//settings.addRanges(ofAlphabet::Korean); //This one makes my soft crash
	//settings.addRanges(ofAlphabet::Arabic); //This one makes my soft crash
	settings.addRanges(ofAlphabet::Devanagari);
	settings.addRanges(ofAlphabet::Greek);
	settings.addRanges(ofAlphabet::Cyrillic);
	P.load(settings);
	ofSetBackgroundColor(0);
}

This is how im drawing them :

void ofApp::draw(){
	ofSetColor(200, 0, 0);

	float sepy = 80;
	float y = 30;
	P.drawString("AEIOUÁÉÍÓÚáéíóú26+15641", ofGetWidth() / 2, y);
	P.drawString("こんにちは", ofGetWidth() / 2, y +=sepy);
	P.drawString("안녕하세요", ofGetWidth() / 2, y += sepy);
	P.drawString("नमस्ते", ofGetWidth() / 2, y += sepy);
	P.drawString("γεια", ofGetWidth() / 2, y += sepy);
	P.drawString("привет", ofGetWidth() / 2, y += sepy);
}

This is what im getting :

I´ve tryed :

  1. Chaging the "character set " in my properties of my project from “Use unicode Character Set” to “Use Multi-Byte Character set” and “”. None of the options work.

2)Tryed with two different PCS without succes.

My specs :

PC1 :
-gtx 1050.
-16gb ram .
-AMD Ryzen 5 1600 six-core processor.

PC2 :
-Intel core i7.
-8gb ram.
-Intel HD graphics 620.

Im using windows in both PCS.

#14

Usually using so many alphabets in one font won’t work cause the texture needed is too big. try using latin only to see if those characters appear and also any messages in the console to make sure that the font is being setup correctly

Apart from that be careful that the source file is saved as utf8, visual studio doesn’t use utf8 by default, i think, which is the encoding we use to load the characters

1 Like
#15

if it’s helpful, working with a student just now on a windows / VS machine, we had to put u8 in front of strings to get everything to work properly – otherwise we didn’t anything:

u8"......."

potentially useful? https://en.cppreference.com/w/cpp/language/string_literal

#16

Already tryed this .

STILL NOT WORKING.

I need to use the Ñ letter.

Not apearing.

Im using arial(arial has the “Ñ” letter).

#17

I was working with Arabic a month ago and ended up using this addon and got great results. https://github.com/armadillu/ofxFontStash