Commit graph

8269 commits

Author SHA1 Message Date
Adrian Johnson
392423aba3 Fix ink extents of recording surfaces within recording surfaces 2022-12-28 13:22:00 +10:30
Adrian Johnson
640e2dadfc user fonts: ensure snap_x/y_scale are initialized 2022-12-28 13:22:00 +10:30
Adrian Johnson
7c5e2758a4 ft: move CAIRO_SCALED_GLYPH_INFO_METRICS into separate function 2022-12-28 13:22:00 +10:30
Christian Rohlfs
e83776572c Round joins fix (spline_cusp_tolerance)
https://gitlab.freedesktop.org/cairo/cairo/-/issues/520
2022-12-28 07:25:30 +05:00
Matthias Clasen
1df5969ef6 Document whether colors are premultiplied
For the various APIs that take or return
RGBA colors, make it explicit that they are
unpremultiplied.
2022-12-24 07:22:39 -05:00
John Ralls
21ab756bd9 Pass the same type when creating the static glyphs and positions arrays.
Fixes https://gitlab.freedesktop.org/cairo/cairo/-/issues/574
2022-11-17 10:49:18 -08:00
Tim-Philipp Müller
e25511ecd6 Fix build on Windows with -Ddefault_library=static
cairo-perf-chart.c.obj : error LNK2019: unresolved external symbol __imp_cairo_create referenced in function main
etc.
2022-10-27 18:18:58 +01:00
Jonathan Kew
77aac45db7 Ensure pbounds.size is initialized even in EXTEND_NONE mode.
Since the if/else was replaced by a switch() here in 2e0075e265,
the size field of pbounds is not being set in the EXTEND_NONE case,
which means we end up passing uninitialized values to CGPatternCreate.
2022-10-19 14:59:45 +01:00
Daniel Hammerschmid
efa1e3d197 Fix output of EOD code with incorrect code width in _cairo_lzw_compress
LZW compression: If the last input byte caused the code width to
increase, the end-of-data code was still output with the old (not yet
increased) code width.
2022-10-04 15:51:45 +02:00
Uli Schlachter
53ee809ad9 cairo_pdf_version_to_string: Check for negative values
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>
2022-09-16 07:47:18 +02:00
Uli Schlachter
2cfd08664d Merge branch 'scaled-font-make-mutex-recursive' into 'master'
Make cairo_scaled_font_t::mutex recursive

See merge request cairo/cairo!356
2022-09-13 16:27:48 +00:00
Luca Bacci
166d718099 Check for scaled_font::cache_frozen in glyph_page_can_remove()
With modifications kindly suggested by Uli Schlachter

Fixes https://gitlab.freedesktop.org/cairo/cairo/-/issues/587
2022-09-05 21:42:49 +02:00
Luca Bacci
531ec8d02d Make cairo_scaled_font_t mutex recursive
Since it can now happen to acquire it recursively,
see https://gitlab.freedesktop.org/cairo/cairo/-/issues/587
2022-09-05 19:41:19 +02:00
Luca Bacci
8266d2d5f2 Pair usage of operator new[] with a corresponding delete[] 2022-09-03 14:16:04 +02:00
Caolán McNamara
311f5e10cd ofz#46165 avoid a divide by zero seen fuzzing libreoffice rendering 2022-08-31 10:32:12 +01:00
Caolán McNamara
5c7e2dafd5 ofz#50805 crash seen in fuzzing libreoffice text rendering
pixman_image_get_format /work/workdir/UnpackedTarball/pixman/pixman/pixman-image.c:939:16
 _cairo_ft_scaled_glyph_init_surface /work/workdir/UnpackedTarball/cairo/src/cairo-ft-font.c:2574:9
 _cairo_ft_scaled_glyph_init /work/workdir/UnpackedTarball/cairo/src/cairo-ft-font.c:2754:11
 _cairo_scaled_glyph_lookup /work/workdir/UnpackedTarball/cairo/src/cairo-scaled-font.c:3073:11
 composite_glyphs /work/workdir/UnpackedTarball/cairo/src/cairo-image-compositor.c:910:15
 composite_glyphs /work/workdir/UnpackedTarball/cairo/src/cairo-traps-compositor.c:2295:12
 clip_and_composite /work/workdir/UnpackedTarball/cairo/src/cairo-traps-compositor.c:1049:15
 _cairo_traps_compositor_glyphs /work/workdir/UnpackedTarball/cairo/src/cairo-traps-compositor.c:2331:11
 _cairo_compositor_glyphs /work/workdir/UnpackedTarball/cairo/src/cairo-compositor.c:292:11
 _cairo_image_surface_glyphs /work/workdir/UnpackedTarball/cairo/src/cairo-image-surface.c:1030:12
 _cairo_surface_show_text_glyphs /work/workdir/UnpackedTarball/cairo/src/cairo-surface.c:2920:15
 _cairo_gstate_show_text_glyphs /work/workdir/UnpackedTarball/cairo/src/cairo-gstate.c:0
 cairo_show_glyphs /work/workdir/UnpackedTarball/cairo/src/cairo.c:3670:14
 CairoTextRender::DrawTextLayout(GenericSalLayout const&, SalGraphics const&) /src/libreoffice/vcl/unx/generic/gdi/cairotextrender.cxx:337:9
