Commit graph

84 commits

Author SHA1 Message Date
Adrian Johnson
0cae2a4a74 Use _cairo_calloc() to allocate structs
To avoid any possibility of uninitialized memory.

The exceptions are:
 - where the allocation is immediately overwritten by a memcpy or struct copy.
 - arrays of structs to avoid any performance impact (except when the
   array is returned by the public API).
2024-06-21 10:32:23 +09:30
Adrian Johnson
b53b48116e Make cairo_tag_begin/end work correctly in groups
Fixes #508
2023-04-18 18:27:12 +09:30
luz.paz
6d93bddbd6 Misc. typos
Found via `codespell -i 3 -w -I ../cairo-word-whitelist.txt -L tim,ned,uint`
Follow up of 12cb59be7d

Reviewed-by: Bryce Harrington <bryce@bryceharrington.org>
2019-01-31 17:37:15 -08:00
Adrian Johnson
1998239387 Use _cairo_malloc instead of malloc
_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>
2018-05-07 16:35:51 -07:00
Unknown
12cb59be7d Cairo trivial typos
Found using `codespell -q 3 -I cairo-whitelist.txt`
whereby whitelist contained:
```
amin
iff
lod
writen
```

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2018-04-02 17:46:58 -07:00
Adrian Johnson
1a307123af pdf-operators: fix bug in line wrapping
patch by jmmorlan@sonic.net

https://bugs.freedesktop.org/show_bug.cgi?id=100029
2017-03-02 19:14:04 +10:30
Adrian Johnson
dcbfb72647 pdf: structured text and hyperlink support 2016-10-01 22:05:42 +09:30
Adrian Johnson
1e07ced66d pdf: change from pdf coordinates to cairo coordinates
When an unbounded recording surface is used multiple times with
different extents for each operation we need the XObject containing
the recording surface to have the same origin for each operation. This
is not possible when the recording surface is converted to PDF
coordinates because each operation has different extents resulting in
a different origin when the Y-axis is flipped (since the flip matrix
depends on the recording surface height which for unbounded surfaces
depends on the extents of the operation that paints the recording
surface).

Switching to cairo coordinates by emitting a Y-axis flip matrix as the
first object of each page allows the recording surface to be emitted
in cairo coordinates. This results in the same origin for all
operations using the recording surface XObject.
2016-06-05 20:43:36 +09:30
Adrian Johnson
ae608035c7 pdf-operators: fix bug with RTL text
bug 86461
2014-11-20 10:16:06 +10:30
Adrian Johnson
e4b78424ac pdf-operators: only wrap text strings for PS output
since the PS Document Structing Conventions impose a 255 character
line limit. PDF does not require wrapping.

pdf-operators is designed to emit the same output for PS and PDF.
Unfortunately some PDF interpreters don't like strings split with
'\\\n' and some PS interpreters don't like strings split with ')('.
So we are forced to make pdf-operators handling string wrapping
differently for PDF and PS.

Bug 85662
2014-10-31 19:26:05 +10:30
Adrian Johnson
ab2a7b61d5 pdf: don't use '\' to split strings across multiple lines
The PDF interpreter in my printer does not handle this correctly.
So instead we add the string delimiters '(' and ')' to each line.
2014-10-12 21:06:45 +10:30
Adrian Johnson
5cafaa7b3b pdf: fix rectangle stroke with non rectilinear pen 2013-12-26 15:28:29 +10:30
Adrian Johnson
dcbe16eb40 pdf/ps: avoid outputting excess decimal places in matrices
Sometimes as a result of rounding errors in matrix transformations the
matrices in ps/pdf output look like:

    0.000000000000000061 1 1 -0.000000000000000061 0 842 cm

This patch rounds to zero matrix elements that are very small compared to
other elements in the same matrix.
2013-12-07 15:54:49 +10:30
Chris Wilson
af9fbd176b Introduce a new compositor architecture
Having spent the last dev cycle looking at how we could specialize the
compositors for various backends, we once again look for the
commonalities in order to reduce the duplication. In part this is
motivated by the idea that spans is a good interface for both the
existent GL backend and pixman, and so they deserve a dedicated
compositor. xcb/xlib target an identical rendering system and so they
should be using the same compositor, and it should be possible to run
that same compositor locally against pixman to generate reference tests.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

P.S. This brings massive upheaval (read breakage) I've tried delaying in
order to fix as many things as possible but now this one patch does far,
far, far too much. Apologies in advance for breaking your favourite
backend, but trust me in that the end result will be much better. :)
2011-09-12 08:29:48 +01:00
Chris Wilson
b132fae5e8 clip: Rudimentary support for clip-polygon extraction
Step 1, fix the failings sighted recently by tracking clip-boxes as an
explicit property of the clipping and of composition.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-19 21:14:34 +01:00
Andrea Canciani
a8ae8759f5 path: Always interpret in forward direction
Path are always interpreted in forward direction, so the ability of
interpreting in the opposite direction (which is very unlikely to be
useful at all) can be removed.
2010-12-10 10:58:51 +01:00
Chris Wilson
abff335348 pdf: Silence compiler for an impossible case
Make the default case be an assert to catch a silly programming error
and silence the compiler:

  cairo-pdf-operators.c: In function ‘_word_wrap_stream_write’:
  cairo-pdf-operators.c:300: warning: ‘count’ may be used uninitialized in
  this function

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2010-11-22 18:49:22 +00:00
Adrian Johnson
3afd7cd031 PDF: Restrict ActualText to PDF version >= 1.5
The use of ActualText in a marked content sequence is a PDF 1.5
feature.

