mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 20:56:26 +00:00
[WIN32SS] Rewrite GetFontFamilyInfoForSubstitutes to use the subsitute list loaded at boot. Patch by Katayama Hirofumi MZ. CORE-13064
svn path=/trunk/; revision=75140
This commit is contained in:
parent
e4ca76000c
commit
7117ea3375
1 changed files with 34 additions and 100 deletions
|
@ -2503,114 +2503,48 @@ GetFontFamilyInfoForList(LPLOGFONTW LogFont,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct FontFamilyInfoCallbackContext
|
|
||||||
{
|
|
||||||
LPLOGFONTW LogFont;
|
|
||||||
PFONTFAMILYINFO Info;
|
|
||||||
DWORD Count;
|
|
||||||
DWORD Size;
|
|
||||||
} FONT_FAMILY_INFO_CALLBACK_CONTEXT, *PFONT_FAMILY_INFO_CALLBACK_CONTEXT;
|
|
||||||
|
|
||||||
_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)
|
|
||||||
{
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
InfoContext = (PFONT_FAMILY_INFO_CALLBACK_CONTEXT) Context;
|
|
||||||
RtlInitUnicodeString(&RegistryName, ValueName);
|
|
||||||
|
|
||||||
/* 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)
|
|
||||||
{
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try to find information about the "real" font */
|
|
||||||
FontGDI = FindFaceNameInLists(&RegistryValue);
|
|
||||||
if (NULL == FontGDI)
|
|
||||||
{
|
|
||||||
/* "Real" font not found, discard this registry entry */
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return info about the "real" font but with the name of the alias */
|
|
||||||
if (InfoContext->Count < InfoContext->Size)
|
|
||||||
{
|
|
||||||
FontFamilyFillInfo(InfoContext->Info + InfoContext->Count,
|
|
||||||
RegistryName.Buffer, NULL, FontGDI);
|
|
||||||
}
|
|
||||||
InfoContext->Count++;
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOLEAN FASTCALL
|
static BOOLEAN FASTCALL
|
||||||
GetFontFamilyInfoForSubstitutes(LPLOGFONTW LogFont,
|
GetFontFamilyInfoForSubstitutes(LPLOGFONTW LogFont,
|
||||||
PFONTFAMILYINFO Info,
|
PFONTFAMILYINFO Info,
|
||||||
DWORD *Count,
|
DWORD *pCount,
|
||||||
DWORD Size)
|
DWORD MaxCount)
|
||||||
{
|
{
|
||||||
RTL_QUERY_REGISTRY_TABLE QueryTable[2] = {{0}};
|
PLIST_ENTRY pEntry, pHead = &FontSubstListHead;
|
||||||
FONT_FAMILY_INFO_CALLBACK_CONTEXT Context;
|
PFONTSUBST_ENTRY pCurrentEntry;
|
||||||
NTSTATUS Status;
|
PUNICODE_STRING pFromW;
|
||||||
|
FONTGDI *FontGDI;
|
||||||
|
LOGFONTW lf = *LogFont;
|
||||||
|
UNICODE_STRING NameW;
|
||||||
|
|
||||||
/* Enumerate font families found in HKLM\Software\Microsoft\Windows NT\CurrentVersion\FontSubstitutes
|
for (pEntry = pHead->Flink; pEntry != pHead; pEntry = pEntry->Flink)
|
||||||
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;
|
pCurrentEntry = CONTAINING_RECORD(pEntry, FONTSUBST_ENTRY, ListEntry);
|
||||||
|
|
||||||
|
pFromW = &pCurrentEntry->FontNames[FONTSUBST_FROM];
|
||||||
|
if (LogFont->lfFaceName[0] != UNICODE_NULL)
|
||||||
|
{
|
||||||
|
if (!FontFamilyInclude(LogFont, pFromW, Info, min(*pCount, MaxCount)))
|
||||||
|
continue; /* mismatch */
|
||||||
|
}
|
||||||
|
|
||||||
|
RtlStringCchCopyW(lf.lfFaceName, LF_FACESIZE, pFromW->Buffer);
|
||||||
|
SubstituteFontRecurse(&lf);
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&NameW, lf.lfFaceName);
|
||||||
|
FontGDI = FindFaceNameInLists(&NameW);
|
||||||
|
if (FontGDI == NULL)
|
||||||
|
{
|
||||||
|
continue; /* no real font */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*pCount < MaxCount)
|
||||||
|
{
|
||||||
|
FontFamilyFillInfo(&Info[*pCount], pFromW->Buffer, NULL, FontGDI);
|
||||||
|
}
|
||||||
|
(*pCount)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NT_SUCCESS(Status) || STATUS_OBJECT_NAME_NOT_FOUND == Status;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue