GetFontData

Huw D M Davies h.davies1 at physics.ox.ac.uk
Tue Oct 23 10:37:37 CDT 2001


Need to re-run autoheader and autoconf for this one.

	Huw D M Davies <hdavies at codeweavers.com>
	Implement GetFontData
-------------- next part --------------
Index: configure.in
===================================================================
RCS file: /home/wine/wine/configure.in,v
retrieving revision 1.228
diff -u -r1.228 configure.in
--- configure.in	2001/10/02 17:49:20	1.228
+++ configure.in	2001/10/23 14:08:45
@@ -414,7 +414,8 @@
                          freetype/ftnames.h \
                          freetype/ftsnames.h \
                          freetype/ttnameid.h \
-                         freetype/ftoutln.h)
+                         freetype/ftoutln.h \
+                         freetype/internal/sfnt.h)
 	CPPFLAGS="$ac_save_CPPFLAGS"
 	wine_cv_msg_freetype=no
     fi
Index: dlls/gdi/freetype.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/freetype.c,v
retrieving revision 1.1
diff -u -r1.1 freetype.c
--- dlls/gdi/freetype.c	2001/09/12 20:21:07	1.1
+++ dlls/gdi/freetype.c	2001/10/23 14:08:47
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <dirent.h>
 #include <stdio.h>
+#include <assert.h>
 
 DEFAULT_DEBUG_CHANNEL(font);
 
@@ -47,6 +48,9 @@
 #ifdef HAVE_FREETYPE_FTOUTLN_H
 #include <freetype/ftoutln.h>
 #endif
+#ifdef HAVE_FREETYPE_INTERNAL_SFNT_H
+#include <freetype/internal/sfnt.h>
+#endif
 
 static FT_Library library = 0;
 
@@ -770,6 +774,43 @@
     return TRUE;
 }
 
+/*************************************************************
+ * WineEngGetFontData
+ *
+ */
+DWORD WineEngGetFontData(GdiFont font, DWORD table, DWORD offset, LPVOID buf,
+			 DWORD cbData)
+{
+    FT_Face ft_face = font->ft_face;
+    TT_Face tt_face;
+    SFNT_Interface *sfnt;
+    DWORD len;
+    FT_Error err;
+
+    if(!FT_IS_SFNT(ft_face))
+        return GDI_ERROR;
+
+    tt_face = (TT_Face) ft_face;
+    sfnt = (SFNT_Interface*)tt_face->sfnt;
+
+    if(!buf || !cbData)
+        len = 0;
+    else
+        len = cbData;
+
+    if(table) { /* MS tags differ in endidness from FT ones */
+        table = table >> 24 | table << 24 |
+	  (table >> 8 & 0xff00) | (table << 8 & 0xff0000);
+    }
+
+    err = sfnt->load_any(tt_face, table, offset, buf, &len);
+    if(err) {
+        ERR("Can't find table %08lx\n", table);
+	return GDI_ERROR;
+    }
+    return len;
+}
+
 #else /* HAVE_FREETYPE */
 
 BOOL WineEngInit(void)
@@ -831,5 +872,11 @@
     return FALSE;
 }
 
+DWORD WineEngGetFontData(GdiFont font, DWORD table, DWORD offset, LPVOID buf,
+			 DWORD cbData)
+{
+    ERR("called but we don't have FreeType\n");
+    return GDI_ERROR;
+}
 #endif /* HAVE_FREETYPE */
 
Index: include/font.h
===================================================================
RCS file: /home/wine/wine/include/font.h,v
retrieving revision 1.7
diff -u -r1.7 font.h
--- include/font.h	2001/09/19 20:32:07	1.7
+++ include/font.h	2001/10/23 14:08:48
@@ -78,6 +78,7 @@
 extern DWORD WineEngDecRefFont(GdiFont);
 extern DWORD WineEngEnumFonts(LPLOGFONTW, DEVICEFONTENUMPROC, LPARAM);
 extern BOOL WineEngGetCharWidth(GdiFont, UINT, UINT, LPINT);
+extern DWORD WineEngGetFontData(GdiFont, DWORD, DWORD, LPVOID, DWORD);
 extern DWORD WineEngGetGlyphOutline(GdiFont, UINT glyph, UINT format,
 				    LPGLYPHMETRICS, DWORD buflen, LPVOID buf,
 				    const MAT2*);
Index: objects/font.c
===================================================================
RCS file: /home/wine/wine/objects/font.c,v
retrieving revision 1.55
diff -u -r1.55 font.c
--- objects/font.c	2001/10/21 15:02:34	1.55
+++ objects/font.c	2001/10/23 14:08:50
@@ -1895,16 +1895,20 @@
  *
  * Calls SetLastError()  
  *
- * BUGS
- *
- * Unimplemented
  */
 DWORD WINAPI GetFontData(HDC hdc, DWORD table, DWORD offset, 
     LPVOID buffer, DWORD length)
 {
-    FIXME("(%x,%ld,%ld,%p,%ld): stub\n", hdc, table, offset, buffer, length);
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return GDI_ERROR;
+    DC *dc = DC_GetDCPtr(hdc);
+    DWORD ret = GDI_ERROR;
+
+    if(!dc) return GDI_ERROR;
+
+    if(dc->gdiFont)
+      ret = WineEngGetFontData(dc->gdiFont, table, offset, buffer, length);
+
+    GDI_ReleaseObj(hdc);
+    return ret;
 }
 
 /*************************************************************************


More information about the wine-patches mailing list