A 'use_actual_text' flag linked to the PDF version has already been
implemented in pdf-operators but for some reason this flag had not
been used to control the use of ActualText.
2010-11-10 20:09:53 +10:30
Adrian Johnson
f96187e31e Rewrite pdf-operators word wrapping
to fix some bugs
2010-10-08 23:17:27 +10:30
Adrian Johnson
cd74f5edab pdf-operators: word wrap latin text strings 2010-10-02 18:13:49 +09:30
Adrian Johnson
165a14b564 pdf-operators: fix bug that was causing unnecessary repositioning of text
This optimizes the output to increase the maximum amount of text that
is emitted with a single Tj operator.
2010-10-01 19:18:28 +09:30
Adrian Johnson
807e690de4 pdf-operators: output (abc) style strings when font is latin 2010-10-01 19:15:26 +09:30
Chris Wilson
5155ebeaa2 pdf: Assert that no other error can occur for an invertible matrix. 2010-05-04 18:53:50 +01:00
Andrea Canciani
b8a7f8621a Update FSF address
I updated the Free Software Foundation address using the following script.

for i in $(git grep Temple | cut -d: -f1 )
do
  sed -e 's/59 Temple Place[, -]* Suite 330, Boston, MA *02111-1307[, ]* USA/51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA/' -i "$i"
done