2022-08-31 10:30:13 +01:00
Jussi Pakkanen
ffc133f703 Add missing commas to array values. 2022-08-03 13:56:15 +03:00
Uli Schlachter
541719ff75 Merge branch 'issue-579' into 'master'
Fix issue 579

Closes #579

See merge request cairo/cairo!340
2022-08-02 11:37:58 +00:00
Simon McVittie
947f40f511 meson: Split tests up into test suites
This allows things like `meson test --no-suite=slow` to run subsets
of the complete set of tests.

Signed-off-by: Simon McVittie <smcv@debian.org>
2022-07-14 18:12:50 +01:00
Uli Schlachter
1dc945863b Fix complaints from check-preprocessor-syntax.sh
Checking that public header files #include "cairo.h" first (or none)
Checking that private header files #include "some cairo header" first (or none)
Checking that source files #include "cairoint.h" first (or none)
./win32/cairo-dwrite-font-public.c:#include "cairo-win32-private.h"
Checking that there is no #include <cairo.*.h>
./win32/cairo-dwrite-font-public.c: * #include <cairo-win32.h>
Checking that feature conditionals are used with #if only (not #ifdef)

This adds a missing cairoint.h include and makes
check-preprocessor-syntax.sh slightly better in not warning about
includes in C comments.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-07-14 18:21:54 +02:00
Uli Schlachter
53faf76e57 Fix issue 579
cairo-trutype-subset.c would blindly trust a font saying that its name
list has thousands of entries. This commit changes find_name() to also
get the size of the input memory region and to do some bounds checking
on its memory accesses.

Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/579
Signed-off-by: Uli Schlachter <psychon@znc.in>
2022-07-07 17:30:15 +02:00
Adrian Johnson
ff08edfcc6 Merge branch 'color-option' into 'master'
Add color mode font option

See merge request cairo/cairo!333
2022-06-30 23:00:12 +00:00
Jeff Muizelaar
d64f9699eb Merge branch 'quartz-memcpy' into 'master'
quartz: Avoid reading beyond the end of image surfaces.

See merge request cairo/cairo!337
2022-06-30 16:03:16 +00:00
Jeff Muizelaar
cccc81ccba quartz: Avoid reading beyond the end of image surfaces.
The last row of data may have less than stride bytes so make sure we
only copy what we need.
2022-06-29 21:30:08 -04:00
Behdad Esfahbod
b29f467330 [mutex] Fix build with no mutexes
NOOP1 is a statement, not an expression.
2022-06-29 11:16:04 -06:00
Adrian Johnson
cdb7c298c7 svg: Fix invalid output when image size is 0x0
cairo_surface_write_to_png_stream fails if width or height is 0
2022-06-26 09:54:15 +09:30
Adrian Johnson
6bd549e8df Add color mode option 2022-06-26 09:54:15 +09:30
Adrian Johnson
f0ba2165a6 Add color palette option 2022-06-17 20:42:43 +09:30
Adrian Johnson
ccb306b8dd Merge branch 'scaled-font-deadlock' into 'master'
Fix deadlock in cairo-scaled-font.c

See merge request cairo/cairo!329
2022-05-28 23:13:33 +00:00
Adrian Johnson
47a21c6e30 Clamp path coordinates
Fixes https://gitlab.freedesktop.org/poppler/poppler/-/issues/1250
2022-05-28 16:03:50 +09:30
Adrian Johnson
f823f46267 Remove unused code 2022-05-28 08:45:26 +09:30
Adrian Johnson
76e0df5665 Fix deadlock in cairo-scaled-font.c
A user font glyph containing a font can cause deadlock in
_cairo_scaled_glyph_fini due to the destroy recording surface while
holding _cairo_scaled_glyph_page_cache_mutex. When the font in the
recording surface is removed from the page cache it will attempt to
also acquire the _cairo_scaled_glyph_page_cache_mutex resulting in
deadlock.

Instead of destroying the recording surface in
_cairo_scaled_glyph_page_cache_mutex, move it to an array in the
scaled font and destroy it after the
_cairo_scaled_glyph_page_cache_mutex is released.

