Skip to content

Commit

Permalink
8234916: [macos 10.15] Garbled text running with native-image
Browse files Browse the repository at this point in the history
  • Loading branch information
mrserb authored and benty-amzn committed Oct 7, 2021
1 parent c391000 commit c92a40e
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 4ddf55428d06dddadfc8cd14baabdc4d17318ee2 Mon Sep 17 00:00:00 2001
From: Jose Pereda <[email protected]>
Date: Thu, 5 Dec 2019 20:13:53 +0000
Subject: [PATCH] 8234916: [macos 10.15] Garbled text running with native-image

Reviewed-by: prr
---
.../graphics/src/main/native-font/coretext.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/modules/graphics/src/main/native-font/coretext.c b/modules/graphics/src/main/native-font/coretext.c
index d84ba0fc1d..f02c626532 100644
--- a/modules/graphics/src/main/native-font/coretext.c
+++ b/modules/graphics/src/main/native-font/coretext.c
@@ -388,7 +388,15 @@ JNIEXPORT jlong JNICALL OS_NATIVE(CTFontCreateWithName)
CGAffineTransform _arg2, *lparg2=NULL;
jlong rc = 0;
if (arg2) if ((lparg2 = getCGAffineTransformFields(env, arg2, &_arg2)) == NULL) goto fail;
- rc = (jlong)CTFontCreateWithName((CFStringRef)arg0, (CGFloat)arg1, (CGAffineTransform*)lparg2);
+ CFStringRef fontName = (CFStringRef)arg0;
+ if (CFStringGetCharacterAtIndex(fontName, 0) == '.') {
+ bool bold = CFStringFind(fontName, CFSTR("bold"), kCFCompareCaseInsensitive).location != kCFNotFound;
+ CTFontRef font = CTFontCreateUIFontForLanguage(bold ? kCTFontUIFontEmphasizedSystem : kCTFontUIFontSystem, 0.0, NULL);
+ rc = (jlong) CTFontCreateCopyWithAttributes(font, (CGFloat)arg1, (CGAffineTransform*)lparg2, NULL);
+ CFRelease(font);
+ } else {
+ rc = (jlong) CTFontCreateWithName(fontName, (CGFloat)arg1, (CGAffineTransform*)lparg2);
+ }
fail:
/* In only */
// if (arg2 && lparg2) setCGAffineTransformFields(env, arg2, lparg2);
--
2.30.1 (Apple Git-130)

0 comments on commit c92a40e

Please sign in to comment.