Commit graph

8236 commits

Author SHA1 Message Date
Emmanuele Bassi
4541e0cd3a Release Cairo 1.18.4 2025-03-08 13:23:25 +00:00
Luca Bacci
4d141f08fb DWrite: Add fallback for OS versions up to Windows 8
IDWriteGlyphRunAnalysis supports gray-scale antialiasing only when
created via IDWriteFactory2 (and newer), introduced in Windows 8.1

Fallback to using DIrect2D on A8 targets when IDWriteFactory2 is
not available.
2025-02-10 17:18:46 +01:00
Luca Bacci
78fca779ba DWrite: Get glyph coverage using IDWriteGlyphRunAnalysis 2025-02-10 17:18:40 +01:00
Emmanuele Bassi
fe87f1c3fb Merge branch 'win32-cleanup' into 'master'
Win32 cleanup

See merge request cairo/cairo!605
2025-01-30 09:29:01 +00:00
Emmanuele Bassi
e2a52c0870 Merge branch 'dwrite-font-variations' into 'master'
DWrite: Add support for font variations

Closes #877

See merge request cairo/cairo!601
2025-01-30 09:26:49 +00:00
Emmanuele Bassi
ed7b0a54b9 Merge branch 'dwrite-fix-warnings' into 'master'
DWrite: Fix warnings

See merge request cairo/cairo!603
2025-01-30 09:25:57 +00:00
Luca Bacci
e0287e09f4 DWrite/GeometryRecorder: Add final specifier 2025-01-21 13:55:27 +01:00
Luca Bacci
46153a0408 DWrite/GeometryRecorder: Complete implementation of QueryInterface
...by checking for IUnknown.

This makes GeometryRecorder::QueryInterface compliant with the
rules of COM.

QueryInterface for IUnknown has a special meaning in COM: it's
used to check whether two interface pointers refer to the same
object.
2025-01-21 13:55:26 +01:00
Luca Bacci
59197e7791 DWrite/GeometryRecorder: Add noexcept specifier
STDMETHOD / IFACEMETHOD macros already add __declspec(nothrow), but
noexcept is better. From MSDN [1]:

  We recommend that all new code use the noexcept operator rather than
  __declspec(nothrow).
  This attribute tells the compiler that the declared function and the
  functions it calls never throw an exception. However, it does not
  enforce the directive. In other words, it never causes std::terminate
  to be invoked, unlike noexcept, or in std:c++17 mode (Visual Studio
  2017 version 15.5 and later), throw().

See also [2]:

  Non-throwing functions are permitted to call potentially-throwing
  functions. Whenever an exception is thrown and the search for a handler
  encounters the outermost block of a non-throwing function, the function
  std::terminate is called:

  extern void f(); // potentially-throwing

  void g() noexcept {
    f();      // valid, even if f throws
    throw 42; // valid, effectively a call to std::terminate
  }

References:

 [1] https://learn.microsoft.com/en-us/cpp/cpp/nothrow-cpp?view=msvc-170
 [2] https://en.cppreference.com/w/cpp/language/noexcept_spec
2025-01-21 13:55:19 +01:00
Luca Bacci
8107086c6a DWrite/GeometryRecorder: Add override specifier
IFACEMETHOD already adds the __override / __allowed(on_function) SAL
annotation (only on Windows SDK, not mingw-w64), which is understood
by some code analysis tools [1]. Since we're compiling in C++11 mode,
we can add the override specifier, so that the compiler is informed
as well.

[1] https://devblogs.microsoft.com/oldnewthing/20200911-00/?p=104205
2025-01-21 12:16:35 +01:00
Luca Bacci
bdac729974 DWrite/GeometryRecorder: Use IFACEMETHOD consistently
Fixes the following warnings on CLang:

  ../cairo/src/win32/cairo-dwrite-font.cpp:869:27: warning: exception specification
  of overriding function is more lax than base version [-Wmicrosoft-exception-spec]
    869 |     IFACEMETHODIMP_(void) SetFillMode(D2D1_FILL_MODE fillMode)
        |                           ^
  D:/msys64/clang64/include/d2d1.h:1491:22: note: overridden virtual function is here
   1491 |     STDMETHOD_(void, SetFillMode)(D2D1_FILL_MODE fillMode) PURE;
        |

