Commit graph

229 commits

Author SHA1 Message Date
Adrian Johnson
a60beb2eef Fix PDF regression with multipage documents 2007-08-28 20:34:55 +09:30
Adrian Johnson
1cdd11873b Add finer-grained fallback support to the PDF surface
The stream handling has been changed to support writing the content to
one or more group objects. Each page has a top level knockout
group. The first operation in the knockout group paints another group
containing the content. Fallback images are painted from the knockout
group. This ensures that fallback images do not composite with any
content under the image.
2007-08-27 14:21:36 -07:00
Chris Wilson
06134df0d0 [cairo-pdf-surface] Check for errors during compression.
Check status return from zlib's compress().
2007-08-16 15:29:47 +01:00
Chris Wilson
e24969a94a [cairo-pdf-surface] cairo_pattern_set_matrix guarantees invertibility.
Be consistent in asserting that the pattern matrix is inverted
successfully and remove a couple of redundant checks.
2007-08-16 15:15:54 +01:00
Adrian Johnson
8881265cca PDF: Fix regression in pdf_surface_set_size() 2007-08-10 20:10:29 +09:30
Adrian Johnson
72c1f5d802 PDF: Fix gradients regression 2007-08-05 00:50:23 +09:30
Vladimir Vukicevic
aaf94ef6c4 [fixpt] remove dependency on some pixman types
Introduce cairo_gradient_stop_t, and remove pixman dependency
for core pattern types.  Perform conversion from cairo types
to pixman types as necessary in fallback code.
2007-07-18 22:45:21 +02:00
Vladimir Vukicevic
be3516335c [fixpt] Replace cairo_rectangle_int16_t with cairo_rectangle_int_t
Mostly s/cairo_rectangle_int16_t/cairo_rectangle_int_t/,
as well as definitions to pick cairo_rectangle_int_t.
2007-07-18 22:45:21 +02:00
Søren Sandmann Pedersen
ef967be630 Merge branch 'master' of git+ssh://sandmann@git.freedesktop.org/git/cairo
Conflicts:

	pixman/src/fbcompose.c
	pixman/src/icimage.c
	pixman/src/pixmanint.h
	pixman/src/pixregionint.h
	src/cairo-clip.c
2007-07-02 08:33:29 -07:00
Vladimir Vukicevic
5c7d2d14d7 [fix] Avoid int overflow when allocating large buffers
This patch introduces three macros: _cairo_malloc_ab,
_cairo_malloc_abc, _cairo_malloc_ab_plus_c and replaces various calls
to malloc(a*b), malloc(a*b*c), and malloc(a*b+c) with them.  The macros
return NULL if int overflow would occur during the allocation.  See
CODING_STYLE for more information.
2007-06-29 09:46:08 -07:00
Søren Sandmann
12cc32b674 [pixman] Initial port to standalone pixman library. 2007-06-21 22:21:11 -07:00
Chris Wilson
e37bee3f52 [cairo-pdf-surface] emit_pattern_stops() array overrun.
_cairo_pdf_surface_emit_pattern_stops() tried to set the last element
to have an offset of exactly 1.0, but missed and set the next element
after the end of the array.
2007-05-16 16:06:26 +01:00
Chris Wilson
27de1869f5 [cairo-pdf-surface] Free allstops on error.
Ensure the locally allocated resources are freed on the error paths.
2007-05-16 16:06:26 +01:00
Chris Wilson
a8c8e17d84 [cairo-pattern] Cache surface for solid patterns
Original work by Jorn Baayen <jorn@openedhand.com>,
2715f20981

We use a small cache of size 16 for surfaces created for solid patterns.
This mainly helps with the X backends where we don't have to create a
pattern for every operation, so we save a lot on X traffic.  Xft uses a
similar cache, so cairo's text rendering traffic with the xlib backend
now completely matches that of Xft.

