diff --git a/modules/juce_graphics/fonts/juce_CustomTypeface.h b/modules/juce_graphics/fonts/juce_CustomTypeface.h index 0acc4f1738..25db68b72f 100644 --- a/modules/juce_graphics/fonts/juce_CustomTypeface.h +++ b/modules/juce_graphics/fonts/juce_CustomTypeface.h @@ -52,6 +52,11 @@ public: /** Loads a typeface from a previously saved stream. The stream must have been created by writeToStream(). + + NOTE! Since this class was written, support was added for loading real font files from + memory, so for most people, using Typeface::createSystemTypefaceFor() to load a real font + is more appropriate than using this class to store it in a proprietary format. + @see writeToStream */ explicit CustomTypeface (InputStream& serialisedTypefaceStream); @@ -116,7 +121,7 @@ public: NOTE! Since this class was written, support was added for loading real font files from memory, so for most people, using Typeface::createSystemTypefaceFor() to load a real font - is more appropriate than using this class to store it in a proprietory format. + is more appropriate than using this class to store it in a proprietary format. */ bool writeToStream (OutputStream& outputStream); diff --git a/modules/juce_graphics/native/juce_mac_Fonts.mm b/modules/juce_graphics/native/juce_mac_Fonts.mm index 7b1ad706e7..81a29a8047 100644 --- a/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -1280,15 +1280,25 @@ Typeface::Ptr Font::getDefaultTypefaceForFont (const Font& font) } #if JUCE_CORETEXT_AVAILABLE -static bool containsNoMemoryTypefaces (const AttributedString& text) +static bool canAllTypefacesBeUsedInLayout (const AttributedString& text) { const int numCharacterAttributes = text.getNumAttributes(); for (int i = 0; i < numCharacterAttributes; ++i) + { if (const Font* const f = text.getAttribute (i)->getFont()) + { if (OSXTypeface* tf = dynamic_cast (f->getTypeface())) + { if (tf->isMemoryFont) return false; + } + else if (dynamic_cast (f->getTypeface()) != nullptr) + { + return false; + } + } + } return true; } @@ -1299,7 +1309,7 @@ bool TextLayout::createNativeLayout (const AttributedString& text) #if JUCE_CORETEXT_AVAILABLE // Seems to be an unfathomable bug in CoreText which prevents the layout working with // typefaces that were loaded from memory, so have to fallback if we hit any of those.. - if (containsNoMemoryTypefaces (text)) + if (canAllTypefacesBeUsedInLayout (text)) { CoreTextTypeLayout::createLayout (*this, text); return true;