Fixes http://bugs.freedesktop.org/show_bug.cgi?id=21356
2010-04-27 11:13:38 +02:00
Chris Wilson
0fc140abc3 pdf: Suppress compiler warning. 2010-04-23 14:39:21 +01:00
Adrian Johnson
42b5cac766 PDF-operators: ensure text operations flushed before emitting clip 2010-04-10 22:15:01 +09:30
Chris Wilson
cfd204824f Constify stroke style and matrices.
As a simple step to ensure that we do not inadvertently modify (or at least
generate compiler warns if we try) user data, mark the incoming style
and matrices as constant.
2010-01-22 23:01:49 +00:00
Chris Wilson
c50c8b90c0 Move _cairo_error() to a standalone header
A pending commit will want to include some utility code from cairo and
so we need to extricate the error handling from the PLT symbol hiding.
2010-01-22 22:30:43 +00:00
Adrian Johnson
600dd83398 Provide a builtin implementation of isspace() and isdigit()
The glibc versions are slow in utf8 locales.
2009-10-29 22:05:19 +10:30
Daniel Holbert
d108b2777f Spelling corrections: s/it's/its/
As a fun itch to scratch, I've been fixing incorrect uses of the
contraction "it's" in comments within the mozilla source tree (tracked
in https://bugzilla.mozilla.org/show_bug.cgi?id=458167 ), and I ran
across 6 instances of this typo in mozilla's snapshot of cairo.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2009-01-29 10:10:40 +00:00
Chris Wilson
bcb2724920 [path] Mark points as const during _cairo_path_fixed_interpret()
Use const to document the read-only nature of the arguments passed to the
callbacks.
2008-12-12 11:11:49 +00:00
Chris Wilson
e6963a5bfe Mark allocation failures as unlikely.
Use the gcc likelihood annotation to indicate that allocation failures are
extremely unlikely.
2008-11-29 11:20:34 +00:00
Chris Wilson
d1801c23fa Mark if(status) as being unlikely.
The error paths should be hit very rarely during normal operation, so mark
them as being unlikely so gcc may emit better code.
2008-11-29 11:20:33 +00:00
Adrian Johnson
1892907e24 PDF: Disable PDF 1.5 features when version 1.4 is selected
JPEG 2000 image embedding and ActualText marked content are
PDF 1.5 features.
2008-11-24 22:27:09 +10:30
Chris Wilson
a856371bef Add CairoScript backend.
A new meta-surface backend for serialising drawing operations to a
CairoScript file. The principal use (as currently envisaged) is to provide
a round-trip testing mechanism for CairoScript - i.e. we can generate
script files for every test in the suite and check that we can replay them
with perfect fidelity. (Obviously this does not provide complete coverage
of CairoScript's syntax, but should give reasonable coverage over the
operators.)
2008-11-13 11:36:54 +00:00
Chris Wilson
ba18d57339 [pdf] Propagate status
Check and return a few forgotten error codes from static functions.
2008-09-26 13:42:28 +01:00
Chris Wilson
ae0511fbbe [pdf] Do not modify the dashes in-place.
As PS has different semantics regarding a zero-length dash, we need to
adjust the dash array before emitting. However, we need to modify a copy
of the dash array since the same array may be used by the meta-surface
when replaying to an image fallback.
2008-09-23 20:08:38 +01:00
Behdad Esfahbod
1fe7088a11 [show_text_glyphs] Replace the bool backward with cairo_text_cluster_flags
Chris rightfully complained that having a boolean function argument is
new in cairo_show_text_glyphs, and indeed avoiding them has been one
of the API design criteria for cairo.  Trying to come up with alternatives,
Owen suggested using a flag type which nicely solves the problem AND
future-proofs such a complex API.

Please welcome _flags_t APIs to cairo.h
2008-09-18 00:26:07 -04:00
Behdad Esfahbod
5926257770 Revamp the build system.
Quick summary of changes:

  - Move list of cairo source files out of src/Makefile.am and into
    src/Sources.mk,

  - Generate files src/Config.mk and src/Config.mk.win32 that choose
    the right set of source files and headers based on configured
    backends and features.  This drastically simplifies building
    using other build systems.  The src/Makefile.win32 file needs
    to be updated to reflect these changes.

  - Add README files to various directories,

  - Add toplevel HACKING file.
2008-09-02 20:24:08 -04:00
Chris Wilson
0549fcfd85 [pdf-operators] Propagate status from end_text().
Check for an error status after end_text().
2008-08-17 15:19:19 +01:00
Chris Wilson
96d45cfeee [pdf-operators] Propagate error from emit_glyph_string*().
Do not overwrite the error status if returned by either of the
emit_glyph_string*() routines.
2008-08-17 15:19:12 +01:00
Chris Wilson
63f64ff336 [pdf-operators] Propagate error from begin_actualtext().
Check the status return from begin_actualtext().
2008-08-17 14:53:55 +01:00
Behdad Esfahbod
bc4d363e92 [pdf-operators] Add note about clusters with no glyphs 2008-08-08 03:01:18 -04:00
Behdad Esfahbod
1bc404e346 Make utf8 handling in font subsets more consistent 2008-08-08 03:01:17 -04:00
Chris Wilson
0ec6c9ca62 [pdf] Propagate status from emit_glyph()
Propagate the error status from _cairo_pdf_operators_emit_glyph().
2008-08-06 11:11:24 +01:00
Adrian Johnson
7127089fe6 PDF/PS: Remember the current line style
So we don't need to emit line style parameters that are already set.
2008-07-08 22:57:22 +09:30
Adrian Johnson
837bf73f08 Add PDF operators function to reset any remembered state 2008-07-08 22:00:15 +09:30
Adrian Johnson
0c05aa60f5 PDF: Limit precision of Td operands
As the translation is in text space, the full precision of a double
for numbers close to zero is not required. Limit the precision to the
same as for numbers > 1.
2008-07-08 21:12:28 +09:30
Adrian Johnson
dac22cf2b9 PDF: Fix glyph positioning bug in Tj operator
Previously this was not correctly checking the position of the first
glyph and falling back to using TJ if the glyph was not at the the
standard glyph advance.
2008-07-05 16:22:35 +09:30
Adrian Johnson
c9c4b0eded PDF: Fix glyph positioning bug in TJ operator
Previously this was not correctly positioning the first glyph in a TJ
string if the glyph was not at the the standard glyph advance.
2008-07-05 16:19:30 +09:30