Commit graph

7911 commits

Author SHA1 Message Date
Adrian Johnson
2b862f632d Merge branch 'lzw_eod_code_width' into 'master'
Fix output of EOD code with incorrect code width in _cairo_lzw_compress

See merge request cairo/cairo!359
2022-12-28 04:45:26 +00: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
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
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
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
John Ralls
243938c61a [quartz] Destroy local copy of snapshot after attaching it.
Because cairo_surface_snapshot_attach refs the snapshot.

Fixes https://gitlab.freedesktop.org/cairo/cairo/-/issues/562
2022-04-23 16:38:01 -07:00
Uli Schlachter
d9a5aa9d97 Merge branch 'issue558' into 'master'
fixed double free in _cairo_ps_surface_emit_base85_string

Closes #558

See merge request cairo/cairo!312
2022-04-23 05:26:22 +00:00
Uli Schlachter
5b662c925c Merge branch 'fix-uaf-stream_internal' into 'master'
Fix a use after free in _cairo_svg_surface_create_for_stream_internal

Closes #561

See merge request cairo/cairo!315
2022-04-22 16:34:39 +00:00
Uli Schlachter
0614305093 Merge branch 'fix-double-free-mono-scan' into 'master'
Fix a double free in _cairo_mono_scan_converter_create

Closes #557

See merge request cairo/cairo!313
2022-04-22 15:49:56 +00:00
Feysh INC
d7cb417e0e Fix a use after free in _cairo_svg_surface_create_for_stream_internal
When `_cairo_svg_surface_create_for_document()` failed, it will free the
`document` by `_cairo_svg_document_destroy()`. But after `_cairo_svg_surface_create_for_document` return a error status, the `document` is still used and destoryed by `_cairo_svg_document_destroy()`.

We remove the redundant `_cairo_svg_document_destroy()` in `_cairo_svg_surface_create_for_stream_internal` to avoid this bug.

This fixes #561.

Signed-off-by: Feysh INC <opensource@feysh.com>
2022-04-22 21:24:09 +08:00
Adrian Johnson
04232d9871 Merge branch 'font-status' into 'master'
Check font status in show_text_glyphs

See merge request cairo/cairo!307
2022-04-22 12:32:21 +00:00