diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-02-28 18:11:22 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-02-28 18:11:22 +0000 |
commit | be5ab6df68cba1bd0709fa4319e29141d4491d94 (patch) | |
tree | e7c6444aae55a04f7bf92dfa848cbf9283fe5994 | |
parent | 2c908f8a42456ab0ec6f12c36a2cf68523287ba7 (diff) |
surface-wrapper: Apply the scaled-font ctm and non-default font-options
Improves record*-text-transform.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/cairo-matrix.c | 15 | ||||
-rw-r--r-- | src/cairo-surface-wrapper.c | 18 | ||||
-rw-r--r-- | src/cairoint.h | 5 |
3 files changed, 36 insertions, 2 deletions
diff --git a/src/cairo-matrix.c b/src/cairo-matrix.c index 252113579..8da0ca7a4 100644 --- a/src/cairo-matrix.c +++ b/src/cairo-matrix.c @@ -333,6 +333,21 @@ cairo_matrix_multiply (cairo_matrix_t *result, const cairo_matrix_t *a, const ca } slim_hidden_def(cairo_matrix_multiply); +void +_cairo_matrix_multiply (cairo_matrix_t *r, + const cairo_matrix_t *a, + const cairo_matrix_t *b) +{ + r->xx = a->xx * b->xx + a->yx * b->xy; + r->yx = a->xx * b->yx + a->yx * b->yy; + + r->xy = a->xy * b->xx + a->yy * b->xy; + r->yy = a->xy * b->yx + a->yy * b->yy; + + r->x0 = a->x0 * b->xx + a->y0 * b->xy + b->x0; + r->y0 = a->x0 * b->yx + a->y0 * b->yy + b->y0; +} + /** * cairo_matrix_transform_distance: * @matrix: a #cairo_matrix_t diff --git a/src/cairo-surface-wrapper.c b/src/cairo-surface-wrapper.c index b4dd64eb0..52d250c45 100644 --- a/src/cairo-surface-wrapper.c +++ b/src/cairo-surface-wrapper.c @@ -418,6 +418,7 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper, cairo_glyph_t *dev_glyphs = stack_glyphs; cairo_scaled_font_t *dev_scaled_font = scaled_font; cairo_pattern_union_t source_copy; + cairo_font_options_t options; if (unlikely (wrapper->target->status)) return wrapper->target->status; @@ -426,6 +427,9 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper, if (_cairo_clip_is_all_clipped (dev_clip)) return CAIRO_INT_STATUS_NOTHING_TO_DO; + cairo_surface_get_font_options (wrapper->target, &options); + cairo_font_options_merge (&options, &scaled_font->options); + if (wrapper->needs_transform) { cairo_matrix_t m; int i; @@ -433,10 +437,13 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper, _cairo_surface_wrapper_get_transform (wrapper, &m); if (! _cairo_matrix_is_translation (&m)) { + cairo_matrix_t ctm; + + _cairo_matrix_multiply (&ctm, &m, &scaled_font->ctm); + dev_scaled_font = cairo_scaled_font_create (scaled_font->font_face, &scaled_font->font_matrix, - &m, - &scaled_font->options); + &ctm, &options); } if (num_glyphs > ARRAY_LENGTH (stack_glyphs)) { @@ -460,6 +467,13 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper, _copy_transformed_pattern (&source_copy.base, source, &m); source = &source_copy.base; } else { + if (! cairo_font_options_equal (&options, &scaled_font->options)) { + dev_scaled_font = cairo_scaled_font_create (scaled_font->font_face, + &scaled_font->font_matrix, + &scaled_font->ctm, + &options); + } + /* show_text_glyphs is special because _cairo_surface_show_text_glyphs is allowed * to modify the glyph array that's passed in. We must always * copy the array before handing it to the backend. diff --git a/src/cairoint.h b/src/cairoint.h index 6656d4b23..855e5449e 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -1771,6 +1771,11 @@ _cairo_utf8_to_utf16 (const char *str, int *items_written); #endif +cairo_private void +_cairo_matrix_multiply (cairo_matrix_t *r, + const cairo_matrix_t *a, + const cairo_matrix_t *b); + /* cairo-observer.c */ cairo_private void |