Title: [185632] trunk
Revision
185632
Author
mmaxfi...@apple.com
Date
2015-06-16 18:26:22 -0700 (Tue, 16 Jun 2015)

Log Message

Source/WebCore:
REGRESSION(r184899): [Cocoa] font-variant: small-caps is not honored with web fonts
https://bugs.webkit.org/show_bug.cgi?id=145873
<rdar://problem/21314282>

Reviewed by Dean Jackson.

When font-variant: small-caps is applied, we create a smaller version of the original font
and draw capital characters in that smaller font. CGFontRefs do not have an intrinsic size,
and web fonts historically only had a CGFontRef, which means that there was no need to
convert the CGFontRef to be smaller (as opposed to regular fonts, which had a CTFontRef and
therefore needed the conversion). Instead, we just changed m_size, which represents
the size that the text should be drawn in.

However, r184899 gave CTFontRefs to web fonts. This means that now the FontPlatformData's
m_size variable disagreed with the CTFontRef member. The solution here is to unify the web
font and regular font codepaths, and treat them the same throughout.

Note that this patch removes the last use of the m_isCustomFont variable. As soon as we
entirely migrate to CORETEXT_WEB_FONTS, we should delete this variable.

Test: fast/text/small-caps-web-font.html

* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::Font::platformCreateScaledFont): Treat web fonts the same as regular fonts.
* platform/text/TextFlags.h: Add a comment regarding teh deletion of m_isCustomFont.

LayoutTests:
font-variant: small-caps is not honored with web fonts
https://bugs.webkit.org/show_bug.cgi?id=145873
<rdar://problem/21314282>

Reviewed by Dean Jackson.

* fast/text/small-caps-web-font-expected.html: Added.
* fast/text/small-caps-web-font.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (185631 => 185632)


--- trunk/LayoutTests/ChangeLog	2015-06-17 01:06:56 UTC (rev 185631)
+++ trunk/LayoutTests/ChangeLog	2015-06-17 01:26:22 UTC (rev 185632)
@@ -1,3 +1,14 @@
+2015-06-16  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        font-variant: small-caps is not honored with web fonts
+        https://bugs.webkit.org/show_bug.cgi?id=145873
+        <rdar://problem/21314282>
+
+        Reviewed by Dean Jackson.
+
+        * fast/text/small-caps-web-font-expected.html: Added.
+        * fast/text/small-caps-web-font.html: Added.
+
 2015-06-16  Michael Saboff  <msab...@apple.com>
 
         Inlining in the DFG trashes ByteCodeParser::m_currentInstruction for the calling function

Added: trunk/LayoutTests/fast/text/small-caps-web-font-expected.html (0 => 185632)


--- trunk/LayoutTests/fast/text/small-caps-web-font-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/small-caps-web-font-expected.html	2015-06-17 01:26:22 UTC (rev 185632)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "WebAhem";
+    src: url("../../resources/Ahem.ttf") format(truetype);
+}
+</style>
+</head>
+<body>
+This test makes sure that small-caps works with webfonts. This test passes if
+there are two black rectangles below which butt up against each other.
+<div style="font: 100px WebAhem;">A<span style="font-size: 70px;">bcdefg</span></div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/small-caps-web-font.html (0 => 185632)


--- trunk/LayoutTests/fast/text/small-caps-web-font.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/small-caps-web-font.html	2015-06-17 01:26:22 UTC (rev 185632)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "WebAhem";
+    src: url("../../resources/Ahem.ttf") format(truetype);
+}
+</style>
+</head>
+<body>
+This test makes sure that small-caps works with webfonts. This test passes if
+there are two black rectangles below which butt up against each other.
+<div style="font: 100px WebAhem; font-variant: small-caps;">Abcdefg</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (185631 => 185632)


--- trunk/Source/WebCore/ChangeLog	2015-06-17 01:06:56 UTC (rev 185631)
+++ trunk/Source/WebCore/ChangeLog	2015-06-17 01:26:22 UTC (rev 185632)
@@ -1,3 +1,31 @@
+2015-06-16  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        REGRESSION(r184899): [Cocoa] font-variant: small-caps is not honored with web fonts
+        https://bugs.webkit.org/show_bug.cgi?id=145873
+        <rdar://problem/21314282>
+
+        Reviewed by Dean Jackson.
+
+        When font-variant: small-caps is applied, we create a smaller version of the original font
+        and draw capital characters in that smaller font. CGFontRefs do not have an intrinsic size,
+        and web fonts historically only had a CGFontRef, which means that there was no need to
+        convert the CGFontRef to be smaller (as opposed to regular fonts, which had a CTFontRef and
+        therefore needed the conversion). Instead, we just changed m_size, which represents
+        the size that the text should be drawn in.
+
+        However, r184899 gave CTFontRefs to web fonts. This means that now the FontPlatformData's
+        m_size variable disagreed with the CTFontRef member. The solution here is to unify the web
+        font and regular font codepaths, and treat them the same throughout.
+
+        Note that this patch removes the last use of the m_isCustomFont variable. As soon as we
+        entirely migrate to CORETEXT_WEB_FONTS, we should delete this variable.
+
+        Test: fast/text/small-caps-web-font.html
+
+        * platform/graphics/cocoa/FontCocoa.mm:
+        (WebCore::Font::platformCreateScaledFont): Treat web fonts the same as regular fonts.
+        * platform/text/TextFlags.h: Add a comment regarding teh deletion of m_isCustomFont.
+
 2015-06-16  Alex Christensen  <achristen...@webkit.org>
 
         [Content Extensions] Implement branch compaction for DFA bytecode.

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (185631 => 185632)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm	2015-06-17 01:06:56 UTC (rev 185631)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm	2015-06-17 01:26:22 UTC (rev 185632)
@@ -311,11 +311,13 @@
 
 PassRefPtr<Font> Font::platformCreateScaledFont(const FontDescription&, float scaleFactor) const
 {
+#if !CORETEXT_WEB_FONTS
     if (isCustomFont()) {
         FontPlatformData scaledFontData(m_platformData);
         scaledFontData.m_size = scaledFontData.m_size * scaleFactor;
         return Font::create(scaledFontData, true, false);
     }
+#endif
 
     float size = m_platformData.size() * scaleFactor;
 

Modified: trunk/Source/WebCore/platform/text/TextFlags.h (185631 => 185632)


--- trunk/Source/WebCore/platform/text/TextFlags.h	2015-06-17 01:06:56 UTC (rev 185631)
+++ trunk/Source/WebCore/platform/text/TextFlags.h	2015-06-17 01:26:22 UTC (rev 185632)
@@ -27,6 +27,8 @@
 #define TextFlags_h
 
 // <rdar://problem/16980736>: Web fonts crash on certain OSes when using CTFontManagerCreateFontDescriptorFromData()
+// FIXME: When we have moved entirely to CORETEXT_WEB_FONTS, remove the isCustomFont member variable from Font, since it will no longer be used.
+// See https://bug-145873-attachments.webkit.org/attachment.cgi?id=254710
 #if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 80000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101000)
 #define CORETEXT_WEB_FONTS 0
 #else
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to