The cache uses an static index variable, which itself acts like a cache of
size 1, remembering the most recently used solid pattern.  So repeated
lookups for the same pattern hit immediately.  If that fails, the cache is
searched linearly, and if that fails too, a new surface is created and a
random member of the cache is evicted.

A cached surface can only be reused if it is similar to the destination.
In order to check for similar surfaces a new test is introduced for the
backends to determine that the cached surface is as would be returned by
a _create_similar() call for the destination and content.

As surfaces are in general complex encapsulation of graphics state we
only return unshared cached surfaces and reset them (to clear any error
conditions and graphics state). In practice this makes little difference
to the efficacy of the cache during various benchmarks. However, in order
to transparently share solid surfaces it would be possible to implement a
COW scheme.

Cache hit rates:    (hit same index + hit in cache) / lookups
cairo-perf:         (42346 + 28480) / 159600 = 44.38%
gtk-theme-torturer: (3023  + 3502)  / 6528   = 99.95%
gtk-perf:           (8270  + 3190)  / 21504  = 53.29%

This translates into a reduction of about 25% of the XRENDER traffic during
cairo-perf.
2007-05-04 14:29:38 +01:00
Adrian Johnson
179e339910 PDF: Change CTM to identity
Some PDF viewers forget the CTM when drawing gradient patterns
with SMasks. This patch works around these bugs by using the default
identity matrix for the CTM. All paths are transformed from
cairo to pdf coordinates before writing to the pdf file.
2007-04-27 16:13:01 -07:00
Adrian Johnson
1816d7c590 Add support for transparent gradients
This is based on the gradient patch written by Miklós Erdélyi at
http://lists.freedesktop.org/archives/cairo/2006-August/007648.html

Currently only EXTEND_NONE and EXTEND_PAD are supported. Other extend
types will go through the image fallback path.
2007-04-27 16:12:55 -07:00
Behdad Esfahbod
29247e5010 [ps/pdf/svg] Fix minor coding style issue 2007-04-21 02:51:04 -04:00
Behdad Esfahbod
20ce190e71 [pdf] Get rid of _cairo_pdf_test_force_fallbacks
in favor of cairo_boilerplate_pdf_surface_force_fallbacks.
2007-04-21 02:50:53 -04:00
Behdad Esfahbod
03477064fa [paginated] Move cairo_paginated_surface_t to cairo-paginated-surface-private.h
The old cairo-paginated-surface-private.h is cairo-paginated-private.h now.
2007-04-21 02:43:28 -04:00
Behdad Esfahbod
68e2158aae [pdf] Move cairo_pdf_surface_t to cairo-pdf-surface-private.h 2007-04-21 02:10:34 -04:00
Adrian Johnson
9d8eb42c01 Exclude Type1 fonts from CID subsets
Make cairo-scaled-font-subsets.c limit Type1 font subsets to
256 glyphs. This allows Type1 subsetting to be enabled again
with type1-fallback as the fallback option for Type1 fonts.
2007-04-20 22:45:12 +09:30
Adrian Johnson
56ad56263b Enable embedding of CID fonts in PDF
Update cairo-pdf-surface.c to embed CFF and TrueType fonts
as CID fonts. Update the ToUnicode CMap to handle CID fonts.
2007-04-20 22:44:04 +09:30
Adrian Johnson
c68a2389f5 Make CFF Subsetting create CID subsets
OpenType/CFF fonts come in two types: CID and non CID.
CFF CID font subsetting was previously disabled in cairo
due 1) to the need to embed CFF CID fonts in PDF as a CID fonts
and 2) there is no easy way to convert CFF CID to CFF non CID.

