Title: [167713] trunk/Source/WebCore
- Revision
- 167713
- Author
- mmaxfi...@apple.com
- Date
- 2014-04-23 10:49:40 -0700 (Wed, 23 Apr 2014)
Log Message
[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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (167712 => 167713)
--- trunk/Source/WebCore/ChangeLog 2014-04-23 16:44:13 UTC (rev 167712)
+++ trunk/Source/WebCore/ChangeLog 2014-04-23 17:49:40 UTC (rev 167713)
@@ -1,3 +1,24 @@
+2014-04-22 Myles C. Maxfield <mmaxfi...@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 Philippe Normand <pnorm...@igalia.com>
[GTK] Focus management API was moved from HTMLDocument to Document in r166668
Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (167712 => 167713)
--- trunk/Source/WebCore/platform/graphics/Font.cpp 2014-04-23 16:44:13 UTC (rev 167712)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp 2014-04-23 17:49:40 UTC (rev 167713)
@@ -481,11 +481,11 @@
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;
Modified: trunk/Source/WebCore/platform/graphics/Font.h (167712 => 167713)
--- trunk/Source/WebCore/platform/graphics/Font.h 2014-04-23 16:44:13 UTC (rev 167712)
+++ trunk/Source/WebCore/platform/graphics/Font.h 2014-04-23 17:49:40 UTC (rev 167713)
@@ -188,6 +188,8 @@
CodePath codePath(const TextRun&) const;
static CodePath characterRangeCodePath(const LChar*, unsigned) { return Simple; }
static CodePath characterRangeCodePath(const UChar*, unsigned len);
+
+ bool primaryFontDataIsSystemFont() const;
private:
enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis };
Modified: trunk/Source/WebCore/platform/graphics/mac/FontMac.mm (167712 => 167713)
--- trunk/Source/WebCore/platform/graphics/mac/FontMac.mm 2014-04-23 16:44:13 UTC (rev 167712)
+++ trunk/Source/WebCore/platform/graphics/mac/FontMac.mm 2014-04-23 17:49:40 UTC (rev 167713)
@@ -34,6 +34,11 @@
#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>)
@@ -535,4 +540,14 @@
}
#endif
+bool Font::primaryFontDataIsSystemFont() const
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ RetainPtr<CTFontDescriptorRef> descriptor = CTFontCopyFontDescriptor(primaryFont()->platformData().ctFont());
+ return CTFontDescriptorIsSystemUIFont(descriptor.get());
+#else
+ return false;
+#endif
}
+
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes