Skip to content
Browse files

android: fix font reloading

  • Loading branch information...
1 parent 9f67298 commit 4aa85f7c3086b34a4a92333e36d094524c23b542 @arturoc arturoc committed
View
2 addons/ofxAndroid/src/ofAppAndroidWindow.cpp
@@ -217,7 +217,7 @@ void ofAppAndroidWindow::setThreadedEvents(bool threadedEvents){
void reloadTextures(){
ofUpdateBitmapCharacterTexture();
ofReloadAllImageTextures();
- //ofReloadAllFontTextures();
+ ofReloadAllFontTextures();
ofResumeVideoGrabbers();
}
View
23 libs/openFrameworks/graphics/ofTrueTypeFont.cpp
@@ -160,7 +160,7 @@ static ofTTFCharacter makeContoursForCharacter(FT_Face &face){
#if defined(TARGET_ANDROID) || defined(TARGET_OF_IPHONE)
#include <set>
- set<ofTrueTypeFont*> all_fonts;
+ static set<ofTrueTypeFont*> all_fonts;
void ofUnloadAllFontTextures(){
set<ofTrueTypeFont*>::iterator it;
for(it=all_fonts.begin();it!=all_fonts.end();it++){
@@ -222,11 +222,11 @@ void ofTrueTypeFont::unloadTextures(){
}
void ofTrueTypeFont::reloadTextures(){
- loadFont(filename, fontSize, bAntiAliased, bFullCharacterSet, false);
+ loadFont(filename, fontSize, bAntiAliased, bFullCharacterSet, makeContours, simplifyAmt, dpi);
}
//-----------------------------------------------------------
-bool ofTrueTypeFont::loadFont(string filename, int fontsize, bool _bAntiAliased, bool _bFullCharacterSet, bool makeContours, float simplifyAmt, int dpi) {
+bool ofTrueTypeFont::loadFont(string _filename, int _fontSize, bool _bAntiAliased, bool _bFullCharacterSet, bool _makeContours, float _simplifyAmt, int _dpi) {
bMakeContours = makeContours;
@@ -238,16 +238,19 @@ bool ofTrueTypeFont::loadFont(string filename, int fontsize, bool _bAntiAliased,
}
//------------------------------------------------
- if( dpi == 0 ){
- dpi = ttfGlobalDpi;
+ if( _dpi == 0 ){
+ _dpi = ttfGlobalDpi;
}
- filename = ofToDataPath(filename);
+ filename = ofToDataPath(_filename,true);
bLoadedOk = false;
bAntiAliased = _bAntiAliased;
bFullCharacterSet = _bFullCharacterSet;
- fontSize = fontsize;
+ fontSize = _fontSize;
+ makeContours = _makeContours;
+ simplifyAmt = _simplifyAmt;
+ dpi = _dpi;
//--------------- load the library and typeface
@@ -272,8 +275,8 @@ bool ofTrueTypeFont::loadFont(string filename, int fontsize, bool _bAntiAliased,
return false;
}
- FT_Set_Char_Size( face, fontsize << 6, fontsize << 6, dpi, dpi);
- lineHeight = fontsize * 1.43f;
+ FT_Set_Char_Size( face, fontSize << 6, fontSize << 6, dpi, dpi);
+ lineHeight = fontSize * 1.43f;
//------------------------------------------------------
//kerning would be great to support:
@@ -479,7 +482,7 @@ bool ofTrueTypeFont::loadFont(string filename, int fontsize, bool _bAntiAliased,
texAtlas.allocate(atlasPixels.getWidth(),atlasPixels.getHeight(),GL_LUMINANCE_ALPHA,false);
- if(bAntiAliased && fontsize>20){
+ if(bAntiAliased && fontSize>20){
texAtlas.setTextureMinMagFilter(GL_LINEAR,GL_LINEAR);
}else{
texAtlas.setTextureMinMagFilter(GL_NEAREST,GL_NEAREST);
View
3 libs/openFrameworks/graphics/ofTrueTypeFont.h
@@ -86,6 +86,9 @@ class ofTrueTypeFont{
int fontSize;
bool bMakeContours;
+ bool makeContours;
+ float simplifyAmt;
+ int dpi;
void drawChar(int c, float x, float y);
void drawCharAsShape(int c, float x, float y);

0 comments on commit 4aa85f7

Please sign in to comment.
Something went wrong with that request. Please try again.