diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2007-10-10 14:00:56 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2007-10-10 14:24:24 +0100 |
commit | 7e6ac74de17cf82f224d9f5fad3ad60e92d7690b (patch) | |
tree | 524486a2185d689d79670baabf9cd2e110228be2 /src/cairo-win32-font.c | |
parent | bee05467a5f398eaaaa8d79b3ff0a8b119856143 (diff) |
[win32] Clean up compiler warnings.
Fix up a few instances of unused status returns.
Diffstat (limited to 'src/cairo-win32-font.c')
-rw-r--r-- | src/cairo-win32-font.c | 89 |
1 files changed, 49 insertions, 40 deletions
diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c index 9e6c3402..32e47df7 100644 --- a/src/cairo-win32-font.c +++ b/src/cairo-win32-font.c @@ -233,23 +233,22 @@ _get_system_quality (void) * all be 0, and face_hfont is the result of calling CreateFontIndirectW on * logfont. */ -static cairo_scaled_font_t * +static cairo_status_t _win32_scaled_font_create (LOGFONTW *logfont, HFONT face_hfont, cairo_font_face_t *font_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm, - const cairo_font_options_t *options) + const cairo_font_options_t *options, + cairo_scaled_font_t **font_out) { cairo_win32_scaled_font_t *f; cairo_matrix_t scale; cairo_status_t status; f = malloc (sizeof(cairo_win32_scaled_font_t)); - if (f == NULL) { - _cairo_error (CAIRO_STATUS_NO_MEMORY); - return NULL; - } + if (f == NULL) + return _cairo_error (CAIRO_STATUS_NO_MEMORY); f->logfont = *logfont; @@ -309,17 +308,17 @@ _win32_scaled_font_create (LOGFONTW *logfont, goto FAIL; status = _cairo_win32_scaled_font_set_metrics (f); - if (status) { _cairo_scaled_font_fini (&f->base); goto FAIL; } - return &f->base; + *font_out = &f->base; + return CAIRO_STATUS_SUCCESS; FAIL: free (f); - return NULL; + return status; } static cairo_status_t @@ -415,7 +414,7 @@ _win32_scaled_font_get_unscaled_hfont (cairo_win32_scaled_font_t *scaled_font, otm = malloc (otm_size); if (!otm) { - _cairo_error (CAIRO_STATUS_NO_MEMORY); + _cairo_error_throw (CAIRO_STATUS_NO_MEMORY); return NULL; } @@ -487,7 +486,6 @@ _cairo_win32_scaled_font_create_toy (cairo_toy_font_face_t *toy_face, cairo_scaled_font_t **scaled_font_out) { LOGFONTW logfont; - cairo_scaled_font_t *scaled_font; uint16_t *face_name; int face_name_len; cairo_status_t status; @@ -546,14 +544,9 @@ _cairo_win32_scaled_font_create_toy (cairo_toy_font_face_t *toy_face, if (!logfont.lfFaceName) return _cairo_error (CAIRO_STATUS_NO_MEMORY); - scaled_font = _win32_scaled_font_create (&logfont, NULL, &toy_face->base, - font_matrix, ctm, options); - if (!scaled_font) - return _cairo_error (CAIRO_STATUS_NO_MEMORY); - - *scaled_font_out = scaled_font; - - return CAIRO_STATUS_SUCCESS; + return _win32_scaled_font_create (&logfont, NULL, &toy_face->base, + font_matrix, ctm, options, + scaled_font_out); } static void @@ -695,7 +688,6 @@ _cairo_win32_scaled_font_text_to_glyphs (void *abstract_font, FAIL1: free (utf16); - _cairo_error (status); return status; } @@ -1021,6 +1013,7 @@ _add_glyph (cairo_glyph_state_t *state, static void _finish_glyphs (cairo_glyph_state_t *state) { + /* ignore errors as we only call _finish_glyphs on the error path */ _flush_glyphs (state); _cairo_array_fini (&state->glyphs); @@ -1223,9 +1216,14 @@ _cairo_win32_scaled_font_show_glyphs (void *abstract_font, r.bottom = height; FillRect (tmp_surface->dc, &r, GetStockObject (WHITE_BRUSH)); - _draw_glyphs_on_surface (tmp_surface, scaled_font, RGB (0, 0, 0), - dest_x, dest_y, - glyphs, num_glyphs); + status = _draw_glyphs_on_surface (tmp_surface, + scaled_font, RGB (0, 0, 0), + dest_x, dest_y, + glyphs, num_glyphs); + if (status) { + cairo_surface_destroy (&tmp_surface->base); + return status; + } if (scaled_font->quality == CLEARTYPE_QUALITY) { /* For ClearType, we need a 4-channel mask. If we are compositing on @@ -1387,8 +1385,7 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font GGO_NATIVE | glyph_index_option, &metrics, bytesGlyph, buffer, &matrix) == GDI_ERROR) { status = _cairo_win32_print_gdi_error ("_cairo_win32_scaled_font_glyph_path"); - free (buffer); - goto CLEANUP_FONT; + goto CLEANUP_BUFFER; } while (ptr < buffer + bytesGlyph) { @@ -1401,7 +1398,9 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font header->pfxStart.x, header->pfxStart.y, &x, &y); - _cairo_path_fixed_move_to (path, x, y); + status = _cairo_path_fixed_move_to (path, x, y); + if (status) + goto CLEANUP_BUFFER; while (ptr < endPoly) { TTPOLYCURVE *curve = (TTPOLYCURVE *)ptr; @@ -1414,13 +1413,17 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font points[i].x, points[i].y, &x, &y); - _cairo_path_fixed_line_to (path, x, y); + status = _cairo_path_fixed_line_to (path, x, y); + if (status) + goto CLEANUP_BUFFER; } break; case TT_PRIM_QSPLINE: for (i = 0; i < curve->cpfx - 1; i++) { cairo_fixed_t p1x, p1y, p2x, p2y, cx, cy, c1x, c1y, c2x, c2y; - _cairo_path_fixed_get_current_point (path, &p1x, &p1y); + status = _cairo_path_fixed_get_current_point (path, &p1x, &p1y); + if (status) + goto CLEANUP_BUFFER; _cairo_win32_transform_FIXED_to_fixed (&transform, points[i].x, points[i].y, @@ -1447,7 +1450,9 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font c2x = 2 * cx / 3 + p2x / 3; c2y = 2 * cy / 3 + p2y / 3; - _cairo_path_fixed_curve_to (path, c1x, c1y, c2x, c2y, p2x, p2y); + status = _cairo_path_fixed_curve_to (path, c1x, c1y, c2x, c2y, p2x, p2y); + if (status) + goto CLEANUP_BUFFER; } break; case TT_PRIM_CSPLINE: @@ -1465,13 +1470,17 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font points[i + 2].x, points[i + 2].y, &x2, &y2); - _cairo_path_fixed_curve_to (path, x, y, x1, y1, x2, y2); + status = _cairo_path_fixed_curve_to (path, x, y, x1, y1, x2, y2); + if (status) + goto CLEANUP_BUFFER; } break; } ptr += sizeof(TTPOLYCURVE) + sizeof (POINTFX) * (curve->cpfx - 1); } - _cairo_path_fixed_close_path (path); + status = _cairo_path_fixed_close_path (path); + if (status) + goto CLEANUP_BUFFER; } free(buffer); @@ -1479,6 +1488,9 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font &scaled_font->base, path); + CLEANUP_BUFFER: + free (buffer); + CLEANUP_FONT: cairo_win32_scaled_font_done_font (&scaled_font->base); @@ -1550,14 +1562,11 @@ _cairo_win32_font_face_scaled_font_create (void *abstract_face, } } - *font = _win32_scaled_font_create (&font_face->logfont, - hfont, - &font_face->base, - font_matrix, ctm, options); - if (*font) - return CAIRO_STATUS_SUCCESS; - else - return _cairo_error (CAIRO_STATUS_NO_MEMORY); + return _win32_scaled_font_create (&font_face->logfont, + hfont, + &font_face->base, + font_matrix, ctm, options, + font); } static const cairo_font_face_backend_t _cairo_win32_font_face_backend = { @@ -1592,7 +1601,7 @@ cairo_win32_font_face_create_for_logfontw_hfont (LOGFONTW *logfont, HFONT font) font_face = malloc (sizeof (cairo_win32_font_face_t)); if (!font_face) { - _cairo_error (CAIRO_STATUS_NO_MEMORY); + _cairo_error_throw (CAIRO_STATUS_NO_MEMORY); return (cairo_font_face_t *)&_cairo_font_face_nil; } |