Author: tkreuzer Date: Sat May 7 16:40:33 2011 New Revision: 51625
URL: http://svn.reactos.org/svn/reactos?rev=51625&view=rev Log: [GDI FONT DRIVER] - handle DESIGNVECTOR for adobe multiple master fonts - implement FtfdDestroyFont
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/font.c [iso-8859-1] Sat May 7 16:40:33 2011 @@ -390,6 +390,7 @@ return NULL; }
+ /* Set basic fields */ pface->pfile = pfile; pface->iFace = iFace; pface->ftface = ftface; @@ -534,6 +535,33 @@ /* Get the file format */ pfile->ulFileFormat = FtfdGetFileFormat(pfile);
+ /* Check for design vector */ + if (pdv) + { + /* Check if the font format supports it */ + if (pfile->apface[0]->ulFontFormat != FMT_TYPE1) + { + WARN("Design vector is not supported\n"); + goto error; + } + + /* Verify the design vector, just in case ... */ + if (pdv->dvReserved != STAMP_DESIGNVECTOR || + pdv->dvNumAxes > MM_MAX_NUMAXES) + { + WARN("Design vector is invalid\n"); + goto error; + } + + /* Copy design vector */ + pfile->dv = *pdv; + } + else + { + /* Mark as not present */ + pfile->dv.dvReserved = 0; + } + /* Loop all additional faces in this file */ for (i = 1; i < cNumFaces; i++) { @@ -650,7 +678,7 @@ /* Unmap the font file */ EngUnmapFontFileFD(pfile->iFile);
- /* Free the memory that was allocated for the font */ + /* Free the memory that was allocated for the file */ EngFreeMem(pfile);
return TRUE;
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/ftfd.h [iso-8859-1] Sat May 7 16:40:33 2011 @@ -12,9 +12,10 @@
#include <ft2build.h> #include FT_FREETYPE_H -#include <freetype/ftadvanc.h> -#include <freetype/ftxf86.h> -#include <freetype/t1tables.h> +#include FT_ADVANCES_H +#include FT_XFREE86_H +#include FT_TYPE1_TABLES_H +#include FT_MULTIPLE_MASTERS_H
extern FT_Library gftlibrary;
@@ -38,6 +39,9 @@ #define FATAL(...) #endif
+// move to appropriate header +#define STAMP_DESIGNVECTOR (0x8000000 + 'd' + ('v' << 8)) + /** Driver specific types *****************************************************/
typedef enum @@ -56,10 +60,10 @@
typedef enum { - FILEFMT_TTF, - FILEFMT_OTF, - FILEFMT_FNT, -} FLE_FORMAT; + FILEFMT_TTF, /* TrueType font file */ + FILEFMT_OTF, /* OpenType font file */ + FILEFMT_FNT, /* Windows .fnt file */ +} FILE_FORMAT;
//"Bold Italic Underline Strikeout" #define MAX_STYLESIZE 35 @@ -96,6 +100,7 @@ ULONG cNumFaces; ULONG ulFastCheckSum; ULONG ulFileFormat; + DESIGNVECTOR dv; PFTFD_FACE apface[1]; } FTFD_FILE, *PFTFD_FILE;
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/glyph.c [iso-8859-1] Sat May 7 16:40:33 2011 @@ -131,6 +131,21 @@ return NULL; }
+ } + + /* Check if there is a design vector */ + if (pfile->dv.dvReserved == STAMP_DESIGNVECTOR) + { + /* Set the coordinates */ + fterror = FT_Set_MM_Design_Coordinates(ftface, + pfile->dv.dvNumAxes, + pfile->dv.dvValues); + if (fterror) + { + /* Failure! */ + WARN("Failed to set design vector\n"); + return NULL; + } }
// FIXME: quantize to 16.16 fixpoint @@ -464,11 +479,10 @@ switch (iMode) { case QFD_GLYPHANDBITMAP: - TRACE("QFD_GLYPHANDBITMAP\n"); - /* Load the requested glyph */ if (!FtfdLoadGlyph(pfont, hg, 0)) return FD_ERROR;
+ /* Render the glyph bitmap */ if (!FtRenderGlyphBitmap(pfont)) return FD_ERROR;
if (pgd) FtfdQueryGlyphData(pfo, hg, pgd, pv); @@ -635,7 +649,20 @@ FtfdDestroyFont( FONTOBJ *pfo) { + PFTFD_FONT pfont = pfo->pvProducer; + TRACE("FtfdDestroyFont()\n"); - __debugbreak(); -} - + + /* Nothing to do? */ + if (!pfont) return; + + /* We don't need this anymore */ + pfo->pvProducer = NULL; + + /* Cleanup the freetype face for this font */ + FT_Done_Face(pfont->ftface); + + /* Free the font structure */ + EngFreeMem(pfont); +} +
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/todo.txt [iso-8859-1] Sat May 7 16:40:33 2011 @@ -6,8 +6,7 @@ - FtfdCompletePDEV: 100% done - FtfdDisablePDEV: 100% done - FtfdEscape: unimplemented, probably unneccessary -- FtfdLoadFontFile: 90% done - - handle DESIGNVECTOR +- FtfdLoadFontFile: 95% done - FtfdQueryFont: 70% done, depends on FtfdInitIfiMetrics - FtfdQueryFontTree: 70% done, depends on FtfdInitGlyphSet and FtfdInitKerningPairs - FtfdUnloadFontFile: 100% done, depends on FtfdDestroyFace @@ -28,7 +27,7 @@ - check possibility of FT_ADVANCE_FLAG_FAST_ONLY - FtfdQueryTrueTypeOutline: unimplemented - FtfdFontManagement: unimplemented, unneccessary -- FtfdDestroyFont: unimplemented, later +- FtfdDestroyFont: 100% implemented
internal interface -------------------
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.c [iso-8859-1] Sat May 7 16:40:33 2011 @@ -50,7 +50,7 @@ ULONG ulTag, PULONG pulLength) { - POTF_FILE_HEADER pFontHeader; + PTT_FILE_HEADER pFontHeader; PTT_COLLECTION pCollection; ULONG i, ulOffset, ulLength, ulNumTables, ulCheckSum; ASSERT(ulFont > 0); @@ -96,8 +96,8 @@
/* Check if number of tables is ok */ ulNumTables = GETW(&pFontHeader->usNumTables); - ulLength = ulNumTables * sizeof(OTF_TABLE_ENTRY); - if (ulLength + sizeof(OTF_FILE_HEADER) > cjView) + ulLength = ulNumTables * sizeof(TT_TABLE_ENTRY); + if (ulLength + sizeof(TT_FILE_HEADER) > cjView) { WARN("Too many tables (%ld)\n", ulNumTables); return NULL; @@ -311,7 +311,7 @@ { PFTFD_FILE pfile = pface->pfile; PVOID pvView = pfile->pvView; - POTF_OS2_DATA pOs2; + PTT_OS2_DATA pOs2;
/* Get the OS/2 table for the face */ // FIXME: get the right table for the face, when multiple faces
Modified: branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/drivers/... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/drivers/video/font/ftfd/tttables.h [iso-8859-1] Sat May 7 16:40:33 2011 @@ -23,15 +23,15 @@ ULONG aulOffsetTable[1]; } TT_COLLECTION, *PTT_COLLECTION;
-typedef struct _OTF_TABLE_ENTRY +typedef struct _TT_TABLE_ENTRY { ULONG ulTag; ULONG ulCheckSum; ULONG ulOffset; ULONG ulLength; -} OTF_TABLE_ENTRY, *POTF_TABLE_ENTRY; +} TT_TABLE_ENTRY, *PTT_TABLE_ENTRY;
-typedef struct _OTF_FILE_HEADER +typedef struct _TT_FILE_HEADER { ULONG ulIdentifier; USHORT usNumTables; @@ -39,12 +39,12 @@ USHORT usEntrySelector; USHORT usRangeshift;
- OTF_TABLE_ENTRY aTableEntries[1]; + TT_TABLE_ENTRY aTableEntries[1];
-} OTF_FILE_HEADER, *POTF_FILE_HEADER; +} TT_FILE_HEADER, *PTT_FILE_HEADER;
#include <pshpack1.h> -typedef struct _OTF_OS2_DATA +typedef struct _TT_OS2_DATA { USHORT version; // 0x0004 SHORT xAvgCharWidth; @@ -91,5 +91,5 @@ USHORT usDefaultChar; USHORT usBreakChar; USHORT usMaxContext; -} OTF_OS2_DATA, *POTF_OS2_DATA; +} TT_OS2_DATA, *PTT_OS2_DATA; #include <poppack.h>