summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-02-05 07:35:03 +0000
committerTofu Linden <tofu.linden@lindenlab.com>2010-02-05 07:35:03 +0000
commit197c78fa4bf372d09b315b1bad3cf6649627eb48 (patch)
treed49217ad4a9b10fa907cfbefeba1453042b66f9a /indra/llrender
parent05e15ccb82541494bf7145652140de187d838cda (diff)
parent367fda833cb5633564c2518f613a00484eb73ec5 (diff)
merge from viewer2 trunk.
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llfontgl.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index 1de1d6ded4..b6a6b448ee 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -601,14 +601,20 @@ S32 LLFontGL::firstDrawableChar(const llwchar* wchars, F32 max_pixels, S32 text_
{
llwchar wch = wchars[i];
- F32 char_width = mFontFreetype->getXAdvance(wch);
+ const LLFontGlyphInfo* fgi= mFontFreetype->getGlyphInfo(wch);
+
+ // last character uses character width, since the whole character needs to be visible
+ // other characters just use advance
+ F32 width = (i == start)
+ ? (F32)(fgi->mWidth + fgi->mXBearing) // use actual width for last character
+ : fgi->mXAdvance; // use advance for all other characters
- if( scaled_max_pixels < (total_width + char_width) )
+ if( scaled_max_pixels < (total_width + width) )
{
break;
}
- total_width += char_width;
+ total_width += width;
drawable_chars++;
if( max_chars >= 0 && drawable_chars >= max_chars )
@@ -626,7 +632,17 @@ S32 LLFontGL::firstDrawableChar(const llwchar* wchars, F32 max_pixels, S32 text_
total_width = llround(total_width);
}
- return start_pos - drawable_chars;
+ if (drawable_chars == 0)
+ {
+ return start_pos; // just draw last character
+ }
+ else
+ {
+ // if only 1 character is drawable, we want to return start_pos as the first character to draw
+ // if 2 are drawable, return start_pos and character before start_pos, etc.
+ return start_pos + 1 - drawable_chars;
+ }
+
}
S32 LLFontGL::charFromPixelOffset(const llwchar* wchars, S32 begin_offset, F32 target_x, F32 max_pixels, S32 max_chars, BOOL round) const