Commit graph

8269 commits

Author SHA1 Message Date
Emmanuele Bassi
64db153c43 Drop OS/2 support
OS/2 support was last built in Cairo 1.12, which was released 10 years
ago.

Additionally, OS/2 is not supported by Meson.
2022-02-25 01:44:57 +00:00
Emmanuele Bassi
81ecff3800 Remove BeOS support
Nobody cares about BeOS in 2022, and it cannot be built with Meson anyway.

Removing the BeOS backend also allows us to drop the dependency on a C++
compiler and simplify the Autotools build considerably by removing all
the extra CXX targets.
2022-02-25 01:39:29 +00:00
Emmanuele Bassi
64ece6d545 Remove Qt surface
It's disabled by default, and unsupported as it depends on Qt4, which
has been EOL since 2015.
2022-02-25 01:19:58 +00:00
John Ralls
2e0075e265 [quartz] Don't use CGContextDrawTiledImage for tiled patterns.
CGContextDrawTiledImage turned up as a significant time-user while
profiling a benchmark created to evaluate
https://gitlab.gnome.org/GNOME/gtk/-/issues/3714. Without this commit
the benchmark is able to perform a mean frame rate of 2.19 frames per
second with a standard deviation of 0.09; with the commit the mean frame
rate is 2.37 fps, s.d. 0.30, both over 15 10-second samples. Student's
t-test reports a 9.8% likelyhood that the two represent the same
distribution.
2022-02-24 17:00:07 -08:00
John Ralls
a502280fcd [quartz] extract function _cairo_quartz_setup_pattern_source
To simplify _cairo_quartz_setup_state.
2022-02-24 17:00:07 -08:00
John Ralls
b6e0f36ee5 [quartz]Cleanup _cairo_quartz_cairo_repeating_surface_pattern_to_quartz 2022-02-24 17:00:07 -08:00
John Ralls
ae320c4d75 [quartz] Use CoreGraphics instead of Qt to write debug png file. 2022-02-24 17:00:07 -08:00
John Ralls
bacbe9bb2d [quartz] Create similar surfaces using a CGLayer for faster drawing. 2022-02-24 17:00:07 -08:00
John Ralls
76e6a0ddf7 [quartz] Remove cached image_surface on quartz surfaces.
Caching doesn't really do anything and removing it provides a 50%
speedup and gets pdf-operators-text to pass on argb32.
2022-02-24 17:00:07 -08:00
John Ralls
64786613ee [quartz] Snapshot CGBitmapContext-mapped surfaces to cache CGImages.
Motivation: Avoid need to recreate CGImages for unchanged surfaces,
an expensive operation, while ensuring that the CGImages are properly
freed and new ones created when the surface does change.

Thanks to Uli Schlacter for suggestion and coding guidance.
2022-02-24 16:59:56 -08:00
Uli Schlachter
4fc72919e1 Merge branch 'mempool-overflow' into 'master'
Fix integer overflows in cairo-mempool

Closes #510

See merge request cairo/cairo!253
2022-02-24 14:35:17 +00:00
Christopher Chavez
04394d5b15 quartz: Fix spelling in comment 2022-02-23 13:12:35 +00:00
Matthias Clasen
402edc71af Fix rendering of color glyphs on a clear surface
We were calling the backend vfuncs directly, thereby
missing some of the surface state bookkeeping that
is done in the wrappers.

Fixes: #539
2022-02-22 19:48:49 -05:00
Uli Schlachter
2ec0a87403 Merge branch 'develop3' into 'master'
miscellaneous math fixes

See merge request cairo/cairo!280
2022-02-20 12:09:02 +00:00
Ayman El Didi
f83e0ed4e6 removed redundant casts in cairoint.h
In a couple of instances, ints are being casted to int before use.
2022-02-19 12:04:21 -07:00
Ayman El Didi
915dd79422 fixed some multiplications prone to overflowing their type
In a couple of instances, code is present where two numbers are being
multiplied in a type like unsigned int, but immediately being casted
to a wider type like size_t.

This means, although the result can be any size_t value, the
multiplication can potentially overflow before it's used because
unsigned int has a smaller range of values.

