Merge branch 'ios' into 'master'

Allow building Quartz font backend for iPhoneOS

See merge request cairo/cairo!606
This commit is contained in:
Mike Hommey 2026-04-04 14:47:04 +00:00
commit 03912f60b5
6 changed files with 30 additions and 4 deletions

View file

@ -454,7 +454,7 @@ if feature_conf.get('CAIRO_HAS_XCB_SURFACE', 0) == 1
endif
if host_machine.system() == 'darwin' and not get_option('quartz').disabled()
quartz_deps = dependency('appleframeworks', modules : ['CoreFoundation', 'ApplicationServices'], required: get_option('quartz'))
quartz_deps = dependency('appleframeworks', modules : ['CoreFoundation', 'CoreGraphics', 'CoreText', 'ImageIO'], required: get_option('quartz'))
if quartz_deps.found()
deps += [quartz_deps]
@ -474,7 +474,7 @@ if host_machine.system() == 'darwin' and not get_option('quartz').disabled()
'deps': quartz_deps,
}]
compiler = meson.get_compiler('c')
if compiler.has_function('CTFontDrawGlyphs', prefix: '#include <ApplicationServices/ApplicationServices.h>',
if compiler.has_function('CTFontDrawGlyphs', prefix: '#include <CoreText/CoreText.h>',
dependencies: quartz_deps)
built_features += [
{
@ -484,6 +484,13 @@ if host_machine.system() == 'darwin' and not get_option('quartz').disabled()
}]
feature_conf.set('CAIRO_HAS_QUARTZ_FONT', 1)
endif
if compiler.has_function('CGDisplayCopyColorSpace', prefix: '#include <CoreGraphics/CoreGraphics.h>',
dependencies: quartz_deps)
feature_conf.set('CAIRO_HAS_QUARTZ_CGDISPLAYCOPYCOLORSPACE', 1)
endif
if compiler.has_header('ApplicationServices/ApplicationServices.h')
feature_conf.set('CAIRO_HAS_QUARTZ_APPLICATION_SERVICES', 1)
endif
endif
endif

View file

@ -65,7 +65,9 @@
/* These are private functions */
static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;
#if CAIRO_HAS_QUARTZ_APPLICATION_SERVICES
static ATSFontRef (*FMGetATSFontRefFromFontPtr) (FMFont iFont) = NULL;
#endif
static cairo_bool_t _cairo_quartz_font_symbol_lookup_done = FALSE;
/* Cairo's transformations assume a unit-scaled font. */
@ -92,7 +94,9 @@ quartz_font_ensure_symbols(void)
CGContextGetAllowsFontSmoothingPtr =
dlsym (RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
#if CAIRO_HAS_QUARTZ_APPLICATION_SERVICES
FMGetATSFontRefFromFontPtr = dlsym(RTLD_DEFAULT, "FMGetATSFontRefFromFont");
#endif
_cairo_quartz_font_symbol_lookup_done = TRUE;
}
@ -803,6 +807,8 @@ _cairo_quartz_scaled_font_get_ct_font (cairo_scaled_font_t *abstract_font)
}
}
#if CAIRO_HAS_QUARTZ_APPLICATION_SERVICES
/*
* compat with old ATSUI backend
*/
@ -849,3 +855,4 @@ cairo_atsui_font_face_create_for_atsu_font_id (ATSUFontID font_id)
{
return cairo_quartz_font_face_create_for_atsu_font_id (font_id);
}
#endif

View file

@ -307,7 +307,11 @@ cairo_quartz_image_surface_create (cairo_surface_t *surface)
colorspace = _cairo_quartz_create_color_space (context);
}
else {
#if CAIRO_HAS_QUARTZ_CGDISPLAYCOPYCOLORSPACE
colorspace = CGDisplayCopyColorSpace (CGMainDisplayID ());
#else
colorspace = CGColorSpaceCreateDeviceRGB ();
#endif
}
bitinfo |= format == CAIRO_FORMAT_ARGB32 ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst;

View file

@ -40,8 +40,6 @@
#if CAIRO_HAS_QUARTZ_IMAGE_SURFACE
#include <Carbon/Carbon.h>
CAIRO_BEGIN_DECLS
cairo_public cairo_surface_t *

View file

@ -200,8 +200,11 @@ _cairo_quartz_create_color_space (CGContextRef context)
if (color_space)
return color_space;
}
#if CAIRO_HAS_QUARTZ_CGDISPLAYCOPYCOLORSPACE
if (!color_space)
color_space = CGDisplayCopyColorSpace (CGMainDisplayID ());
#endif
if (!color_space)
color_space = CGColorSpaceCreateDeviceRGB ();

View file

@ -40,7 +40,12 @@
#if CAIRO_HAS_QUARTZ_SURFACE
#include <CoreGraphics/CoreGraphics.h>
#include <CoreText/CoreText.h>
#include <ImageIO/ImageIO.h>
#if CAIRO_HAS_QUARTZ_APPLICATION_SERVICES
#include <ApplicationServices/ApplicationServices.h>
#endif
CAIRO_BEGIN_DECLS
@ -66,8 +71,10 @@ cairo_quartz_surface_get_cg_context (cairo_surface_t *surface);
cairo_public cairo_font_face_t *
cairo_quartz_font_face_create_for_cgfont (CGFontRef font);
#if CAIRO_HAS_QUARTZ_APPLICATION_SERVICES
cairo_public cairo_font_face_t *
cairo_quartz_font_face_create_for_atsu_font_id (ATSUFontID font_id);
#endif
#endif /* CAIRO_HAS_QUARTZ_FONT */