~ubuntu-branches/ubuntu/intrepid/cairo/intrepid-updates

« back to all changes in this revision

Viewing changes to src/cairo-type3-glyph-surface.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabien Tassin
  • Date: 2008-09-25 16:22:33 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20080925162233-btx61ymk181i7mcc
Tags: 1.7.6-0ubuntu1
* New upstream version. Most noticable changes are:
  - some API changes with especially the removal of
    cairo_font_options_set_lcd_filter and cairo_font_options_get_lcd_filter
  - xlib: Faster bookkeeping
  - PS: Fix gradients with non-constant alpha
  - Fix deadlock in user-font code
* debian/patches/00list: Remove 03_from_git_fix_lcd_filter_default.dpatch,
  add debian/patches/03_fix_ftbfs_withing_xcb.dpatch
* debian/libcairo2.symbols, debian/libcairo-directfb2.symbols: update
  list of symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 */
36
36
 
37
37
#include "cairoint.h"
 
38
 
 
39
#if CAIRO_HAS_FONT_SUBSET
 
40
 
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"
41
45
 
42
46
static const cairo_surface_backend_t cairo_type3_glyph_surface_backend;
43
47
 
44
48
cairo_surface_t *
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)
48
53
{
49
54
    cairo_type3_glyph_surface_t *surface;
50
55
    cairo_matrix_t invert_y_axis;
71
76
    _cairo_pdf_operators_init (&surface->pdf_operators,
72
77
                               surface->stream,
73
78
                               &surface->cairo_to_pdf,
74
 
                               NULL);
 
79
                               font_subsets);
75
80
 
76
81
    return &surface->base;
77
82
}
112
117
    if (image_mask != image)
113
118
        cairo_surface_destroy (&image_mask->base);
114
119
 
115
 
    return CAIRO_STATUS_SUCCESS;
 
120
    return status;
116
121
}
117
122
 
118
123
static cairo_status_t
260
265
                                        cairo_scaled_font_t  *scaled_font,
261
266
                                        int                  *remaining_glyphs)
262
267
{
263
 
    /* XXX: Some refactoring is required before we can add font
264
 
     * subsets in the middle of emitting all the subsets. */
265
 
 
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;
 
272
    int i;
 
273
 
 
274
    for (i = 0; i < num_glyphs; i++)
 
275
        cairo_matrix_transform_point (&surface->cairo_to_pdf, &glyphs[i].x, &glyphs[i].y);
 
276
 
 
277
    /* We require the matrix to be invertable. */
 
278
    ctm_inverse = scaled_font->ctm;
 
279
    status = cairo_matrix_invert (&ctm_inverse);
 
280
    if (status)
 
281
        return CAIRO_INT_STATUS_IMAGE_FALLBACK;
 
282
 
 
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,
 
286
                                     &new_ctm,
 
287
                                     &scaled_font->options);
 
288
 
 
289
    status = _cairo_pdf_operators_show_text_glyphs (&surface->pdf_operators,
 
290
                                                    NULL, 0,
 
291
                                                    glyphs, num_glyphs,
 
292
                                                    NULL, 0,
 
293
                                                    FALSE,
 
294
                                                    font);
 
295
 
 
296
    cairo_scaled_font_destroy (font);
 
297
 
 
298
    return status;
267
299
}
268
300
 
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);
346
378
}
347
379
 
 
380
void
 
381
_cairo_type3_glyph_surface_set_font_subsets_callback (void                                  *abstract_surface,
 
382
                                                      cairo_pdf_operators_use_font_subset_t  use_font_subset,
 
383
                                                      void                                  *closure)
 
384
{
 
385
    cairo_type3_glyph_surface_t *surface = abstract_surface;
 
386
 
 
387
    _cairo_pdf_operators_set_font_subsets_callback (&surface->pdf_operators,
 
388
                                                    use_font_subset,
 
389
                                                    closure);
 
390
}
 
391
 
 
392
cairo_status_t
 
393
_cairo_type3_glyph_surface_analyze_glyph (void               *abstract_surface,
 
394
                                          unsigned long       glyph_index)
 
395
{
 
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;
 
400
 
 
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,
 
404
                                         glyph_index,
 
405
                                         CAIRO_SCALED_GLYPH_INFO_METRICS |
 
406
                                         CAIRO_SCALED_GLYPH_INFO_META_SURFACE,
 
407
                                         &scaled_glyph);
 
408
    if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
 
409
        goto cleanup;
 
410
 
 
411
    if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
 
412
        status = CAIRO_STATUS_SUCCESS;
 
413
        goto cleanup;
 
414
    }
 
415
 
 
416
    status = _cairo_meta_surface_replay (scaled_glyph->meta_surface,
 
417
                                         &surface->base);
 
418
 
 
419
    status = _cairo_pdf_operators_flush (&surface->pdf_operators);
 
420
    if (status)
 
421
        return status;
 
422
 
 
423
    if (status == CAIRO_INT_STATUS_IMAGE_FALLBACK)
 
424
        status = CAIRO_STATUS_SUCCESS;
 
425
 
 
426
cleanup:
 
427
    status2 = _cairo_output_stream_destroy (null_stream);
 
428
    if (status)
 
429
        return status;
 
430
 
 
431
    return status2;
 
432
}
 
433
 
348
434
cairo_status_t
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,
429
515
                                         &surface->base);
 
516
 
 
517
        status = _cairo_pdf_operators_flush (&surface->pdf_operators);
 
518
        if (status)
 
519
            return status;
 
520
 
430
521
        _cairo_output_stream_printf (surface->stream, "Q\n");
431
522
 
432
523
        _cairo_type3_glyph_surface_set_stream (surface, stream);
443
534
 
444
535
    return status;
445
536
}
 
537
 
 
538
#endif /* CAIRO_HAS_FONT_SUBSET */