summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Pino Garcia <dpino@igalia.com>2024-01-15 14:30:51 +0100
committerDiego Pino Garcia <dpino@igalia.com>2024-01-17 09:07:12 +0100
commitbd6aa966df0a593b44830582b2e2b1f160768295 (patch)
tree3a085ee0ebf31109173d67ee74f139af99e61e12
parent10fffac83c576f5aeba7d804e39470b4a88b79dc (diff)
[quartz] Fix: Cairo 1.18.0 doesn't draw italic or bold text on Mac
Commit cf351a8a attempted to convert the font generation in '_cairo_quartz_font_create_for_toy' to use CTFontCreateWithName and that uses only Postscript Names, meaning with the hyphens. Commit c6dc5df6 converted back to CGFont. CGFontCreateWithFontName is supposed to work with Postscript Names, but it seems sometimes it does not. In case a CGFont cannot be created using Postscript Names, attempt unhyphenated version of font family name.
-rw-r--r--src/cairo-quartz-font.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c
index 621d3540c..b7efc54de 100644
--- a/src/cairo-quartz-font.c
+++ b/src/cairo-quartz-font.c
@@ -165,6 +165,17 @@ _cairo_quartz_font_face_create_for_toy (cairo_toy_font_face_t *toy_face,
cgFont = CGFontCreateWithFontName (FontName);
CFRelease (FontName);
+ if (!cgFont) {
+ /* Attempt to create font by replacing hyphens for spaces in font name. */
+ for (size_t i = 0; i < strlen (full_name); i++) {
+ if (full_name[i] == '-')
+ full_name[i] = ' ';
+ }
+ FontName = CFStringCreateWithCString (NULL, full_name, kCFStringEncodingASCII);
+ cgFont = CGFontCreateWithFontName (FontName);
+ CFRelease (FontName);
+ }
+
if (cgFont)
break;
}