Skip to content

Commit

Permalink
ofTTF: fix custom letter space
Browse files Browse the repository at this point in the history
it now adds the space in pixels to the glyph default advance

Fixes #6066
  • Loading branch information
arturoc committed Jul 30, 2018
1 parent ce77dae commit d9d7bc5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions libs/openFrameworks/graphics/ofTrueTypeFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ bool ofTrueTypeFont::initLibraries(){
ofTrueTypeFont::ofTrueTypeFont()
:settings("",0){
bLoadedOk = false;
letterSpacing = 1;
letterSpacing = 0;
spaceSize = 1;
fontUnitScale = 1;
stringQuads.setMode(OF_PRIMITIVE_TRIANGLES);
Expand Down Expand Up @@ -1150,7 +1150,8 @@ void ofTrueTypeFont::iterateString(const string & str, float x, float y, bool vF
} else if (c == '\t') {
if (settings.direction == OF_TTF_LEFT_TO_RIGHT){
f(c, pos);
pos.x += getGlyphProperties(' ').advance * TAB_WIDTH * letterSpacing * directionX;
pos.x += getGlyphProperties(' ').advance * TAB_WIDTH;
pos.x += letterSpacing * directionX;
} else{
pos.x += getGlyphProperties(' ').advance * TAB_WIDTH * letterSpacing * directionX;
f(c, pos);
Expand All @@ -1162,10 +1163,12 @@ void ofTrueTypeFont::iterateString(const string & str, float x, float y, bool vF
pos.x += getKerning(c,prevC);// * directionX;
}
if(settings.direction == OF_TTF_LEFT_TO_RIGHT){
f(c,pos);
pos.x += props.advance * letterSpacing * directionX;
f(c,pos);
pos.x += props.advance * directionX;
pos.x += letterSpacing * directionX;
}else{
pos.x += props.advance * letterSpacing * directionX;
pos.x += props.advance * directionX;
pos.x += letterSpacing * directionX;
f(c,pos);
}
prevC = c;
Expand Down

0 comments on commit d9d7bc5

Please sign in to comment.