diff options
Diffstat (limited to 'src/win32/cairo-win32-font.c')
-rw-r--r--[-rwxr-xr-x] | src/win32/cairo-win32-font.c | 97 |
1 files changed, 47 insertions, 50 deletions
diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c index a65d81b1a..1599b0751 100755..100644 --- a/src/win32/cairo-win32-font.c +++ b/src/win32/cairo-win32-font.c @@ -157,10 +157,6 @@ static cairo_status_t _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font, cairo_scaled_glyph_t *scaled_glyph); -static void -_cairo_win32_font_face_destroy (void *abstract_face); - - #define NEARLY_ZERO(d) (fabs(d) < (1. / 65536.)) static HDC @@ -1847,49 +1843,6 @@ struct _cairo_win32_font_face { HFONT hfont; }; -/* implement the platform-specific interface */ - -static cairo_bool_t -_is_scale (const cairo_matrix_t *matrix, double scale) -{ - return matrix->xx == scale && matrix->yy == scale && - matrix->xy == 0. && matrix->yx == 0. && - matrix->x0 == 0. && matrix->y0 == 0.; -} - -static cairo_status_t -_cairo_win32_font_face_scaled_font_create (void *abstract_face, - const cairo_matrix_t *font_matrix, - const cairo_matrix_t *ctm, - const cairo_font_options_t *options, - cairo_scaled_font_t **font) -{ - HFONT hfont = NULL; - - cairo_win32_font_face_t *font_face = abstract_face; - - if (font_face->hfont) { - /* Check whether it's OK to go ahead and use the font-face's HFONT. */ - if (_is_scale (ctm, 1.) && - _is_scale (font_matrix, -font_face->logfont.lfHeight)) { - hfont = font_face->hfont; - } - } - - return _win32_scaled_font_create (&font_face->logfont, - hfont, - &font_face->base, - font_matrix, ctm, options, - font); -} - -const cairo_font_face_backend_t _cairo_win32_font_face_backend = { - CAIRO_FONT_TYPE_WIN32, - _cairo_win32_font_face_create_for_toy, - _cairo_win32_font_face_destroy, - _cairo_win32_font_face_scaled_font_create -}; - /* We maintain a hash table from LOGFONT,HFONT => #cairo_font_face_t. * The primary purpose of this mapping is to provide unique * #cairo_font_face_t values so that our cache and mapping from @@ -1950,7 +1903,7 @@ _cairo_win32_font_face_hash_table_unlock (void) CAIRO_MUTEX_UNLOCK (_cairo_win32_font_face_mutex); } -static void +static cairo_bool_t _cairo_win32_font_face_destroy (void *abstract_face) { cairo_win32_font_face_t *font_face = abstract_face; @@ -1960,10 +1913,10 @@ _cairo_win32_font_face_destroy (void *abstract_face) /* All created objects must have been mapped in the hash table. */ assert (hash_table != NULL); - if (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&font_face->base.ref_count)) { + if (! _cairo_reference_count_dec_and_test (&font_face->base.ref_count)) { /* somebody recreated the font whilst we waited for the lock */ _cairo_win32_font_face_hash_table_unlock (); - return; + return FALSE; } /* Font faces in SUCCESS status are guaranteed to be in the @@ -1975,6 +1928,7 @@ _cairo_win32_font_face_destroy (void *abstract_face) _cairo_hash_table_remove (hash_table, &font_face->base.hash_entry); _cairo_win32_font_face_hash_table_unlock (); + return TRUE; } static void @@ -2015,6 +1969,49 @@ _cairo_win32_font_face_keys_equal (const void *key_a, return FALSE; } +/* implement the platform-specific interface */ + +static cairo_bool_t +_is_scale (const cairo_matrix_t *matrix, double scale) +{ + return matrix->xx == scale && matrix->yy == scale && + matrix->xy == 0. && matrix->yx == 0. && + matrix->x0 == 0. && matrix->y0 == 0.; +} + +static cairo_status_t +_cairo_win32_font_face_scaled_font_create (void *abstract_face, + const cairo_matrix_t *font_matrix, + const cairo_matrix_t *ctm, + const cairo_font_options_t *options, + cairo_scaled_font_t **font) +{ + HFONT hfont = NULL; + + cairo_win32_font_face_t *font_face = abstract_face; + + if (font_face->hfont) { + /* Check whether it's OK to go ahead and use the font-face's HFONT. */ + if (_is_scale (ctm, 1.) && + _is_scale (font_matrix, -font_face->logfont.lfHeight)) { + hfont = font_face->hfont; + } + } + + return _win32_scaled_font_create (&font_face->logfont, + hfont, + &font_face->base, + font_matrix, ctm, options, + font); +} + +const cairo_font_face_backend_t _cairo_win32_font_face_backend = { + CAIRO_FONT_TYPE_WIN32, + _cairo_win32_font_face_create_for_toy, + _cairo_win32_font_face_destroy, + _cairo_win32_font_face_scaled_font_create +}; + /** * cairo_win32_font_face_create_for_logfontw_hfont: * @logfont: A #LOGFONTW structure specifying the font to use. |