Author: gedmurphy Date: Wed Dec 9 00:09:32 2015 New Revision: 70315
URL: http://svn.reactos.org/svn/reactos?rev=70315&view=rev Log: [WIN32K/NTGDI] - Fix setting the correct font in certain code paths - non-eisting glyphs should return 0xffff, not 0x001f - Don't set last error on failure, GDI APIs don't do that - Remove GreGetGlyphIndicesW, it was mostly a copy of NtGdiGetGlyphIndicesW and it wasn't used - Fixes the GetGlyphIndices tests and fixes showing invalid fonts in charmap
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.... ============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/freetype.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/freetype.c [iso-8859-1] Wed Dec 9 00:09:32 2015 @@ -4368,102 +4368,6 @@ return TRUE; }
-#if 0 -DWORD -FASTCALL -GreGetGlyphIndicesW( - _In_ HDC hdc, - _In_reads_(cwc) LPWSTR pwc, - _In_ INT cwc, - _Out_writes_opt_(cwc) LPWORD pgi, - _In_ DWORD iMode, - _In_ DWORD dwUnknown) -{ - PDC dc; - PDC_ATTR pdcattr; - PTEXTOBJ TextObj; - PFONTGDI FontGDI; - HFONT hFont = 0; - OUTLINETEXTMETRICW *potm; - INT i; - FT_Face face; - WCHAR DefChar = 0xffff; - PWSTR Buffer = NULL; - ULONG Size; - - if ((!pwc) && (!pgi)) return cwc; - - dc = DC_LockDc(hdc); - if (!dc) - { - EngSetLastError(ERROR_INVALID_HANDLE); - return GDI_ERROR; - } - pdcattr = dc->pdcattr; - hFont = pdcattr->hlfntNew; - TextObj = RealizeFontInit(hFont); - DC_UnlockDc(dc); - if (!TextObj) - { - EngSetLastError(ERROR_INVALID_HANDLE); - return GDI_ERROR; - } - - FontGDI = ObjToGDI(TextObj->Font, FONT); - TEXTOBJ_UnlockText(TextObj); - - Buffer = ExAllocatePoolWithTag(PagedPool, cwc*sizeof(WORD), GDITAG_TEXT); - if (!Buffer) - { - EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); - return GDI_ERROR; - } - - if (iMode & GGI_MARK_NONEXISTING_GLYPHS) DefChar = 0x001f; /* Indicate non existence */ - else - { - Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL); - potm = ExAllocatePoolWithTag(PagedPool, Size, GDITAG_TEXT); - if (!potm) - { - EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); - cwc = GDI_ERROR; - goto ErrorRet; - } - IntGetOutlineTextMetrics(FontGDI, Size, potm); - DefChar = potm->otmTextMetrics.tmDefaultChar; // May need this. - ExFreePoolWithTag(potm, GDITAG_TEXT); - } - - IntLockFreeType; - face = FontGDI->face; - - for (i = 0; i < cwc; i++) - { - Buffer[i] = FT_Get_Char_Index(face, pwc[i]); - if (Buffer[i] == 0) - { - if (DefChar == 0xffff && FT_IS_SFNT(face)) - { - TT_OS2 *pOS2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2); - DefChar = (pOS2->usDefaultChar ? FT_Get_Char_Index(face, pOS2->usDefaultChar) : 0); - } - Buffer[i] = DefChar; - } - } - - IntUnLockFreeType; - - if (pgi != NULL) - { - RtlCopyMemory(pgi, Buffer, cwc * sizeof(WORD)); - } - -ErrorRet: - if (Buffer) ExFreePoolWithTag(Buffer, GDITAG_TEXT); - return cwc; -} -#endif // 0
/* * @implemented @@ -4487,7 +4391,6 @@ NTSTATUS Status = STATUS_SUCCESS; OUTLINETEXTMETRICW *potm; INT i; - FT_Face face; WCHAR DefChar = 0xffff; PWSTR Buffer = NULL; ULONG Size, pwcSize; @@ -4506,7 +4409,6 @@ dc = DC_LockDc(hdc); if (!dc) { - EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; } pdcattr = dc->pdcattr; @@ -4515,7 +4417,6 @@ DC_UnlockDc(dc); if (!TextObj) { - EngSetLastError(ERROR_INVALID_HANDLE); return GDI_ERROR; }
@@ -4525,23 +4426,33 @@ Buffer = ExAllocatePoolWithTag(PagedPool, cwc*sizeof(WORD), GDITAG_TEXT); if (!Buffer) { - EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); return GDI_ERROR; }
- if (iMode & GGI_MARK_NONEXISTING_GLYPHS) DefChar = 0x001f; /* Indicate non existence */ + if (iMode & GGI_MARK_NONEXISTING_GLYPHS) + { + DefChar = 0xffff; + } else { - Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL); - potm = ExAllocatePoolWithTag(PagedPool, Size, GDITAG_TEXT); - if (!potm) - { - Status = STATUS_NO_MEMORY; - goto ErrorRet; - } - IntGetOutlineTextMetrics(FontGDI, Size, potm); - DefChar = potm->otmTextMetrics.tmDefaultChar; // May need this. - ExFreePoolWithTag(potm, GDITAG_TEXT); + if (FT_IS_SFNT(FontGDI->face)) + { + TT_OS2 *pOS2 = FT_Get_Sfnt_Table(FontGDI->face, ft_sfnt_os2); + DefChar = (pOS2->usDefaultChar ? FT_Get_Char_Index(FontGDI->face, pOS2->usDefaultChar) : 0); + } + else + { + Size = IntGetOutlineTextMetrics(FontGDI, 0, NULL); + potm = ExAllocatePoolWithTag(PagedPool, Size, GDITAG_TEXT); + if (!potm) + { + cwc = GDI_ERROR; + goto ErrorRet; + } + IntGetOutlineTextMetrics(FontGDI, Size, potm); + DefChar = potm->otmTextMetrics.tmDefaultChar; + ExFreePoolWithTag(potm, GDITAG_TEXT); + } }
pwcSize = cwc * sizeof(WCHAR); @@ -4567,17 +4478,10 @@ if (!NT_SUCCESS(Status)) goto ErrorRet;
IntLockFreeType; - face = FontGDI->face; - - if (DefChar == 0xffff && FT_IS_SFNT(face)) - { - TT_OS2 *pOS2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2); - DefChar = (pOS2->usDefaultChar ? FT_Get_Char_Index(face, pOS2->usDefaultChar) : 0); - }
for (i = 0; i < cwc; i++) { - Buffer[i] = FT_Get_Char_Index(face, Safepwc[i]); + Buffer[i] = FT_Get_Char_Index(FontGDI->face, Safepwc[i]); if (Buffer[i] == 0) { Buffer[i] = DefChar; @@ -4604,7 +4508,6 @@ ExFreePoolWithTag(Safepwc, GDITAG_TEXT); } if (NT_SUCCESS(Status)) return cwc; - SetLastNtError(Status); return GDI_ERROR; }