[OS X] Glyph spacing for system fonts may be incorrect
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Apr 2014 20:38:00 +0000 (20:38 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Apr 2014 20:38:00 +0000 (20:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131967

Reviewed by Simon Fraser.

Source/WebCore:
Covered by existing tests.

* platform/graphics/mac/SimpleFontDataMac.mm:
(WebCore::SimpleFontData::platformWidthForGlyph): Update to use CTFontGetAdvancesForGlyphs() for system fonts
(WebCore::hasCustomTracking):

LayoutTests:
Updating test to be more robust.

* fast/forms/search/intrinsic-search-width-with-decoration-border-padding-expected.txt:
* fast/forms/search/intrinsic-search-width-with-decoration-border-padding.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167679 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/search/intrinsic-search-width-with-decoration-border-padding-expected.txt
LayoutTests/fast/forms/search/intrinsic-search-width-with-decoration-border-padding.html
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm

index fd570855a0a1dfbc75ddbd67543eb864868c9a21..34af15bc472c209d8ed5609c474a343a5a2562c8 100644 (file)
@@ -1,3 +1,15 @@
+2014-04-21  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [OS X] Glyph spacing for system fonts may be incorrect
+        https://bugs.webkit.org/show_bug.cgi?id=131967
+
+        Reviewed by Simon Fraser.
+
+        Updating test to be more robust.
+
+        * fast/forms/search/intrinsic-search-width-with-decoration-border-padding-expected.txt:
+        * fast/forms/search/intrinsic-search-width-with-decoration-border-padding.html:
+
 2014-04-22  Manuel Rego Casasnovas  <rego@igalia.com>
 
         REGRESSION (r167652): Broke fast/regions/cssom/region-range-for-box-crash.html in debug mode
index 494580df5fb06bbf463e27be0a89259d4441977b..05242ac47286892fc6ff8c2205d3d462c1416807 100644 (file)
@@ -13,6 +13,7 @@
 <script src="../../../resources/js-test-pre.js"></script>
 
 <input type="search" id="search1">
+<br/>
 <input type="search" id="search2">
 <script>
 shouldBe('document.getElementById("search1").offsetWidth', 'document.getElementById("search2").offsetWidth');
index 0a8394710c86afcd18b20b94930de23031016e9c..5575a5ea891d6837f88b6c64d6c67109485611c7 100644 (file)
@@ -1,3 +1,16 @@
+2014-04-21  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [OS X] Glyph spacing for system fonts may be incorrect
+        https://bugs.webkit.org/show_bug.cgi?id=131967
+
+        Reviewed by Simon Fraser.
+
+        Covered by existing tests.
+
+        * platform/graphics/mac/SimpleFontDataMac.mm:
+        (WebCore::SimpleFontData::platformWidthForGlyph): Update to use CTFontGetAdvancesForGlyphs() for system fonts
+        (WebCore::hasCustomTracking):
+
 2014-04-22  David Hyatt  <hyatt@apple.com>
 
         [New Multicolumn] widows/orphans cause assertion failures.
index 2640cc47958828ab528dc41aa8593465946b5e2e..f45d903b85fb8a6762f2e4a02e95a903376412fe 100644 (file)
 #import <wtf/StdLibExtras.h>
 #import <wtf/RetainPtr.h>
 
+#if defined(__has_include) && __has_include(<CoreText/CTFontDescriptorPriv.h>)
+#import <CoreText/CTFontDescriptorPriv.h>
+#endif
+
+extern "C" bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
+
 #if !PLATFORM(IOS)
 @interface NSFont (WebAppKitSecretAPI)
 - (BOOL)_isFakeFixedPitch;
@@ -359,11 +365,23 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
     return boundingBox;
 }
 
+static bool hasCustomTracking(CTFontRef font)
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090
+    UNUSED_PARAM(font);
+    return false;
+#else
+    RetainPtr<CTFontDescriptorRef> descriptor = CTFontCopyFontDescriptor(font);
+    return CTFontDescriptorIsSystemUIFont(descriptor.get())
+#endif
+}
+
 #if !PLATFORM(IOS)
 float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
 {
     CGSize advance = CGSizeZero;
-    if (platformData().orientation() == Horizontal || m_isBrokenIdeographFallback) {
+    bool horizontal = platformData().orientation() == Horizontal;
+    if ((horizontal || m_isBrokenIdeographFallback) && !hasCustomTracking(m_platformData.ctFont())) {
         NSFont *font = platformData().font();
         if (font && platformData().isColorBitmapFont())
             advance = NSSizeToCGSize([font advancementForGlyph:glyph]);
@@ -376,7 +394,7 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
             }
         }
     } else
-        CTFontGetAdvancesForGlyphs(m_platformData.ctFont(), kCTFontVerticalOrientation, &glyph, &advance, 1);
+        CTFontGetAdvancesForGlyphs(m_platformData.ctFont(), horizontal ? kCTFontHorizontalOrientation : kCTFontVerticalOrientation, &glyph, &advance, 1);
 
     return advance.width + m_syntheticBoldOffset;
 }