Commit graph

12264 commits

Author SHA1 Message Date
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
396d258e41 Merge branch 'fix-rtl-color-glyphs' into 'master'
Fix rtl handling for color glyphs

Closes #533

See merge request cairo/cairo!272
2022-02-11 11:43:02 +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
Emmanuele Bassi
fb3734fac0 Merge branch 'fix-build-when-pdf-is-disabled' into 'master'
meson: Fix build when PDF backend is disabled

See merge request cairo/cairo!269
2022-01-21 14:14:23 +00: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
Uli Schlachter
5c9112b25e Merge branch 'meson-redundant-version_compare' into 'master'
meson: Remove useless version_compare()

See merge request cairo/cairo!267
2022-01-09 19:02:22 +00:00
Nirbheek Chauhan
e3b4db1645 meson: Remove useless version_compare()
We require meson 0.56 in project() now, all these are redundant.
2022-01-09 17:17:28 +05:30
Adrian Johnson
a4d8eb98ba pdf: ensure url strings are correctly encoded
Fixes #526
2022-01-09 17:49:25 +10:30
Uli Schlachter
46c0b8bb4f Merge branch 'amos/win32-static-build' into 'master'
Set CAIRO_WIN32_STATIC_BUILD when doing a static build on windows

See merge request cairo/cairo!265
2022-01-01 19:37:24 +00:00
Amos Wenger
ca25e9860d Upgrade to expat-2.2.9-4 wrap
This provides the XML_STATIC definition when cairo is built as a static
library on Windows, see https://github.com/mesonbuild/wrapdb/pull/237
2021-12-08 13:36:07 +01:00
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
Tim-Philipp Müller
a04786b933 Merge branch 'ci-update-windows-image-2' into 'master'
ci: bump windows image to latest

See merge request cairo/cairo!258
2021-10-07 14:29:57 +00:00
Tim-Philipp Müller
d3e0d27234 ci: update links in ci template from gst-ci to gstreamer monorep 2021-10-07 14:37:49 +01:00
Tim-Philipp Müller
e1646a7403 ci: bump windows image to latest
Which should include the subprojects cache again.
2021-10-07 14:32:55 +01:00
Adrian Johnson
b63dc83c8b Merge branch 'ci-update-windows-image' into 'master'
ci: update windows image and fix pixman build on android

Closes #515

See merge request cairo/cairo!257
2021-10-04 02:35:50 +00:00
Tim-Philipp Müller
ccb57d21ce ci: disable aarch64 neon asm in pixman to fix android build
To work around build failures, see #515
2021-10-03 13:17:49 +01:00
Tim-Philipp Müller
e3ba30bf7e ci: update windows image
Some root certs expired, which causes problems with letsencrypt
certificates, so update to latest image with updated certificates.

https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/

Fixes #515
2021-10-03 12:47:31 +01:00
Adrian Johnson
d87fe096b9 Merge branch 'user-font-foreground-color' into 'master'
Support user fonts that use the foreground color

See merge request cairo/cairo!249
2021-09-20 09:01:58 +00:00
Adrian Johnson
8ea4ae5413 Allow user fonts to use the foreground color 2021-09-18 07:05:35 +09:30
Uli Schlachter
4f761bd5aa Merge branch 'fix-core-diff' into 'master'
Explicitly handle image formats in buffer_diff_core and pdiff_compare

Closes #25

See merge request cairo/cairo!243
2021-09-17 13:48:46 +00:00
Adrian Johnson
994e33215e Merge branch 'color-font-foreground-color' into 'master'
Support color fonts that use the foreground color

See merge request cairo/cairo!246
2021-09-16 21:47:25 +00:00
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
Tim-Philipp Müller
224b44e9d4 Merge branch 'fix-no-png-dep' into 'master'
meson: fix build without libpng

See merge request cairo/cairo!252
2021-09-12 15:49:13 +00:00
Tim-Philipp Müller
08cd1fdebe meson: fix build without libpng
meson.build:966:2: ERROR: Expected 1 arguments, got 0.
2021-09-12 15:55:31 +01: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
Manuel Stoeckl
6647511593 test: explicitly handle image formats in buffer_diff_core
In practice, the A and B images may be any mixture of RGB24 and
ARGB32 formats, so this change accepts all combinations of these
types, and converts the pixel values to a common (ARGB32) format
as needed.

Some of the newly added test failures are cases where the image
output is RGB24, but the matching reference image is ARGB32 with
noticeable transparency. Some of the newly passing tests are cases
where the unused 'alpha' channel of an RGB24 image was not equal
to 0xff, and the previous code had incorrectly used this channel
in max_diff calculations.
2021-08-29 11:57:30 -04:00
Manuel Stoeckl
0490607584 pdiff: convert RGB24 image values to ARGB32 on read
To avoid reading a potentially garbage alpha channel when users
of pdiff_compare pass in RGB24 images, if the format is RGB24,
force the alpha channel to be 0xff.

This commit also updates CI to adjust for the new tests that have
started/stopped failing. New failures often are cases where
the reference image has alpha transparency, but the test output
does not; new passing tests may indicate that the unused alpha
channel of an RGB24 image was garbage, but now is ignored.
2021-08-29 11:56:27 -04:00
Manuel Stoeckl
a8012953ed ci: sort lists of ignored tests 2021-08-29 11:54:36 -04:00
Tim-Philipp Müller
42d3f4cc29 Merge branch 'meson-pthread-tests' into 'master'
meson: enable pthread tests if 'real pthread' is available

Closes #477

See merge request cairo/cairo!176
2021-08-28 12:49:37 +00:00
Tim-Philipp Müller
b1135db014 test: update quartz ref image to fix macos pthread test failure
The proper pthread check activated some tests that weren't active
before, which resulted in a test failure apparently caused by
inexact test rendering.

Update the quartz reference image accordingly.
2021-08-28 12:57:17 +01:00
Tim-Philipp Müller
e78a90ed98 meson: enable pthread tests if 'real pthread' is available
Fixes #477
2021-08-28 12:53:43 +01:00
Tim-Philipp Müller
187fd83aaa Merge branch 'meson-rely-on-subproject-wrap-promotion-for-indirectly-needed-wraps' into 'master'
meson: rely on automatic wrap promotion from subprojects

Closes #445

See merge request cairo/cairo!131
2021-08-28 11:52:26 +00:00
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
Adrian Johnson
6d169c6995 Merge branch 'cairo-fix-glyph-clipping' into 'master'
Remove the approximate glyph bounds check - with updated ref images

See merge request cairo/cairo!245
2021-08-28 07:55:49 +00:00
Adrian Johnson
e73f236da6 Update user-font-mask ref images 2021-08-28 09:19:09 +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