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; ULONG cjSize, cNumFaces; 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"); return HFF_INVALID; } // HACK!!! pvView = HackFixup(pvView, cjView); fterror = FT_New_Memory_Face(gftlibrary, pvView, cjView, 0, &ftface); if (fterror) { DbgPrint("No faces found in file\n"); /* Unmap the file */ EngUnmapFontFileFD(*piFile); /* Failure! */ return HFF_INVALID; } /* Get number of faces from the first face */ cNumFaces = ftface->num_faces; cjSize = sizeof(FTFD_FILE) + cNumFaces * sizeof(FT_Face); pfile = EngAllocMem(0, cjSize, 'dftF'); if (!pfile) { DbgPrint("EngAllocMem() failed.\n"); /* Unmap the file */ EngUnmapFontFileFD(*piFile); /* Failure! */ return HFF_INVALID; } pfile->cNumFaces = cNumFaces; pfile->iFile = *piFile; pfile->pvView = pvView; pfile->cjView = cjView; for (i = 0; i < pfile->cNumFaces; i++) { pfile->aftface[i] = ftface; FT_Select_Charmap(ftface, FT_ENCODING_UNICODE); } DbgPrint("Success! Returning %ld faces\n", cNumFaces); return (ULONG_PTR)pfile; }
ULONG_PTR APIENTRY BmfdLoadFontFile( ULONG cFiles, ULONG_PTR *piFile, PVOID *ppvView, ULONG *pcjView, DESIGNVECTOR *pdv, ULONG ulLangID, ULONG ulFastCheckSum) { PBMFD_FILE pfile = NULL; PVOID pvView; ULONG cjView; DbgPrint("BmfdLoadFontFile()\n"); __debugbreak(); /* 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; } DbgPrint("mapped font file to %p, site if %ld\n", pvView, cjView); /* Try to parse a .fon file */ pfile = ParseFonFile(pvView, cjView); if (!pfile) { /* Could be a .fnt file */ pfile = ParseFntFile(pvView, cjView); } /* Check whether we succeeded finding a font */ if (!pfile) { DbgPrint("No font data found\n"); /* Unmap the file */ EngUnmapFontFileFD(*piFile); /* Failure! */ return HFF_INVALID; } pfile->iFile = *piFile; pfile->pvView = pvView; /* Success, return the pointer to font info structure */ return (ULONG_PTR)pfile; }