From 1f738c5b4e1e4e1330b23c39459ad7600fe966df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 16 May 2005 11:03:28 +0000 Subject: [PATCH] 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 --- src/servers/app/ServerFont.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/servers/app/ServerFont.cpp b/src/servers/app/ServerFont.cpp index 8465647df5..dcb2d822d1 100644 --- a/src/servers/app/ServerFont.cpp +++ b/src/servers/app/ServerFont.cpp @@ -333,14 +333,26 @@ ServerFont::GetEscapements(const char charArray[], int32 numChars, BPoint *escapements = (BPoint *)malloc(sizeof(BPoint) * numChars); for (int i = 0; i < numChars; i++) { FT_Load_Char(face, charArray[i], FT_LOAD_NO_BITMAP); - escapements[i].x = float(face->glyph->metrics.width / 64) / fSize; - escapements[i].y = 0; +// escapements[i].x = float(face->glyph->metrics.width / 64) / fSize; +// 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]; } return escapements; } +// is_white_space +inline bool +is_white_space(uint16 glyph) +{ + // TODO: handle them all! + if (glyph == ' ') + return true; + return false; +} + bool ServerFont::GetEscapements(const char charArray[], int32 numChars, float widthArray[], escapement_delta delta) const @@ -376,11 +388,9 @@ ServerFont::GetEscapements(const char charArray[], int32 numChars, for (int i = 0; i < numChars; i++) { FT_Load_Char(face, glyphIndex[i], FT_LOAD_NO_BITMAP); - // TODO: It appears that "white spaces" are not handled correctly: - // metrics.width will be zero, which is in now way correct! - widthArray[i] = float(face->glyph->metrics.width / 64) / fSize; - // TODO: - // widthArray[i] += is_white_space(glyphIndex[i]) ? delta.space : delta.nonspace; +// widthArray[i] = float(face->glyph->metrics.width / 64) / fSize; + widthArray[i] = float(face->glyph->metrics.horiAdvance / 64) / fSize; + widthArray[i] += is_white_space(glyphIndex[i]) ? delta.space : delta.nonspace; } } delete[] convertedBuffer;