Commit graph

2353 commits

Author SHA1 Message Date
Uli Schlachter
04656d7450 Merge branch 'tests-misc-fixes' into 'master'
Tests: Misc enhancements

See merge request cairo/cairo!634
2025-07-17 18:38:49 +00:00
Luca Bacci
2e0713971f Update Quartz reference images 2025-07-16 11:52:45 +02:00
Luca Bacci
2b7ab8b895 Remove leftover scripts from the autotools build 2025-07-15 14:28:18 +02:00
Luca Bacci
471f8410a5 make-constructors.py: Sort tests list
This way cairo-test-suite works on sorted data
2025-07-15 14:27:15 +02:00
Alan Coopersmith
936f20c37e Fix pdf-structure test build on Solaris
Adds include of <sys/wait.h> if system has it, in order to fix:

../test/pdf-structure.c: In function ‘check_pdf’:
../test/pdf-structure.c:551:21: error: implicit declaration of function
 ‘WIFEXITED’ [-Wimplicit-function-declaration]
  551 |                     WIFEXITED (ret) ? WEXITSTATUS (ret) : -1);
      |                     ^~~~~~~~~
../test/pdf-structure.c:551:39: error: implicit declaration of function
 ‘WEXITSTATUS’ [-Wimplicit-function-declaration]
  551 |                     WIFEXITED (ret) ? WEXITSTATUS (ret) : -1);
      |                                       ^~~~~~~~~~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-10-13 11:01:59 -07:00
Heiko Lewin
d8c1db11dd
Fix cairo_glyph_path() early clipping 2024-07-26 08:18:20 +02:00
Adrian Johnson
6967beb24e ps: fix max form size
Fixes: #845
2024-06-27 07:07:22 +09:30
Adrian Johnson
b00db10ae8 meson: Use cc.has_define instead of cc.get_define for variables that may be undefined
Fixes the message:

  Fetching value of define "DEBUG_SVG_RENDER" : (undefined)
2024-06-01 21:34:41 +09:30
Adrian Johnson
4f38b502e5 Fix meson deprecation warning
test/meson.build:663: WARNING: Project targets '>= 1.3.0' but uses feature deprecated since '0.64.0': copy arg in configure_file. Use fs.copyfile instead
2024-06-01 21:34:35 +09:30
Adrian Johnson
b31ca9a3c3 Enable pdf-structure test
Fedora 40 contains a recent version of poppler that supports
extracting the pdf structure.

And add missing pdf-structure ref data.
2024-05-25 19:51:28 +09:30
Adrian Johnson
94e3c5ce81 Update minimum FreeType to 2.10
and remove feature guards for FT functions that are in 2.10 or later.
2024-05-25 09:02:53 +09:30
Koichi Akabe
d163670f97 Merge branch 'master' into fix-gradient-scale-crash 2024-05-22 10:19:50 +09:00
Emmanuele Bassi
820bb0ba7f Apply 1 suggestion(s) to 1 file(s)
Co-authored-by: Emmanuele Bassi <ebassi@gmail.com>
2024-05-21 22:43:36 +00:00
Emmanuele Bassi
d253188651 Merge branch 'moz-bug-1896173' into 'master'
pdf tags: Fix crash when popping the top most group following by a show_text

See merge request cairo/cairo!549
2024-05-21 11:59:14 +00:00
Adrian Johnson
54cbe51481 Merge branch 'update-to-fedora-40' into 'master'
Update CI to Fedora 40

See merge request cairo/cairo!546
2024-05-21 09:41:13 +00:00
Adrian Johnson
1a0933d67d pdf tags: Fix crash when popping the top most group following by a show_text
https://bugzilla.mozilla.org/show_bug.cgi?id=1896173
2024-05-19 10:53:54 +09:30
Adrian Johnson
754f431642 Allow links to specify 'dest' and 'uri'
- If a link has both 'dest' and 'uri', the 'dest' will be used if it
  exists, otherwise it will fallback to using the 'uri'.

- Ensure that a missing 'dest' does not result in an error. Instead a
  warning is printed if CAIRO_DEBUG_TAG is set, and a link to the
  current location is embedded in the PDF. ie the link does
  nothing. Cairo needs to embed a link even if no destination is
  available because when links are embedded at the end of the
  document, the content stream already contains link tags.

- Remove cairo_pdf_interchange_write_forward_links. This code was
  originally used prior to !463 when cairo wrote the links at the end
  of each page. Now the links are written at the end of the document
  so there are no longer any forward links with an unknown
  destination, unless the destination does not exist.

