Title: [94352] trunk
Revision
94352
Author
m...@apple.com
Date
2011-09-01 15:32:43 -0700 (Thu, 01 Sep 2011)

Log Message

<rdar://problem/9528843> STIX glyphs not rendered on this stackoverflow answer
https://bugs.webkit.org/show_bug.cgi?id=67444

Reviewed by Darin Adler.

Source/WebCore: 

Test: fast/text/fallback-traits-fixup.html

After obtaining STIX Regular as a fallback font for some characters, getFontDataForCharacters()
proceeded to ask for a font from the same family having the desired traits and weight (because
wkGetFontInLanguageForRange() does not preserve traits and weight). The returned font was different
and happened to not contain the desired character.

* platform/graphics/mac/FontCacheMac.mm:
(WebCore::FontCache::getFontDataForCharacters): Only ask for a family member with the desired
traits and weight if the substitute font does not already have them, and only use the returned
member if it actually contains the desired character.

LayoutTests: 

* fast/text/fallback-traits-fixup.html: Added.
* platform/mac/fast/text/fallback-traits-fixup-expected.png: Added.
* platform/mac/fast/text/fallback-traits-fixup-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (94351 => 94352)


--- trunk/LayoutTests/ChangeLog	2011-09-01 22:27:53 UTC (rev 94351)
+++ trunk/LayoutTests/ChangeLog	2011-09-01 22:32:43 UTC (rev 94352)
@@ -1,3 +1,14 @@
+2011-09-01  Dan Bernstein  <m...@apple.com>
+
+        <rdar://problem/9528843> STIX glyphs not rendered on this stackoverflow answer
+        https://bugs.webkit.org/show_bug.cgi?id=67444
+
+        Reviewed by Darin Adler.
+
+        * fast/text/fallback-traits-fixup.html: Added.
+        * platform/mac/fast/text/fallback-traits-fixup-expected.png: Added.
+        * platform/mac/fast/text/fallback-traits-fixup-expected.txt: Added.
+
 2011-09-01  James Robinson  <jam...@chromium.org>
 
         [chromium] Update more SVG baselines

Added: trunk/LayoutTests/fast/text/fallback-traits-fixup.html (0 => 94352)


--- trunk/LayoutTests/fast/text/fallback-traits-fixup.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/fallback-traits-fixup.html	2011-09-01 22:32:43 UTC (rev 94352)
@@ -0,0 +1,10 @@
+<p>
+    Test for <i><a href=""
+    STIX glyphs not rendered on this stackoverflow answer</i>.
+</p>
+<p>
+    A black circle: <span style="font-size: xx-large;">&#x26ab;</span>
+</p>
+<p>
+    Another black circle: <span style="font-size: xx-large; font-weight: bold;">&#x26ab;</span>
+</p>

Added: trunk/LayoutTests/platform/mac/fast/text/fallback-traits-fixup-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/text/fallback-traits-fixup-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/text/fallback-traits-fixup-expected.txt (0 => 94352)


