https://bugs.webkit.org/show_bug.cgi?id=132030
Reviewed by Dean Jackson.
Instead of inspecting a font's name to determine if it is a system font,
on OS X we can ask the system directly.
This patch also moves a platform-specific check into platform-specific
code, so that other platforms don't check for OS X-specific behavior.
Covered by existing tests.
* platform/graphics/Font.cpp:
(WebCore::Font::hasValidAverageCharWidth):
* platform/graphics/Font.h:
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::primaryFontDataIsSystemFont):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167724
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-04-23 Myles C. Maxfield <mmaxfield@apple.com>
+
+ [OS X] Make checking if a font is the system font more robust
+ https://bugs.webkit.org/show_bug.cgi?id=132030
+
+ Reviewed by Dean Jackson.
+
+ Instead of inspecting a font's name to determine if it is a system font,
+ on OS X we can ask the system directly.
+
+ This patch also moves a platform-specific check into platform-specific
+ code, so that other platforms don't check for OS X-specific behavior.
+
+ Covered by existing tests.
+
+ * platform/graphics/Font.cpp:
+ (WebCore::Font::hasValidAverageCharWidth):
+ * platform/graphics/Font.h:
+ * platform/graphics/mac/FontMac.mm:
+ (WebCore::Font::primaryFontDataIsSystemFont):
+
2014-04-23 David Hyatt <hyatt@apple.com>
[New Multicolumn] Assertion failure in huge-column-count.html
if (family.isEmpty())
return false;
- // Internal fonts on OS X also have an invalid entry in the table for avgCharWidth.
- // They are hidden by having a name that begins with a period, so simply search
- // for that here rather than try to keep the list up to date.
- if (family.startsWith('.'))
+#if PLATFORM(MAC) || PLATFORM(IOS)
+ // Internal fonts on OS X and iOS also have an invalid entry in the table for avgCharWidth.
+ if (primaryFontDataIsSystemFont())
return false;
+#endif
static HashSet<AtomicString>* fontFamiliesWithInvalidCharWidthMap = 0;
static CodePath characterRangeCodePath(const LChar*, unsigned) { return Simple; }
static CodePath characterRangeCodePath(const UChar*, unsigned len);
+ bool primaryFontDataIsSystemFont() const;
+
private:
enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis };
#endif
#import <wtf/MathExtras.h>
+#if __has_include(<CoreText/CTFontDescriptorPriv.h>)
+#import <CoreText/CTFontDescriptorPriv.h>
+#endif
+extern "C" bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
+
#if ENABLE(LETTERPRESS)
#import "SoftLinking.h"
#if __has_include(<CoreGraphics/CoreGraphicsPrivate.h>)
}
#endif
+bool Font::primaryFontDataIsSystemFont() const
+{
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED > 1090
+ RetainPtr<CTFontDescriptorRef> descriptor = CTFontCopyFontDescriptor(primaryFont()->platformData().ctFont());
+ return CTFontDescriptorIsSystemUIFont(descriptor.get());
+#else
+ // System fonts are hidden by having a name that begins with a period, so simply search
+ // for that here rather than try to keep the list up to date.
+ return firstFamily().startsWith('.');
+#endif
+}
+
}