Index: reactos/win32ss/gdi/ntgdi/freetype.c =================================================================== --- reactos/win32ss/gdi/ntgdi/freetype.c (revision 75066) +++ reactos/win32ss/gdi/ntgdi/freetype.c (working copy) @@ -2503,116 +2503,51 @@ return TRUE; } -typedef struct FontFamilyInfoCallbackContext +static BOOLEAN FASTCALL +GetFontFamilyInfoForSubstitutes(LPLOGFONTW LogFont, + PFONTFAMILYINFO Info, + DWORD *pCount, + DWORD MaxCount) { - LPLOGFONTW LogFont; - PFONTFAMILYINFO Info; - DWORD Count; - DWORD Size; -} FONT_FAMILY_INFO_CALLBACK_CONTEXT, *PFONT_FAMILY_INFO_CALLBACK_CONTEXT; + PLIST_ENTRY pEntry, pHead = &FontSubstListHead; + PFONTSUBST_ENTRY pCurrentEntry; + PUNICODE_STRING pFromW; + FONTGDI *FontGDI; + LOGFONTW lf = *LogFont; + UNICODE_STRING NameW; -_Function_class_(RTL_QUERY_REGISTRY_ROUTINE) -static NTSTATUS APIENTRY -FontFamilyInfoQueryRegistryCallback(IN PWSTR ValueName, IN ULONG ValueType, - IN PVOID ValueData, IN ULONG ValueLength, - IN PVOID Context, IN PVOID EntryContext) -{ - PFONT_FAMILY_INFO_CALLBACK_CONTEXT InfoContext; - UNICODE_STRING RegistryName, RegistryValue; - int Existing; - PFONTGDI FontGDI; - - if (REG_SZ != ValueType) + for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink) { - return STATUS_SUCCESS; - } - InfoContext = (PFONT_FAMILY_INFO_CALLBACK_CONTEXT) Context; - RtlInitUnicodeString(&RegistryName, ValueName); + pCurrentEntry = + (PFONTSUBST_ENTRY)CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry); - /* Do we need to include this font family? */ - if (FontFamilyInclude(InfoContext->LogFont, &RegistryName, InfoContext->Info, - min(InfoContext->Count, InfoContext->Size))) - { - RtlInitUnicodeString(&RegistryValue, (PCWSTR) ValueData); - Existing = FindFaceNameInInfo(&RegistryValue, InfoContext->Info, - min(InfoContext->Count, InfoContext->Size)); - if (0 <= Existing) + pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM]; + if (LogFont->lfFaceName[0] != UNICODE_NULL) { - /* We already have the information about the "real" font. Just copy it */ - if (InfoContext->Count < InfoContext->Size) - { - InfoContext->Info[InfoContext->Count] = InfoContext->Info[Existing]; - RtlStringCbCopyNW(InfoContext->Info[InfoContext->Count].EnumLogFontEx.elfLogFont.lfFaceName, - sizeof(InfoContext->Info[InfoContext->Count].EnumLogFontEx.elfLogFont.lfFaceName), - RegistryName.Buffer, - RegistryName.Length); - } - InfoContext->Count++; - return STATUS_SUCCESS; + if (!FontFamilyInclude(LogFont, pFromW, Info, min(*pCount, MaxCount))) + continue; /* mismatch */ } - /* Try to find information about the "real" font */ - FontGDI = FindFaceNameInLists(&RegistryValue); - if (NULL == FontGDI) + RtlStringCchCopyW(lf.lfFaceName, LF_FACESIZE, pFromW->Buffer); + SubstituteFontRecurse(&lf); + + RtlInitUnicodeString(&NameW, lf.lfFaceName); + FontGDI = FindFaceNameInLists(&NameW); + if (FontGDI == NULL) { - /* "Real" font not found, discard this registry entry */ - return STATUS_SUCCESS; + continue; /* no real font */ } - /* Return info about the "real" font but with the name of the alias */ - if (InfoContext->Count < InfoContext->Size) + if (*pCount < MaxCount) { - FontFamilyFillInfo(InfoContext->Info + InfoContext->Count, - RegistryName.Buffer, NULL, FontGDI); + FontFamilyFillInfo(&Info[*pCount], NameW.Buffer, NULL, FontGDI); } - InfoContext->Count++; - return STATUS_SUCCESS; + (*pCount)++; } - return STATUS_SUCCESS; + return TRUE; } -static BOOLEAN FASTCALL -GetFontFamilyInfoForSubstitutes(LPLOGFONTW LogFont, - PFONTFAMILYINFO Info, - DWORD *Count, - DWORD Size) -{ - RTL_QUERY_REGISTRY_TABLE QueryTable[2] = {{0}}; - FONT_FAMILY_INFO_CALLBACK_CONTEXT Context; - NTSTATUS Status; - - /* Enumerate font families found in HKLM\Software\Microsoft\Windows NT\CurrentVersion\FontSubstitutes - The real work is done in the registry callback function */ - Context.LogFont = LogFont; - Context.Info = Info; - Context.Count = *Count; - Context.Size = Size; - - QueryTable[0].QueryRoutine = FontFamilyInfoQueryRegistryCallback; - QueryTable[0].Flags = 0; - QueryTable[0].Name = NULL; - QueryTable[0].EntryContext = NULL; - QueryTable[0].DefaultType = REG_NONE; - QueryTable[0].DefaultData = NULL; - QueryTable[0].DefaultLength = 0; - - QueryTable[1].QueryRoutine = NULL; - QueryTable[1].Name = NULL; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT, - L"FontSubstitutes", - QueryTable, - &Context, - NULL); - if (NT_SUCCESS(Status)) - { - *Count = Context.Count; - } - - return NT_SUCCESS(Status) || STATUS_OBJECT_NAME_NOT_FOUND == Status; -} - BOOL FASTCALL ftGdiGetRasterizerCaps(LPRASTERIZER_STATUS lprs)