Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8234916: [macos 10.15] Garbled text running with native-image #335

Merged
merged 1 commit into from
Oct 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 <jpereda@openjdk.org>
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)