diff --git a/reactos/dll/3rdparty/freetype/ftfd/enable.c b/reactos/dll/3rdparty/freetype/ftfd/enable.c new file mode 100644 index 00000000000..a6d1aeab088 --- /dev/null +++ b/reactos/dll/3rdparty/freetype/ftfd/enable.c @@ -0,0 +1,105 @@ +/* + * PROJECT: ReactOS win32 subsystem + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: GDI font driver for bitmap fonts + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +#include "ftfd.h" + +static DRVFN gadrvfn[] = +{ + {INDEX_DrvEnablePDEV, (PFN)FtfdEnablePDEV}, + {INDEX_DrvCompletePDEV, (PFN)FtfdCompletePDEV}, + {INDEX_DrvDisablePDEV, (PFN)FtfdDisablePDEV}, + {INDEX_DrvLoadFontFile, (PFN)FtfdLoadFontFile}, + {INDEX_DrvUnloadFontFile, (PFN)FtfdUnloadFontFile}, + {INDEX_DrvQueryFontFile, (PFN)FtfdQueryFontFile}, + {INDEX_DrvQueryFontCaps, (PFN)FtfdQueryFontCaps}, + {INDEX_DrvQueryFontTree, (PFN)FtfdQueryFontTree}, + {INDEX_DrvQueryFont, (PFN)FtfdQueryFont}, + {INDEX_DrvFree, (PFN)FtfdFree}, + {INDEX_DrvQueryGlyphAttrs, (PFN)FtfdQueryGlyphAttrs}, + {INDEX_DrvQueryFontData, (PFN)FtfdQueryFontData}, +}; + +FT_Library gftlibrary; + + +BOOL +APIENTRY +FtfdEnableDriver( + ULONG iEngineVersion, + ULONG cj, + PDRVENABLEDATA pded) +{ + FT_Error fterror; + + DbgPrint("FtfdEnableDriver()\n"); + + /* Check parameter */ + if (cj < sizeof(DRVENABLEDATA)) + { + return FALSE; + } + + /* Initialize freetype library */ + fterror = FT_Init_FreeType(&gftlibrary); + if (fterror) + { + DbgPrint("an error occurred during library initialization: %ld.\n", fterror); + return FALSE; + } + + /* Fill DRVENABLEDATA */ + pded->c = sizeof(gadrvfn) / sizeof(DRVFN); + pded->pdrvfn = gadrvfn; + pded->iDriverVersion = DDI_DRIVER_VERSION_NT5; + + /* Success */ + return TRUE; +} + + +DHPDEV +APIENTRY +FtfdEnablePDEV( + IN DEVMODEW *pdm, + IN LPWSTR pwszLogAddress, + IN ULONG cPat, + OUT HSURF *phsurfPatterns, + IN ULONG cjCaps, + OUT ULONG *pdevcaps, + IN ULONG cjDevInfo, + OUT DEVINFO *pdi, + IN HDEV hdev, + IN LPWSTR pwszDeviceName, + IN HANDLE hDriver) +{ + DbgPrint("FtfdEnablePDEV(hdev=%p)\n", hdev); + + + /* Return a dummy DHPDEV */ + return (PVOID)1; +} + + +VOID +APIENTRY +FtfdCompletePDEV( + IN DHPDEV dhpdev, + IN HDEV hdev) +{ + DbgPrint("FtfdCompletePDEV()\n"); + /* Nothing to do */ +} + + +VOID +APIENTRY +FtfdDisablePDEV( + IN DHPDEV dhpdev) +{ + DbgPrint("FtfdDisablePDEV()\n"); + /* Nothing to do */ +} diff --git a/reactos/dll/3rdparty/freetype/ftfd/font.c b/reactos/dll/3rdparty/freetype/ftfd/font.c new file mode 100644 index 00000000000..e7145bbc4ae --- /dev/null +++ b/reactos/dll/3rdparty/freetype/ftfd/font.c @@ -0,0 +1,215 @@ +/* + * PROJECT: ReactOS win32 subsystem + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: GDI font driver for bitmap fonts + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +#include "ftfd.h" + +PVOID +HackFixup( + PVOID pvView, + ULONG cjView) +{ + CHAR *pc; + CHAR c; + + pc = EngAllocMem(0, cjView, 'tmp '); + memcpy(pc, pvView, cjView); + + c = *pc; + *pc = 0; + + return pc; +} + +/** Public Interface **********************************************************/ + +ULONG_PTR +APIENTRY +FtfdLoadFontFile( + ULONG cFiles, + ULONG_PTR *piFile, + PVOID *ppvView, + ULONG *pcjView, + DESIGNVECTOR *pdv, + ULONG ulLangID, + ULONG ulFastCheckSum) +{ + PVOID pvView; + ULONG cjView, i; + FT_Error fterror; + FT_Face ftface; + PFTFD_FILE pfile; + + DbgPrint("FtfdLoadFontFile()\n"); + + /* Check parameters */ + if (cFiles != 1) + { + DbgPrint("Only 1 File is allowed, got %ld!\n", cFiles); + return HFF_INVALID; + } + + /* Map the font file */ + if (!EngMapFontFileFD(*piFile, (PULONG*)&pvView, &cjView)) + { + DbgPrint("Could not map font file!\n", cFiles); + return HFF_INVALID; + } + + // HACK!!! + pvView = HackFixup(pvView, cjView); + + /* Look for faces in the file */ + for (i = 0; i < 100; i++) + { + fterror = FT_New_Memory_Face(gftlibrary, pvView, cjView, i, &ftface); + if (fterror) + { + DbgPrint("Error reading font file (error code: %u)\n", fterror); + break; + } + FT_Done_Face(ftface); + } + + /* Check whether we succeeded finding a face */ + if (i > 0) + { + pfile = EngAllocMem(0, sizeof(FTFD_FILE), 'dftF'); + if (pfile) + { + pfile->cNumFaces = i; + pfile->iFile = *piFile; + pfile->pvView = pvView; + pfile->cjView = cjView; + + DbgPrint("Success! Returning %ld faces\n", i); + + return (ULONG_PTR)pfile; + } + } + + DbgPrint("No faces found in file\n"); + + /* Unmap the file */ + EngUnmapFontFileFD(*piFile); + + /* Failure! */ + return HFF_INVALID; + +} + +BOOL +APIENTRY +FtfdUnloadFontFile( + IN ULONG_PTR iFile) +{ + PFTFD_FILE pfile = (PFTFD_FILE)iFile; + + DbgPrint("FtfdUnloadFontFile()\n"); + + // HACK!!! + EngFreeMem(pfile->pvView); + + /* Free the memory that was allocated for the font */ + EngFreeMem(pfile); + + /* Unmap the font file */ + EngUnmapFontFileFD(pfile->iFile); + + return TRUE; +} + + +LONG +APIENTRY +FtfdQueryFontFile( + ULONG_PTR iFile, + ULONG ulMode, + ULONG cjBuf, + ULONG *pulBuf) +{ + PFTFD_FILE pfile = (PFTFD_FILE)iFile; + + DbgPrint("FtfdQueryFontFile(ulMode=%ld)\n", ulMode); +// DbgBreakPoint(); + + switch (ulMode) + { + case QFF_DESCRIPTION: + { + return 0; + } + + case QFF_NUMFACES: + /* return the number of faces in the file */ + return pfile->cNumFaces; + + } + + return FD_ERROR; +} + +LONG +APIENTRY +FtfdQueryFontCaps( + ULONG culCaps, + ULONG *pulCaps) +{ + DbgPrint("BmfdQueryFontCaps()\n"); + + /* We need room for 2 ULONGs */ + if (culCaps < 2) + { + return FD_ERROR; + } + + /* We only support 1 bpp */ + pulCaps[0] = 2; + pulCaps[1] = QC_1BIT; + + return 2; +} + + +PVOID +APIENTRY +FtfdQueryFontTree( + DHPDEV dhpdev, + ULONG_PTR iFile, + ULONG iFace, + ULONG iMode, + ULONG_PTR *pid) +{ + return NULL; +} + +PIFIMETRICS +APIENTRY +FtfdQueryFont( + IN DHPDEV dhpdev, + IN ULONG_PTR iFile, + IN ULONG iFace, + IN ULONG_PTR *pid) +{ + return 0; +} + + +VOID +APIENTRY +FtfdFree( + PVOID pv, + ULONG_PTR id) +{ + DbgPrint("FtfdFree()\n"); + if (id) + { + EngFreeMem((PVOID)id); + } +} + + + diff --git a/reactos/dll/3rdparty/freetype/ftfd/ftfd.h b/reactos/dll/3rdparty/freetype/ftfd/ftfd.h new file mode 100644 index 00000000000..e2efd4a51e7 --- /dev/null +++ b/reactos/dll/3rdparty/freetype/ftfd/ftfd.h @@ -0,0 +1,136 @@ +/* + * PROJECT: ReactOS win32 subsystem + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: GDI font driver for bitmap fonts + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +#include +#include +#include +#include + +#include +#include FT_FREETYPE_H + +extern FT_Library gftlibrary; + +/** Driver specific types *****************************************************/ + + +typedef struct +{ + PVOID pvView; + ULONG cjView; + ULONG_PTR iFile; + ULONG cNumFaces; +} FTFD_FILE, *PFTFD_FILE; + +/** Function prototypes *******************************************************/ + +ULONG +DbgPrint(IN PCHAR Format, IN ...); + +static __inline__ +void +DbgBreakPoint(void) +{ + asm volatile ("int $3"); +} + +DHPDEV +APIENTRY +FtfdEnablePDEV( + IN DEVMODEW *pdm, + IN LPWSTR pwszLogAddress, + IN ULONG cPat, + OUT HSURF *phsurfPatterns, + IN ULONG cjCaps, + OUT ULONG *pdevcaps, + IN ULONG cjDevInfo, + OUT DEVINFO *pdi, + IN HDEV hdev, + IN LPWSTR pwszDeviceName, + IN HANDLE hDriver); + +VOID +APIENTRY +FtfdCompletePDEV( + IN DHPDEV dhpdev, + IN HDEV hdev); + +VOID +APIENTRY +FtfdDisablePDEV( + IN DHPDEV dhpdev); + +ULONG_PTR +APIENTRY +FtfdLoadFontFile( + ULONG cFiles, + ULONG_PTR *piFile, + PVOID *ppvView, + ULONG *pcjView, + DESIGNVECTOR *pdv, + ULONG ulLangID, + ULONG ulFastCheckSum); + +BOOL +APIENTRY +FtfdUnloadFontFile( + IN ULONG_PTR iFile); + +LONG +APIENTRY +FtfdQueryFontFile( + ULONG_PTR iFile, + ULONG ulMode, + ULONG cjBuf, + ULONG *pulBuf); + +LONG +APIENTRY +FtfdQueryFontCaps( + ULONG culCaps, + ULONG *pulCaps); + +PVOID +APIENTRY +FtfdQueryFontTree( + DHPDEV dhpdev, + ULONG_PTR iFile, + ULONG iFace, + ULONG iMode, + ULONG_PTR *pid); + +PIFIMETRICS +APIENTRY +FtfdQueryFont( + IN DHPDEV dhpdev, + IN ULONG_PTR iFile, + IN ULONG iFace, + IN ULONG_PTR *pid); + +VOID +APIENTRY +FtfdFree( + PVOID pv, + ULONG_PTR id); + +PFD_GLYPHATTR +APIENTRY +FtfdQueryGlyphAttrs( + FONTOBJ *pfo, + ULONG iMode); + +LONG +APIENTRY +FtfdQueryFontData( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + HGLYPH hg, + OUT GLYPHDATA *pgd, + PVOID pv, + ULONG cjSize); + diff --git a/reactos/dll/3rdparty/freetype/ftfd/glyph.c b/reactos/dll/3rdparty/freetype/ftfd/glyph.c new file mode 100644 index 00000000000..a242fbe6acd --- /dev/null +++ b/reactos/dll/3rdparty/freetype/ftfd/glyph.c @@ -0,0 +1,34 @@ +/* + * PROJECT: ReactOS win32 subsystem + * LICENSE: GPL - See COPYING in the top level directory + * PURPOSE: GDI font driver for bitmap fonts + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +#include "ftfd.h" + + +/** Public Interface **********************************************************/ + +PFD_GLYPHATTR +APIENTRY +FtfdQueryGlyphAttrs( + FONTOBJ *pfo, + ULONG iMode) +{ + return NULL; +} + +LONG +APIENTRY +FtfdQueryFontData( + DHPDEV dhpdev, + FONTOBJ *pfo, + ULONG iMode, + HGLYPH hg, + OUT GLYPHDATA *pgd, + PVOID pv, + ULONG cjSize) +{ + return FD_ERROR; +}