COM objects are usually implemented like that:

1. The class is defined with only method declarations. For that,
   one should use IFACEMETHOD macros.
2. Then methods are implemented (defined), outside of the class
   definition. For that, one should use the IFACEMETHODIMP macros

If one really wants to provide inline method definitions (that is,
inside the class definition), then IFACEMETHOD macros should be used
(and not IFACEMETHODIMP, though it's a definition / implementation).
2025-01-21 12:02:51 +01:00
Luca Bacci
864ede8e1a Win32: Load system DLLs from System32 2025-01-21 11:59:09 +01:00
Luca Bacci
995c09ba67 Win32: Avoid library finalization on process termination
Library finalization should be done only for explicit library
unloads (dlclose / FreeLibrary), not for process termination.
2025-01-21 11:32:06 +01:00
Luca Bacci
1e5740c756 Revert "win32: Initialize mutexes for static builds for win32"
This reverts commit 5f90f0a706.

This is not needed anymore now that we have TLS callbacks.
2025-01-21 11:32:06 +01:00
Luca Bacci
3921eb96be Win32: Use TLS callback for module initialization and finalization
TLS callbacks are pretty much like DllMain but work also in
static builds.
2025-01-21 11:19:29 +01:00
Luca Bacci
3bc6b616a4 Win32: Rename _cairo_win32_print_gdi_error function
...to _cairo_win32_print_api_error, since it should not be used
with most GDI functions. Also move the function definition to
cairo-win32-system.c and change argument signature.
2025-01-21 11:10:02 +01:00
Luca Bacci
85f308f690 Win32: Avoid checking the last error for GDI functions that don't set it
Most GDI functions do not set the last error, so GetLastError() returns
unrelated error codes. There are some exceptions, however, like BitBlt
and CreateDIBSection.

Whether a GDI function sets the last error is stated in the reference
documentation on MSDN.
2025-01-21 11:06:48 +01:00
Luca Bacci
e10adb1c2b Win32: Pass FORMAT_MESSAGE_IGNORE_INSERTS
This should always be passed when retreving messages from third
parties (unless the third party documents format strings)

See https://devblogs.microsoft.com/oldnewthing/20071128-00/?p=24353
2025-01-16 16:49:05 +01:00
Luca Bacci
d0ee67a142 Win32: Remove unused code and defines for old toolchains 2025-01-16 16:49:05 +01:00
Luca Bacci
361240657c Win32: Do not load msimg32.dll at runtime
This commit drops support for Windows 98
2025-01-16 16:49:05 +01:00
Luca Bacci
613df92660 Win32: Remove check for Windows 98 2025-01-16 16:49:05 +01:00
bandithedoge
6e0f760117 cairo-xcb-connection.c: fix undefined behavior in DEPTH_MASK
Bit-shifting a signed integer (which is what 1 is here) left is
undefined behavior – you can see it when compiling with
`-fsanitize=undefined`. Explicitly declaring 1 as unsigned fixes this.
2025-01-13 13:17:56 +01:00
Luca Bacci
56b8933ede DWrite: Remove unused variables 2025-01-08 11:06:26 +01:00
Luca Bacci
b84b3542d1 DWrite: Add support for font variations
Fixes https://gitlab.freedesktop.org/cairo/cairo/-/issues/877
2024-11-11 19:41:07 +01:00
Luca Bacci
6cd0a7d395 DWrite: Add IDWriteFontFace field in the scaled font subclass
...and make the code use that instead of the original IDWriteFontFace
in the font face subclass. We do that because to apply a few settings
(font variations) a new IDWriteFontFace must be created out of the
original one.

For now the IDWriteFontFace in the scaled font is a copy of the one in
the font face. In the next commit we'll add code to create a different
object.
2024-11-08 17:00:45 +01:00
Nirbheek Chauhan
0835add95c dwrite: Fix build with MinGW 11
DWRITE_GLYPH_IMAGE_FORMATS is now defined by dcommon.h

In file included from C:/msys64/ucrt64/include/minwindef.h:163,
                 from C:/msys64/ucrt64/include/windef.h:9,
                 from C:/msys64/ucrt64/include/windows.h:69,
                 from ..\src/cairo-mutex-impl-private.h:182,
                 from ..\src/cairo-mutex-type-private.h:45,
                 from ..\src/cairo-scaled-font-private.h:45,
                 from ..\src/cairoint.h:415,
                 from ../src/win32/cairo-dwrite-font.cpp:37:
../src/win32/dw-extra.h:26:1: error: redefinition of 'DWRITE_GLYPH_IMAGE_FORMATS operator|(DWRITE_GLYPH_IMAGE_FORMATS, DWRITE_GLYPH_IMAGE_FORMATS)'
   26 | DEFINE_ENUM_FLAG_OPERATORS(DWRITE_GLYPH_IMAGE_FORMATS);
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/ucrt64/include/dcommon.h:67:1: note: 'DWRITE_GLYPH_IMAGE_FORMATS operator|(DWRITE_GLYPH_IMAGE_FORMATS, DWRITE_GLYPH_IMAGE_FORMATS)' previously defined here
   67 | DEFINE_ENUM_FLAG_OPERATORS(DWRITE_GLYPH_IMAGE_FORMATS)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
2024-10-18 04:33:55 +05:30
Thomas Devoogdt
9607e19a9e
cairo-ft-private.h: fix missing FT_Color error
In file included from ../src/cairo-colr-glyph-render.c:37:
../src/cairo-ft-private.h:87:30: error: unknown type name 'FT_Color'
   87 |                              FT_Color               *palette,
      |                              ^~~~~~~~

Fixes https://gitlab.freedesktop.org/cairo/cairo/-/issues/792

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
2024-09-20 15:26:21 +02:00
Adrian Johnson
f19e2fe080 cff: Don't fail if no local subs
Fixes: #870
2024-09-13 06:29:25 +09:30
Emmanuele Bassi
e90b49ed50 Post-release version bump to 1.18.3 2024-09-01 14:21:28 +01:00
Emmanuele Bassi
200441e685 Release Cairo 1.18.2 2024-09-01 14:09:23 +01:00
Uli Schlachter
43e08aed8b Merge branch 'fix_glyph_path' into 'master'
Fix cairo_glyph_path() early clipping

See merge request cairo/cairo!576
2024-08-02 16:57:48 +00:00
Heiko Lewin
d8c1db11dd
Fix cairo_glyph_path() early clipping 2024-07-26 08:18:20 +02:00
Adrian Johnson
b99f6ff534 Fix MSYS clang build error
../src/cairo-atomic-private.h:210:43: warning: incompatible pointer types passing 'void **' to param
eter of type 'cairo_atomic_intptr_t *' (aka 'long long *') [-Wincompatible-pointer-types]
  210 |     return __atomic_compare_exchange_n(x, &expected, newv, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ
_CST);
      |                                           ^~~~~~~~~
../src/cairo-atomic-private.h:210:54: error: incompatible pointer to integer conversion passing 'voi
d *' to parameter of type 'cairo_atomic_intptr_t' (aka 'long long') [-Wint-conversion]
  210 |     return __atomic_compare_exchange_n(x, &expected, newv, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ
_CST);
      |                                                      ^~~~
../src/cairo-atomic-private.h:220:43: warning: incompatible pointer types passing 'void **' to param
eter of type 'cairo_atomic_intptr_t *' (aka 'long long *') [-Wincompatible-pointer-types]
  220 |     (void) __atomic_compare_exchange_n(x, &expected, newv, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ
_CST);
      |                                           ^~~~~~~~~
../src/cairo-atomic-private.h:220:54: error: incompatible pointer to integer conversion passing 'voi
d *' to parameter of type 'cairo_atomic_intptr_t' (aka 'long long') [-Wint-conversion]
  220 |     (void) __atomic_compare_exchange_n(x, &expected, newv, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ
_CST);
      |                                                      ^~~~
2024-07-25 08:23:46 +09:30
Adrian Johnson
64301c6105 doc: Ensure @ in "@cairo:" is escaped when referring the the font family name
Fixes: #851
2024-06-27 07:07:22 +09:30
Adrian Johnson
c8ce9f1900 Check return value of _cairo_boxes_copy_to_clip()
Fixes: #850
2024-06-27 07:07:22 +09:30
Adrian Johnson
545073d7ed Ensure extent_y_scale is initialized
Fixes: #849
2024-06-27 07:07:22 +09:30
Adrian Johnson
fff7b8f392 Make Coverity happy
Fixes: #847
2024-06-27 07:07:22 +09:30
Adrian Johnson
2f671582ee Ensure face variables in cairo_stroker_t are initialized
Fixes: #846
2024-06-27 07:07:22 +09:30
Adrian Johnson
6967beb24e ps: fix max form size
Fixes: #845
2024-06-27 07:07:22 +09:30
Adrian Johnson
16dd5cd4c2 Merge branch 'wip/otte/xlib-overflow' into 'master'
xlib: Enlarge array for new formats

See merge request cairo/cairo!567
2024-06-24 21:26:26 +00:00
Adrian Johnson
409a6b5229 Merge branch 'master' into 'master'
Fix a memory leak

See merge request cairo/cairo!568
2024-06-24 21:18:07 +00:00
Matthias Clasen
f1d1f0ac77 Avoid an uninitialized use
Coverity complained that val may be used uninitialized in this
function, and I think it is right in this case.
2024-06-24 14:25:32 -04:00
Matthias Clasen
dd40d34fee Fix a memory leak
Coverity flagged this minor memory leak.
2024-06-24 14:17:00 -04:00
Benjamin Otte
18bb4f50cf xlib: Enlarge array for new formats
Fixes a potential overflow in _cairo_xlib_display_get_xrender_format().

Caught by Coverity
2024-06-24 18:08:47 +00:00
Adrian Johnson
0cae2a4a74 Use _cairo_calloc() to allocate structs
To avoid any possibility of uninitialized memory.

The exceptions are:
 - where the allocation is immediately overwritten by a memcpy or struct copy.
 - arrays of structs to avoid any performance impact (except when the
   array is returned by the public API).
2024-06-21 10:32:23 +09:30
Adrian Johnson
8da24bf7fb Make _cairo_calloc() consistent with _cairo_malloc()
ie

  _cairo_calloc(size)
  _cairo_calloc_ab(a, size)
2024-06-21 08:53:01 +09:30
Adrian Johnson
00ce12846a Fix cairo-ft-font.c build failure when fontconfig not available 2024-06-10 11:07:46 +09:30
Adrian Johnson
b0b5562b9e Set CLOEXEC when opening files
Based on the patch by Christian Persch in #213.

Closes #213
2024-06-08 06:40:55 +09:30
Adrian Johnson
f0a651e1ac Merge branch 'c11-atomics' into 'master'
Add support for C11 atomics

See merge request cairo/cairo!479
2024-05-31 09:40:37 +00:00
Adrian Johnson
09779a7e58 Merge branch 'update-fontconfig-and-libpng' into 'master'
Update fontconfig and libpng versions

See merge request cairo/cairo!558
2024-05-26 23:09:52 +00:00