From 7213cb626cd150fdc88ae767750753b59e63bc5e Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 5 Feb 2006 02:03:09 +0000 Subject: [PATCH] * Changed DrawShape() to take the current pen location into account (Stephan please review that AGG part) * Fixed GetEscapements() to return the correct values * Corrected and enabled the rotate / shear transform for GetGlyphShapes() and GetEscapements() The Iterview sample code demo is now working. If you play with it a bit you can also rotate the text. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16232 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/ServerFont.cpp | 21 +++--- src/servers/app/drawing/Painter/Painter.cpp | 79 ++++++++------------- 2 files changed, 37 insertions(+), 63 deletions(-) diff --git a/src/servers/app/ServerFont.cpp b/src/servers/app/ServerFont.cpp index a7d7da8877..817044bf21 100644 --- a/src/servers/app/ServerFont.cpp +++ b/src/servers/app/ServerFont.cpp @@ -358,9 +358,7 @@ ServerFont::GetGlyphShapes(const char charArray[], int32 numChars) const // Multiply togheter FT_Matrix_Multiply(&rmatrix, &smatrix); - - //FT_Vector pen; - //FT_Set_Transform(face, &smatrix, &pen); + FT_Set_Transform(face, &smatrix, NULL); BShape **shapes = new BShape *[numChars]; for (int i = 0; i < numChars; i++) { @@ -374,6 +372,8 @@ ServerFont::GetGlyphShapes(const char charArray[], int32 numChars) const shapes[i]->Close(); } + // Reset transformation + FT_Set_Transform(face, NULL, NULL); return shapes; } @@ -498,25 +498,20 @@ ServerFont::GetEscapements(const char charArray[], int32 numChars, // Multiply togheter FT_Matrix_Multiply(&rmatrix, &smatrix); - - //FT_Vector pen; - //FT_Set_Transform(face, &smatrix, &pen); - - // TODO: I'm not sure if this the correct interpretation - // of the BeBook. Have actual tests been done here? + FT_Set_Transform(face, &smatrix, NULL); // TODO: handle UTF8... see below!! BPoint *escapements = new BPoint[numChars]; for (int i = 0; i < numChars; i++) { // TODO : this is wrong (the nth char isn't charArray[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.horiAdvance / 64) / fSize; - escapements[i].y = float(face->glyph->metrics.vertAdvance / 64) / fSize; + escapements[i].x = float(face->glyph->advance.x) / 64 / fSize; + escapements[i].y = -float(face->glyph->advance.y) / 64 / fSize; escapements[i] += offsetArray[i]; } + // Reset transformation + FT_Set_Transform(face, NULL, NULL); return escapements; } diff --git a/src/servers/app/drawing/Painter/Painter.cpp b/src/servers/app/drawing/Painter/Painter.cpp index c4a6570b36..266f658e2c 100644 --- a/src/servers/app/drawing/Painter/Painter.cpp +++ b/src/servers/app/drawing/Painter/Painter.cpp @@ -518,60 +518,39 @@ Painter::DrawShape(const int32& opCount, const uint32* opList, agg::path_storage path; for (int32 i = 0; i < opCount; i++) { - switch (opList[i] & 0xFF000000) { - case OP_LINETO: { - int32 count = opList[i] & 0x00FFFFFF; - while (count--) { - path.line_to(points->x, points->y); - points++; - } - break; - } - case (OP_MOVETO | OP_LINETO): { - int32 count = opList[i] & 0x00FFFFFF; - path.move_to(points->x, points->y); + uint32 op = opList[i] & 0xFF000000; + if (op & OP_MOVETO) { + path.move_to(points->x, points->y); + points++; + } + + if (op & OP_LINETO) { + int32 count = opList[i] & 0x00FFFFFF; + while (count--) { + path.line_to(points->x, points->y); points++; - // execute "line to(s)" - while (count--) { - path.line_to(points->x, points->y); - points++; - } - break; - } - case OP_BEZIERTO: { - int32 count = opList[i] & 0x00FFFFFF; - while (count) { - path.curve4(points[0].x, points[0].y, - points[1].x, points[1].y, - points[2].x, points[2].y); - points += 3; - count -= 3; - } - break; - } - case (OP_MOVETO | OP_BEZIERTO): { - int32 count = opList[i] & 0x00FFFFFF; - // execute "move to" - path.move_to(points->x, points->y); - points++; - // execute "bezier to(s)" - while (count) { - path.curve4(points[0].x, points[0].y, - points[1].x, points[1].y, - points[2].x, points[2].y); - points += 3; - count -= 3; - } - break; - } - case OP_CLOSE: - case OP_CLOSE | OP_LINETO | OP_BEZIERTO: { - path.close_polygon(); - break; } } + + if (op & OP_BEZIERTO) { + int32 count = opList[i] & 0x00FFFFFF; + while (count) { + path.curve4(points[0].x, points[0].y, + points[1].x, points[1].y, + points[2].x, points[2].y); + points += 3; + count -= 3; + } + } + + if (op & OP_CLOSE) + path.close_polygon(); } - agg::conv_curve curve(path); + + typedef agg::conv_transform conv_trans_type; + conv_trans_type transformed(path, agg::trans_affine_translation(fPenLocation.x, fPenLocation.y)); + agg::conv_curve curve(transformed); + if (filled) return _FillPath(curve); else