Commit graph

331 commits

Author SHA1 Message Date
Adrian Johnson
42c212135d Implement PS Type 3 font image support
There does not appear to be any way of emulating PDF inline images in
PostScript so we call back to the PS or PDF surface to emit the image.
2008-06-08 17:12:02 +09:30
Adrian Johnson
100a34bea6 Implement PDF Type 3 font subsetting of user fonts
show_glyphs inside a Type 3 font currently results in a fallback
image. Some refactoring is required before font subsets can be created
while emitting all the font subsets.
2008-06-08 17:11:39 +09:30
Adrian Johnson
6139fdc107 PDF: Don't emit a new text object for every call to show_glyphs
A text object is a series of text operations enclosed in a 'BT'/'ET'
pair.

After a call to _cairo_pdf_operators_show_glyphs() the closing 'ET'
will not be emitted. This allows subsequent calls to show_glyphs() to
emit text into the same text object. A call to any other operator or
_cairo_pdf_operators_flush() will close the text object.
2008-06-03 23:24:09 +09:30
Adrian Johnson
6258f1a4e2 PDF: Remember the current color
Don't emit the set fill or stroke color operator if the required fill
or stroke color is already selected.
2008-06-03 23:16:22 +09:30
Adrian Johnson
fd42b74a4f Add _cairo_pdf_operators_flush()
The optimizations planned for pdf-operators will mean that it will no
longer emit complete operations on each call to
fill/stroke/show_glyphs. For example a call to _show_glyphs() may not
finish the text operation to allow a subsequent call to _show_glyphs()
to be merged into the same text object.

A flush function is required to force pdf_operators to complete the
current operation before the pdf surface can emit any pdf operators.
2008-06-03 22:40:51 +09:30
Adrian Johnson
ce56e0cd0c Add missing argument to _cairo_pdf_surface_show_glyphs()
cf473f4a75 missed the PDF surface when
it added an argument to the show_glyphs() surface backend function.
2008-05-27 12:44:50 +09:30
Behdad Esfahbod
f81b857e1f [cairo-paginated-surface] Clean up reference counting mess
Previously the paginated constructor didn't reference the target surface, but
simply assume ownership of the reference, and then unref it when shutting
down.  The callers to paginated constructor then, where just give away their
reference to paginated and not unref the reference they were holding.  While
this works correctly, it's against the usual idioms that everyone is
responsible for the reference they are holding, and should get their own
reference if they need to keep an object alive.  Fix it all.
2008-05-09 15:54:12 +02:00
Adrian Johnson
76e655e508 Fix group-paint PDF test failure 2008-04-27 22:59:22 +09:30
Adrian Johnson
5e102b06d1 PDF: Fix unbalanced save/restore 2008-04-27 21:52:25 +09:30
Adrian Johnson
f99d86e708 PDF: Fix gradients with one stop 2008-04-27 21:52:25 +09:30
Carl Worth
f2a94c84a1 Add underscore prefix to private _cairo_pdf_surface_set_size_internal 2008-04-07 13:03:58 -07:00
Adrian Johnson
688fbc24c3 PDF: Add a function for changing the surface size
The smask-fill test was failing for PDF output because in some places
where the surface size is changed (eg when emitting patterns or
smasks) the cairo_to_pdf matrix was not updated.

Fix this by adding a function to handle the surface size change and
replace all the duplicated code for changing surface size with a call
to this function.
2008-04-06 20:24:40 +09:30
Chris Wilson
c0593d16c7 [pdf] Copy the glyphs for use within an smask group.
When constructing an smask group using PDF_SHOW_GLYPHS, we need a copy
of the glyphs else they'll be freed be we use them (in _show_page()).
2008-04-04 13:40:46 +01:00
Chris Wilson
6101dc3e93 [cairo-pdf-surface] Do not bitswap big-endian A1 masks.
Pixman stores the bits A1 surfaces in native byte order, PDF stores
A1 masks in MSb - so only perform swapping for little-endian machines.

