freetype: GetCharABCWidths should ignore font orientation

Huw D M Davies h.davies1 at physics.ox.ac.uk
Thu Feb 12 09:18:58 CST 2004


        Huw Davies <huw at codeweavers.com>
        GetCharABCWidths returns the widths of unrotated glyphs like
        GetCharWidth already does.
-- 
Huw Davies
huw at codeweavers.com
Index: objects/font.c
===================================================================
RCS file: /home/wine/wine/objects/font.c,v
retrieving revision 1.115
diff -u -r1.115 font.c
--- objects/font.c	9 Feb 2004 20:47:43 -0000	1.115
+++ objects/font.c	12 Feb 2004 15:15:00 -0000
@@ -1668,19 +1668,25 @@
                                    LPABC abc )
 {
     DC *dc = DC_GetDCPtr(hdc);
-    int		i;
-    GLYPHMETRICS gm;
+    int	i;
     BOOL ret = FALSE;
 
-    if(dc->gdiFont) {
-        for (i=firstChar;i<=lastChar;i++) {
-	    GetGlyphOutlineW(hdc, i, GGO_METRICS, &gm, 0, NULL, NULL);
-	    abc[i-firstChar].abcA = gm.gmptGlyphOrigin.x;
-	    abc[i-firstChar].abcB = gm.gmBlackBoxX;
-	    abc[i-firstChar].abcC = gm.gmCellIncX - gm.gmptGlyphOrigin.x - gm.gmBlackBoxX;
+    if(dc->gdiFont)
+        ret = WineEngGetCharABCWidths( dc->gdiFont, firstChar, lastChar, abc );
+    else
+        FIXME(": stub\n");
+
+    if (ret)
+    {
+        /* convert device units to logical */
+        for( i = firstChar; i <= lastChar; i++, abc++ ) {
+            abc->abcA = INTERNAL_XDSTOWS(dc, abc->abcA);
+            abc->abcB = INTERNAL_XDSTOWS(dc, abc->abcB);
+            abc->abcC = INTERNAL_XDSTOWS(dc, abc->abcC);
 	}
-	ret = TRUE;
+        ret = TRUE;
     }
+
     GDI_ReleaseObj(hdc);
     return ret;
 }
Index: dlls/gdi/freetype.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/freetype.c,v
retrieving revision 1.54
diff -u -r1.54 freetype.c
--- dlls/gdi/freetype.c	2 Feb 2004 23:03:54 -0000	1.54
+++ dlls/gdi/freetype.c	12 Feb 2004 15:15:00 -0000
@@ -2377,6 +2377,31 @@
 }
 
 /*************************************************************
+ * WineEngGetCharABCWidths
+ *
+ */
+BOOL WineEngGetCharABCWidths(GdiFont font, UINT firstChar, UINT lastChar,
+			     LPABC buffer)
+{
+    UINT c;
+    GLYPHMETRICS gm;
+    FT_UInt glyph_index;
+
+    TRACE("%p, %d, %d, %p\n", font, firstChar, lastChar, buffer);
+
+    for(c = firstChar; c <= lastChar; c++) {
+        glyph_index = get_glyph_index(font, c);
+        WineEngGetGlyphOutline(font, glyph_index, GGO_METRICS | GGO_GLYPH_INDEX,
+                               &gm, 0, NULL, NULL);
+	buffer[c - firstChar].abcA = font->gm[glyph_index].lsb;
+	buffer[c - firstChar].abcB = font->gm[glyph_index].bbx;
+	buffer[c - firstChar].abcC = font->gm[glyph_index].adv - font->gm[glyph_index].lsb -
+	  font->gm[glyph_index].bbx;
+    }
+    return TRUE;
+}
+
+/*************************************************************
  * WineEngGetTextExtentPoint
  *
  */
@@ -2552,6 +2577,13 @@
 
 BOOL WineEngGetCharWidth(GdiFont font, UINT firstChar, UINT lastChar,
 			 LPINT buffer)
+{
+    ERR("called but we don't have FreeType\n");
+    return FALSE;
+}
+
+BOOL WineEngGetCharABCWidths(GdiFont font, UINT firstChar, UINT lastChar,
+			     LPABC buffer)
 {
     ERR("called but we don't have FreeType\n");
     return FALSE;
Index: dlls/gdi/gdi_private.h
===================================================================
RCS file: /home/wine/wine/dlls/gdi/gdi_private.h,v
retrieving revision 1.2
diff -u -r1.2 gdi_private.h
--- dlls/gdi/gdi_private.h	18 Jan 2004 23:35:13 -0000	1.2
+++ dlls/gdi/gdi_private.h	12 Feb 2004 15:15:00 -0000
@@ -218,6 +218,8 @@
 extern GdiFont WineEngCreateFontInstance(DC*, HFONT);
 extern BOOL WineEngDestroyFontInstance(HFONT handle);
 extern DWORD WineEngEnumFonts(LPLOGFONTW, FONTENUMPROCW, LPARAM);
+extern BOOL WineEngGetCharABCWidths(GdiFont font, UINT firstChar,
+                                    UINT lastChar, LPABC buffer);
 extern BOOL WineEngGetCharWidth(GdiFont, UINT, UINT, LPINT);
 extern DWORD WineEngGetFontData(GdiFont, DWORD, DWORD, LPVOID, DWORD);
 extern DWORD WineEngGetGlyphIndices(GdiFont font, LPCWSTR lpstr, INT count,



More information about the wine-patches mailing list