With the switch to CID fonts cairo-cff-subset.c has been
updated to subset CID fonts and to covert non CID fonts to
CID. A further advantage of converting non CID CFF fonts
to CID is the reduction in size due to not embedding the
name of each glyph in the font subset.
2007-04-20 22:30:05 +09:30
Adrian Johnson
073fce5a85 Add support for creating CID/composite font subsets
cairo-scaled-font-subsets.c now provides three functions for creating subsets:

  _cairo_scaled_font_subsets_create_scaled()
    Create a subset for each scaled font with maximum size INT_MAX.

  _cairo_scaled_font_subsets_create_simple()
    Create subsets suitable for embedding as simple fonts in PS/PDF.

  _cairo_scaled_font_subsets_create_composite()
    Create subsets suitable for embedding as composite fonts in PS/PDF.

The _create_simple() and _create_composite() functions both merge
scaled fonts with the same face and an outline path available into
the same subset. _create_composite() has a maximum subset size of
65536 for outline fonts. Bitmap fonts have a separate subset for
each scale with a maximum subset size of 256.

The _create_simple() and _create_composite() functions both reserve
the first glyph in the subset for the .notdef glyph. CID fonts require
CID 0 to be .notdef.

Update Type1, TrueType and CFF subsetting to expect glyph 0 of each
subset to be the .notdef.
2007-04-20 22:29:41 +09:30
Adrian Johnson
d0745c08b7 PDF: Fix glyph positioning bug when glyphs are not horizontal
Bug reported in
http://lists.freedesktop.org/archives/cairo/2007-April/010337.html
2007-04-12 06:32:29 +09:30
Carl Worth
9c810625e7 PDF: Added error checking and propagation for _cairo_array_append 2007-04-11 01:55:59 -07:00
Carl Worth
01ac5f1aea Assert that cairo_matrix_invert succeeds rather than ignoring tis return value
This assertion is safe as an internal consistency check thanks to
the recent checks added to cairo_pattern_set_matrix.
2007-04-11 01:35:11 -07:00
Carl Worth
dca69f73e3 Check (and assert) return values of cairo_matrix_invert
Now that we have matrix validation at the time of _cairo_scaled_font_init
we know that it is safe to invert this matrix.
2007-04-11 01:21:09 -07:00
Carl Worth
2f46867716 Rename _cairo_pdf_surface_emit_toUnicode_stream to eliminate StudlyCaps
Obviously, the new name is _cairo_pdf_surface_emit_to_unicode_stream which
is consistent with the to_unicode_stream identifiers already existing in
the implementation.
2007-04-10 13:53:58 -07:00
Carl Worth
cc6c115e3c PDF: Check return value of _cairo_output_stream_destroy and propagate 2007-04-10 13:51:46 -07:00
Chris Wilson
66d3e25202 cairo-pdf-surface - propagate error status
Catch and propagate any error status.
2007-04-09 15:05:45 +01:00
Chris Wilson
2a74fd5c7f Propagate one error return through pdf. 2007-04-06 11:50:00 -07:00
Adrian Johnson
e9a2696648 PDF: Use the TJ operator to show glyphs 2007-03-23 23:08:46 +10:30
Behdad Esfahbod
88632575bf [PS/PDF/SVG] Rename internal symbols to have _cairo_*_surface prefix 2007-03-07 16:02:09 -05:00
Adrian Johnson
81b98c93b6 PDF: Set page group color space to DeviceRGB
See http://lists.freedesktop.org/archives/cairo/2006-November/008551.html
2007-03-06 23:11:38 +10:30
Carl Worth
df2d42ac7f Merge branch 'radial-gradient-fixes' into cairo 2007-03-01 17:08:03 -08:00
Behdad Esfahbod
ec11ca33a7 [PS/PDF] Mark CAIRO_EXTEND_PAD for surface patterns as natively supported
since the image surface does not implement that case either, so image
fallbacks have no benefit.
2007-03-01 19:14:40 -05:00
Carl Worth
0439f4c4f7 Rename radial gradient inner/outer to c1/c2
The inner/outer names were totally bogus. It is quite
legitimate to have the first circle's radius be larger than
that of the second.
2007-03-01 13:21:54 -08:00
Adrian Johnson
dc0043383b PDF: Ensure ToUnicode CMap name is unique
and remove an unused printf argument.
2007-03-01 23:39:10 +10:30
Behdad Esfahbod
e2ce27db30 [PS/PDF] Fix xstep/ystep values for CAIRO_EXTEND_NONE
This fixes the fallback-resolution test, as well as the two of
surface-pattern-scale-up and surface-pattern-scale-down.
2007-02-27 18:47:47 -05:00
Behdad Esfahbod
7c39276366 [PS/PDF] Accept CAIRO_EXTEND_REFLECT surface patterns natively
With the hack in _cairo_pattern_acquire_surface to return a 2x2
surface for reflected patterns, we can now accept REFLECT surface
patterns natively in all backends.  SVG was already doing that.
The PDF case needed some changes to go through
_cairo_pattern_acquire_surface.  A similar change to the recent
change in SVG.
2007-02-23 17:26:42 -05:00
Adrian Johnson
641f0919d5 PDF/PS: Don't embed multiple copies of the same font
cairo-scaled-font-subsets stores two sets of subsets -
scaled and unscaled. The first time each glyph is mapped,
_cairo_scaled_glyph_lookup() is called to determine if
the glyph is bitmap or outline. Outline glyphs are put
in the unscaled subsets. Bitmap glyphs are put in the
scaled subsets. The unscaled subsets hash table keyed is
the scaled_font->font_face to ensure only one font for
each font face is created. The scaled subsets hash
table is keyed by scaled_font.