Note this also removes the extraneous packing as per the PDF spec 4.8.2:
"Byte boundaries are ignored, except that each row of sample data must
begin on a byte boundary. If the number of data bits per row is not a
multiple of 8, the end of the row is padded with extra bits to fill out
the last byte."
2008-04-03 15:41:31 +01:00
Chris Wilson
94db91b65e [cairo-pdf-surface] Do not mask error during cleanup.
Be careful to preserve the original error status whilst on the common
cleanup path for _cairo_pdf_surface_emit_meta_surface().
2008-04-02 10:50:47 +01:00
Chris Wilson
3580b99a8f [cairo-pdf-surface] Check surface status before extracting the pdf target.
We need to check and report the existent status, else we may try to
modify the inert error object.
2008-04-02 10:50:47 +01:00
Adrian Johnson
47981226db Fix PDF analysis of OPERATOR_SOURCE surface patterns 2008-03-29 23:45:31 +10:30
Adrian Johnson
5b8b3a9765 PS/PDF: Save/Restore surface clip when emitting a meta-surface pattern 2008-03-29 15:52:37 +10:30
Carl Worth
75972167a2 Use floating-point offsets for color stops
Previously we were using the cairo_fixed_t type which meant we've
historically only been using 16 bits of precision for these offsets,
and recently only 8 bits. Meanwhile, all manipulatons of offsets
have been in floating-point anyway, so we might as well store them
that way.

This change also prevents a rendering regression introduced with the
24.8->16.16 change betwen snapshots 1.5.10 and 1.5.12 .

This change affected gradient-rendering details for the clip-operator
and operator-source tests, so the corresponding reference images are
updated here.
2008-03-26 14:52:09 -07:00
Adrian Johnson
7e83d6e6fb Do not use PDF fill-stroke operator with transparent fill
because the PDF rendering does not match cairo. See
PDF Reference 7.6.3.

Bug report at
https://bugs.launchpad.net/inkscape/+bug/202096
2008-03-14 21:37:14 +10:30
Chris Wilson
222eb6f140 Define _BSD_SOURCE to enable prototypes for strdup, snprintf.
strdup() and friends require at least _BSD_SOURCE or
_XOPEN_SOURCE >= 500 to be defined for the prototypes to be included.
For the time being, add the define to each source file that requires one
of the BSD functions.
2008-03-12 17:52:16 +00:00
Adrian Johnson
f534fe434d PDF: Use cairo_image_analyse_transparency during analysis
OPERATOR_SOURCE is only supported for opaque images. Check if and ARGB
image really contains transparency before returing unsupported.
2008-03-10 17:23:10 +10:30
Adrian Johnson
7c8c9cf334 PDF: Support OPERATOR_SOURCE when pattern is opaque 2008-02-25 21:50:37 +10:30
Adrian Johnson
eaaa1415a9 Change PDF newline characters from \r\n to \n
The PDF backend has always used "\r\n" for the newline character.
There was no particular reason for this choice. PDF allows "\n", "\r",
or "\r\n" as the end of line marker.

Since the PS backend (which uses "\n") has started sharing
cairo-pdf-operators.c with the PDF backend, the PS output has been
getting mixed "\n" and "\r\n" newlines.

Fix this by changing the PDF backend to use "\n".
2008-02-20 21:05:23 +10:30
Adrian Johnson
8fb624dbf2 Use correct prefix for _cairo_pdf_operators_stroke
s/operator/operators/
2008-02-17 21:33:25 +10:30
Adrian Johnson
d2a1576941 PDF/PS: Fix mismatched save restore when using fill-stroke 2008-02-17 21:33:16 +10:30
Adrian Johnson
3a05b5d2d5 PDF/PS: No need to use save/restore for solid colors 2008-02-17 21:33:04 +10:30
Adrian Johnson
2dfe32a0ff Implement PDF fill-stroke 2008-02-17 17:21:35 +10:30
Behdad Esfahbod
1e7fa4b9f5 [cairo-pdf-operators] Pass matrix by reference, not by value 2008-02-16 22:48:06 -05:00
Chris Wilson
bc83e028b8 [cairo-output-stream] Add format(printf) markup.
Add CAIRO_PRINTF_FORMAT attribute to the printf-esque output stream
functions, and fixup the one warning caught by the compiler.
2008-02-15 13:50:42 +00:00
Chris Wilson
d0cc1d9291 [cairo-pdf-surface] Minor code tidy.
Remove code duplication.
2008-02-15 13:50:41 +00:00
Adrian Johnson
fd3181c7bf PDF: Remove stale comments 2008-02-12 20:22:38 +10:30
Adrian Johnson
bdb857a78b PDF: Fix uninitialized variable in previous commit 2008-02-12 20:19:03 +10:30
Kristian Høgsberg
ba6788fc96 [pdf] Use compressed PDF stream instead of compress_dup()
The deflate stream has bounded (constant) memory overhead, whereas
compress_dup() allocates memory proportional to the uncompressed data.

