gdi32: Move the get_glyph_outline() helper to the font function interface.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-10-22 11:56:47 +02:00
parent 26f8b4a7bc
commit a3b08dd3f3
3 changed files with 73 additions and 146 deletions

View File

@ -57,6 +57,8 @@ static inline struct font_physdev *get_font_dev( PHYSDEV dev )
static const struct font_backend_funcs *font_funcs;
static const MAT2 identity = { {0,1}, {0,0}, {0,0}, {0,1} };
/* Device -> World size conversion */
/* Performs a device to world transformation on the specified width (which
@ -937,17 +939,22 @@ static BOOL CDECL font_FontIsLinked( PHYSDEV dev )
static BOOL CDECL font_GetCharABCWidths( PHYSDEV dev, UINT first, UINT last, ABC *buffer )
{
struct font_physdev *physdev = get_font_dev( dev );
BOOL ret;
GLYPHMETRICS gm;
UINT c;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetCharABCWidths );
return dev->funcs->pGetCharABCWidths( dev, first, last, buffer );
}
TRACE( "%p, %u, %u, %p\n", physdev->font, first, last, buffer );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetCharABCWidths( physdev->font, first, last, buffer );
for (c = first; c <= last; c++, buffer++)
font_funcs->get_glyph_outline( physdev->font, c, GGO_METRICS, &gm, buffer, 0, NULL, &identity );
LeaveCriticalSection( &font_cs );
return ret;
return TRUE;
}
@ -957,17 +964,23 @@ static BOOL CDECL font_GetCharABCWidths( PHYSDEV dev, UINT first, UINT last, ABC
static BOOL CDECL font_GetCharABCWidthsI( PHYSDEV dev, UINT first, UINT count, WORD *gi, ABC *buffer )
{
struct font_physdev *physdev = get_font_dev( dev );
BOOL ret;
GLYPHMETRICS gm;
UINT c;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetCharABCWidthsI );
return dev->funcs->pGetCharABCWidthsI( dev, first, count, gi, buffer );
}
TRACE( "%p, %u, %u, %p\n", physdev->font, first, count, buffer );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetCharABCWidthsI( physdev->font, first, count, gi, buffer );
for (c = 0; c < count; c++, buffer++)
font_funcs->get_glyph_outline( physdev->font, gi ? gi[c] : first + c, GGO_METRICS | GGO_GLYPH_INDEX,
&gm, buffer, 0, NULL, &identity );
LeaveCriticalSection( &font_cs );
return ret;
return TRUE;
}
@ -977,17 +990,29 @@ static BOOL CDECL font_GetCharABCWidthsI( PHYSDEV dev, UINT first, UINT count, W
static BOOL CDECL font_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
{
struct font_physdev *physdev = get_font_dev( dev );
BOOL ret;
GLYPHMETRICS gm;
ABC abc;
UINT c;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetCharWidth );
return dev->funcs->pGetCharWidth( dev, first, last, buffer );
}
TRACE( "%p, %d, %d, %p\n", physdev->font, first, last, buffer );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetCharWidth( physdev->font, first, last, buffer );
for (c = first; c <= last; c++)
{
if (font_funcs->get_glyph_outline( physdev->font, c, GGO_METRICS,
&gm, &abc, 0, NULL, &identity ) == GDI_ERROR)
buffer[c - first] = 0;
else
buffer[c - first] = abc.abcA + abc.abcB + abc.abcC;
}
LeaveCriticalSection( &font_cs );
return ret;
return TRUE;
}
@ -1100,6 +1125,7 @@ static DWORD CDECL font_GetGlyphOutline( PHYSDEV dev, UINT glyph, UINT format,
{
struct font_physdev *physdev = get_font_dev( dev );
DWORD ret;
ABC abc;
if (!physdev->font)
{
@ -1107,7 +1133,7 @@ static DWORD CDECL font_GetGlyphOutline( PHYSDEV dev, UINT glyph, UINT format,
return dev->funcs->pGetGlyphOutline( dev, glyph, format, gm, buflen, buf, mat );
}
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetGlyphOutline( physdev->font, glyph, format, gm, buflen, buf, mat );
ret = font_funcs->get_glyph_outline( physdev->font, glyph, format, gm, &abc, buflen, buf, mat );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -1179,17 +1205,27 @@ static UINT CDECL font_GetTextCharsetInfo( PHYSDEV dev, FONTSIGNATURE *fs, DWORD
static BOOL CDECL font_GetTextExtentExPoint( PHYSDEV dev, const WCHAR *str, INT count, INT *dxs )
{
struct font_physdev *physdev = get_font_dev( dev );
BOOL ret;
GLYPHMETRICS gm;
INT i, pos;
ABC abc;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetTextExtentExPoint );
return dev->funcs->pGetTextExtentExPoint( dev, str, count, dxs );
}
TRACE( "%p, %s, %d\n", physdev->font, debugstr_wn(str, count), count );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetTextExtentExPoint( physdev->font, str, count, dxs );
for (i = pos = 0; i < count; i++)
{
font_funcs->get_glyph_outline( physdev->font, str[i], GGO_METRICS, &gm, &abc, 0, NULL, &identity );
pos += abc.abcA + abc.abcB + abc.abcC;
dxs[i] = pos;
}
LeaveCriticalSection( &font_cs );
return ret;
return TRUE;
}
@ -1199,17 +1235,28 @@ static BOOL CDECL font_GetTextExtentExPoint( PHYSDEV dev, const WCHAR *str, INT
static BOOL CDECL font_GetTextExtentExPointI( PHYSDEV dev, const WORD *indices, INT count, INT *dxs )
{
struct font_physdev *physdev = get_font_dev( dev );
BOOL ret;
GLYPHMETRICS gm;
INT i, pos;
ABC abc;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetTextExtentExPointI );
return dev->funcs->pGetTextExtentExPointI( dev, indices, count, dxs );
}
TRACE( "%p, %p, %d\n", physdev->font, indices, count );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetTextExtentExPointI( physdev->font, indices, count, dxs );
for (i = pos = 0; i < count; i++)
{
font_funcs->get_glyph_outline( physdev->font, indices[i], GGO_METRICS | GGO_GLYPH_INDEX,
&gm, &abc, 0, NULL, &identity );
pos += abc.abcA + abc.abcB + abc.abcC;
dxs[i] = pos;
}
LeaveCriticalSection( &font_cs );
return ret;
return TRUE;
}
@ -3140,7 +3187,6 @@ BOOL WINAPI GetCharWidth32A( HDC hdc, UINT firstChar, UINT lastChar,
static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT flags, UINT aa_flags,
GLYPHMETRICS *metrics, struct gdi_image_bits *image )
{
static const MAT2 identity = { {0,1}, {0,0}, {0,0}, {0,1} };
UINT indices[3] = {0, 0, 0x20};
unsigned int i;
DWORD ret, size;

View File

@ -6662,11 +6662,15 @@ static FT_Int get_load_flags( UINT format )
return load_flags;
}
static DWORD get_glyph_outline(GdiFont *incoming_font, UINT glyph, UINT format,
LPGLYPHMETRICS lpgm, ABC *abc, DWORD buflen, LPVOID buf,
const MAT2* lpmat)
/*************************************************************
* freetype_get_glyph_outline
*/
static DWORD CDECL freetype_get_glyph_outline( struct gdi_font *incoming_gdi_font, UINT glyph, UINT format,
GLYPHMETRICS *lpgm, ABC *abc, DWORD buflen, void *buf,
const MAT2 *lpmat )
{
GLYPHMETRICS gm;
GdiFont *incoming_font = get_font_ptr( incoming_gdi_font );
FT_Face ft_face = incoming_font->ft_face;
GdiFont *font = incoming_font;
struct gdi_font *gdi_font = font->gdi_font;
@ -7364,17 +7368,6 @@ end:
return ret;
}
/*************************************************************
* freetype_GetGlyphOutline
*/
static DWORD CDECL freetype_GetGlyphOutline( struct gdi_font *font, UINT glyph, UINT format,
LPGLYPHMETRICS lpgm, DWORD buflen, LPVOID buf, const MAT2 *lpmat )
{
ABC abc;
return get_glyph_outline( get_font_ptr(font), glyph, format, lpgm, &abc, buflen, buf, lpmat );
}
/*************************************************************
* freetype_GetTextMetrics
*/
@ -7498,27 +7491,6 @@ done:
return FALSE;
}
/*************************************************************
* freetype_GetCharWidth
*/
static BOOL CDECL freetype_GetCharWidth( struct gdi_font *font, UINT firstChar, UINT lastChar, LPINT buffer )
{
static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
UINT c;
GLYPHMETRICS gm;
ABC abc;
TRACE("%p, %d, %d, %p\n", font, firstChar, lastChar, buffer);
for(c = firstChar; c <= lastChar; c++) {
if (get_glyph_outline( get_font_ptr(font), c, GGO_METRICS, &gm, &abc, 0, NULL, &identity ) == GDI_ERROR)
buffer[c - firstChar] = 0;
else
buffer[c - firstChar] = abc.abcA + abc.abcB + abc.abcC;
}
return TRUE;
}
/*************************************************************
* freetype_GetCharWidthInfo
*/
@ -7545,87 +7517,6 @@ static BOOL CDECL freetype_GetCharWidthInfo( struct gdi_font *gdi_font, struct c
return TRUE;
}
/*************************************************************
* freetype_GetCharABCWidths
*/
static BOOL CDECL freetype_GetCharABCWidths( struct gdi_font *font, UINT firstChar, UINT lastChar, LPABC buffer )
{
static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
UINT c;
GLYPHMETRICS gm;
TRACE("%p, %d, %d, %p\n", font, firstChar, lastChar, buffer);
for(c = firstChar; c <= lastChar; c++, buffer++)
get_glyph_outline( get_font_ptr(font), c, GGO_METRICS, &gm, buffer, 0, NULL, &identity );
return TRUE;
}
/*************************************************************
* freetype_GetCharABCWidthsI
*/
static BOOL CDECL freetype_GetCharABCWidthsI( struct gdi_font *gdi_font, UINT firstChar, UINT count, LPWORD pgi, LPABC buffer )
{
GdiFont *font = get_font_ptr(gdi_font);
static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
UINT c;
GLYPHMETRICS gm;
if(!FT_HAS_HORIZONTAL(font->ft_face))
return FALSE;
for(c = 0; c < count; c++, buffer++)
get_glyph_outline( font, pgi ? pgi[c] : firstChar + c, GGO_METRICS | GGO_GLYPH_INDEX,
&gm, buffer, 0, NULL, &identity );
return TRUE;
}
/*************************************************************
* freetype_GetTextExtentExPoint
*/
static BOOL CDECL freetype_GetTextExtentExPoint( struct gdi_font *font, LPCWSTR wstr, INT count, INT *dxs )
{
static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
INT idx, pos;
ABC abc;
GLYPHMETRICS gm;
TRACE("%p, %s, %d\n", font, debugstr_wn(wstr, count), count);
for (idx = pos = 0; idx < count; idx++)
{
get_glyph_outline( get_font_ptr(font), wstr[idx], GGO_METRICS, &gm, &abc, 0, NULL, &identity );
pos += abc.abcA + abc.abcB + abc.abcC;
dxs[idx] = pos;
}
return TRUE;
}
/*************************************************************
* freetype_GetTextExtentExPointI
*/
static BOOL CDECL freetype_GetTextExtentExPointI( struct gdi_font *font, const WORD *indices, INT count, INT *dxs )
{
static const MAT2 identity = { {0,1},{0,0},{0,0},{0,1} };
INT idx, pos;
ABC abc;
GLYPHMETRICS gm;
TRACE("%p, %p, %d\n", font, indices, count);
for (idx = pos = 0; idx < count; idx++)
{
get_glyph_outline( get_font_ptr(font), indices[idx], GGO_METRICS | GGO_GLYPH_INDEX,
&gm, &abc, 0, NULL, &identity );
pos += abc.abcA + abc.abcB + abc.abcC;
dxs[idx] = pos;
}
return TRUE;
}
/*************************************************************
* freetype_GetFontData
*/
@ -7989,18 +7880,12 @@ static const struct font_backend_funcs font_funcs =
{
freetype_EnumFonts,
freetype_FontIsLinked,
freetype_GetCharABCWidths,
freetype_GetCharABCWidthsI,
freetype_GetCharWidth,
freetype_GetCharWidthInfo,
freetype_GetFontData,
freetype_GetFontUnicodeRanges,
freetype_GetGlyphIndices,
freetype_GetGlyphOutline,
freetype_GetKerningPairs,
freetype_GetOutlineTextMetrics,
freetype_GetTextExtentExPoint,
freetype_GetTextExtentExPointI,
freetype_GetTextMetrics,
freetype_SelectFont,
freetype_AddFontResourceEx,
@ -8009,6 +7894,7 @@ static const struct font_backend_funcs font_funcs =
freetype_CreateScalableFontResource,
freetype_GetFontFileData,
freetype_alloc_font,
freetype_get_glyph_outline,
freetype_destroy_font
};

