Skip to content

Commit c5204e3

Browse files
committed
[0.4.11] Revert "[FONT][GDI32] Fix font enumeration functions (reactos#1221)"
This reverts commit 0.4.11-RC-25-g d332edc. reactos#1221 == 0.4.12-dev-320-g 6e4e5a0 == 0.4.11-RC-25-g d332edc aimed to fix historic regression CORE-15558 (Abisoft Font-listbox showing too many fonts) Unfortunately, it would introduce a new regression CORE-15755. (wrong font chosen in NLite 1.4.9.3) Beside that reactos#1221 introduced a retrospective and potentially time-expensive qsort()-call on the enumerated font-list. Due to this uncertainty / open issues I decided to keep it out of releases/0.4.11 and stick with the better evaluated state before that patch.
1 parent a9be77c commit c5204e3

File tree

2 files changed

+158
-136
lines changed

2 files changed

+158
-136
lines changed

win32ss/gdi/gdi32/objects/font.c

Lines changed: 6 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -204,88 +204,9 @@ NewTextMetricExW2A(NEWTEXTMETRICEXA *tma, NEWTEXTMETRICEXW *tmw)
204204
tma->ntmFontSig = tmw->ntmFontSig;
205205
}
206206

207-
// IntFontFamilyCompareEx's flags
208-
#define IFFCX_CHARSET 1
209-
#define IFFCX_STYLE 2
210-
211-
FORCEINLINE int FASTCALL
212-
IntFontFamilyCompareEx(const FONTFAMILYINFO *ffi1,
213-
const FONTFAMILYINFO *ffi2, DWORD dwCompareFlags)
214-
{
215-
const LOGFONTW *plf1 = &ffi1->EnumLogFontEx.elfLogFont;
216-
const LOGFONTW *plf2 = &ffi2->EnumLogFontEx.elfLogFont;
217-
ULONG WeightDiff1, WeightDiff2;
218-
int cmp = _wcsicmp(plf1->lfFaceName, plf2->lfFaceName);
219-
if (cmp)
220-
return cmp;
221-
if (dwCompareFlags & IFFCX_STYLE)
222-
{
223-
WeightDiff1 = labs(plf1->lfWeight - FW_NORMAL);
224-
WeightDiff2 = labs(plf2->lfWeight - FW_NORMAL);
225-
if (WeightDiff1 < WeightDiff2)
226-
return -1;
227-
if (WeightDiff1 > WeightDiff2)
228-
return 1;
229-
if (plf1->lfItalic < plf2->lfItalic)
230-
return -1;
231-
if (plf1->lfItalic > plf2->lfItalic)
232-
return 1;
233-
}
234-
if (dwCompareFlags & IFFCX_CHARSET)
235-
{
236-
if (plf1->lfCharSet < plf2->lfCharSet)
237-
return -1;
238-
if (plf1->lfCharSet > plf2->lfCharSet)
239-
return 1;
240-
}
241-
return 0;
242-
}
243-
244-
static int __cdecl
245-
IntFontFamilyCompare(const void *ffi1, const void *ffi2)
246-
{
247-
return IntFontFamilyCompareEx(ffi1, ffi2, IFFCX_STYLE | IFFCX_CHARSET);
248-
}
249-
250-
// IntEnumFontFamilies' flags:
251-
#define IEFF_UNICODE 1
252-
#define IEFF_EXTENDED 2
253-
254-
int FASTCALL
255-
IntFontFamilyListUnique(FONTFAMILYINFO *InfoList, INT nCount,
256-
const LOGFONTW *plf, DWORD dwFlags)
257-
{
258-
FONTFAMILYINFO *first, *last, *result;
259-
DWORD dwCompareFlags = 0;
260-
261-
if (plf->lfFaceName[0])
262-
dwCompareFlags |= IFFCX_STYLE;
263-
264-
if ((dwFlags & IEFF_EXTENDED) && plf->lfCharSet == DEFAULT_CHARSET)
265-
dwCompareFlags |= IFFCX_CHARSET;
266-
267-
// std::unique(first, last, IntFontFamilyCompareEx);
268-
if (nCount == 0)
269-
return 0;
270-
271-
result = first = InfoList;
272-
last = &InfoList[nCount];
273-
while (++first != last)
274-
{
275-
if (IntFontFamilyCompareEx(result, first, dwCompareFlags) != 0 &&
276-
++result != first)
277-
{
278-
*result = *first;
279-
}
280-
}
281-
nCount = (int)(++result - InfoList);
282-
283-
return nCount;
284-
}
285-
286207
static int FASTCALL
287208
IntEnumFontFamilies(HDC Dc, LPLOGFONTW LogFont, PVOID EnumProc, LPARAM lParam,
288-
DWORD dwFlags)
209+
BOOL Unicode)
289210
{
290211
int FontFamilyCount;
291212
int FontFamilySize;
@@ -335,15 +256,9 @@ IntEnumFontFamilies(HDC Dc, LPLOGFONTW LogFont, PVOID EnumProc, LPARAM lParam,
335256
}
336257
}
337258

