...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.
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.
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.
...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.
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)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
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>
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).
There are two check-link.c files which were "tests" in the autotools
build and are unused ever since the autotools build was removed.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Not all platforms handle a zero sized allocation in calloc the
same. This macro ensures that _cairo_calloc(0) always returns NULL
similar to _cairo_malloc(0).