Fixes the font in user font case in #440
2022-05-28 07:20:52 +09:30
Adrian Johnson
a8c1858cf2 Fix deadlock in cairo-scaled-font.c
When cairo_scaled_glyph_page_cache needs to remove entries,
cairo-cache calls _cairo_hash_table_random_entry() with the predicate
_cairo_scaled_glyph_page_can_remove(). This function checks that the
glyph_page scaled_font is not locked by testing
scaled_font->cache_frozen. The scaled font is locked in the
cache-cache destroy entry callback: _cairo_scaled_glyph_page_pluck().

There is a race condition here between testing
scaled_font->cache_frozen and locking the font. Fix this by adding a
new CAIRO_MUTEX_TRY_LOCK mutex operation, and using it to test and
lock the scaled font in _cairo_scaled_glyph_page_can_remove().

Fixes the multithreaded case in #440
2022-05-28 06:34:55 +09:30
Behdad Esfahbod
b41cfe3fe0 [unicode] Non-characters are allowed in Unicode strings
https://www.unicode.org/faq/private_use.html#nonchar_codes

Fixes https://github.com/harfbuzz/harfbuzz/issues/3590
2022-05-18 17:35:38 -06:00
Adrian Johnson
4823aa606b Merge branch 'warnings' into 'master'
Add -Werror for meson CI build

See merge request cairo/cairo!320
2022-05-09 21:30:35 +00:00
Nikolaus Waxweiler
b50b168a2e Set default LCD filter to FreeType's default 2022-05-09 21:16:28 +01:00
Adrian Johnson
7c037e5254 dwrite: Fix incorrect rendering of some SVG fonts
SVG fonts are returning DWRITE_GLYPH_IMAGE_FORMATS_NONE as well
as DWRITE_GLYPH_IMAGE_FORMATS_SVG in GetCurrentRun() resulting in the
outline glyph and color glyph both rendered to the same glyph image.
2022-05-08 20:28:41 +09:30
Adrian Johnson
0ea231fae5 Fix GL warnings 2022-05-07 17:45:02 +09:30
Adrian Johnson
455a4cca54 Merge branch 'quartz-core-text' into 'master'
quartz: support rendering colored bitmap fonts

See merge request cairo/cairo!289
2022-04-27 00:04:43 +00:00
Adrian Johnson
f07d539c07 Merge branch 'issue-514' into 'master'
pdf: reset current operator when resetting clip

Closes #514

See merge request cairo/cairo!256
2022-04-26 12:58:41 +00:00
John Ralls
2784159d0e [quartz] Adjust x_extents metric.
CoreText uses different advances depending on the font size, with very
small point sizes sometimes getting advances that are smaller than the
glyph's width. This is manifested in the Apple Color Emoji font with the
Emoji glyphs having a width of 1.25 and an advance width of 1.0. That
results in overlapping emoji when they're in a string.

The small spacing difference also affects 3 tests so updated reference
images are included in this commit.

 # Please enter the commit message for your changes. Lines starting
2022-04-25 11:30:10 -07:00
John Ralls
c755e48c2e [quartz] Implement color font support. 2022-04-25 11:29:52 -07:00
Uli Schlachter
fafbfcda91 Merge branch 'issue562' into 'master'
[quartz] Destroy local copy of snapshot after attaching it.

Closes #562

See merge request cairo/cairo!316
2022-04-25 14:34:38 +00:00
Adrian Johnson
4815949d2f Fix the scaled_glyph_init color glyph logic
and split _cairo_user_scaled_glyph_init() into multiple functions.

Update user-font test to test changing foreground text color.
2022-04-25 17:08:07 +09:30
Adrian Johnson
cdcb67ef87 Merge branch 'fix-color-glyph-clear-surface' into 'master'
Fix rendering of color glyphs on a clear surface

Closes #539

See merge request cairo/cairo!283
2022-04-25 05:15:52 +00:00
John Ralls
c6dc5df612 [quartz] Convert font handling from CGFont to CTFont. 2022-04-24 13:08:48 -07:00
John Ralls
cf351a8a0a Reimplement cairo-quartz-font with Core Text. 2022-04-24 13:08:48 -07:00
John Ralls
77a8d0f9e4 [quartz] Require at least Mac OS X 10.7 Lion
Allows removal of most conditional compilation and dlsym lookups.
2022-04-24 13:08:48 -07:00
John Ralls
0048f0f803 [quartz] Fix some compiler warnings. 2022-04-24 13:08:48 -07:00
Adrian Johnson
083ff4b511 Merge branch 'color-font-vector-surface' into 'master'
Paint color glyphs in fallback resolution on vector surfaces

See merge request cairo/cairo!293
2022-04-24 12:26:20 +00:00