gdi32: Use NtGdiGetCharABCWidthsW for GetCharABCWidthsI.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-08-27 13:51:50 +01:00 committed by Alexandre Julliard
parent 78a935138e
commit ce9b1ddc1a
2 changed files with 31 additions and 62 deletions

View File

@ -4886,7 +4886,9 @@ BOOL WINAPI NtGdiGetCharWidthW( HDC hdc, UINT first, UINT last, WCHAR *chars,
if (!(abc = HeapAlloc(GetProcessHeap(), 0, count * sizeof(ABC))))
return FALSE;
if (!GetCharABCWidthsI( hdc, first, last, chars, abc ))
if (!NtGdiGetCharABCWidthsW( hdc, first, last, chars,
NTGDI_GETCHARABCWIDTHS_INT | NTGDI_GETCHARABCWIDTHS_INDICES,
abc ))
{
HeapFree( GetProcessHeap(), 0, abc );
return FALSE;
@ -5641,18 +5643,26 @@ BOOL WINAPI NtGdiGetCharABCWidthsW( HDC hdc, UINT first, UINT last, WCHAR *chars
return FALSE;
}
if (!chars) count = last - first + 1;
/* unlike GetCharABCWidthsFloatW, this one is supposed to fail on non-scalable fonts */
dev = GET_DC_PHYSDEV( dc, pGetTextMetrics );
if (!dev->funcs->pGetTextMetrics( dev, &tm ) || !(tm.tmPitchAndFamily & TMPF_VECTOR))
if (flags & NTGDI_GETCHARABCWIDTHS_INDICES)
{
release_dc_ptr( dc );
return FALSE;
dev = GET_DC_PHYSDEV( dc, pGetCharABCWidthsI );
ret = dev->funcs->pGetCharABCWidthsI( dev, first, count, chars, buffer );
}
else
{
/* unlike GetCharABCWidthsFloatW, this one is supposed to fail on non-scalable fonts */
dev = GET_DC_PHYSDEV( dc, pGetTextMetrics );
if (!dev->funcs->pGetTextMetrics( dev, &tm ) || !(tm.tmPitchAndFamily & TMPF_VECTOR))
{
release_dc_ptr( dc );
return FALSE;
}
if (!chars) count = last - first + 1;
dev = GET_DC_PHYSDEV( dc, pGetCharABCWidths );
ret = dev->funcs->pGetCharABCWidths( dev, first, count, chars, buffer );
}
dev = GET_DC_PHYSDEV( dc, pGetCharABCWidths );
ret = dev->funcs->pGetCharABCWidths( dev, first, count, chars, buffer );
if (ret)
{
ABC *abc = buffer;
@ -5670,58 +5680,6 @@ BOOL WINAPI NtGdiGetCharABCWidthsW( HDC hdc, UINT first, UINT last, WCHAR *chars
}
/******************************************************************************
* GetCharABCWidthsI [GDI32.@]
*
* Retrieves widths of characters in range.
*
* PARAMS
* hdc [I] Handle of device context
* firstChar [I] First glyphs in range to query
* count [I] Last glyphs in range to query
* pgi [i] Array of glyphs to query
* abc [O] Address of character-width structure
*
* NOTES
* Only works with TrueType fonts
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL WINAPI GetCharABCWidthsI( HDC hdc, UINT firstChar, UINT count,
LPWORD pgi, LPABC abc)
{
DC *dc = get_dc_ptr(hdc);
PHYSDEV dev;
unsigned int i;
BOOL ret;
if (!dc) return FALSE;
if (!abc)
{
release_dc_ptr( dc );
return FALSE;
}
dev = GET_DC_PHYSDEV( dc, pGetCharABCWidthsI );
ret = dev->funcs->pGetCharABCWidthsI( dev, firstChar, count, pgi, abc );
if (ret)
{
/* convert device units to logical */
for( i = 0; i < count; i++, abc++ ) {
abc->abcA = width_to_LP(dc, abc->abcA);
abc->abcB = width_to_LP(dc, abc->abcB);
abc->abcC = width_to_LP(dc, abc->abcC);
}
}
release_dc_ptr( dc );
return ret;
}
/***********************************************************************
* GetGlyphOutlineA (GDI32.@)
*/

View File

@ -1707,3 +1707,14 @@ BOOL WINAPI GetCharABCWidthsA( HDC hdc, UINT first, UINT last, ABC *abc )
HeapFree( GetProcessHeap(), 0, chars );
return ret;
}
/***********************************************************************
* GetCharABCWidthsI (GDI32.@)
*/
BOOL WINAPI GetCharABCWidthsI( HDC hdc, UINT first, UINT count, WORD *glyphs, ABC *buffer )
{
TRACE( "(%p, %d, %d, %p, %p)\n", hdc, first, count, glyphs, buffer );
return NtGdiGetCharABCWidthsW( hdc, first, count, glyphs,
NTGDI_GETCHARABCWIDTHS_INDICES | NTGDI_GETCHARABCWIDTHS_INT,
buffer );
}