In another more niche case, I also cast to size_t before multiplying
a signed integer, since the result is immediately used as an argument
to memcpy, which would give memory corruption if the value was negative
anyway.
2022-02-19 11:59:41 -07:00
Ayman El Didi
c932bb7ae7 added missing documentation to cairo_font_options_status
The documentation for cairo_font_options_status says it can return
either CAIRO_STATUS_SUCCESS or CAIRO_STATUS_NO_MEMORY, but the
implementation can also return CAIRO_STATUS_NULL_POINTER, which wasn't
mentioned.
2022-02-18 15:14:57 -07:00
Ayman El Didi
8f7d039801 fixed some comparisons between signed and unsigned integers
In some places, there were int variables being compared to unsigned
ints when they would never take a negative value, exposing some edge
cases that didn't need to be there.
2022-02-18 15:00:53 -07:00
Uli Schlachter
01c93c7f36 Fix bug #535 in cairo-script
cairo-script has a special case for drawing a set of rectangles. The
rectangle detection can trip over a "degenerate rectangle": Just a
horizontal line. It detects the line as the beginning of a rectangle and
then claims CAIRO_STATUS_INVALID_PATH_DATA when the other sides of the
rectangle are missing.

This commit simply changes the return value to
CAIRO_INT_STATUS_UNSUPPORTED to trigger a fallback to the generate case.

Test case is a straight-forward adaption from the original bug report.

Signed-off-by: Uli Schlachter <psychon@znc.in>
Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/535
2022-02-16 17:53:49 +01:00
Behdad Esfahbod
a62eea4aec [user-font] Implement subpixel-positioning
See:

https://github.com/harfbuzz/harfbuzz/pull/3411#issuecomment-1033118545
https://github.com/harfbuzz/harfbuzz/pull/3411#issuecomment-1033125311
https://github.com/harfbuzz/harfbuzz/pull/3411#issuecomment-1037765840

Basically the code in cairo-image-compositor.c:composite_glyphs()
is flooring glyph positions and putting some phase in the glyph-id.
This was being lost in the user-font backend. Fetch that and put it
in the recording-surface's device-transform translation, to be applied.
2022-02-13 14:34:24 -06:00
Behdad Esfahbod
c90faeb749 Merge branch 'mixed-color-clusters' into 'master'
Fix mixed color clusters

See merge request cairo/cairo!273
2022-02-13 05:08:03 +00:00
Matthias Clasen
65d4325e6f Fix mixed color clusters
When rendering clusters that have colored and non-colored
glyphs, we were falling back to using show_text_glyphs,
rendering all glyphs in the cluster without color.
Instead, make composite_one_color_glyph smart enough
to handle non-color glyphs, and only skip clusters
that are entirely non-color.

Testcase: hb-view AmiriQuranColored.otf -u 627,64e
2022-02-12 21:19:39 -06:00
Emmanuele Bassi
cd21fa0814 Merge branch 'fix-user-font-leaks' into 'master'
user-font: Plug some memory leaks

See merge request cairo/cairo!271
2022-02-11 11:59:03 +00:00
Emmanuele Bassi
1bc922d045 Apply 1 suggestion(s) to 1 file(s) 2022-02-11 10:58:39 +00:00
Matthias Clasen
603cdf939f Fix rtl handling for color glyphs
When the run contains a mix of color and non-color
glyphs, composite_color_glyphs returns the non-color
glyphs unhandled in the same array. In the rtl case,
the glyphs are processed from the end and the unhandled
glyphs are accumulated at the end as well, and we
need to move them to the beginning of the array before
we return. Add the missing memmove call to do that.

Fixes: #533
2022-02-11 05:47:01 -05:00
Matthias Clasen
139f3f25b1 Plug another memory leak 2022-02-10 22:19:10 -05:00
Matthias Clasen
537445c4f0 user-font: Plug some memory leaks
We were leaking a cairo_t and a surface here, in
some code paths.
2022-02-10 21:17:58 -05:00
Nirbheek Chauhan
57498b301c meson: Fix build when PDF backend is disabled
Symbols from cairo-tag-stack.c are used by cairo-tag-attributes.c, so
this should be in the same list of sources as that. Fixes this build
error:

