summaryrefslogtreecommitdiff
path: root/src/cairo-pdf-surface.c
Commit message (Collapse)AuthorAgeFilesLines
* pdf: Don't use snprintf() to print floatsAdrian Johnson2023-04-181-8/+16
| | | | It is not locale independent.
* Make cairo_tag_begin/end work correctly in groupsAdrian Johnson2023-04-181-126/+307
| | | | Fixes #508
* Fix -Wsometimes-uninitialized warningKhaled Hosny2023-02-061-1/+1
| | | | | | | | | | | | | | | ../src/cairo-pdf-surface.c:2505:9: warning: variable 'status' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (surface->base.status != CAIRO_STATUS_SUCCESS) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/cairo-pdf-surface.c:2573:9: note: uninitialized use occurs here if (status == CAIRO_STATUS_SUCCESS) ^~~~~~ ../src/cairo-pdf-surface.c:2505:5: note: remove the 'if' if its condition is always false if (surface->base.status != CAIRO_STATUS_SUCCESS) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/cairo-pdf-surface.c:2497:5: note: variable 'status' is declared here cairo_status_t status, status2; ^
* PDF Type 3 color fontsAdrian Johnson2023-01-291-28/+379
| | | | | | | | | This implements Type 3 color fonts for PDF for any font with a CAIRO_SCALED_GLYPH_INFO_RECORDING_SURFACE. This includes user-fonts, SVG fonts, and COLR fonts. Glyphs with foreground colors are not yet implemented as Type 3 glyphs and will be rendered as images by cairo-surface.
* Mime type updatesAdrian Johnson2023-01-281-4/+4
|
* Fix shared use of recording surface with paginated targetsAdrian Johnson2023-01-151-2/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is _cairo_recording_surface_replay_and_create_regions() stores the cairo_recording_region_type_t in the same structure as the recording commands. This does not work well when the recording surface is used as source by multiple surfaces Fix this by moving the cairo_recording_region_type_t into a separate struct cairo_recording_regions_array_t. This struct is stored in a list that allows multiple create regions results to be store in the surface. The new function _cairo_recording_surface_region_array_attach() is used to create a new cairo_recording_regions_array_t, attach it to the recording surface and return a unique region id. The _cairo_recording_surface_replay_and_create_regions() and _cairo_recording_surface_replay_region() functions use this region id to identify the cairo_recording_regions_array_t. To handle nested recording surfaces, when replaying a recording, the region id is passed to the target as an extra parameter in the surface pattern. The wrapper surface makes a temporary copy of the pattern to ensure the snapshot pattern in the recording surface is not modified. cairo_recording_regions_array_t has a reference count so the target can hold on to the cairo_recording_regions_array_t after the paginated surface has called _cairo_recording_surface_region_array_remove().
* Merge branch 'mingw-fixes' into 'master'Adrian Johnson2023-01-031-3/+4
|\ | | | | | | | | Fix mingw build failure when SVG fonts enabled See merge request cairo/cairo!389
| * Use _cairo_strndup where appropriateAdrian Johnson2023-01-031-3/+4
| |
* | Fix user-font with foreground in group failures on image, PDF, and PSAdrian Johnson2023-01-031-47/+0
|/
* Merge branch 'ft-svg-fonts' into 'master'Adrian Johnson2022-12-311-1/+1
|\ | | | | | | | | Support SVG fonts in FT backend See merge request cairo/cairo!319
| * Fix x/y typo in _cairo_pdf_surface_analyze_operationJonathan Kew2022-12-281-1/+1
| | | | | | This can result in spuriously returning UNSUPPORTED and generating rasterized output in cases where this isn't actually necessary.
* | cairo_pdf_version_to_string: Check for negative valuesUli Schlachter2022-09-161-1/+1
|/ | | | | | | | | | | | Before this commit, cairo_pdf_version_to_string() would return the result of an out-of-bounds array access when called with a negative value. This commit adds a check against this. No unit test added since there are no tests for cairo_pdf_version_to_string() that I could easily add such a test to. Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/590 Signed-off-by: Uli Schlachter <psychon@znc.in>
* Add missing commas to array values.Jussi Pakkanen2022-08-031-2/+2
|
* Merge branch 'issue-514' into 'master'Adrian Johnson2022-04-261-12/+26
|\ | | | | | | | | | | | | pdf: reset current operator when resetting clip Closes #514 See merge request cairo/cairo!256
| * pdf: reset gstate in groupsAdrian Johnson2021-10-041-12/+25
| |
| * pdf: reset current operator when resetting clipAdrian Johnson2021-10-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | PDF output uses q/Q operators to reset the clip path. This also resets the PDF graphics state including the current blend mode. When resetting the clip path, reset the current blend mode tracked by the PDF surface so that if a non-default blend mode is required, the surface will emit the correct blend mode. Fixes #514
* | Fix mingw warningAdrian Johnson2022-04-191-3/+1
| | | | | | | | it doesn't like '%lld' in snprintf
* | pdf: ensure filenames are correctly encodedAdrian Johnson2022-01-161-3/+13
| |
* | pdf: ensure url strings are correctly encodedAdrian Johnson2022-01-091-8/+20
|/ | | | Fixes #526
* Merge branch 'custom-metadata' into 'master'Adrian Johnson2021-09-161-0/+36
|\ | | | | | | | | Add cairo_pdf_surface_set_custom_metadata() See merge request cairo/cairo!240
| * Add cairo_pdf_surface_set_custom_metadata()Adrian Johnson2021-08-221-0/+36
| |
* | Allow > 2GB PDF files on platforms with 32-bit longAdrian Johnson2021-09-021-24/+24
|/
* pdf links: fix forward references to dest names with 'internal' flagAdrian Johnson2021-07-291-0/+6
|
* Merge branch 'pdf-object-streams' into 'master'Adrian Johnson2021-07-281-78/+481
|\ | | | | | | | | pdf: use cross-reference stream for PDF >= 1.5 See merge request cairo/cairo!197
| * pdf: convert all document interchange features to use object streamsAdrian Johnson2021-07-261-1/+2
| |
| * pdf: add support for object streams for PDF >= 1.5Adrian Johnson2021-07-261-68/+320
| | | | | | | | | | | | | | | | This allows all objects that were previously emitted uncompressed to be compressed into a an object stream. Currently only /Page, /Pages, and /Catalog have been converted to use object streams.
| * pdf: use cross-reference stream for PDF >= 1.5Adrian Johnson2021-07-261-23/+173
| | | | | | | | This reduces the output size and is required for object streams.
* | pdf: use floating point widths when emitting fontsAdrian Johnson2021-07-271-12/+12
|/
* tags: allow links to page numbers not yet createdAdrian Johnson2021-07-241-0/+2
| | | | | | | | | | | | | Previously, forward references were required to use named destinations. This patch is based on the patch in #336 by Guillaume Ayoub <guillaume.ayoub@kozea.fr> that converted all links to indirect objects written at the end of the document. I have reworked the patch so that only forward references to future page numbers are written as indirect objects. Backward references and named destinations remain as they are. This is to minimize the number of objects written to the PDF file. Fixes #336
* pdf: Properly pass on stdio write errorsUli Schlachter2021-07-231-1/+3
| | | | | | | | | | | | | | | | | | | | cairo-pdf was silently ignoring write errors in _cairo_pdf_surface_finish(). Any write errors that happened here ended up setting a "status" variable, but the value in this variable was then unused. This commit fixes this bug by passing this error on to the caller. Additionally, this also adds a test case for this behaviour based on writing to /dev/full. This file is non-standard and thus the test first checks that this file exists and is writable before trying to write to it. This bug was found based on a report from Knut Petersen [0]. [0]: https://lists.cairographics.org/archives/cairo/2021-July/029281.html Signed-off-by: Uli Schlachter <psychon@znc.in>
* Remove all gstate from _cairo_surface_tagAdrian Johnson2021-07-181-6/+1
| | | | | The gstate is not required and was causing some tag operations to be ignored.
* pdf font subset: Generate valid font namesUli Schlachter2021-02-091-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | A hash value is encoded in base 26 with upper case letters for font names. Commit ed984146 replaced "numerator = abs (hash);" with "numerator = hash;" in this code, because hash has type uint32_t and the compiler warned about taking the absolute value of an unsigned value. However, abs() is actually defined to take an int argument. Thus, there was some implicit cast. Since numerator has type long, i.e. is signed, it is now actually possible to get an overflow in the implicit cast and then have a negative number. The following code is not prepared for this and produces non-letters when encoding the hash. This commit fixes that problem by not using ldiv() and instead using / and % to directly compute the needed values. This gets rid of the need to convert to type long. Since now everything works with uint32_t, there is no more chance for negative numbers messing things up. Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/449 Signed-off-by: Uli Schlachter <psychon@znc.in>
* 'Fix' a NULL pointer 'dereference' in cairo-pdf-surfaceUli Schlachter2021-01-171-1/+2
| | | | | | | | | | | | | The expression &image_surface->base basically just casts the cairo_image_surface_t* to cairo_surface_t*. However, technically it is a NULL pointer dereference and UndefinedBehaviorSanitizer flags it as such: runtime error: member access within null pointer of type 'cairo_image_surface_t' (aka 'struct _cairo_image_surface') This commit fixes this by adding a NULL check. Signed-off-by: Uli Schlachter <psychon@znc.in>
* The array introduced in bff47b43 isn't cleared on surface finishFĂ©lix Poisot2020-11-211-0/+7
|
* build: Fix various compiler warningsGeorge Matsumura2020-11-071-11/+11
| | | | | | This fixes a few compiler warnings that were encountered with gcc 9.3.0. Signed-off-by: George Matsumura <gmmatsumura01@bvsd.org>
* pdf: add missing flushAdrian Johnson2018-10-251-0/+5
| | | | Issue #342
* Revert "Correctly decode Adobe CMYK JPEGs in PDF export"Bryce Harrington2018-10-161-2/+0
| | | | | | | | | | | | | | | | From further testing and investigation it appears that many PDF viewers already have a workaround to invert Adobe CMYK JPEGs, so our generated PDFs display incorrectly with those viewers due to double-inversion. Further investigation will be needed to find a better solution that doesn't cause regression for some PDF viewers; perhaps PDF viewers that lack this inversion workaround should be changed to include it. For now we'll drop the patch to avoid shipping the regression in 1.16.0. This reverts commit b207a932a2d3740984319dffd58a0791580597cd. Reference: https://bugs.freedesktop.org/show_bug.cgi?id=97612 Fixes: https://gitlab.freedesktop.org/cairo/cairo/issues/156
* pdf: Fix potential null ptr deref when creating smask groups (CID #1159559)Bryce Harrington2018-06-131-1/+0
| | | | | | | | | | | | | | | Patch 37a22669 improved performance by using bounding box extents. However, the code appears to be incorrect. If extents is non-NULL it copies its contents to group->extents, otherwise it sets group->extents to sensible defaults, but then goes ahead and tries to copy the undefined contents. This second copy is unnecessary if extents is non-NULL and will cause a crash if it is NULL. Drop the extra copy, guessing it's just a typo. Coverity ID: #1159559 Signed-off-by: Bryce Harrington <bryce@bryceharrington.org> Reviewed-By: Uli Schlachter <psychon@znc.in>
* Use _cairo_malloc instead of mallocAdrian Johnson2018-05-071-6/+6
| | | | | | | | | | _cairo_malloc(0) always returns NULL, but has not been used consistently. This patch replaces many calls to malloc() with _cairo_malloc(). Fixes: fdo# 101547 CVE: CVE-2017-9814 Heap buffer overflow at cairo-truetype-subset.c:1299 Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* Cairo trivial typosUnknown2018-04-021-1/+1
| | | | | | | | | | | | | Found using `codespell -q 3 -I cairo-whitelist.txt` whereby whitelist contained: ``` amin iff lod writen ``` Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* pdf: fix some annotation bugsAdrian Johnson2017-11-261-1/+2
| | | | | | | | | - each annotation was emitted on every page instead of just the page that contains the annotation - the document structure did not correctly link to annotation objects - fix some annotation related memory leaks
* pdf: fix mime-unique-id jpeg attached to recording testAdrian Johnson2017-11-091-67/+142
| | | | | | | | | | | | | | - Restructure the emit_surface code so that mime types are checked first. - Add a test parameter to emit_surface to test if the surface will be emitted as an image or recording instead checking the surface type as the attached mime may override this. - Mark surface as not clear when mime is attached to avoid optimizing away "clear" surfaces that have mime attached. - Include entire surface in analysis if mime attached (also fixes bug with calculating the extents CONTENT_COLOR surfaces)
* pdf: fix mime-unique-id unbounded recording testAdrian Johnson2017-11-091-20/+65
| | | | | | PDF XObjects need to specify the bounding box. Emit unbounded surfaces when finishing as at this point the extents of all uses of the unbounded surface are known.
* pdf: fix mime-unique-id bounded recording testAdrian Johnson2017-11-091-46/+31
| | | | | The embedded bounded recording surface was being clipped to the extents of its first use.
* pdf: remove old commentAdrian Johnson2017-10-241-9/+0
| | | | These issues have been fixed.
* pdf: set default create dateAdrian Johnson2017-10-241-1/+0
|
* pdf: set ca/CA instead of using an smask when the mask has constant alphaAdrian Johnson2017-10-241-16/+58
|
* Allow mime image to be different size to cairo imageAdrian Johnson2017-10-221-124/+0
| | | | | | | | | | | | | | | Previously it was assumed the mime image size is the same as the cairo image surface size. When using the 1 bpp formats (CCITT, JBIG2), creating a cairo image of the same size will have very large memory requirements and in some case may exceed the pixman image size limits. In these cases it is useful to allow the mime image to have a different resolution to the cairo image and in the PDF/PS output scale the mime image to be the same physical size as the cairo image. In PDF, this is easy as all PDF images are scaled to 1x1 unit and the CTM is used to scale the image to the required size. The PS surface has been changed to also scale images to 1x1 and use the CTM to get the required size.
* Add CCITT_FAX mime type for PDF and PS surfacesAdrian Johnson2017-10-221-26/+237
| | | | | | | | | | | This completes the full set of PDF/PS image filters allowing image data to be passed though without decompressing then recompresssing in a less efficient format. The difficulty with CCITT_FAX is it needs some decoding parameters that are not stored inside the image data. This is achieved by using an additional mime type CCITT_FAX_PARAMS that contains the params in key=value format.
* replace _BSD_SOURCE with _DEFAULT_SOURCEAdrian Johnson2017-09-161-1/+1
| | | | | | fixes the warning: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"