Author: mjansen Date: Sat Aug 5 20:04:24 2017 New Revision: 75491 URL: http://svn.reactos.org/svn/reactos?rev=75491&view=rev Log: [WIN32SS] Improve GetFontResourceInfoW. Patch by Katayama Hirofumi MZ & Doug Lyons. CORE-13365 #resolve #comment Thanks!
Modified: trunk/reactos/win32ss/gdi/ntgdi/freetype.c Modified: trunk/reactos/win32ss/gdi/ntgdi/freetype.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/freetype.c?rev=75491&r1=75490&r2=75491&view=diff ============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/freetype.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/freetype.c [iso-8859-1] Sat Aug 5 20:04:24 2017 @@ -2450,53 +2450,84 @@ return FindFaceNameInInfo(FaceName, Info, InfoEntries) < 0; } +static BOOL FASTCALL +FontFamilyFound(PFONTFAMILYINFO InfoEntry, + PFONTFAMILYINFO Info, DWORD InfoCount) +{ + LPLOGFONTW plf1 = &InfoEntry->EnumLogFontEx.elfLogFont; + LPWSTR pFullName1 = InfoEntry->EnumLogFontEx.elfFullName; + LPWSTR pFullName2; + DWORD i; + + for (i = 0; i < InfoCount; ++i) + { + LPLOGFONTW plf2 = &Info[i].EnumLogFontEx.elfLogFont; + if (plf1->lfCharSet != plf2->lfCharSet) + continue; + + pFullName2 = Info[i].EnumLogFontEx.elfFullName; + if (_wcsicmp(pFullName1, pFullName2) != 0) + continue; + + return TRUE; + } + return FALSE; +} + static BOOLEAN FASTCALL GetFontFamilyInfoForList(LPLOGFONTW LogFont, PFONTFAMILYINFO Info, - DWORD *Count, - DWORD Size, + DWORD *pCount, + DWORD MaxCount, PLIST_ENTRY Head) { PLIST_ENTRY Entry; PFONT_ENTRY CurrentEntry; - ANSI_STRING EntryFaceNameA; - UNICODE_STRING EntryFaceNameW; FONTGDI *FontGDI; - NTSTATUS status; - - Entry = Head->Flink; - while (Entry != Head) - { - CurrentEntry = (PFONT_ENTRY) CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry); - + FONTFAMILYINFO InfoEntry; + DWORD Count = *pCount; + + for (Entry = Head->Flink; Entry != Head; Entry = Entry->Flink) + { + CurrentEntry = CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry); FontGDI = CurrentEntry->Font; ASSERT(FontGDI); - RtlInitAnsiString(&EntryFaceNameA, FontGDI->SharedFace->Face->family_name); - status = RtlAnsiStringToUnicodeString(&EntryFaceNameW, &EntryFaceNameA, TRUE); - if (!NT_SUCCESS(status)) - { - return FALSE; - } - - if ((LF_FACESIZE - 1) * sizeof(WCHAR) < EntryFaceNameW.Length) - { - EntryFaceNameW.Length = (LF_FACESIZE - 1) * sizeof(WCHAR); - EntryFaceNameW.Buffer[LF_FACESIZE - 1] = L'\0'; - } - - if (FontFamilyInclude(LogFont, &EntryFaceNameW, Info, min(*Count, Size))) - { - if (*Count < Size) - { - FontFamilyFillInfo(Info + *Count, EntryFaceNameW.Buffer, - NULL, FontGDI); - } - (*Count)++; - } - RtlFreeUnicodeString(&EntryFaceNameW); - Entry = Entry->Flink; - } + if (LogFont->lfCharSet != DEFAULT_CHARSET && + LogFont->lfCharSet != FontGDI->CharSet) + { + continue; + } + + if (LogFont->lfFaceName[0] == UNICODE_NULL) + { + if (Count < MaxCount) + { + FontFamilyFillInfo(&Info[Count], NULL, NULL, FontGDI); + } + Count++; + continue; + } + + FontFamilyFillInfo(&InfoEntry, NULL, NULL, FontGDI); + + if (_wcsicmp(LogFont->lfFaceName, InfoEntry.EnumLogFontEx.elfLogFont.lfFaceName) != 0 && + _wcsicmp(LogFont->lfFaceName, InfoEntry.EnumLogFontEx.elfFullName) != 0) + { + continue; + } + + if (!FontFamilyFound(&InfoEntry, Info, min(Count, MaxCount))) + { + if (Count < MaxCount) + { + RtlCopyMemory(&Info[Count], &InfoEntry, sizeof(InfoEntry)); + } + Count++; + } + } + + *pCount = Count; return TRUE; }