_cairo_scaled_font_subsets_create() now takes two arguments
to specify the maximum size of the scaled and unscaled subsets.
If the unscaled max size is set to 0 all glyphs are mapped
to scaled subsets.

A separate foreach function is provided for scaled and unscaled
subsets. The PDF and PS backends iterate over the unscaled
subsets to emit CFF, TrueType, and Type1 fonts. The scaled
subsets are iterated to emit Type3 bitmap fonts.
2007-02-21 00:32:07 +10:30
Adrian Johnson
6f7cfdf5c7 PDF: Add missing character code to Differences array 2007-02-13 23:53:38 +10:30
Adrian Johnson
ac01dcb5ad PDF: Remove dead code
The function _cairo_pdf_surface_write_fonts is the
original PDF TrueType font embedding function that was
disabled in commit f500cef19f
shortly before Type3 font support was added.

TrueType font embedding was later reintroduced as new code
making this function obsolete.
2007-02-11 23:14:40 +10:30
Adrian Johnson
a2fefcc9e9 PDF: Compress Type3 fonts 2007-02-11 21:57:43 +10:30
Adrian Johnson
9f47879ae3 PDF: Fix Type3 font metrics to make text selection work 2007-02-11 21:50:46 +10:30
Eugeniy Meshcheryakov
a37f21cb17 [PS/PDF/SVG] Return a write_error nil surface on write errors 2007-02-08 15:29:58 -08:00
Adrian Johnson
2d1db24d1e PDF: Another fix for TrueType metrics
Not all TrueType fonts have an em size of 2048.
2007-02-07 23:10:47 +10:30
Adrian Johnson
274dfa4598 PDF: Make text selection and extraction work
- Add a to_unicode array to the scaled_font_subsets
  for mapping glyphs to unicode characters

- Add a function to the TrueType subsetting for
  performing a reverse cmap for mapping glyph indices
  to unicode characters.

- Add a new scaled font backend function for mapping
  glyph indices to unicode characters. Provide FreeType
  and Win32 implementations of the font backend mapping
  function.

- Modify the PDF backend to embed ToUnicode streams
  into each font. The unicode mapping is obtained by
  first trying the reverse cmap. If this fails the font
  backend mapping function is called.
2007-02-07 22:35:59 +10:30
Adrian Johnson
fc660511ec PDF: Correct the y value of Td in show_glyphs
This bug would occur if the y coordinate of all the glyphs
in a single cairo_show_glyphs() call was not the same.
2007-02-07 11:05:33 +10:30