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
Since a user-font might be calling stroke, and PDF has separate
stroke and fill colors.
Note that this bug was not exposed in Poppler. It's probably a
bug there. But multiple other viewers expoed this bug.
Fixes https://gitlab.freedesktop.org/cairo/cairo/-/issues/813
GCC 14 introduces a new -Walloc-size included in -Wextra which gives:
```
src/cairo-ps-surface.c:3524:18: warning: allocation of insufficient size ‘1’ for type ‘cairo_ps_form_t’ {aka ‘struct _cairo_ps_form’} with size ‘88’ [-Walloc-size]
```
The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
```
So, just swap the number of members and size arguments to match the prototype, as
we're initialising 1 struct of size `sizeof(cairo_ps_form_t)`. GCC then sees we're not
doing anything wrong.
Signed-off-by: Sam James <sam@gentoo.org>
kCTFontColorGlyphsTrait is available in Mac OS X 10.7 and later.
kCTFontTraitColorGlyphs is available in OS X 10.8 and later.
Fixes build failure on Mac OS X 10.7.
Closes#810
Something changed in the docbook XSL, and we cannot use the `index`
element for the versioned indices any more. Using `chapter` brings the
indices back.
I hit the problem with _cairo_arc_in_direction() failing the
angle_max >= angle_min assertion earlier this year when using
Thunderbird on openSUSE Tumbleweed. Thunderbird would crash
when rendering some (but not all) HTML email due to this
assert. For some reason, one of the angles passed in was
NaN. Making _cairo_arc_in_direction() return immediately if
either angle is not finite fixed the problem for me, but I
don't know enough about the internals of Cairo to know if
this is, strictly speaking, the "right" fix. Also, having
tested again today _without_ this change applied, I am now
no longer able to reproduce the problem :-/ I still have the
same version of Cairo installed (1.17.8), but various other
packages on that system have been updated in the meantime,
so maybe that's a factor. Or maybe I'm just lucky and
haven't hit a "bad" HTML email this time...?
Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/352
Signed-off-by: Tim Serong <tserong@suse.com>
Font options are allocated in _cairo_gstate_ensure_scaled_font() for local
processing, but never freed. Run _cairo_font_options_fini() on these and
fix the leak.
Signed-off-by: Christian Hesse <mail@eworm.de>
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>
I added options->variations = strdup("slnt=0,wght=400,wdth=100"); to the
end of _cairo_font_options_init_default(). This makes all font option
objects own some memory that needs to be freed. Then I ran some random
test under valgrind and found memory leaks.
This commit makes the script surface finish the font options that it
contains. This fixes the following valgrind report:
25 bytes in 1 blocks are definitely lost in loss record 8 of 21
at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4ECBC99: strdup (strdup.c:42)
by 0x4886B7F: _cairo_font_options_init_default (cairo-font-options.c:86)
by 0x49768F4: _cairo_script_implicit_context_init (cairo-script-surface.c:3676)
by 0x4976B22: _cairo_script_surface_create_internal (cairo-script-surface.c:3733)
by 0x4976EA1: cairo_script_surface_create (cairo-script-surface.c:3962)
by 0x1B0A97: _cairo_boilerplate_script_create_surface (cairo-boilerplate-script.c:63)
by 0x129B7F: cairo_test_for_target (cairo-test.c:824)
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>
I added options->variations = strdup("slnt=0,wght=400,wdth=100"); to the
end of _cairo_font_options_init_default(). This makes all font option
objects own some memory that needs to be freed. Then I ran some random
test under valgrind and found memory leaks.
_cairo_surface_copy_similar_properties() gets the font options of a
surface via cairo_surface_get_font_options(). This creates a copy of the
font variations that I added above. _cairo_surface_set_font_options()
then copies this again (it calls _cairo_font_options_init_copy). Thus,
the original copy is still owned by
_cairo_surface_copy_similar_properties() and needs to be freed.
This commit fixes four leaks in "valgrind --leak-check=full
./cairo-test-suite -f leaks-set-scaled-font". A random example is:
25 bytes in 1 blocks are definitely lost in loss record 4 of 25
at 0x48407B4: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4ECBC99: strdup (strdup.c:42)
by 0x4886C0C: _cairo_font_options_init_copy (cairo-font-options.c:99)
by 0x48F1DDE: cairo_surface_get_font_options (cairo-surface.c:1620)
by 0x48F0691: _cairo_surface_copy_similar_properties (cairo-surface.c:454)
by 0x48F087C: cairo_surface_create_similar (cairo-surface.c:528)
by 0x1B168A: _cairo_boilerplate_pdf_create_surface (cairo-boilerplate-pdf.c:92)
by 0x129B7F: cairo_test_for_target (cairo-test.c:824)
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>
When calling cairo_surface_get_font_options(), a font options instance
is allocated for the surface. Normally, this just initialised some
otherwise uninitialised fields in cairo_surface_t. Since commit
67eeed44, cairo_font_options_t can contain an extra allocation for a
custom palette. Since commit edf9497c3a, cairo_font_options_t can
contain 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_surface_destroy() finish the contained font
options if they were initialised.
I didn't manage to produce a self-contained test case for this leak. I
found it by just looking at the code. However, I found a way to force a
leak: By adding options->variations=strdtup("slnt=0,wght=400,wdth=100");
to the end of _cairo_font_options_init_default(), all font option
instances now cause a leak unless they are finished. With this extra
change, this commit fixes a memory leak that is simply caused by calling
cairo_surface_get_font_options().
Signed-off-by: Uli Schlachter <psychon@znc.in>