Suggestion: Add JUCE_USE_CORETEXT to AppConfig.h


#1

I ran into a problem when using TextLayout with an embedded font not installed as a system font. Instead of using the embedded font it would use Lucida Grande in TextLayout::Draw.

I tracked this problem down to TextLayout::createLayout which contains the following code.

if (! createNativeLayout (text)) createStandardLayout (text);
createNativeLayout uses CoreText and from what I can tell CoreText cannot find the font I request and ends up substituting it with Lucida Grande.

If I force TextLayout::createLayout to use createStandardLayout, the embedded font is used correctly.

TextLayout::createNativeLayout in juce_mac_Fonts.mm looks like this.

bool TextLayout::createNativeLayout (const AttributedString& text) { #if JUCE_CORETEXT_AVAILABLE CoreTextTypeLayout::createLayout (*this, text); return true; #else (void) text; return false; #endif }
and JUCE_CORETEXT_AVAILABLE is defined as

#if JUCE_IOS || (JUCE_MAC && MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4) #define JUCE_CORETEXT_AVAILABLE 1 #endif
If this could be changed to something like

#if JUCE_USE_CORETEXT && (JUCE_IOS || (JUCE_MAC && MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4)) #define JUCE_CORETEXT_AVAILABLE 1 #endif
And JUCE_USE_CORETEXT could be added to AppConfig.h, then I could disable the CoreText behaviour without having to patch TextLayout::createLayout.


#2

Ok, it doesn’t require a new flag with a different name, but I’ve made it so that you can define JUCE_CORETEXT_AVAILABLE to 0 if you want to, without it overriding that.


#3

Thanks!