This replaces compress_dup() usage with a compressed PDF stream for
emitting images, alpha masks and font subsets, and eliminates the
compress_dup() function.
2008-02-11 16:57:56 -05:00
Vladimir Vukicevic
80e11a85a9 [pdf] restore alpha_size back to correct bit size 2008-02-07 14:36:51 -08:00
Vladimir Vukicevic
a9b0e54d38 Avoid buffer overflow in ps/pdf surface
A few places weren't using _cairo_malloc_*; fixed.
2008-02-06 13:52:33 -08:00
Adrian Johnson
367e50137e PDF: Use correct surface size when emitting patterns
Store the surface size in each pattern and smask group and use this
size when the pattern/group is emitted. This is required as a pattern
or group may be used from a meta surface with a different size to the
PDF surface. However the pattern or group is emitted after the the meta
surface content has been emitted and the surface size has been
restored to the the page size.

This fixes the following pdf test failures:
  extend-reflect-similar
  extend-repeat-similar
  mask
2008-02-02 21:22:16 +10:30
Behdad Esfahbod
f0633f4449 [doc] Make sure all function names in docs are followed by () 2008-01-28 21:49:57 -05:00
Behdad Esfahbod
0d898f2bad [doc] Make sure all type names in docs are prefixed by # 2008-01-28 20:49:44 -05:00
Behdad Esfahbod
9ecde82d35 [doc] Make sure all macro names in docs are prefixed by % 2008-01-28 20:48:48 -05:00
Behdad Esfahbod
efd3a96524 [cairo-scaled-font] Don't err on font size 0, really
First, seems like we were rejecting degenerate font matrix right away
at the constructor.  Don't do that.

Next, PS/PDF were inverting the font scale matrix, assuming that it's
invertible.  We now keep the inverse too, so they can use it.  For the
case of a size 0 font, both the scale matrix and its invert are set to
0,0,0,0.  That's safe, even if slightly inconsistent.
2008-01-24 23:35:06 -05:00
Vladimir Vukicevic
02970ac8cf Fix usage of cairo_rectangle_int16_t leading to memory corruption
cairo_rectangle_int16_t was being used in a number of places instead
of cairo_rectangle_int_t, which led to memory corruption when cairo was
using a fixed point format with a bigger space than 16.16 (such as 24.8).
2008-01-22 15:32:11 -08:00
Adrian Johnson
ec272fbd09 Fix PDF extend-reflect test failure
Previously, when emitting image patterns the PDF backend used
_cairo_pattern_acquire_surface to get the image. For reflected images
this would return an image containing four images in a reflect
pattern.  When drawn in a PDF pattern (which only does repeating
patterns) this would create the reflected pattern in PDF.

For some reason _cairo_pattern_acquire_surface is no longer returning
a reflected image pattern.

This is fixed by only using _cairo_surface_acquire_source_image to get
the image and using the same code as is used for reflected
meta-surface patterns to created a reflected pattern by drawing four
transformed copies of the image inside the PDF patten.

This is the better way to implement reflected images as we are no
longer embedding an image four times larger than the original.
2008-01-19 12:46:24 +10:30
Chris Wilson
dec2daeaf3 [cairo-{ps,pdf}-surface] Assert the font is supported during emission.
Add an ASSERT_NOT_REACHED to the tail of the font subset emission
functions - as they should always, at least, be supported by the
fallbacks.
2008-01-17 15:34:51 +00:00
Chris Wilson
1bccbd88c3 [cairo-pdf-surface] Review error propagation from output stream.
Ensure that errors encountered whilst processing the output stream are
propagated back to the surface (and the user).
2008-01-16 17:02:52 +00:00
Chris Wilson
7111b18c27 [cairo-surface] Introduce _cairo_surface_create_in_error().
Unexport all the static error surfaces and use a function to select
the appropriate error surface for the status.
2008-01-16 16:51:32 +00:00
Chris Wilson
409e91b576 [cairo-pdf-surface] Review error handling.
Ensure all errors are propagated back to the caller with locally
allocated resources destroy as required.
2008-01-10 17:11:04 +00:00
Chris Wilson
6134600988 [cairo-pdf-surface] Skip emitting the font subset if not among resources.
Do not emit the font_subset if we did not successfully add it to the list
of font resources - can only happen after an error
2008-01-10 17:10:52 +00:00
Adrian Johnson
25f24e79f8 PDF: Update the PDF page structure comment 2008-01-07 21:19:35 +10:30
Adrian Johnson
21f842f0df PDF: Remove copy_page
Now that the content stream is no longer split into multiple streams
it is not possible to implement a copy_page function that shares the
common content between pages.

Remove this function so the paginated surface will rewrite the
content from the meta surface.
2008-01-07 21:17:26 +10:30