Merge branch 'fix-freetype2' into 'master'

Fix freetype2

See merge request cairo/cairo!260
This commit is contained in:
Heiko Lewin 2026-01-29 16:07:54 +00:00
commit b5bcd81ad1

View file

@ -698,8 +698,9 @@ static cairo_bool_t
_has_unlocked_face (const void *entry)
{
const cairo_ft_unscaled_font_t *unscaled = entry;
return (!unscaled->from_face && unscaled->lock_count == 0 && unscaled->face);
cairo_bool_t result;
result = (!unscaled->from_face && unscaled->lock_count == 0 && unscaled->face);
return result;
}
/* Ensures that an unscaled font has a face object. If we exceed
@ -716,16 +717,20 @@ _cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t *unscaled)
FT_Error error;
CAIRO_MUTEX_LOCK (unscaled->mutex);
font_map = _cairo_ft_unscaled_font_map_lock ();
unscaled->lock_count++;
if (unscaled->face)
{
_cairo_ft_unscaled_font_map_unlock ();
return unscaled->face;
}
/* If this unscaled font was created from an FT_Face then we just
* returned it above. */
assert (!unscaled->from_face);
font_map = _cairo_ft_unscaled_font_map_lock ();
{
assert (font_map != NULL);
@ -741,7 +746,6 @@ _cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t *unscaled)
_font_map_release_face_lock_held (font_map, entry);
}
}
_cairo_ft_unscaled_font_map_unlock ();
error = FT_New_Face (font_map->ft_library,
unscaled->filename,
@ -749,7 +753,8 @@ _cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t *unscaled)
&face);
if (error)
{
unscaled->lock_count--;
unscaled->lock_count--;
_cairo_ft_unscaled_font_map_unlock ();
CAIRO_MUTEX_UNLOCK (unscaled->mutex);
_cairo_error_throw (_cairo_ft_to_cairo_error (error));
return NULL;
@ -762,6 +767,8 @@ _cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t *unscaled)
font_map->num_open_faces++;
_cairo_ft_unscaled_font_map_unlock ();
return face;
}
@ -771,10 +778,11 @@ _cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t *unscaled)
static void
_cairo_ft_unscaled_font_unlock_face (cairo_ft_unscaled_font_t *unscaled)
{
_cairo_ft_unscaled_font_map_lock ();
assert (unscaled->lock_count > 0);
unscaled->lock_count--;
_cairo_ft_unscaled_font_map_unlock ();
CAIRO_MUTEX_UNLOCK (unscaled->mutex);
}