openframeworks / openframeworks/openFrameworks
ofTrueTypeFont does not work properly on RaspberryPi3-Raspbian(stretch) with the drawString()
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
OF0.10.0-RC3, ofTrueTypeFont does not work properly on RaspberryPi3-Raspbian(stretch) with the drawString() method. Here are the codes:
//--------------------------------------------------------------
void ofApp::setup(){
ofTrueTypeFontSettings settings( "fz.ttf", 36);
settings.addRange(ofUnicode::CJKUnified);
settings.addRange(ofUnicode::Latin);
_font.load(settings);
}
//--------------------------------------------------------------
void ofApp::draw(){
ofSetColor(255,0,0);
char fpsStr[256];
sprintf(fpsStr, "framerate: %f", ofGetFrameRate());
_font.drawString(fpsStr, 100,100);
_font.drawString("你好,OF!", 100,400);
}
and the snapshot of the running OF window on Raspbian:
https://forum.openframeworks.cc/uploads/default/original/2X/8/8dec8b099302517837e930b00efb5010b3f5277e.jpeg
As you can see, the characters are improperly drawed as rectangle blocks. If I change the line
_font.drawString("你好,OF!", 100,400);
to
_font.getStringTexture("你好,OF!").draw(100,400);
The characters are correctly drawed, which is strange. But the code looks awkward.
================================================================
And I changed to use drawStringAsShapes(), the window will take about 10 seconds(tooooo long) to show up, but the Chinese characters could be displayed properly. Here are the codes:
//--------------------------------------------------------------
void ofApp::setup(){
ofTrueTypeFontSettings settings( "fz.ttf", 36);
settings.addRange(ofUnicode::CJKUnified);
settings.addRange(ofUnicode::Latin);
settings.contours=true;
_font.load(settings);
}
//--------------------------------------------------------------
void ofApp::draw(){
ofSetColor(255,0,0);
char fpsStr[256];
sprintf(fpsStr, "framerate: %f", ofGetFrameRate());
_font.drawStringAsShapes(fpsStr, 100,100);
_font.drawStringAsShapes("你好,OF!", 100,400);
}
and the snapshot of the running OF window on Raspbian:
https://forum.openframeworks.cc/uploads/default/original/2X/a/abcc55c44e561768169f5098d81aa6e81b792628.jpeg
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided ofTrueTypeFont setup and drawString calls on RaspberryPi3-Raspbian(stretch), comparing drawString with getStringTexture().draw() and drawStringAsShapes(). Done means Chinese characters render correctly through drawString without the workaround or the roughly 10-second startup delay.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, raspberry-pi
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100