- When 'internal' is not used, use the 'dest' name to reference the
  link. Ensure non ASCII names are correctly encoded.
2024-05-11 19:52:02 +09:30
Adrian Johnson
293b75a1c4 Update CI to Fedora 40 2024-04-28 21:28:41 +09:30
Félix Poisot
bf471919a9 tests: remove gl reference images
Leftover from b5793081
2024-04-01 16:44:21 +00:00
Adrian Johnson
bbbc68e619 Merge branch 'surface-error-png' into 'master'
_cairo_surface_create_in_error(): Add PNG_ERROR support

See merge request cairo/cairo!524
2024-02-17 10:01:14 +00:00
Koichi Akabe
ad93bbad19 coding style 2024-02-07 23:21:13 +09:00
Koichi Akabe
3a06998b6a Destroy used pattern 2024-02-07 00:19:13 +09:00
Koichi Akabe
d517773ff1 Fix "out of memory" when using linear gradient 2024-02-06 22:18:06 +09:00
Behdad Esfahbod
3bcad03f6b Copy font-options during creation of a fallback font
Specially important for font variations, which before did not
work in PDF, etc, output.

Script surface is not updated. It seems out of date with all
recent additions to cairo_font_options_t, so it loses the
variations :(.

Fixes https://gitlab.freedesktop.org/cairo/cairo/-/issues/819
2024-01-16 18:13:59 -07:00
Uli Schlachter
23a643c80d _cairo_surface_create_in_error(): Add PNG_ERROR support
Traditionally, loading a malformed PNG file with
cairo_image_surface_create_from_png() resulted in
CAIRO_STATUS_NO_MEMORY. This was apparently changed in commit
c5ee3f11b5 by adding CAIRO_STATUS_PNG_ERROR and using it for errors
returned from libpng. However, I don't see how this was supposed to
actually work.

There are a couple of error codes supported by
_cairo_surface_create_in_error(). Anything else is turned into
CAIRO_STATUS_NO_MEMORY, which is not a helpful status. For this reason,
CAIRO_STATUS_PNG_ERROR would be turned into CAIRO_STATUS_NO_MEMORY.

This commit adds support for CAIRO_STATUS_PNG_ERROR to
_cairo_surface_create_in_error() so that this error can actually be
returned to the caller.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2023-10-31 14:54:06 +01:00
Emmanuele Bassi
900b713af1 Merge branch 'ebassi/dithering' into 'master'
Enable access to the pixman dithering path

See merge request cairo/cairo!511
2023-09-23 11:49:49 +00:00
Uli Schlachter
ac1ac72ff1 tests: Add more dithering tests
Use operator add to add the same source over and over again, to make the
dithering more pronounced.
2023-09-23 12:15:27 +01:00
Emmanuele Bassi
6d2d6f312b Merge branch 'leak-bug-431' into 'master'
Fix leak in test/bug-431.c

See merge request cairo/cairo!513
2023-09-23 11:10:47 +00:00
Uli Schlachter
14ae7c7fd2 Fix leak in test/bug-431.c
This test creates surfaces and patterns that it never cleans up. Found via
running:

  CAIRO_TEST_TARGET=image valgrind --leak-check=full ./cairo-test-suite -f bug-431

Output before this commit:

==21310==
==21310== HEAP SUMMARY:
==21310==     in use at exit: 569,788 bytes in 26 blocks
==21310==   total heap usage: 1,523 allocs, 1,497 frees, 2,034,252 bytes allocated
==21310==
==21310== 336 bytes in 2 blocks are definitely lost in loss record 5 of 17
==21310==    at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==21310==    by 0x48BE2B0: _cairo_pattern_create_solid (cairo-pattern.c:614)
==21310==    by 0x48BE4B1: cairo_pattern_create_rgba (cairo-pattern.c:720)
==21310==    by 0x1358C6: draw (bug-431.c:50)
==21310==    by 0x129EDB: cairo_test_for_target (cairo-test.c:938)
==21310==    by 0x12B36A: _cairo_test_context_run_for_target (cairo-test.c:1545)
==21310==    by 0x12C370: _cairo_test_runner_draw (cairo-test-runner.c:258)
==21310==    by 0x12DEA0: main (cairo-test-runner.c:962)
==21310==
==21310== 278,534 (144 direct, 278,390 indirect) bytes in 1 blocks are definitely lost in loss record 15 of 17
==21310==    at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==21310==    by 0x48BE51E: cairo_pattern_create_for_surface (cairo-pattern.c:756)
==21310==    by 0x135838: draw (bug-431.c:41)
==21310==    by 0x129EDB: cairo_test_for_target (cairo-test.c:938)
==21310==    by 0x12B36A: _cairo_test_context_run_for_target (cairo-test.c:1545)
==21310==    by 0x12C370: _cairo_test_runner_draw (cairo-test-runner.c:258)
==21310==    by 0x12DEA0: main (cairo-test-runner.c:962)
==21310==
==21310== 278,534 (144 direct, 278,390 indirect) bytes in 1 blocks are definitely lost in loss record 16 of 17
==21310==    at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==21310==    by 0x48BE51E: cairo_pattern_create_for_surface (cairo-pattern.c:756)
==21310==    by 0x488274D: _cairo_default_context_set_source_surface (cairo-default-context.c:327)
==21310==    by 0x49063DB: cairo_set_source_surface (cairo.c:977)
==21310==    by 0x1AC1DD: _cairo_boilerplate_get_image_surface (cairo-boilerplate.c:337)
==21310==    by 0x12A486: cairo_test_for_target (cairo-test.c:1145)
==21310==    by 0x12B36A: _cairo_test_context_run_for_target (cairo-test.c:1545)
==21310==    by 0x12C370: _cairo_test_runner_draw (cairo-test-runner.c:258)
==21310==    by 0x12DEA0: main (cairo-test-runner.c:962)
==21310==
==21310== LEAK SUMMARY:
==21310==    definitely lost: 624 bytes in 4 blocks
==21310==    indirectly lost: 556,780 bytes in 16 blocks
==21310==      possibly lost: 0 bytes in 0 blocks
==21310==    still reachable: 12,384 bytes in 6 blocks
==21310==         suppressed: 0 bytes in 0 blocks
==21310== Reachable blocks (those to which a pointer was found) are not shown.
==21310== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==21310==
==21310== For lists of detected and suppressed errors, rerun with: -s
==21310== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2023-09-17 12:26:19 +02:00
Uli Schlachter
7bf743a92f Fix font options leak in scaled font
A scaled font contains font options. Since commit 67eeed44, this can
contain an extra allocation for a custom palette. Since commit
edf9497c3a, this contains an extra allocation for a string. Before these
commit, font options could just be dropped, but now they need to be
freed.

This commit makes the relevant code for creating and finishing scaled
fonts also clean up the font options.

The test added in the previous commit also hits this bug (I only found
these leaks accidentially!). Running "valgrind --leak-check=full
./cairo-test-suite -f leaks-set-scaled-font" no longer reports the following
after this change:

 40 bytes in 1 blocks are definitely lost in loss record 1 of 11
    at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x4886C62: _cairo_font_options_init_copy (cairo-font-options.c:105)
    by 0x48DAFFB: _cairo_scaled_font_init_key (cairo-scaled-font.c:675)
    by 0x48DC077: cairo_scaled_font_create (cairo-scaled-font.c:1096)
    by 0x15BF08: leaks_set_scaled_font (leaks.c:43)
    by 0x129EF0: cairo_test_for_target (cairo-test.c:938)
    by 0x12B37F: _cairo_test_context_run_for_target (cairo-test.c:1545)
    by 0x12C385: _cairo_test_runner_draw (cairo-test-runner.c:258)
    by 0x12DEB5: main (cairo-test-runner.c:962)

 40 bytes in 1 blocks are definitely lost in loss record 2 of 11
    at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x4886C62: _cairo_font_options_init_copy (cairo-font-options.c:105)
    by 0x49337BB: _cairo_ft_font_face_scaled_font_create (cairo-ft-font.c:2073)
    by 0x48DC340: cairo_scaled_font_create (cairo-scaled-font.c:1176)
    by 0x15BF08: leaks_set_scaled_font (leaks.c:43)
    by 0x129EF0: cairo_test_for_target (cairo-test.c:938)
    by 0x12B37F: _cairo_test_context_run_for_target (cairo-test.c:1545)
    by 0x12C385: _cairo_test_runner_draw (cairo-test-runner.c:258)
    by 0x12DEB5: main (cairo-test-runner.c:962)

 40 bytes in 1 blocks are definitely lost in loss record 3 of 11
    at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x4886C62: _cairo_font_options_init_copy (cairo-font-options.c:105)
    by 0x48DB280: _cairo_scaled_font_init (cairo-scaled-font.c:742)
    by 0x4933804: _cairo_ft_font_face_scaled_font_create (cairo-ft-font.c:2076)
    by 0x48DC340: cairo_scaled_font_create (cairo-scaled-font.c:1176)
    by 0x15BF08: leaks_set_scaled_font (leaks.c:43)
    by 0x129EF0: cairo_test_for_target (cairo-test.c:938)
    by 0x12B37F: _cairo_test_context_run_for_target (cairo-test.c:1545)
    by 0x12C385: _cairo_test_runner_draw (cairo-test-runner.c:258)
    by 0x12DEB5: main (cairo-test-runner.c:962)

Signed-off-by: Uli Schlachter <psychon@znc.in>
2023-09-17 09:32:10 +02:00
Uli Schlachter
9529d02f6a Fix font options leak in gstate
cairo_gstate_t contains a cairo_font_options_t. Since commit 67eeed44,
this can contain an extra allocation for a custom palette. Since commit
edf9497c3a, this contains an extra allocation for a string. Before these
commit, font options could just be dropped, but now they need to be
freed.

This commit makes _cairo_gstate_fini() finish the font options to free
the memory allocation.

The new test was run via "valgrind --leak-check=full ./cairo-test-suite
-f leaks-set-scaled-font". The following reported leak goes away thanks
to this commit:

 1,040 bytes in 26 blocks are definitely lost in loss record 6 of 12
    at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x4886C62: _cairo_font_options_init_copy (cairo-font-options.c:105)
    by 0x488C029: _cairo_gstate_set_font_options (cairo-gstate.c:1757)
    by 0x48841D7: _cairo_default_context_set_scaled_font (cairo-default-context.c:1310)
    by 0x490809A: cairo_set_scaled_font (cairo.c:3318)
    by 0x15BF1F: leaks_set_scaled_font (leaks.c:45)
    by 0x129EF0: cairo_test_for_target (cairo-test.c:938)
    by 0x12B37F: _cairo_test_context_run_for_target (cairo-test.c:1545)
    by 0x12C385: _cairo_test_runner_draw (cairo-test-runner.c:258)
    by 0x12DEB5: main (cairo-test-runner.c:962)

Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/795
Signed-off-by: Uli Schlachter <psychon@znc.in>
2023-09-17 09:22:29 +02:00
Marc Jeanmougin
e6ab85712c Enable access to the pixman dithering path
Newer versions of Pixman allow choosing the dithering format.
2023-09-07 15:42:21 +01:00
Sebastian Dröge
baf2593852 Hurd has no MAP_NORESERVE so don't use it there 2023-07-02 10:19:06 -04:00
Adrian Johnson
c381a773de Update CI to Fedora 38 2023-06-05 22:04:33 +09:30
Adrian Johnson
b53b48116e Make cairo_tag_begin/end work correctly in groups
Fixes #508
2023-04-18 18:27:12 +09:30
Taylor R Campbell
b1ccd52183 Avoid misuse of ctype(3) functions
The ctype(3) character classification and mapping functions have a
peculiarly limited definition (C11, Sec. 7.4 `Character handling
<ctype.h>', p. 200):

	`The header <ctype.h> declares several functions useful for
	 classifying and mapping characters.  In all cases the
	 argument is an int, the value of which shall be
	 representable as an unsigned char or shall equal the value
	 of the macro EOF.  If the argument has any other value, the
	 behavior is undefined.'

In other words, in the most common case of 8-bit char and EOF = -1,
the domain of the 257 allowed arguments is:

	-1, 0, 1, 2, ..., 254, 255

The ctype(3) functions are designed for use with stdio functions like
getchar and fgetc which return int values in the same domain.

In an ABI where char is signed (e.g., x86 SysV ABI used by most
Unixish operating systems), passing an argument of type char as is
can go wrong in two ways:

1. The value of a non-EOF input octet interpreted as `char' may
   coincide, as an integer, with the value of EOF, leading to wrong
   answers for some non-EOF inputs.

   E.g., if EOF = 1, and an input octet has all bits set, i.e., 255
   as an unsigned char, then as a char the value is -1, which will be
   confused with EOF.  In the ISO-8859-1 locale, the code point 255
   is (in Unicode terminology) LATIN SMALL LETTER Y WITH DIAERESIS,
   for which isprint, isalpha, &c., are true.  But isprint, isalpha,
   &c., are false for EOF.  So if char *s points to a string with
   that character, isprint(*s) will return false when it should
   return true.

2. Passing a negative char whose value does not coincide with EOF is
   undefined behaviour.

   This isn't purely theoretical: often the functions are implemented
   by an array lookup, #define isprint(c) (ctypetab[c] & ISPRINT).
   If c is out of range (e.g., 192, ISO-8859-1 for LATIN CAPITAL
   LETTER A WITH GRAVE, which convers to (signed) char as -64), then
   you can get garbage answers by reading uninitialized memory or
   application crashes with SIGSEGV if the page preceding the table
   is unmapped.

If what you have is an arbitrary char (e.g., from a char * string
pointing at user input), then the only correct way to use the
ctype(3) functions is by converting to unsigned char first -- e.g.,
isprint((unsigned char)*s).  (If the functions were defined as macros
that convert to unsigned char first, they would then spuriously
interpret EOF as a non-EOF, so they can't do that themselves.)

It is possible, in some cases, to prove that the input always
actually lies in {0, 1, 2, ..., 127}, so the conversion to unsigned
char is not necessary.  I didn't check whether this was the case --
it's safer to just adopt the habit of always casting char to unsigned
char first before using the ctype(3) macros, which satisfies a
compiler warning on some systems designed to detect this class of
application errors at compile-time.
2023-03-29 09:04:46 +00:00
John Ralls
e5ed09a1ab [quartz] Replace surface-pattern xfail with latest CI fail image. 2023-02-14 11:53:02 -08:00
Khaled Hosny
59c195dc82 Fix -Wlogical-not-parentheses
The code is doing "if (!double_buf_equal () != 0)" which seems to be a
convoluted way to do "if (!double_buf_equal ())". Fixes:

../test/pattern-getters.c:153:6: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
        if (!double_buf_equal (ctx, new_buf, expected_values,
            ^
../test/pattern-getters.c:153:6: note: add parentheses after the '!' to evaluate the comparison first
        if (!double_buf_equal (ctx, new_buf, expected_values,
            ^
             (
../test/pattern-getters.c:153:6: note: add parentheses around left hand side expression to silence this warning
        if (!double_buf_equal (ctx, new_buf, expected_values,
            ^
            (
2023-02-06 11:39:08 +02:00
Khaled Hosny
7980301fe4 Remove dead code
This is no-op as the functions always return TRUE and the code is never
executed.
2023-02-04 10:59:41 +02:00
Khaled Hosny
c1564baf61 Fix -Wunused-but-set-parameter
../test/cairo-test-runner.c:730:48: warning: parameter 'str' set but not used [-Wunused-but-set-parameter]
_has_required_ghostscript_version (const char *str)
2023-02-04 10:58:13 +02:00
Adrian Johnson
00453e9a7d Merge branch 'pdf-color-fonts' into 'master'
PDF Type 3 color fonts

See merge request cairo/cairo!434
2023-02-02 10:58:52 +00:00
Adrian Johnson
9d85055bb2 meson: Replace existing link if it already exists
Fixes #631
2023-02-01 20:10:33 +10:30
Adrian Johnson
79501baaa1 PDF Type 3 color fonts
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.
2023-01-29 18:08:42 +10:30
Emmanuele Bassi
47a932bffc Merge branch 'no-more-gl' into 'master'
Drop cairo-gl

See merge request cairo/cairo!287
2023-01-29 01:32:55 +00:00
Emmanuele Bassi
b5793081d0 Drop cairo-gl
The GL support in Cairo has always been a prototype, and
nothing happened in the past 10+ years to make it work as
it was meant to.

GL support is not enabled by any downstream packagers of
Cairo, so nobody should notice its absence.
2023-01-27 19:21:46 +00:00
Adrian Johnson
9e59808ecb svg: test foreground colors
Convert the ft-svg-render-palette test to a color test that test
both palettes and foreground colors.
2023-01-27 20:22:18 +10:30
Adrian Johnson
c8695f0503 Foreground color fixes for ft, svg, colrv1 2023-01-27 20:22:18 +10:30
Adrian Johnson
f35f757e8f Update user font tests to test foreground colors 2023-01-26 19:49:06 +10:30
Adrian Johnson
b68583ee54 Add test for SVG font palettes 2023-01-21 17:46:18 +10:30
Adrian Johnson
745c3717aa Merge branch 'fix-shared-recording-surface' into 'master'
Fix shared use of recording surfaces

See merge request cairo/cairo!391
2023-01-16 08:59:32 +00:00