summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2007-10-28 20:24:55 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2007-10-28 20:24:55 +0100
commit748c727a414e12443622accd3fe5bffd5846e374 (patch)
tree6c8d815c687e1da24f7fb3ff9af877a2eaae106f
parent07bb34c54a53c447f8068fcd26c616cbe2386966 (diff)
fscalc: Support for UTF-8 strings.HEADmaster
fscalc: Fixed the get_line_height() function.
-rw-r--r--fscalc.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/fscalc.cpp b/fscalc.cpp
index 6842a65..83ec5da 100644
--- a/fscalc.cpp
+++ b/fscalc.cpp
@@ -87,7 +87,18 @@ unsigned int Font::get_text_width(std::string s) {
bool kerning = FT_HAS_KERNING(face);
double width = 0;
for(std::string::iterator c = s.begin(); c < s.end(); c++) {
- int i = FT_Get_Char_Index(face, *c);
+ FT_UInt character;
+ unsigned char first;
+ first = character = *c;
+ if(first & 0x80) {
+ character += *(++c) << 8;
+ if((first & 0xf0) == 0xe0) {
+ character += *(++c) << 16;
+ if((first & 0xf8) == 0xf0)
+ character += *(++c) << 24;
+ }
+ }
+ int i = FT_Get_Char_Index(face, character);
if(kerning && prev && i)
width += get_kerning(prev, i);
if(FT_Load_Char(face, *c, 0))
@@ -98,5 +109,5 @@ unsigned int Font::get_text_width(std::string s) {
}
unsigned int Font::get_line_height() {
- return face->bbox.yMax - face->bbox.yMin;
+ return (face->size->metrics.ascender - face->size->metrics.descender) / 64;
}