diff --git a/reactos/win32ss/gdi/ntgdi/font.c b/reactos/win32ss/gdi/ntgdi/font.c index 10bd73b1a8e..74dd207eb4b 100644 --- a/reactos/win32ss/gdi/ntgdi/font.c +++ b/reactos/win32ss/gdi/ntgdi/font.c @@ -1003,6 +1003,61 @@ NtGdiGetRealizationInfo( return Ret; } + +HFONT +APIENTRY +HfontCreate( + IN PENUMLOGFONTEXDVW pelfw, + IN ULONG cjElfw, + IN LFTYPE lft, + IN FLONG fl, + IN PVOID pvCliData ) +{ + HFONT hNewFont; + PLFONT plfont; + + if (!pelfw) + { + return NULL; + } + + plfont = LFONT_AllocFontWithHandle(); + if (!plfont) + { + return NULL; + } + hNewFont = plfont->BaseObject.hHmgr; + + plfont->lft = lft; + plfont->fl = fl; + RtlCopyMemory (&plfont->logfont, pelfw, sizeof(ENUMLOGFONTEXDVW)); + ExInitializePushLock(&plfont->lock); + + if (pelfw->elfEnumLogfontEx.elfLogFont.lfEscapement != + pelfw->elfEnumLogfontEx.elfLogFont.lfOrientation) + { + /* This should really depend on whether GM_ADVANCED is set */ + plfont->logfont.elfEnumLogfontEx.elfLogFont.lfOrientation = + plfont->logfont.elfEnumLogfontEx.elfLogFont.lfEscapement; + } + LFONT_UnlockFont(plfont); + + if (pvCliData && hNewFont) + { + // FIXME: Use GDIOBJ_InsertUserData + KeEnterCriticalRegion(); + { + INT Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)hNewFont); + PGDI_TABLE_ENTRY Entry = &GdiHandleTable->Entries[Index]; + Entry->UserData = pvCliData; + } + KeLeaveCriticalRegion(); + } + + return hNewFont; +} + + HFONT APIENTRY NtGdiHfontCreate( @@ -1013,8 +1068,6 @@ NtGdiHfontCreate( IN PVOID pvCliData ) { ENUMLOGFONTEXDVW SafeLogfont; - HFONT hNewFont; - PLFONT plfont; NTSTATUS Status = STATUS_SUCCESS; /* Silence GCC warnings */ @@ -1042,40 +1095,7 @@ NtGdiHfontCreate( return NULL; } - plfont = LFONT_AllocFontWithHandle(); - if (!plfont) - { - return NULL; - } - hNewFont = plfont->BaseObject.hHmgr; - - plfont->lft = lft; - plfont->fl = fl; - RtlCopyMemory (&plfont->logfont, &SafeLogfont, sizeof(ENUMLOGFONTEXDVW)); - ExInitializePushLock(&plfont->lock); - - if (SafeLogfont.elfEnumLogfontEx.elfLogFont.lfEscapement != - SafeLogfont.elfEnumLogfontEx.elfLogFont.lfOrientation) - { - /* This should really depend on whether GM_ADVANCED is set */ - plfont->logfont.elfEnumLogfontEx.elfLogFont.lfOrientation = - plfont->logfont.elfEnumLogfontEx.elfLogFont.lfEscapement; - } - LFONT_UnlockFont(plfont); - - if (pvCliData && hNewFont) - { - // FIXME: Use GDIOBJ_InsertUserData - KeEnterCriticalRegion(); - { - INT Index = GDI_HANDLE_GET_INDEX((HGDIOBJ)hNewFont); - PGDI_TABLE_ENTRY Entry = &GdiHandleTable->Entries[Index]; - Entry->UserData = pvCliData; - } - KeLeaveCriticalRegion(); - } - - return hNewFont; + return HfontCreate(&SafeLogfont, cjElfw, lft, fl, pvCliData); }