JBR-1756 use CoreText for all font rendering on Catalina

This commit is contained in:
Dennis Ushakov
2019-08-15 19:34:12 +03:00
committed by jbrbot
parent eb654b3972
commit 6b508f82b4
2 changed files with 18 additions and 6 deletions

View File

@@ -58,8 +58,17 @@ extern jint* gButtonDownMasks;
#define kCFCoreFoundationVersionNumber10_13_Max 1499
#endif
#ifndef kCFCoreFoundationVersionNumber10_14_Max
#define kCFCoreFoundationVersionNumber10_14_Max 1599
#endif
#ifndef IS_OSX_GT10_13
#define IS_OSX_GT10_13 (floor(kCFCoreFoundationVersionNumber) > \
kCFCoreFoundationVersionNumber10_13_Max)
#endif
#ifndef IS_OSX_GT10_14
#define IS_OSX_GT10_14 (floor(kCFCoreFoundationVersionNumber) > \
kCFCoreFoundationVersionNumber10_14_Max)
#endif

View File

@@ -31,6 +31,7 @@
#import "fontscalerdefs.h" // contains the definition of GlyphInfo struct
#import "sun_awt_SunHints.h"
#import "LWCToolkit.h"
//#define USE_IMAGE_ALIGNED_MEMORY 1
//#define CGGI_DEBUG 1
@@ -611,7 +612,7 @@ CGGI_CreateNewGlyphInfoFrom(CGSize advance, CGRect bbox,
static inline void
CGGI_CreateImageForGlyph
(CGGI_GlyphCanvas *canvas, const CGGlyph glyph,
GlyphInfo *info, const CGGI_GlyphInfoDescriptor *glyphDescriptor, const AWTStrike *strike, CTFontRef font)
GlyphInfo *info, const CGGI_GlyphInfoDescriptor *glyphDescriptor, const AWTStrike *strike, CTFontRef font, const bool isCatalinaOrAbove)
{
if (isnan(info->topLeftX) || isnan(info->topLeftY)) {
// Explicitly set glyphInfo width/height to be 0 to ensure
@@ -631,7 +632,7 @@ CGGI_CreateImageForGlyph
CGFloat x = -info->topLeftX;
CGFloat y = canvas->image->height + info->topLeftY;
if (glyphDescriptor == &argb) {
if (isCatalinaOrAbove || glyphDescriptor == &argb) {
// Emoji glyphs are not rendered by CGContextShowGlyphsAtPoint.
// Also, it's not possible to use transformation matrix to get the emoji glyph
// rendered for the desired font size - actual-size font object is needed.
@@ -670,7 +671,8 @@ CGGI_CreateImageForGlyph
static inline GlyphInfo *
CGGI_CreateImageForUnicode
(CGGI_GlyphCanvas *canvas, const AWTStrike *strike,
const CGGI_RenderingMode *mode, const UnicodeScalarValue uniChar)
const CGGI_RenderingMode *mode, const UnicodeScalarValue uniChar,
const bool isCatalinaOrAbove)
{
// save the state of the world
CGContextSaveGState(canvas->context);
@@ -713,7 +715,7 @@ CGGI_CreateImageForUnicode
CFRelease(cgFallback);
// clean the canvas - align, strike, and copy the glyph from the canvas into the info
CGGI_CreateImageForGlyph(canvas, glyph, info, glyphDescriptor, strike, fallback);
CGGI_CreateImageForGlyph(canvas, glyph, info, glyphDescriptor, strike, fallback, isCatalinaOrAbove);
// restore the state of the world
CGContextRestoreGState(canvas->context);
@@ -759,13 +761,14 @@ CGGI_FillImagesForGlyphsWithSizedCanvas(CGGI_GlyphCanvas *canvas,
CTFontRef mainFont = (CTFontRef)strike->fAWTFont->fFont;
CGGI_GlyphInfoDescriptor* mainFontDescriptor = CGGI_GetGlyphInfoDescriptor(mode, mainFont);
const bool isCatalinaOrAbove = IS_OSX_GT10_14;
CFIndex i;
for (i = 0; i < len; i++) {
GlyphInfo *info = (GlyphInfo *)jlong_to_ptr(glyphInfos[i]);
if (info != NULL) {
CGGI_CreateImageForGlyph(canvas, glyphs[i], info, mainFontDescriptor, strike, mainFont);
CGGI_CreateImageForGlyph(canvas, glyphs[i], info, mainFontDescriptor, strike, mainFont, isCatalinaOrAbove);
} else {
info = CGGI_CreateImageForUnicode(canvas, strike, mode, uniChars[i]);
info = CGGI_CreateImageForUnicode(canvas, strike, mode, uniChars[i], isCatalinaOrAbove);
glyphInfos[i] = ptr_to_jlong(info);
}
#ifdef CGGI_DEBUG