Title: [226839] trunk
Revision
226839
Author
mmaxfi...@apple.com
Date
2018-01-11 19:16:52 -0800 (Thu, 11 Jan 2018)

Log Message

[Cocoa] Star character disappears when bolded
https://bugs.webkit.org/show_bug.cgi?id=181568
<rdar://problem/18755569>

Reviewed by Simon Fraser.

Source/WebCore:

We had some code in ComplexTextController to ask the FontCache for a font, given the name
of a particular font CoreText used inside a CTRun. This is wrong for two reasons: fonts
are not identifiable by PostScript name (in the general case), and because the lookup
procedure requires a FontDescription, the result may yield a font that is not the one
looked up. The goal of this code was simply to preserve the rendering mode of the font,
but we removed support for these rendering modes years ago. So the solution is to skip
that lookup and use the CoreText font directly.

Test: fast/text/unknown-font.html

* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):

LayoutTests:

* fast/text/unknown-font-expected-mismatch.html: Added.
* fast/text/unknown-font.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (226838 => 226839)


--- trunk/LayoutTests/ChangeLog	2018-01-12 03:13:05 UTC (rev 226838)
+++ trunk/LayoutTests/ChangeLog	2018-01-12 03:16:52 UTC (rev 226839)
@@ -1,3 +1,14 @@
+2018-01-11  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] Star character disappears when bolded
+        https://bugs.webkit.org/show_bug.cgi?id=181568
+        <rdar://problem/18755569>
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/unknown-font-expected-mismatch.html: Added.
+        * fast/text/unknown-font.html: Added.
+
 2018-01-11  James Craig  <jcr...@apple.com>
 
         AX: when invert colors is on, double-invert video elements in UserAgentStyleSheet

Added: trunk/LayoutTests/fast/text/unknown-font-expected-mismatch.html (0 => 226839)


--- trunk/LayoutTests/fast/text/unknown-font-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/unknown-font-expected-mismatch.html	2018-01-12 03:16:52 UTC (rev 226839)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/unknown-font.html (0 => 226839)


--- trunk/LayoutTests/fast/text/unknown-font.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/unknown-font.html	2018-01-12 03:16:52 UTC (rev 226839)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<div style="font-size: 100px; font-weight: bold;">⭐︎</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (226838 => 226839)


--- trunk/Source/WebCore/ChangeLog	2018-01-12 03:13:05 UTC (rev 226838)
+++ trunk/Source/WebCore/ChangeLog	2018-01-12 03:16:52 UTC (rev 226839)
@@ -1,3 +1,24 @@
+2018-01-11  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] Star character disappears when bolded
+        https://bugs.webkit.org/show_bug.cgi?id=181568
+        <rdar://problem/18755569>
+
+        Reviewed by Simon Fraser.
+
+        We had some code in ComplexTextController to ask the FontCache for a font, given the name
+        of a particular font CoreText used inside a CTRun. This is wrong for two reasons: fonts
+        are not identifiable by PostScript name (in the general case), and because the lookup
+        procedure requires a FontDescription, the result may yield a font that is not the one
+        looked up. The goal of this code was simply to preserve the rendering mode of the font,
+        but we removed support for these rendering modes years ago. So the solution is to skip
+        that lookup and use the CoreText font directly.
+
+        Test: fast/text/unknown-font.html
+
+        * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
+
 2018-01-11  Keith Rollin  <krol...@apple.com>
 
         Add optional logging of ITP-related user interaction information

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm (226838 => 226839)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2018-01-12 03:13:05 UTC (rev 226838)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2018-01-12 03:16:52 UTC (rev 226839)
@@ -248,7 +248,6 @@
             RetainPtr<CFTypeRef> runFontEqualityObject = FontPlatformData::objectForEqualityCheck(runCTFont);
             if (!safeCFEqual(runFontEqualityObject.get(), font->platformData().objectForEqualityCheck().get())) {
                 // Begin trying to see if runFont matches any of the fonts in the fallback list.
-
                 for (unsigned i = 0; !m_font.fallbackRangesAt(i).isNull(); ++i) {
                     runFont = m_font.fallbackRangesAt(i).fontForCharacter(baseCharacter);
                     if (!runFont)
@@ -257,24 +256,14 @@
                         break;
                     runFont = nullptr;
                 }
-                // If there is no matching font, look up by name in the font cache.
                 if (!runFont) {
-                    // Rather than using runFont as an NSFont and wrapping it in a FontPlatformData, go through
-                    // the font cache and ultimately through NSFontManager in order to get an NSFont with the right
-                    // NSFontRenderingMode.
                     RetainPtr<CFStringRef> fontName = adoptCF(CTFontCopyPostScriptName(runCTFont));
                     if (CFEqual(fontName.get(), CFSTR("LastResort"))) {
                         m_complexTextRuns.append(ComplexTextRun::create(m_font.primaryFont(), cp, stringLocation, length, runRange.location, runRange.location + runRange.length, m_run.ltr()));
                         continue;
                     }
-                    auto& fontCache = FontCache::singleton();
-                    runFont = fontCache.fontForFamily(m_font.fontDescription(), fontName.get()).get();
-                    // Core Text may have used a font that our font lookup path cannot find. In that case, fall back on
-                    // using the font as returned.
-                    if (!runFont) {
-                        FontPlatformData runFontPlatformData(runCTFont, CTFontGetSize(runCTFont));
-                        runFont = fontCache.fontForPlatformData(runFontPlatformData).ptr();
-                    }
+                    FontPlatformData runFontPlatformData(runCTFont, CTFontGetSize(runCTFont));
+                    runFont = FontCache::singleton().fontForPlatformData(runFontPlatformData).ptr();
                 }
                 if (m_fallbackFonts && runFont != &m_font.primaryFont())
                     m_fallbackFonts->add(runFont);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to