summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}