```
/usr/bin/ld: src/libcairo.so.2.11705.0.p/cairo-tag-attributes.c.o: in function `parse_array':
/path/to/cairo/_build/../src/cairo-tag-attributes.c:347: undefined reference to `_cairo_tag_error'
/usr/bin/ld: src/libcairo.so.2.11705.0.p/cairo-tag-attributes.c.o: in function `parse_name':
/path/to/cairo/cairo/_build/../src/cairo-tag-attributes.c:359: undefined reference to `_cairo_tag_error'
/usr/bin/ld: src/libcairo.so.2.11705.0.p/cairo-tag-attributes.c.o: in function `parse_attributes':
/path/to/cairo/cairo/_build/../src/cairo-tag-attributes.c:410: undefined reference to `_cairo_tag_error'
/usr/bin/ld: /path/to/cairo/cairo/_build/../src/cairo-tag-attributes.c:431: undefined reference to `_cairo_tag_error'
/usr/bin/ld: /path/to/cairo/cairo/_build/../src/cairo-tag-attributes.c:441: undefined reference to `_cairo_tag_error'
/usr/bin/ld: src/libcairo.so.2.11705.0.p/cairo-tag-attributes.c.o:/path/to/cairo/cairo/_build/../src/cairo-tag-attributes.c:455: more undefined references to `_cairo_tag_error' follow
/usr/bin/ld: src/libcairo.so.2.11705.0: hidden symbol `_cairo_tag_error' isn't defined
```
2022-01-21 11:59:36 +05:30
Adrian Johnson
895b249b0a pdf: ensure filenames are correctly encoded 2022-01-16 13:49:53 +10:30
Uli Schlachter
a6b2a39f36 Merge branch 'fix-doc-warning' into 'master'
Fix a doc comment

See merge request cairo/cairo!263
2022-01-12 16:52:45 +00:00
Adrian Johnson
a4d8eb98ba pdf: ensure url strings are correctly encoded
Fixes #526
2022-01-09 17:49:25 +10:30
Amos Wenger
4d9657ad0d Set CAIRO_WIN32_STATIC_BUILD when doing a static build on windows 2021-12-07 12:13:02 +01:00
Uli Schlachter
ef149976e2 Fix a doc comment
This commit fixes the following warning from our check-def.sh:

PASS: check-def.sh
Checking documentation for incorrect syntax
./cairoint.h (523): ERROR: Get invalid doc id (should be 'cairo_...:')
./cairoint.h (534): ERROR: Get bad line: ' */'
./cairoint.h (534): ERROR: Get documentation comment not closed with **/

Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-11-02 20:10:10 +01:00
Adrian Johnson
059f044e62 pdf: reset gstate in groups 2021-10-04 14:30:33 +10:30
Adrian Johnson
58aadd1481 pdf: reset current operator when resetting clip
PDF output uses q/Q operators to reset the clip path. This also resets
the PDF graphics state including the current blend mode.

When resetting the clip path, reset the current blend mode tracked by
the PDF surface so that if a non-default blend mode is required, the
surface will emit the correct blend mode.

Fixes #514
2021-10-03 14:48:06 +10:30
Adrian Johnson
8ea4ae5413 Allow user fonts to use the foreground color 2021-09-18 07:05:35 +09:30
Adrian Johnson
23815978cc Merge branch 'master' into color-font-foreground-color 2021-09-17 06:25:07 +09:30
Adrian Johnson
4c520fea21 Merge branch 'custom-metadata' into 'master'
Add cairo_pdf_surface_set_custom_metadata()

See merge request cairo/cairo!240
2021-09-16 20:47:50 +00:00
Adrian Johnson
ffa2374b05 Merge branch 'large-pdf-file' into 'master'
Allow > 2GB PDF files on platforms with 32-bit long

See merge request cairo/cairo!251
2021-09-16 20:47:08 +00:00
Uli Schlachter
c0d2527ad0 Fix integer overflows in cairo-mempool
The expression "1 << whatever" has type int, no matter what the type of
"whatever" is. Thus, "1 << 31" ends up overflowing an "int" and
undefined behaviour occurs.

The above happened in cairo-mempool.c. I saw the following line:

  pool->free_bytes += 1 << (bits + pool->min_bits);