338-
DPRINT("qsort\n");
339-
qsort(Info, FontFamilyCount, sizeof(*Info), IntFontFamilyCompare);
340-
DPRINT("qsort done\n");
341-
FontFamilyCount = IntFontFamilyListUnique(Info, FontFamilyCount, LogFont, dwFlags);
342-
DPRINT("unique done\n");
343-
344259
for (i = 0; i < FontFamilyCount; i++)
345260
{
346-
if (dwFlags & IEFF_UNICODE)
261+
if (Unicode)
347262
{
348263
Ret = ((FONTENUMPROCW) EnumProc)(
349264
(VOID*)&Info[i].EnumLogFontEx,
@@ -384,8 +299,7 @@ int WINAPI
384299
EnumFontFamiliesExW(HDC hdc, LPLOGFONTW lpLogfont, FONTENUMPROCW lpEnumFontFamExProc,
385300
LPARAM lParam, DWORD dwFlags)
386301
{
387-
return IntEnumFontFamilies(hdc, lpLogfont, lpEnumFontFamExProc, lParam,
388-
IEFF_UNICODE | IEFF_EXTENDED);
302+
return IntEnumFontFamilies(hdc, lpLogfont, lpEnumFontFamExProc, lParam, TRUE);
389303
}
390304

391305

@@ -406,7 +320,7 @@ EnumFontFamiliesW(HDC hdc, LPCWSTR lpszFamily, FONTENUMPROCW lpEnumFontFamProc,
406320
lstrcpynW(LogFont.lfFaceName, lpszFamily, LF_FACESIZE);
407321
}
408322

409-
return IntEnumFontFamilies(hdc, &LogFont, lpEnumFontFamProc, lParam, IEFF_UNICODE);
323+
return IntEnumFontFamilies(hdc, &LogFont, lpEnumFontFamProc, lParam, TRUE);
410324
}
411325

412326

@@ -427,7 +341,7 @@ EnumFontFamiliesExA (HDC hdc, LPLOGFONTA lpLogfont, FONTENUMPROCA lpEnumFontFamE
427341
else pLogFontW = NULL;
428342

429343
/* no need to convert LogFontW back to lpLogFont b/c it's an [in] parameter only */
430-
return IntEnumFontFamilies(hdc, pLogFontW, lpEnumFontFamExProc, lParam, IEFF_EXTENDED);
344+
return IntEnumFontFamilies(hdc, pLogFontW, lpEnumFontFamExProc, lParam, FALSE);
431345
}
432346

433347

@@ -448,7 +362,7 @@ EnumFontFamiliesA(HDC hdc, LPCSTR lpszFamily, FONTENUMPROCA lpEnumFontFamProc,
448362
MultiByteToWideChar(CP_THREAD_ACP, 0, lpszFamily, -1, LogFont.lfFaceName, LF_FACESIZE);
449363
}
450364

451-
return IntEnumFontFamilies(hdc, &LogFont, lpEnumFontFamProc, lParam, 0);
365+
return IntEnumFontFamilies(hdc, &LogFont, lpEnumFontFamProc, lParam, FALSE);
452366
}
453367

454368

0 commit comments

Comments
 (0)