37
37
#include "cairoint.h"
39
#if CAIRO_HAS_FONT_SUBSET
38
41
#include "cairo-type3-glyph-surface-private.h"
39
42
#include "cairo-output-stream-private.h"
40
43
#include "cairo-meta-surface-private.h"
44
#include "cairo-analysis-surface-private.h"
42
46
static const cairo_surface_backend_t cairo_type3_glyph_surface_backend;
45
49
_cairo_type3_glyph_surface_create (cairo_scaled_font_t *scaled_font,
46
50
cairo_output_stream_t *stream,
47
cairo_type3_glyph_surface_emit_image_t emit_image)
51
cairo_type3_glyph_surface_emit_image_t emit_image,
52
cairo_scaled_font_subsets_t *font_subsets)
49
54
cairo_type3_glyph_surface_t *surface;
50
55
cairo_matrix_t invert_y_axis;
260
265
cairo_scaled_font_t *scaled_font,
261
266
int *remaining_glyphs)
263
/* XXX: Some refactoring is required before we can add font
264
* subsets in the middle of emitting all the subsets. */
266
return CAIRO_INT_STATUS_IMAGE_FALLBACK;
268
cairo_type3_glyph_surface_t *surface = abstract_surface;
269
cairo_int_status_t status;
270
cairo_scaled_font_t *font;
271
cairo_matrix_t new_ctm, ctm_inverse;
274
for (i = 0; i < num_glyphs; i++)
275
cairo_matrix_transform_point (&surface->cairo_to_pdf, &glyphs[i].x, &glyphs[i].y);
277
/* We require the matrix to be invertable. */
278
ctm_inverse = scaled_font->ctm;
279
status = cairo_matrix_invert (&ctm_inverse);
281
return CAIRO_INT_STATUS_IMAGE_FALLBACK;
283
cairo_matrix_multiply (&new_ctm, &scaled_font->ctm, &ctm_inverse);
284
font = cairo_scaled_font_create (scaled_font->font_face,
285
&scaled_font->font_matrix,
287
&scaled_font->options);
289
status = _cairo_pdf_operators_show_text_glyphs (&surface->pdf_operators,
296
cairo_scaled_font_destroy (font);
269
301
static const cairo_surface_backend_t cairo_type3_glyph_surface_backend = {
345
377
return _cairo_type3_glyph_surface_emit_image (surface, image, &mat);
381
_cairo_type3_glyph_surface_set_font_subsets_callback (void *abstract_surface,
382
cairo_pdf_operators_use_font_subset_t use_font_subset,
385
cairo_type3_glyph_surface_t *surface = abstract_surface;
387
_cairo_pdf_operators_set_font_subsets_callback (&surface->pdf_operators,
393
_cairo_type3_glyph_surface_analyze_glyph (void *abstract_surface,
394
unsigned long glyph_index)
396
cairo_type3_glyph_surface_t *surface = abstract_surface;
397
cairo_scaled_glyph_t *scaled_glyph;
398
cairo_status_t status, status2;
399
cairo_output_stream_t *null_stream;
401
null_stream = _cairo_null_stream_create ();
402
_cairo_type3_glyph_surface_set_stream (surface, null_stream);
403
status = _cairo_scaled_glyph_lookup (surface->scaled_font,
405
CAIRO_SCALED_GLYPH_INFO_METRICS |
406
CAIRO_SCALED_GLYPH_INFO_META_SURFACE,
408
if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
411
if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
412
status = CAIRO_STATUS_SUCCESS;
416
status = _cairo_meta_surface_replay (scaled_glyph->meta_surface,
419
status = _cairo_pdf_operators_flush (&surface->pdf_operators);
423
if (status == CAIRO_INT_STATUS_IMAGE_FALLBACK)
424
status = CAIRO_STATUS_SUCCESS;
427
status2 = _cairo_output_stream_destroy (null_stream);
349
435
_cairo_type3_glyph_surface_emit_notdef_glyph (void *abstract_surface,
350
436
cairo_output_stream_t *stream,
427
513
_cairo_output_stream_printf (surface->stream, "q\n");
428
514
status = _cairo_meta_surface_replay (scaled_glyph->meta_surface,
517
status = _cairo_pdf_operators_flush (&surface->pdf_operators);
430
521
_cairo_output_stream_printf (surface->stream, "Q\n");
432
523
_cairo_type3_glyph_surface_set_stream (surface, stream);