Used other font metrics members in the GetEscapement implementation in order to support white spaces. As suggested by DarkWyrm. It seems to work better now, but I realised that DisplayDriverPainter::StringWidth() is broken in the same way. Will be fixed next.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12681 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2005-05-16 11:03:28 +00:00
parent 92acca78db
commit 1f738c5b4e
+17 -7
View File
@@ -333,14 +333,26 @@ ServerFont::GetEscapements(const char charArray[], int32 numChars,
BPoint *escapements = (BPoint *)malloc(sizeof(BPoint) * numChars); BPoint *escapements = (BPoint *)malloc(sizeof(BPoint) * numChars);
for (int i = 0; i < numChars; i++) { for (int i = 0; i < numChars; i++) {
FT_Load_Char(face, charArray[i], FT_LOAD_NO_BITMAP); FT_Load_Char(face, charArray[i], FT_LOAD_NO_BITMAP);
escapements[i].x = float(face->glyph->metrics.width / 64) / fSize; // escapements[i].x = float(face->glyph->metrics.width / 64) / fSize;
escapements[i].y = 0; // escapements[i].y = 0;
escapements[i].x = float(face->glyph->metrics.horiAdvance / 64) / fSize;
escapements[i].y = float(face->glyph->metrics.vertAdvance / 64) / fSize;
escapements[i] += offsetArray[i]; escapements[i] += offsetArray[i];
} }
return escapements; return escapements;
} }
// is_white_space
inline bool
is_white_space(uint16 glyph)
{
// TODO: handle them all!
if (glyph == ' ')
return true;
return false;
}
bool bool
ServerFont::GetEscapements(const char charArray[], int32 numChars, ServerFont::GetEscapements(const char charArray[], int32 numChars,
float widthArray[], escapement_delta delta) const float widthArray[], escapement_delta delta) const
@@ -376,11 +388,9 @@ ServerFont::GetEscapements(const char charArray[], int32 numChars,
for (int i = 0; i < numChars; i++) { for (int i = 0; i < numChars; i++) {
FT_Load_Char(face, glyphIndex[i], FT_LOAD_NO_BITMAP); FT_Load_Char(face, glyphIndex[i], FT_LOAD_NO_BITMAP);
// TODO: It appears that "white spaces" are not handled correctly: // widthArray[i] = float(face->glyph->metrics.width / 64) / fSize;
// metrics.width will be zero, which is in now way correct! widthArray[i] = float(face->glyph->metrics.horiAdvance / 64) / fSize;
widthArray[i] = float(face->glyph->metrics.width / 64) / fSize; widthArray[i] += is_white_space(glyphIndex[i]) ? delta.space : delta.nonspace;
// TODO:
// widthArray[i] += is_white_space(glyphIndex[i]) ? delta.space : delta.nonspace;
} }
} }
delete[] convertedBuffer; delete[] convertedBuffer;