View File

@ -344,19 +344,12 @@ struct font_backend_funcs
{
BOOL (CDECL *pEnumFonts)( LOGFONTW *lf, FONTENUMPROCW proc, LPARAM lparam );
BOOL (CDECL *pFontIsLinked)( struct gdi_font *font );
BOOL (CDECL *pGetCharABCWidths)( struct gdi_font *font, UINT first, UINT last, ABC *buffer );
BOOL (CDECL *pGetCharABCWidthsI)( struct gdi_font *font, UINT first, UINT count, WORD *gi, ABC *buffer );
BOOL (CDECL *pGetCharWidth)( struct gdi_font *font, UINT first, UINT last, INT *buffer );
BOOL (CDECL *pGetCharWidthInfo)( struct gdi_font *font, struct char_width_info *info );
DWORD (CDECL *pGetFontData)( struct gdi_font *font, DWORD table, DWORD offset, void *buf, DWORD size );
DWORD (CDECL *pGetFontUnicodeRanges)( struct gdi_font *font, GLYPHSET *glyphset );
DWORD (CDECL *pGetGlyphIndices)( struct gdi_font *font, const WCHAR *str, INT count, WORD *gi, DWORD flags );
DWORD (CDECL *pGetGlyphOutline)( struct gdi_font *font, UINT glyph, UINT format,
GLYPHMETRICS *gm, DWORD buflen, void *buf, const MAT2 *mat );
DWORD (CDECL *pGetKerningPairs)( struct gdi_font *font, DWORD count, KERNINGPAIR *pairs );
UINT (CDECL *pGetOutlineTextMetrics)( struct gdi_font *font, UINT size, OUTLINETEXTMETRICW *metrics );
BOOL (CDECL *pGetTextExtentExPoint)( struct gdi_font *font, LPCWSTR wstr, INT count, INT *dxs );
BOOL (CDECL *pGetTextExtentExPointI)( struct gdi_font *font, const WORD *indices, INT count, INT *dxs );
BOOL (CDECL *pGetTextMetrics)( struct gdi_font *font, TEXTMETRICW *metrics );
struct gdi_font * (CDECL *pSelectFont)( DC *dc, HFONT hfont, UINT *aa_flags, UINT default_aa_flags );
@ -369,6 +362,8 @@ struct font_backend_funcs
void *buff, DWORD buff_size );
BOOL (CDECL *alloc_font)( struct gdi_font *font );
DWORD (CDECL *get_glyph_outline)( struct gdi_font *font, UINT glyph, UINT format,
GLYPHMETRICS *gm, ABC *abc, DWORD buflen, void *buf, const MAT2 *mat );
void (CDECL *destroy_font)( struct gdi_font *font );
};