gdi32: Move the font critical section out of freetype.c.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-10-22 11:54:35 +02:00
parent b3d55e2ce5
commit 26f8b4a7bc
3 changed files with 125 additions and 118 deletions

View File

@ -340,6 +340,14 @@ static inline BOOL is_dbcs_ansi_cp(UINT ansi_cp)
|| ansi_cp == 950 ); /* CP950 for Chinese Traditional */
}
static CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &font_cs,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": font_cs") }
};
CRITICAL_SECTION font_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
/* realized font objects */
#define FIRST_FONT_HANDLE 1
@ -909,13 +917,17 @@ static BOOL CDECL font_EnumFonts( PHYSDEV dev, LOGFONTW *lf, FONTENUMPROCW proc,
static BOOL CDECL font_FontIsLinked( PHYSDEV dev )
{
struct font_physdev *physdev = get_font_dev( dev );
BOOL ret;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pFontIsLinked );
return dev->funcs->pFontIsLinked( dev );
}
return font_funcs->pFontIsLinked( physdev->font );
EnterCriticalSection( &font_cs );
ret = font_funcs->pFontIsLinked( physdev->font );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -925,13 +937,17 @@ 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;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetCharABCWidths );
return dev->funcs->pGetCharABCWidths( dev, first, last, buffer );
}
return font_funcs->pGetCharABCWidths( physdev->font, first, last, buffer );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetCharABCWidths( physdev->font, first, last, buffer );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -941,13 +957,17 @@ 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;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetCharABCWidthsI );
return dev->funcs->pGetCharABCWidthsI( dev, first, count, gi, buffer );
}
return font_funcs->pGetCharABCWidthsI( physdev->font, first, count, gi, buffer );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetCharABCWidthsI( physdev->font, first, count, gi, buffer );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -957,13 +977,17 @@ 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;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetCharWidth );
return dev->funcs->pGetCharWidth( dev, first, last, buffer );
}
return font_funcs->pGetCharWidth( physdev->font, first, last, buffer );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetCharWidth( physdev->font, first, last, buffer );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -1054,13 +1078,17 @@ static DWORD CDECL font_GetFontUnicodeRanges( PHYSDEV dev, GLYPHSET *glyphset )
static DWORD CDECL font_GetGlyphIndices( PHYSDEV dev, const WCHAR *str, INT count, WORD *gi, DWORD flags )
{
struct font_physdev *physdev = get_font_dev( dev );
DWORD ret;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetGlyphIndices );
return dev->funcs->pGetGlyphIndices( dev, str, count, gi, flags );
}
return font_funcs->pGetGlyphIndices( physdev->font, str, count, gi, flags );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetGlyphIndices( physdev->font, str, count, gi, flags );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -1071,13 +1099,17 @@ static DWORD CDECL font_GetGlyphOutline( PHYSDEV dev, UINT glyph, UINT format,
GLYPHMETRICS *gm, DWORD buflen, void *buf, const MAT2 *mat )
{
struct font_physdev *physdev = get_font_dev( dev );
DWORD ret;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetGlyphOutline );
return dev->funcs->pGetGlyphOutline( dev, glyph, format, gm, buflen, buf, mat );
}
return font_funcs->pGetGlyphOutline( physdev->font, glyph, format, gm, buflen, buf, mat );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetGlyphOutline( physdev->font, glyph, format, gm, buflen, buf, mat );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -1087,13 +1119,17 @@ static DWORD CDECL font_GetGlyphOutline( PHYSDEV dev, UINT glyph, UINT format,
static DWORD CDECL font_GetKerningPairs( PHYSDEV dev, DWORD count, KERNINGPAIR *pairs )
{
struct font_physdev *physdev = get_font_dev( dev );
DWORD ret;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetKerningPairs );
return dev->funcs->pGetKerningPairs( dev, count, pairs );
}
return font_funcs->pGetKerningPairs( physdev->font, count, pairs );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetKerningPairs( physdev->font, count, pairs );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -1103,13 +1139,20 @@ static DWORD CDECL font_GetKerningPairs( PHYSDEV dev, DWORD count, KERNINGPAIR *
static UINT CDECL font_GetOutlineTextMetrics( PHYSDEV dev, UINT size, OUTLINETEXTMETRICW *metrics )
{
struct font_physdev *physdev = get_font_dev( dev );
UINT ret;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetOutlineTextMetrics );
return dev->funcs->pGetOutlineTextMetrics( dev, size, metrics );
}
return font_funcs->pGetOutlineTextMetrics( physdev->font, size, metrics );
if (!physdev->font->scalable) return 0;
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetOutlineTextMetrics( physdev->font, size, metrics );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -1136,13 +1179,17 @@ 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;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetTextExtentExPoint );
return dev->funcs->pGetTextExtentExPoint( dev, str, count, dxs );
}
return font_funcs->pGetTextExtentExPoint( physdev->font, str, count, dxs );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetTextExtentExPoint( physdev->font, str, count, dxs );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -1152,13 +1199,17 @@ 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;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetTextExtentExPointI );
return dev->funcs->pGetTextExtentExPointI( dev, indices, count, dxs );
}
return font_funcs->pGetTextExtentExPointI( physdev->font, indices, count, dxs );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetTextExtentExPointI( physdev->font, indices, count, dxs );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -1191,13 +1242,18 @@ static INT CDECL font_GetTextFace( PHYSDEV dev, INT count, WCHAR *str )
static BOOL CDECL font_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
{
struct font_physdev *physdev = get_font_dev( dev );
BOOL ret;
if (!physdev->font)
{
dev = GET_NEXT_PHYSDEV( dev, pGetTextMetrics );
return dev->funcs->pGetTextMetrics( dev, metrics );
}
return font_funcs->pGetTextMetrics( physdev->font, metrics );
EnterCriticalSection( &font_cs );
ret = font_funcs->pGetTextMetrics( physdev->font, metrics );
LeaveCriticalSection( &font_cs );
return ret;
}
@ -1216,10 +1272,14 @@ static HFONT CDECL font_SelectFont( PHYSDEV dev, HFONT hfont, UINT *aa_flags )
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectFont );
next->funcs->pSelectFont( next, hfont, &default_aa_flags );
}
if (!hfont) /* notification that the font has been changed by another driver */
physdev->font = NULL;
else
if (hfont)
{
EnterCriticalSection( &font_cs );
physdev->font = font_funcs->pSelectFont( dc, hfont, aa_flags, default_aa_flags );
LeaveCriticalSection( &font_cs );
}
else physdev->font = NULL; /* notification that the font has been changed by another driver */
if (prev) release_gdi_font( prev );
return physdev->font ? hfont : 0;
@ -4973,7 +5033,11 @@ INT WINAPI AddFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
BOOL hidden;
if (!font_funcs) return 1;
if (!(ret = font_funcs->pAddFontResourceEx( str, fl, pdv )))
EnterCriticalSection( &font_cs );
ret = font_funcs->pAddFontResourceEx( str, fl, pdv );
LeaveCriticalSection( &font_cs );
if (!ret)
{
/* FreeType <2.3.5 has problems reading resources wrapped in PE files. */
HMODULE hModule = LoadLibraryExW(str, NULL, LOAD_LIBRARY_AS_DATAFILE);
@ -4991,7 +5055,9 @@ INT WINAPI AddFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
else if ((filename = get_scalable_filename( str, &hidden )) != NULL)
{
if (hidden) fl |= FR_PRIVATE | FR_NOT_ENUM;
EnterCriticalSection( &font_cs );
ret = font_funcs->pAddFontResourceEx( filename, fl, pdv );
LeaveCriticalSection( &font_cs );
HeapFree( GetProcessHeap(), 0, filename );
}
}
@ -5028,7 +5094,9 @@ HANDLE WINAPI AddFontMemResourceEx( PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD
return NULL;
}
if (!font_funcs) return NULL;
EnterCriticalSection( &font_cs );
ret = font_funcs->pAddFontMemResourceEx( pbFont, cbFont, pdv, &num_fonts );
LeaveCriticalSection( &font_cs );
if (ret)
{
__TRY
@ -5081,7 +5149,11 @@ BOOL WINAPI RemoveFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
if (!font_funcs) return TRUE;
if (!(ret = font_funcs->pRemoveFontResourceEx( str, fl, pdv )))
EnterCriticalSection( &font_cs );
ret = font_funcs->pRemoveFontResourceEx( str, fl, pdv );
LeaveCriticalSection( &font_cs );
if (!ret)
{
/* FreeType <2.3.5 has problems reading resources wrapped in PE files. */
HMODULE hModule = LoadLibraryExW(str, NULL, LOAD_LIBRARY_AS_DATAFILE);
@ -5093,7 +5165,9 @@ BOOL WINAPI RemoveFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
else if ((filename = get_scalable_filename( str, &hidden )) != NULL)
{
if (hidden) fl |= FR_PRIVATE | FR_NOT_ENUM;
EnterCriticalSection( &font_cs );
ret = font_funcs->pRemoveFontResourceEx( filename, fl, pdv );
LeaveCriticalSection( &font_cs );
HeapFree( GetProcessHeap(), 0, filename );
}
}
@ -5291,10 +5365,15 @@ BOOL WINAPI GetRasterizerCaps( LPRASTERIZER_STATUS lprs, UINT cbNumBytes)
*/
BOOL WINAPI GetFontFileData( DWORD instance_id, DWORD unknown, UINT64 offset, void *buff, DWORD buff_size )
{
struct gdi_font *font = get_font_from_handle( instance_id );
struct gdi_font *font;
BOOL ret = FALSE;
if (!font_funcs || !font) return FALSE;
return font_funcs->pGetFontFileData( font, unknown, offset, buff, buff_size );
if (!font_funcs) return FALSE;
EnterCriticalSection( &font_cs );
if ((font = get_font_from_handle( instance_id )))
ret = font_funcs->pGetFontFileData( font, unknown, offset, buff, buff_size );
LeaveCriticalSection( &font_cs );
return ret;
}
/*************************************************************************
@ -5303,24 +5382,26 @@ BOOL WINAPI GetFontFileData( DWORD instance_id, DWORD unknown, UINT64 offset, vo
BOOL WINAPI GetFontFileInfo( DWORD instance_id, DWORD unknown, struct font_fileinfo *info,
SIZE_T size, SIZE_T *needed )
{
SIZE_T required_size;
struct gdi_font *font = get_font_from_handle( instance_id );
SIZE_T required_size = 0;
struct gdi_font *font;
BOOL ret = FALSE;
if (!needed) needed = &required_size;
EnterCriticalSection( &font_cs );
if (!font)
if ((font = get_font_from_handle( instance_id )))
{
*needed = 0;
return FALSE;
required_size = sizeof(*info) + strlenW( font->fileinfo->path ) * sizeof(WCHAR);
if (required_size <= size)
{
memcpy( info, font->fileinfo, required_size );
ret = TRUE;
}
else SetLastError( ERROR_INSUFFICIENT_BUFFER );
}
*needed = sizeof(*info) + strlenW( font->fileinfo->path ) * sizeof(WCHAR);
if (*needed > size)
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return FALSE;
}
memcpy( info, font->fileinfo, *needed );
return TRUE;
LeaveCriticalSection( &font_cs );
if (needed) *needed = required_size;
return ret;
}
struct realization_info

View File

@ -464,15 +464,6 @@ static UINT default_aa_flags;
static HKEY hkey_font_cache;
static BOOL antialias_fakes = TRUE;
static CRITICAL_SECTION freetype_cs;
static CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &freetype_cs,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": freetype_cs") }
};
static CRITICAL_SECTION freetype_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
static const WCHAR font_mutex_nameW[] = {'_','_','W','I','N','E','_','F','O','N','T','_','M','U','T','E','X','_','_','\0'};
static const WCHAR szDefaultFallbackLink[] = {'M','i','c','r','o','s','o','f','t',' ','S','a','n','s',' ','S','e','r','i','f',0};
@ -3130,8 +3121,6 @@ static INT CDECL freetype_AddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv
INT ret = 0;
DWORD addfont_flags = ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE;
EnterCriticalSection( &freetype_cs );
if (!(flags & FR_PRIVATE)) addfont_flags |= ADDFONT_ADD_TO_CACHE;
if (GetFullPathNameW( file, MAX_PATH, path, NULL ))
ret = add_font_resource( path, addfont_flags );
@ -3147,8 +3136,6 @@ static INT CDECL freetype_AddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv
ret = add_font_resource( path, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE );
}
}
LeaveCriticalSection( &freetype_cs );
return ret;
}
@ -3163,10 +3150,7 @@ static HANDLE CDECL freetype_AddFontMemResourceEx(PVOID pbFont, DWORD cbFont, PV
TRACE("Copying %d bytes of data from %p to %p\n", cbFont, pbFont, pFontCopy);
memcpy(pFontCopy, pbFont, cbFont);
EnterCriticalSection( &freetype_cs );
*pcFonts = AddFontToList(NULL, NULL, pFontCopy, cbFont, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE);
LeaveCriticalSection( &freetype_cs );
if (*pcFonts == 0)
{
TRACE("AddFontToList failed\n");
@ -3190,8 +3174,6 @@ static BOOL CDECL freetype_RemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID
INT ret = 0;
DWORD addfont_flags = ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE;
EnterCriticalSection( &freetype_cs );
if(!(flags & FR_PRIVATE)) addfont_flags |= ADDFONT_ADD_TO_CACHE;
if (GetFullPathNameW( file, MAX_PATH, path, NULL ))
ret = remove_font_resource( path, addfont_flags );
@ -3206,8 +3188,6 @@ static BOOL CDECL freetype_RemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID
ret = remove_font_resource( path, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE );
}
}
LeaveCriticalSection( &freetype_cs );
return ret;
}
@ -4749,8 +4729,6 @@ static struct gdi_font * CDECL freetype_SelectFont( DC *dc, HFONT hfont, UINT *a
TRACE("DC transform %f %f %f %f\n", dcmat.eM11, dcmat.eM12,
dcmat.eM21, dcmat.eM22);
EnterCriticalSection( &freetype_cs );
/* check the cache first */
if ((gdi_font = find_cached_gdi_font( &lf, &dcmat, can_use_bitmap ))) {
ret = get_font_ptr( gdi_font );
@ -4957,8 +4935,7 @@ static struct gdi_font * CDECL freetype_SelectFont( DC *dc, HFONT hfont, UINT *a
if(!last_resort_family) {
FIXME("can't find a single appropriate font - bailing\n");
free_gdi_font(gdi_font);
ret = NULL;
goto done;
return NULL;
}
WARN("could only find a bitmap font - this will probably look awful!\n");
@ -5074,8 +5051,7 @@ found_face:
if (!ret->ft_face)
{
free_gdi_font( gdi_font );
ret = NULL;
goto done;
return NULL;
}
set_gdi_font_file_info( gdi_font, face->file, face->font_data_size );
@ -5151,7 +5127,6 @@ done:
}
TRACE( "%p %s %d aa %x\n", hfont, debugstr_w(lf.lfFaceName), lf.lfHeight, *aa_flags );
}
LeaveCriticalSection( &freetype_cs );
return gdi_font;
}
@ -5419,9 +5394,9 @@ static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_cha
elf.elfLogFont.lfItalic, elf.elfLogFont.lfWeight,
ntm.ntmTm.ntmFlags);
/* release section before callback (FIXME) */
LeaveCriticalSection( &freetype_cs );
LeaveCriticalSection( &font_cs );
if (!proc(&elf.elfLogFont, (TEXTMETRICW *)&ntm, type, lparam)) return FALSE;
EnterCriticalSection( &freetype_cs );
EnterCriticalSection( &font_cs );
}
return TRUE;
}
@ -5449,7 +5424,7 @@ static BOOL CDECL freetype_EnumFonts( LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM
create_enum_charset_list(plf->lfCharSet, &enum_charsets);
EnterCriticalSection( &freetype_cs );
EnterCriticalSection( &font_cs );
if(plf->lfFaceName[0]) {
WCHAR *face_name = plf->lfFaceName;
FontSubst *psub = get_font_subst(&font_subst_list, plf->lfFaceName, plf->lfCharSet);
@ -5475,7 +5450,7 @@ static BOOL CDECL freetype_EnumFonts( LPLOGFONTW plf, FONTENUMPROCW proc, LPARAM
if (!enum_face_charsets(family, face, &enum_charsets, proc, lparam, NULL)) return FALSE;
}
}
LeaveCriticalSection( &freetype_cs );
LeaveCriticalSection( &font_cs );
return TRUE;
}
@ -5762,8 +5737,6 @@ static DWORD CDECL freetype_GetGlyphIndices( struct gdi_font *gdi_font, LPCWSTR
got_default = TRUE;
}
EnterCriticalSection( &freetype_cs );
for(i = 0; i < count; i++)
{
pgi[i] = get_gdi_glyph_index(font, lpstr[i]);
@ -5779,7 +5752,6 @@ static DWORD CDECL freetype_GetGlyphIndices( struct gdi_font *gdi_font, LPCWSTR
else
pgi[i] = get_GSUB_vert_glyph(font, pgi[i]);
}
LeaveCriticalSection( &freetype_cs );
return count;
}
@ -7398,13 +7370,9 @@ end:
static DWORD CDECL freetype_GetGlyphOutline( struct gdi_font *font, UINT glyph, UINT format,
LPGLYPHMETRICS lpgm, DWORD buflen, LPVOID buf, const MAT2 *lpmat )
{
DWORD ret;
ABC abc;
EnterCriticalSection( &freetype_cs );
ret = get_glyph_outline( get_font_ptr(font), glyph, format, lpgm, &abc, buflen, buf, lpmat );
LeaveCriticalSection( &freetype_cs );
return ret;
return get_glyph_outline( get_font_ptr(font), glyph, format, lpgm, &abc, buflen, buf, lpmat );
}
/*************************************************************
@ -7412,12 +7380,7 @@ static DWORD CDECL freetype_GetGlyphOutline( struct gdi_font *font, UINT glyph,
*/
static BOOL CDECL freetype_GetTextMetrics( struct gdi_font *font, TEXTMETRICW *metrics )
{
BOOL ret;
EnterCriticalSection( &freetype_cs );
ret = get_text_metrics( get_font_ptr(font), metrics );
LeaveCriticalSection( &freetype_cs );
return ret;
return get_text_metrics( get_font_ptr(font), metrics );
}
/*************************************************************
@ -7430,10 +7393,6 @@ static UINT CDECL freetype_GetOutlineTextMetrics( struct gdi_font *gdi_font, UIN
TRACE("font=%p\n", font);
if (!gdi_font->scalable) return 0;
EnterCriticalSection( &freetype_cs );
if (font->potm || get_outline_text_metrics( font ))
{
if(potm && cbSize >= font->potm->otmSize)
@ -7443,7 +7402,6 @@ static UINT CDECL freetype_GetOutlineTextMetrics( struct gdi_font *gdi_font, UIN
}
ret = font->potm->otmSize;
}
LeaveCriticalSection( &freetype_cs );
return ret;
}
@ -7552,14 +7510,12 @@ static BOOL CDECL freetype_GetCharWidth( struct gdi_font *font, UINT firstChar,
TRACE("%p, %d, %d, %p\n", font, firstChar, lastChar, buffer);
EnterCriticalSection( &freetype_cs );
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;
}
LeaveCriticalSection( &freetype_cs );
return TRUE;
}
@ -7600,12 +7556,9 @@ static BOOL CDECL freetype_GetCharABCWidths( struct gdi_font *font, UINT firstCh
TRACE("%p, %d, %d, %p\n", font, firstChar, lastChar, buffer);
EnterCriticalSection( &freetype_cs );
for(c = firstChar; c <= lastChar; c++, buffer++)
get_glyph_outline( get_font_ptr(font), c, GGO_METRICS, &gm, buffer, 0, NULL, &identity );
LeaveCriticalSection( &freetype_cs );
return TRUE;
}
@ -7622,13 +7575,10 @@ static BOOL CDECL freetype_GetCharABCWidthsI( struct gdi_font *gdi_font, UINT fi
if(!FT_HAS_HORIZONTAL(font->ft_face))
return FALSE;
EnterCriticalSection( &freetype_cs );
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 );
LeaveCriticalSection( &freetype_cs );
return TRUE;
}
@ -7644,8 +7594,6 @@ static BOOL CDECL freetype_GetTextExtentExPoint( struct gdi_font *font, LPCWSTR
TRACE("%p, %s, %d\n", font, debugstr_wn(wstr, count), count);
EnterCriticalSection( &freetype_cs );
for (idx = pos = 0; idx < count; idx++)
{
get_glyph_outline( get_font_ptr(font), wstr[idx], GGO_METRICS, &gm, &abc, 0, NULL, &identity );
@ -7653,7 +7601,6 @@ static BOOL CDECL freetype_GetTextExtentExPoint( struct gdi_font *font, LPCWSTR
dxs[idx] = pos;
}
LeaveCriticalSection( &freetype_cs );
return TRUE;
}
@ -7669,8 +7616,6 @@ static BOOL CDECL freetype_GetTextExtentExPointI( struct gdi_font *font, const W
TRACE("%p, %p, %d\n", font, indices, count);
EnterCriticalSection( &freetype_cs );
for (idx = pos = 0; idx < count; idx++)
{
get_glyph_outline( get_font_ptr(font), indices[idx], GGO_METRICS | GGO_GLYPH_INDEX,
@ -7678,8 +7623,6 @@ static BOOL CDECL freetype_GetTextExtentExPointI( struct gdi_font *font, const W
pos += abc.abcA + abc.abcB + abc.abcC;
dxs[idx] = pos;
}
LeaveCriticalSection( &freetype_cs );
return TRUE;
}
@ -7781,12 +7724,7 @@ static DWORD CDECL freetype_GetFontUnicodeRanges( struct gdi_font *font, GLYPHSE
*/
static BOOL CDECL freetype_FontIsLinked( struct gdi_font *font )
{
BOOL ret;
EnterCriticalSection( &freetype_cs );
ret = !list_empty( &get_font_ptr(font)->child_fonts );
LeaveCriticalSection( &freetype_cs );
return ret;
return !list_empty( &get_font_ptr(font)->child_fonts );
}
/*************************************************************************
@ -7920,7 +7858,6 @@ static DWORD CDECL freetype_GetKerningPairs( struct gdi_font *gdi_font, DWORD cP
USHORT i, nTables;
USHORT *glyph_to_char;
EnterCriticalSection( &freetype_cs );
if (font->total_kern_pairs != (DWORD)-1)
{
if (cPairs && kern_pair)
@ -7929,8 +7866,6 @@ static DWORD CDECL freetype_GetKerningPairs( struct gdi_font *gdi_font, DWORD cP
memcpy(kern_pair, font->kern_pairs, cPairs * sizeof(*kern_pair));
}
else cPairs = font->total_kern_pairs;
LeaveCriticalSection( &freetype_cs );
return cPairs;
}
@ -7941,17 +7876,11 @@ static DWORD CDECL freetype_GetKerningPairs( struct gdi_font *gdi_font, DWORD cP
if (length == GDI_ERROR)
{
TRACE("no kerning data in the font\n");
LeaveCriticalSection( &freetype_cs );
return 0;
}
buf = HeapAlloc(GetProcessHeap(), 0, length);
if (!buf)
{
WARN("Out of memory\n");
LeaveCriticalSection( &freetype_cs );
return 0;
}
if (!buf) return 0;
get_font_data(font, MS_KERN_TAG, 0, buf, length);
@ -7959,9 +7888,7 @@ static DWORD CDECL freetype_GetKerningPairs( struct gdi_font *gdi_font, DWORD cP
glyph_to_char = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(USHORT) * 65536);
if (!glyph_to_char)
{
WARN("Out of memory allocating a glyph index to char code map\n");
HeapFree(GetProcessHeap(), 0, buf);
LeaveCriticalSection( &freetype_cs );
return 0;
}
@ -8055,8 +7982,6 @@ static DWORD CDECL freetype_GetKerningPairs( struct gdi_font *gdi_font, DWORD cP
memcpy(kern_pair, font->kern_pairs, cPairs * sizeof(*kern_pair));
}
else cPairs = font->total_kern_pairs;
LeaveCriticalSection( &freetype_cs );
return cPairs;
}

View File

@ -384,6 +384,7 @@ extern BOOL get_gdi_font_glyph_metrics( struct gdi_font *font, UINT index,
extern void set_gdi_font_glyph_metrics( struct gdi_font *font, UINT index,
const GLYPHMETRICS *gm, const ABC *abc ) DECLSPEC_HIDDEN;
extern void font_init(void) DECLSPEC_HIDDEN;
extern CRITICAL_SECTION font_cs DECLSPEC_HIDDEN;
/* freetype.c */