Implement font glyph rotation

Warren_Baird at cimmetry.com Warren_Baird at cimmetry.com
Thu Feb 6 08:50:57 CST 2003



ChangeLog:

     Add support for font glyph rotation in GetGlyphOutline.

Description:

     Fixed bad angle conversion from tenths of degree to FT_Fixed on
     big-endian machines.

     Fixed bad calculation of the gmCellIncY bounding box field
     in the case of a rotation. (just imagine what you would get
     as result from "-(vec.y+63) >> 6" when vec.y is zero... what
     we expect really is zero, not -1).

     Fixed wrong rotation matrix used to transform the outline.

     Rotate each point of the outline before it gets converted
     by FTVectorToPOINTFX in the GGO_NATIVE case.

Warren Baird : Warren_Baird at cimmetry.com
Dave Belanger

diff -ur clean/wine/dlls/gdi/freetype.c wine/dlls/gdi/freetype.c
--- clean/wine/dlls/gdi/freetype.c 24 Jan 2003 15:12:16 -0000     1.1.1.3
+++ wine/dlls/gdi/freetype.c  28 Jan 2003 18:37:34 -0000
@@ -1428,7 +1428,7 @@
         INT xc, yc;
     FT_Vector vec;
     angle = font->orientation / 10 << 16;
-    angle |= ((font->orientation % 10) * (1 << 16)) / 10;
+    angle |= (((font->orientation % 10) * (1 << 16)) / 10) & 0x0000ffff;
     TRACE("angle %ld\n", angle >> 16);
     for(xc = 0; xc < 2; xc++) {
         for(yc = 0; yc < 2; yc++) {
@@ -1459,7 +1459,7 @@
     vec.y = 0;
     pFT_Vector_Rotate(&vec, angle);
     lpgm->gmCellIncX = (vec.x+63) >> 6;
-    lpgm->gmCellIncY = -(vec.y+63) >> 6;
+    lpgm->gmCellIncY = -((vec.y+63) >> 6);
     }
     lpgm->gmBlackBoxX = (right - left) >> 6;
     lpgm->gmBlackBoxY = (top - bottom) >> 6;
@@ -1510,7 +1510,7 @@
         if(font->orientation) {
             FT_Matrix matrix;
          matrix.xx = matrix.yy = pFT_Cos(angle);
-         matrix.xy = -pFT_Sin(angle);
+         matrix.xy = pFT_Sin(angle);
          matrix.yx = -matrix.xy;

          pFT_Outline_Transform(&ft_face->glyph->outline, &matrix);
@@ -1591,7 +1591,8 @@
     FT_Outline *outline = &ft_face->glyph->outline;
     TTPOLYGONHEADER *pph;
     TTPOLYCURVE *ppc;
-    DWORD pph_start, cpfx, type;
+    DWORD pph_start, cpfx, type;
+    FT_Vector rotatedVec;

     if(buflen == 0) buf = NULL;

@@ -1600,8 +1601,10 @@
         pph = buf + needed;
         first_pt = point;
         if(buf) {
-            pph->dwType = TT_POLYGON_TYPE;
-         FTVectorToPOINTFX(&outline->points[point], &pph->pfxStart);
+             pph->dwType = TT_POLYGON_TYPE;
+              rotatedVec = outline->points[point];
+              pFT_Vector_Rotate(&rotatedVec, angle);
+             FTVectorToPOINTFX(&rotatedVec, &pph->pfxStart);
         }
         needed += sizeof(*pph);
         point++;
@@ -1611,8 +1614,11 @@
            TT_PRIM_LINE : TT_PRIM_QSPLINE;
          cpfx = 0;
          do {
-             if(buf)
-                 FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
+           if(buf) {
+                rotatedVec = outline->points[point];
+                pFT_Vector_Rotate(&rotatedVec, angle);
+               FTVectorToPOINTFX(&rotatedVec, &ppc->apfx[cpfx]);
+           }
              cpfx++;
              point++;
          } while(point <= outline->contours[contour] &&
@@ -1622,14 +1628,20 @@
             only for Beziers */
          if(point > outline->contours[contour] &&
             !(outline->tags[point-1] & FT_Curve_Tag_On)) {
-             if(buf)
-                 FTVectorToPOINTFX(&outline->points[first_pt],
&ppc->apfx[cpfx]);
+            if(buf) {
+                  rotatedVec = outline->points[first_pt];
+                   pFT_Vector_Rotate(&rotatedVec, angle);
+                 FTVectorToPOINTFX(&rotatedVec, &ppc->apfx[cpfx]);
+              }
              cpfx++;
          } else if(point <= outline->contours[contour] &&
                 outline->tags[point] & FT_Curve_Tag_On) {
            /* add closing pt for bezier */
-             if(buf)
-                 FTVectorToPOINTFX(&outline->points[point], &ppc->apfx[cpfx]);
+             if(buf) {
+                  rotatedVec = outline->points[point];
+                   pFT_Vector_Rotate(&rotatedVec, angle);
+                 FTVectorToPOINTFX(&rotatedVec, &ppc->apfx[cpfx]);
+              }
              cpfx++;
              point++;
          }





More information about the wine-patches mailing list