being executed with bits=15 and pool->min_bits=16, i.e. we had 1 << 31.
This ended up being INT_MIN due to the overflow. This was then promoted
to size_t and we ended up with a *huge* value being added to free_bytes.

This is obviously not the intended behaviour. Thus, this commit replaces
the "1" in all left shifts in cairo-mempool.c with "((size_t) 1)".

This fix avoids the integer overflow, but it does not fix issue #510,
because some allocation keeps the memory pool alive.

Related-to: https://gitlab.freedesktop.org/cairo/cairo/-/issues/510
Signed-off-by: Uli Schlachter <psychon@znc.in>
2021-09-15 18:02:05 +02:00
Adrian Johnson
918fe02666 Merge branch 'ming-warnings' into 'master'
Fix some MinGW warnings

See merge request cairo/cairo!247
2021-09-02 20:36:19 +00:00
Adrian Johnson
2822728f2a Fix some MinGW warnings
The FT change is because my MinGW build is using a more recent version
of FT.

Remove the disabled _cairo_win32_scaled_font_text_to_glyphs() code to
fix the defined but not used warning.

_cairo_win32_scaled_font_text_to_glyphs() was diabled in d9408041aa with
the comment:

  "Currently disable the win32-font text_to_glyphs(), until that one
   is updated.  Or better yet, remove it and implement
   ucs4_to_index().  It's the toy font API afterall."

_cairo_win32_scaled_font_ucs4_to_index() was added in d1c619bc7d.
2021-09-02 21:14:51 +09:30
Adrian Johnson
6e3c7431ff Allow > 2GB PDF files on platforms with 32-bit long 2021-09-02 18:39:53 +09:30
Adrian Johnson
fea2463107 Support color fonts that use the foreground color
COLR fonts can have a layer with the same color as the current text
color. This change passes the current color (if solid) through to
the font backend where it can be used to render color fonts.

scaled_glyph_lookup checks if the foreground color has changed (for
glyph that require it) and requests a new color surface if required.

This also fixes a bug where scaled_glyph_lookup would always request a
color surface for glyphs for glyphs in color fonts that do not have
color.
2021-08-28 18:07:01 +09:30
Matthias Clasen
4c7a8afb3b Remove the approximate glyph bounds check
We are trying to get an approximate bounding box for
the extents of a glyph string and use it for bailing
early if there's nothing to do, but the code computing
that approximation makes invalid assumptions: It assumes
that a glyph never extends further than max-advance-width
before or after its position. That is not true in general,
as can be seen in https://gitlab.gnome.org/GNOME/gtk/-/issues/4132
In the example there, we have a monospace fonts with ligatures
that have a negative lsb of two or three times the glyph width.

The optimization here could theoretically be fixed by iterating
over the font once to determine suitable values for how far
glyphs can extend before or after their position, but this
patch just removes it.
2021-08-28 09:19:09 +09:30
Adrian Johnson
5e76dd7a5c Merge branch 'fix-comparison-warning' into 'master'
Fix comparison is always false in malloc overflow check

See merge request cairo/cairo!236
2021-08-27 23:44:08 +00:00
Adrian Johnson
9bb1cbf724 Merge branch 'fix-warnings' into 'master'
Fix build warnings

See merge request cairo/cairo!239
2021-08-27 23:41:56 +00:00
Adrian Johnson
068e9b2eb4 Fix malloc overflow check warning
To fix this warning:

../src/cairo-malloc-private.h:83:32: warning: comparison is always false due to limited range of data type [-Wtype-limits]
   83 |   ((size) != 0 && (size_t) (a) >= SIZE_MAX / (size_t) (size) ? NULL : \
      |                                ^~

Create two new macros to do the overflow checks:
_cairo_addl_size_t_overflow and _cairo_mul_size_t_overflow. Implement
them using compiler builtins where available.

Update cairo-malloc-private to use these fuctions and add an overflow
test to test the functions.
2021-08-24 07:26:35 +09:30
Uli Schlachter
923715f2e9 Merge branch 'fix-png-write-endian' into 'master'
Read/write 16-bpc PNG data in native endian

Closes #501

See merge request cairo/cairo!230
2021-08-23 16:31:57 +00:00
Adrian Johnson
ca3e776abe Fix PS emit image for 16-bit images 2021-08-22 15:19:47 +09:30