unicode text input

I want to print on screen the text that I press on my keyboard that would switch from latin to greek characters (on cmd-space)

I am trying to achieve this with using 2010 NISHIHARA Hiroaki classes from here:


but it just posts blanks squares instead


#include "ofTrueTypeFontWS.h"  
ofTrueTypeFontWS  myfont;  
		wstring textString;  


void testApp::setup(){	   
	wstring textString = L"";  
	myfont.loadFont("frabk.ttf", 32);  
void testApp::update(){  
void testApp::draw(){  
	myfont.drawString(textString, 100,100);  
void testApp::keyPressed  (int key){   
	if((key==127||key==8) && textString.size()>0) {   
		textString = textString.substr(0, textString.size()-1);  
	} else {  
		textString.append (1, (char)key );  

maybe there is some other way ??

I am on mac os X 10.6 with xcode - but I was wandering if there is a cross-platform way of doing so


I just tried with a greek letter font and got the same thing, however, it works fine with Pango, and there’s ofxPango, which you can find out more about in this thread: http://forum.openframeworks.cc/t/text-rendering–text-layout–utf8/4182/0

Also works for Chinese, Japanese, etc, etc, etc.

Hope that helps a bit

I have installed ofPango and I am looking in the example project, but I cannot understand how to use it…

It seems a bit complicated - I just want to draw a string - what is the easiest way to do so ???

no one ??

or at least some other idea/example ??

I really have to make this work…

after several efforts I cannot make pango work… I get all sorts of compilation errors so I will try to focus on some other way to do so

Hi guys,

I’m quite new with OF and I’m working on this code:
I want to type on the keyboard and print the text on the screen. I started from OF examples and it works fine:

void testApp::keyPressed(int key){

if(key == OF_KEY_DEL || key == OF_KEY_BACKSPACE){
typeStr = typeStr.substr(0, typeStr.length()-1);
else if(key == OF_KEY_RETURN ){
typeStr += “\n”;
if( bFirst ){
bFirst = false;

typeStr.append(1, (char)key);


but I have problems with accents and special characters. It doesn’t print the right char
f.e. if I press:
“ò” it print “Ã2”
“ç” -> “ç”
“à” -> “Ô
“ù” -> “Ã1”

Can you help me? any ideas how to solve this problem?
Thank you

I might be wrong, but if you’re using a Unicode font I think these should be rendered correctly. Trying using a font that’s definitely unicode (i.e. that definitely supports accents and alternate characters).

@gioanin - please don’t double post. it becomes trickier to see answers, etc.

I’ve responded here to another version of the same question:


it’s unclear if you mean console output or fonts, and I offer some suggestions there…

  • zach