--- trunk/LayoutTests/platform/mac/fast/text/fallback-traits-fixup-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/text/fallback-traits-fixup-expected.txt	2011-09-01 22:32:43 UTC (rev 94352)
@@ -0,0 +1,31 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 53x18
+          text run at (0,0) width 53: "Test for "
+        RenderInline {I} at (0,0) size 507x18
+          RenderInline {A} at (0,0) size 154x18 [color=#0000EE]
+            RenderText {#text} at (53,0) size 154x18
+              text run at (53,0) width 154: "rdar://problem/9528843"
+          RenderText {#text} at (207,0) size 353x18
+            text run at (207,0) width 4: " "
+            text run at (211,0) width 349: "STIX glyphs not rendered on this stackoverflow answer"
+        RenderText {#text} at (560,0) size 4x18
+          text run at (560,0) width 4: "."
+      RenderBlock {P} at (0,34) size 784x49
+        RenderText {#text} at (0,20) size 96x18
+          text run at (0,20) width 96: "A black circle: "
+        RenderInline {SPAN} at (0,0) size 24x37
+          RenderText {#text} at (96,5) size 24x37
+            text run at (96,5) width 24: "\x{26AB}"
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {P} at (0,99) size 784x49
+        RenderText {#text} at (0,20) size 136x18
+          text run at (0,20) width 136: "Another black circle: "
+        RenderInline {SPAN} at (0,0) size 25x37
+          RenderText {#text} at (136,5) size 25x37
+            text run at (136,5) width 25: "\x{26AB}"
+        RenderText {#text} at (0,0) size 0x0

Modified: trunk/Source/WebCore/ChangeLog (94351 => 94352)


--- trunk/Source/WebCore/ChangeLog	2011-09-01 22:27:53 UTC (rev 94351)
+++ trunk/Source/WebCore/ChangeLog	2011-09-01 22:32:43 UTC (rev 94352)
@@ -1,3 +1,22 @@
+2011-09-01  Dan Bernstein  <m...@apple.com>
+
+        <rdar://problem/9528843> STIX glyphs not rendered on this stackoverflow answer
+        https://bugs.webkit.org/show_bug.cgi?id=67444
+
+        Reviewed by Darin Adler.
+
+        Test: fast/text/fallback-traits-fixup.html
+
+        After obtaining STIX Regular as a fallback font for some characters, getFontDataForCharacters()
+        proceeded to ask for a font from the same family having the desired traits and weight (because
+        wkGetFontInLanguageForRange() does not preserve traits and weight). The returned font was different
+        and happened to not contain the desired character.
+
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::FontCache::getFontDataForCharacters): Only ask for a family member with the desired
+        traits and weight if the substitute font does not already have them, and only use the returned
+        member if it actually contains the desired character.
+
 2011-09-01  Kentaro Hara  <hara...@google.com>
 
         Generate an XSLTProcessor constructor of V8 using the IDL 'Constructor' extended attribute

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (94351 => 94352)


--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2011-09-01 22:27:53 UTC (rev 94351)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2011-09-01 22:32:43 UTC (rev 94352)
@@ -101,7 +101,9 @@
 
 const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
 {
-    const FontPlatformData& platformData = font.fontDataAt(0)->fontDataForCharacter(characters[0])->platformData();
+    UChar32 character;
+    U16_GET(characters, 0, 0, length, character);
+    const FontPlatformData& platformData = font.fontDataAt(0)->fontDataForCharacter(character)->platformData();
     NSFont *nsFont = platformData.font();
 
     NSString *string = [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(characters) length:length freeWhenDone:NO];
@@ -140,13 +142,21 @@
         size = font.pixelSize();
     }
 
-    if (NSFont *bestVariation = [fontManager fontWithFamily:[substituteFont familyName] traits:traits weight:weight size:size])
-        substituteFont = bestVariation;
+    NSFontTraitMask substituteFontTraits = [fontManager traitsOfFont:substituteFont];
+    NSInteger substituteFontWeight = [fontManager weightOfFont:substituteFont];
 
+    if (traits != substituteFontTraits || weight != substituteFontWeight) {
+        if (NSFont *bestVariation = [fontManager fontWithFamily:[substituteFont familyName] traits:traits weight:weight size:size]) {
+            if (([fontManager traitsOfFont:bestVariation] != substituteFontTraits || [fontManager weightOfFont:bestVariation] != substituteFontWeight)
+                && [[bestVariation coveredCharacterSet] longCharacterIsMember:character])
+                substituteFont = bestVariation;
+        }
+    }
+
     substituteFont = font.fontDescription().usePrinterFont() ? [substituteFont printerFont] : [substituteFont screenFont];
 
-    NSFontTraitMask substituteFontTraits = [fontManager traitsOfFont:substituteFont];
-    NSInteger substituteFontWeight = [fontManager weightOfFont:substituteFont];
+    substituteFontTraits = [fontManager traitsOfFont:substituteFont];
+    substituteFontWeight = [fontManager weightOfFont:substituteFont];
 
     FontPlatformData alternateFont(substituteFont, platformData.size(),
         !font.isPlatformFont() && isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(substituteFontWeight),
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to