FT_ULong os2_ulCodePageRange1;
FT_UShort os2_usWeightClass;
- if (SharedFace == NULL && CharSetIndex == -1)
- {
- /* load a face from memory */
- IntLockFreeType();
- Error = FT_New_Memory_Face(
- g_FreeTypeLibrary,
- pLoadFont->Memory->Buffer,
- pLoadFont->Memory->BufferSize,
- ((FontIndex != -1) ? FontIndex : 0),
- &Face);
-
- if (!Error)
- SharedFace = SharedFace_Create(Face, pLoadFont->Memory);
+ ASSERT(SharedFace != NULL);
+ ASSERT(FontIndex != -1);
- IntUnLockFreeType();
-
- if (!Error && FT_IS_SFNT(Face))
- pLoadFont->IsTrueType = TRUE;
-
- if (Error || SharedFace == NULL)
- {
- if (SharedFace)
- SharedFace_Release(SharedFace);
-
- if (Error == FT_Err_Unknown_File_Format)
- DPRINT1("Unknown font file format\n");
- else
- DPRINT1("Error reading font (error code: %d)\n", Error);
- return 0; /* failure */
- }
- }
- else
- {
- Face = SharedFace->Face;
- IntLockFreeType();
- SharedFace_AddRef(SharedFace);
- IntUnLockFreeType();
- }
+ IntLockFreeType();
+ Face = SharedFace->Face;
+ SharedFace_AddRef(SharedFace);
+ IntUnLockFreeType();
/* allocate a FONT_ENTRY */
Entry = ExAllocatePoolWithTag(PagedPool, sizeof(FONT_ENTRY), TAG_FONT);
}
IntUnLockFreeType();
- if (FontIndex == -1)
- {
- FT_Long iFace, num_faces = Face->num_faces;
- for (iFace = 1; iFace < num_faces; ++iFace)
- {
- FaceCount += IntGdiLoadFontsFromMemory(pLoadFont, NULL, iFace, -1);
- }
- FontIndex = 0;
- }
-
if (CharSetIndex == -1)
{
INT i;
return FaceCount; /* number of loaded faces */
}
+static INT FASTCALL
+IntGdiLoadFontByIndexFromMemory(PGDI_LOAD_FONT pLoadFont, FT_Long FontIndex)
+{
+ FT_Error Error;
+ FT_Face Face;
+ FT_Long iFace, num_faces;
+ PSHARED_FACE SharedFace;
+ INT FaceCount = 0;
+
+ IntLockFreeType();
+
+ /* Load a face from memory */
+ Error = FT_New_Memory_Face(g_FreeTypeLibrary,
+ pLoadFont->Memory->Buffer, pLoadFont->Memory->BufferSize,
+ ((FontIndex == -1) ? 0 : FontIndex), &Face);
+ if (Error)
+ {
+ if (Error == FT_Err_Unknown_File_Format)
+ DPRINT1("Unknown font file format\n");
+ else
+ DPRINT1("Error reading font (error code: %d)\n", Error);
+ IntUnLockFreeType();
+ return 0; /* Failure */
+ }
+
+ pLoadFont->IsTrueType = FT_IS_SFNT(Face);
+ num_faces = Face->num_faces;
+ SharedFace = SharedFace_Create(Face, pLoadFont->Memory);
+
+ IntUnLockFreeType();
+
+ if (!SharedFace)
+ {
+ DPRINT1("SharedFace_Create failed\n");
+ EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return 0; /* Failure */
+ }
+
+ if (FontIndex == -1)
+ {
+ for (iFace = 1; iFace < num_faces; ++iFace)
+ {
+ FaceCount += IntGdiLoadFontByIndexFromMemory(pLoadFont, iFace);
+ }
+ FontIndex = 0;
+ }
+
+ FaceCount += IntGdiLoadFontsFromMemory(pLoadFont, SharedFace, FontIndex, -1);
+ return FaceCount;
+}
+
static LPCWSTR FASTCALL
NameFromCharSet(BYTE CharSet)
{
return 0;
}
+ RtlZeroMemory(&LoadFont, sizeof(LoadFont));
LoadFont.pFileName = &PathName;
LoadFont.Memory = SharedMem_Create(Buffer, ViewSize, TRUE);
LoadFont.Characteristics = Characteristics;
RtlInitUnicodeString(&LoadFont.RegValueName, NULL);
- LoadFont.IsTrueType = FALSE;
LoadFont.CharSet = DEFAULT_CHARSET;
- LoadFont.PrivateEntry = NULL;
- FontCount = IntGdiLoadFontsFromMemory(&LoadFont, NULL, -1, -1);
+ FontCount = IntGdiLoadFontByIndexFromMemory(&LoadFont, -1);
/* Release our copy */
IntLockFreeType();
}
RtlCopyMemory(BufferCopy, Buffer, dwSize);
- LoadFont.pFileName = NULL;
+ RtlZeroMemory(&LoadFont, sizeof(LoadFont));
LoadFont.Memory = SharedMem_Create(BufferCopy, dwSize, FALSE);
LoadFont.Characteristics = FR_PRIVATE | FR_NOT_ENUM;
RtlInitUnicodeString(&LoadFont.RegValueName, NULL);
- LoadFont.IsTrueType = FALSE;
- LoadFont.PrivateEntry = NULL;
- FaceCount = IntGdiLoadFontsFromMemory(&LoadFont, NULL, -1, -1);
+ FaceCount = IntGdiLoadFontByIndexFromMemory(&LoadFont, -1);
RtlFreeUnicodeString(&LoadFont.RegValueName);