Author: tkreuzer
Date: Mon May 30 17:19:46 2011
New Revision: 52012
URL:
http://svn.reactos.org/svn/reactos?rev=52012&view=rev
Log:
[WIN32K]
- Implement GreAddFontResourceInternal
- Refactor EngLoadFontFileFD once again
- Load Tahoma font after initializing the font driver (hack)
Modified:
branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fntdrvsup.c
branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fontrsrc.c
branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/font.h
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fntdrvsup.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyst…
==============================================================================
--- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fntdrvsup.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fntdrvsup.c [iso-8859-1]
Mon May 30 17:19:46 2011
@@ -30,9 +30,7 @@
HSEMAPHORE ghsemFontDriver;
LIST_ENTRY gleFontDriverList = {&gleFontDriverList, &gleFontDriverList};
-HSEMAPHORE ghsemPFFList;
-LIST_ENTRY glePFFList = {&glePFFList, &glePFFList};
-
+extern HSEMAPHORE ghsemPFFList;
BOOL FASTCALL
InitFontSupport(VOID)
@@ -60,141 +58,6 @@
ASSERT(gbAttachedCSRSS);
KeUnstackDetachProcess(pApcState);
gbAttachedCSRSS = FALSE;
-}
-
-static
-HFF
-FONTDEV_hffLoadFontFile(
- PFONTDEV pfntdev,
- ULONG cFiles,
- ULONG_PTR *piFile,
- PVOID *ppvView,
- ULONG *pcjView,
- DESIGNVECTOR *pdv,
- ULONG ulLangID,
- ULONG ulFastCheckSum)
-{
- HFF hff;
- ASSERT(gbAttachedCSRSS);
-
- /* Call the drivers DrvLoadFontFile function */
- hff = pfntdev->pldev->pfn.LoadFontFile(cFiles,
- piFile,
- ppvView,
- pcjView,
- pdv,
- ulLangID,
- ulFastCheckSum);
-
- if (hff == 0) return 0;
-
- return hff;
-}
-
-static
-HFF
-EngLoadFontFileFD(
- ULONG cFiles,
- PFONTFILEVIEW *ppffv,
- DESIGNVECTOR *pdv,
- ULONG ulCheckSum,
- PFONTDEV *ppfntdev)
-{
- PULONG_PTR piFiles = (PULONG_PTR)ppffv;
- PVOID apvView[FD_MAX_FILES];
- ULONG acjView[FD_MAX_FILES];
- ULONG i, ulLangID = 0;
- PFONTDEV pfntdev;
- PLIST_ENTRY ple;
- HFF hff = 0;
-
- /* Loop all files */
- for (i = 0; i < cFiles; i++)
- {
- /* Map the font file */
- if (!EngMapFontFileFD(piFiles[i], (PULONG*)&apvView[i], &acjView[i]))
- {
- ASSERT(FALSE);
- }
- }
-
- /* Acquire font driver list lock */
- EngAcquireSemaphore(ghsemFontDriver);
-
- /* Loop all installed font drivers */
- for (ple = gleFontDriverList.Flink;
- ple != &gleFontDriverList;
- ple = ple->Flink)
- {
- pfntdev = CONTAINING_RECORD(ple, FONTDEV, leLink);
-
- /* Try to load the font file */
- hff = FONTDEV_hffLoadFontFile(pfntdev,
- cFiles,
- piFiles,
- apvView,
- acjView,
- pdv,
- ulLangID,
- ulCheckSum);
- if (hff)
- {
- *ppfntdev = pfntdev;
- break;
- }
- }
-
- /* Release font friver list lock */
- EngReleaseSemaphore(ghsemFontDriver);
-
- return hff;
-}
-
-static
-BOOL
-PFF_bCompareFiles(
- PPFF ppff,
- ULONG cFiles,
- PFONTFILEVIEW pffv[])
-{
- ULONG i;
-
- /* Check if number of files matches */
- if (ppff->cFiles != cFiles) return FALSE;
-
- /* Loop all files */
- for (i = 0; i < cFiles; i++)
- {
- /* Check if the files match */
- if (pffv[i] != ppff->apffv[i]) return FALSE;
- }
-
- return TRUE;
-}
-
-static PPFF
-EngFindPFF(ULONG cFiles, PFONTFILEVIEW *ppffv)
-{
- PLIST_ENTRY ple;
- PPFF ppff;
- ASSERT(cFiles >= 1 && cFiles <= FD_MAX_FILES);
-
- /* Acquire PFF list lock */
- EngAcquireSemaphore(ghsemPFFList);
-
- /* Loop all physical font files (PFF) */
- for (ple = glePFFList.Flink; ple != &glePFFList; ple = ple->Flink)
- {
- ppff = CONTAINING_RECORD(ple, PFF, leLink);
-
- /* Check if the files are already loaded */
- if (PFF_bCompareFiles(ppff, cFiles, ppffv)) break;
- }
-
- /* Release PFF list lock */
- EngReleaseSemaphore(ghsemPFFList);
-
- return ple != &glePFFList ? ppff : NULL;
}
static void
@@ -245,45 +108,59 @@
PPFF
NTAPI
-EngLoadFontFile(
- IN ULONG cFiles,
- IN PWCHAR apwszFiles[],
- IN DESIGNVECTOR *pdv)
-{
- PFONTFILEVIEW apffv[FD_MAX_FILES];
+EngLoadFontFileFD(
+ ULONG cFiles,
+ PFONTFILEVIEW *ppffv,
+ DESIGNVECTOR *pdv,
+ ULONG ulCheckSum)
+{
+ PULONG_PTR piFiles = (PULONG_PTR)ppffv;
+ PVOID apvView[FD_MAX_FILES];
+ ULONG acjView[FD_MAX_FILES];
KAPC_STATE ApcState;
+ PLIST_ENTRY ple;
+ PFONTDEV pfntdev = NULL;
+ HFF hff = 0;
+ ULONG cFaces, cjSize, i, ulLangID = 0;
PPFF ppff = NULL;
- ULONG i, cjSize, cFaces, ulChecksum = 0;
- PFONTDEV pfntdev = NULL;
- HFF hff;
-
- /* Loop the files */
- for (i = 0; i < cFiles; i++)
- {
- /* Try to load the file */
- apffv[i] = (PVOID)EngLoadModuleEx(apwszFiles[i], 0, FVF_FONTFILE);
- if (!apffv[i])
- {
- /* Cleanup and return */
- while (i--) EngFreeModule(apffv[i]);
- return NULL;
- }
- }
-
- /* Try to find an existing PFF */
- ppff = EngFindPFF(cFiles, apffv);
- if (ppff)
- {
- /* Cleanup loaded files, we don't need them anymore */
- for (i = 0; i < cFiles; i++) EngFreeModule(apffv[i]);
- return ppff;
- }
/* Attach to CSRSS */
AttachCSRSS(&ApcState);
- /* Try to load the font with any of the font drivers */
- hff = EngLoadFontFileFD(cFiles, apffv, pdv, ulChecksum, &pfntdev);
+ /* Loop all files */
+ for (i = 0; i < cFiles; i++)
+ {
+ /* Map the font file */
+ if (!EngMapFontFileFD(piFiles[i], (PULONG*)&apvView[i], &acjView[i]))
+ {
+ ASSERT(FALSE);
+ }
+ }
+
+ /* Acquire font driver list lock */
+ EngAcquireSemaphore(ghsemFontDriver);
+
+ /* Loop all installed font drivers */
+ for (ple = gleFontDriverList.Flink;
+ ple != &gleFontDriverList;
+ ple = ple->Flink)
+ {
+ pfntdev = CONTAINING_RECORD(ple, FONTDEV, leLink);
+
+ /* Call the drivers DrvLoadFontFile function */
+ hff = pfntdev->pldev->pfn.LoadFontFile(cFiles,
+ piFiles,
+ apvView,
+ acjView,
+ pdv,
+ ulLangID,
+ ulCheckSum);
+ if (hff) break;
+ }
+
+ /* Release font driver list lock */
+ EngReleaseSemaphore(ghsemFontDriver);
+
if (!hff)
{
DPRINT1("File format is not supported by any font driver\n");
@@ -310,7 +187,7 @@
ppff->hff = hff;
/* Copy the FONTFILEVIEW pointers */
- for (i = 0; i < cFiles; i++) ppff->apffv[i] = apffv[i];
+ for (i = 0; i < cFiles; i++) ppff->apffv[i] = ppffv[i];
/* Loop all faces in the font file */
for (i = 0; i < cFaces; i++)
@@ -319,16 +196,7 @@
PFE_vInitialize(&ppff->apfe[i], ppff, i + 1);
}
- /* Insert the PFF into the list */
- EngAcquireSemaphore(ghsemPFFList);
- InsertTailList(&glePFFList, &ppff->leLink);
- EngReleaseSemaphore(ghsemPFFList);
-
leave:
- if (!ppff)
- {
- for (i = 0; i < cFiles; i++) EngFreeModule(apffv[i]);
- }
/* Detach from CSRSS */
DetachCSRSS(&ApcState);
@@ -393,6 +261,9 @@
NTAPI
GreStartupFontDrivers(VOID)
{
+ ULONG cFonts;
+ static PWSTR pwszFile = L"\\??\\c:\\ReactOS\\Fonts\\tahoma.ttf";
+
/* Load freetype font driver */
if (!EngLoadFontDriver(L"ftfd.dll"))
{
@@ -403,5 +274,10 @@
/* TODO: Enumerate installed font drivers */
DPRINT1("############ Started font drivers\n");
-}
-
+
+ // lets load some fonts
+ cFonts = GreAddFontResourceInternal(&pwszFile, 1, 0, 0, NULL);
+ ASSERT(cFonts > 0);
+
+}
+
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fontrsrc.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyst…
==============================================================================
--- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fontrsrc.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fontrsrc.c [iso-8859-1]
Mon May 30 17:19:46 2011
@@ -11,19 +11,98 @@
#define NDEBUG
#include <debug.h>
+HSEMAPHORE ghsemPFFList;
+static LIST_ENTRY glePrivatePFFList = {&glePrivatePFFList, &glePrivatePFFList};
+static LIST_ENTRY glePublicPFFList = {&glePublicPFFList, &glePublicPFFList};
+
+static
+BOOL
+PFF_bCompareFiles(
+ PPFF ppff,
+ ULONG cFiles,
+ PFONTFILEVIEW pffv[])
+{
+ ULONG i;
+
+ /* Check if number of files matches */
+ if (ppff->cFiles != cFiles) return FALSE;
+
+ /* Loop all files */
+ for (i = 0; i < cFiles; i++)
+ {
+ /* Check if the files match */
+ if (pffv[i] != ppff->apffv[i]) return FALSE;
+ }
+
+ return TRUE;
+}
+
INT
NTAPI
GreAddFontResourceInternal(
IN PWCHAR apwszFiles[],
IN ULONG cFiles,
- IN FLONG f,
+ IN FLONG fl,
IN DWORD dwPidTid,
IN OPTIONAL DESIGNVECTOR *pdv)
{
-
-
- ASSERT(FALSE);
- return 0;
+ PFONTFILEVIEW apffv[FD_MAX_FILES];
+ PPFF ppff = NULL;
+ PLIST_ENTRY ple, pleListHead;
+ ULONG i, ulCheckSum = 0;
+
+ /* Loop the files */
+ for (i = 0; i < cFiles; i++)
+ {
+ /* Try to load the file */
+ apffv[i] = (PVOID)EngLoadModuleEx(apwszFiles[i], 0, FVF_FONTFILE);
+ if (!apffv[i])
+ {
+ DPRINT1("Failed to load file: '%ls'\n", apwszFiles[i]);
+ /* Cleanup and return */
+ while (i--) EngFreeModule(apffv[i]);
+ return 0;
+ }
+ }
+
+ pleListHead = fl & FR_PRIVATE ? &glePrivatePFFList : &glePublicPFFList;
+
+ /* Acquire PFF list lock */
+ EngAcquireSemaphore(ghsemPFFList);
+
+ /* Loop all physical font files (PFF) */
+ for (ple = pleListHead->Flink; ple != pleListHead; ple = ple->Flink)
+ {
+ ppff = CONTAINING_RECORD(ple, PFF, leLink);
+
+ /* Check if the files are already loaded */
+ if (PFF_bCompareFiles(ppff, cFiles, apffv)) break;
+ }
+
+ /* Release PFF list lock */
+ EngReleaseSemaphore(ghsemPFFList);
+
+ if (ple == pleListHead)
+ {
+ /* Cleanup loaded files, we don't need them anymore */
+ for (i = 0; i < cFiles; i++) EngFreeModule(apffv[i]);
+ return ppff->cFonts;
+ }
+
+ /* Load the font file with a font driver */
+ ppff = EngLoadFontFileFD(cFiles, apffv, pdv, ulCheckSum);
+ if (!ppff)
+ {
+ DPRINT1("Failed to load font with font driver\n");
+ return 0;
+ }
+
+ /* Insert the PFF into the list */
+ EngAcquireSemaphore(ghsemPFFList);
+ InsertTailList(pleListHead, &ppff->leLink);
+ EngReleaseSemaphore(ghsemPFFList);
+
+ return ppff->cFonts;
}
static
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/font.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyst…
==============================================================================
--- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/font.h [iso-8859-1]
(original)
+++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/font.h [iso-8859-1]
Mon May 30 17:19:46 2011
@@ -220,4 +220,20 @@
NTAPI
DC_prfnt(PDC pdc);
-
+PPFF
+NTAPI
+EngLoadFontFileFD(
+ ULONG cFiles,
+ PFONTFILEVIEW *ppffv,
+ DESIGNVECTOR *pdv,
+ ULONG ulCheckSum);
+
+INT
+NTAPI
+GreAddFontResourceInternal(
+ IN PWCHAR apwszFiles[],
+ IN ULONG cFiles,
+ IN FLONG fl,
+ IN DWORD dwPidTid,
+ IN OPTIONAL DESIGNVECTOR *pdv);
+