Title: [176372] trunk
Revision
176372
Author
[email protected]
Date
2014-11-19 17:35:09 -0800 (Wed, 19 Nov 2014)

Log Message

[OS X] Upright vertical text is completely broken for multi-code-unit codepoints
https://bugs.webkit.org/show_bug.cgi?id=138891

Reviewed by Dan Bernstein.

Source/WebCore:

We were assuming that we can use the string index (in UTF-16) as the glyph
index. This falls down when a single codepoint (and glyph) contians
multiple code units.

Test: platform/mac/fast/text/multiple-codeunit-vertical-upright.html

* platform/graphics/GlyphPage.h:
* platform/graphics/mac/GlyphPageTreeNodeMac.cpp:
(WebCore::GlyphPage::fill):

LayoutTests:

Make sure a single upright vertical multi-code-unit codepoint is rendered the same as
the same codepoint rendered horizontally.

* platform/mac/fast/text/multiple-codeunit-vertical-upright-expected.html: Added.
* platform/mac/fast/text/multiple-codeunit-vertical-upright.html: Added.
* platform/mac/fast/text/resources/multiple-codeunit-vertical-upright.otf: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (176371 => 176372)


--- trunk/LayoutTests/ChangeLog	2014-11-20 01:23:38 UTC (rev 176371)
+++ trunk/LayoutTests/ChangeLog	2014-11-20 01:35:09 UTC (rev 176372)
@@ -1,3 +1,17 @@
+2014-11-19  Myles C. Maxfield  <[email protected]>
+
+        [OS X] Upright vertical text is completely broken for multi-code-unit codepoints
+        https://bugs.webkit.org/show_bug.cgi?id=138891
+
+        Reviewed by Dan Bernstein.
+
+        Make sure a single upright vertical multi-code-unit codepoint is rendered the same as
+        the same codepoint rendered horizontally.
+
+        * platform/mac/fast/text/multiple-codeunit-vertical-upright-expected.html: Added.
+        * platform/mac/fast/text/multiple-codeunit-vertical-upright.html: Added.
+        * platform/mac/fast/text/resources/multiple-codeunit-vertical-upright.otf: Added.
+
 2014-11-16  Sam Weinig  <[email protected]>
 
         Move the 'quotes' CSS property to the new StyleBuilder

Added: trunk/LayoutTests/platform/mac/fast/text/multiple-codeunit-vertical-upright-expected.html (0 => 176372)


--- trunk/LayoutTests/platform/mac/fast/text/multiple-codeunit-vertical-upright-expected.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/text/multiple-codeunit-vertical-upright-expected.html	2014-11-20 01:35:09 UTC (rev 176372)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "Litherum";
+    src: url("resources/multiple-codeunit-vertical-upright.otf") format("opentype");
+}
+</style>
+</head>
+<body style="-webkit-font-smoothing: none;">
+<div style="font: 96px Litherum; position: relative; left: 3.5px; top: 1px;">&#x2000b;</div>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac/fast/text/multiple-codeunit-vertical-upright.html (0 => 176372)


--- trunk/LayoutTests/platform/mac/fast/text/multiple-codeunit-vertical-upright.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/text/multiple-codeunit-vertical-upright.html	2014-11-20 01:35:09 UTC (rev 176372)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "Litherum";
+    src: url("resources/multiple-codeunit-vertical-upright.otf") format("opentype");
+}
+</style>
+</head>
+<body style="-webkit-font-smoothing: none;">
+<div style="font: 96px Litherum; -webkit-writing-mode: vertical-rl; -webkit-text-orientation: upright;">&#x2000b;</div>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac/fast/text/resources/multiple-codeunit-vertical-upright.otf (0 => 176372)


--- trunk/LayoutTests/platform/mac/fast/text/resources/multiple-codeunit-vertical-upright.otf	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/text/resources/multiple-codeunit-vertical-upright.otf	2014-11-20 01:35:09 UTC (rev 176372)
@@ -0,0 +1,4 @@
+OTTO\x80`CFF :\x92\xDA\xEC\xBFGSUBU\xAC\xA8OS/2PW\BTDVORG\x98cmapQ\xA04head\xECA\xDAa\xD46hhea;
+/$hmtx0kern\xFF8&maxp\xFE` name\x80post\x94 vheas\xB4$vmtx\xD8.\x87\x87\xC8\xF4TWZ\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xF4\xFF\xC8\xFF\xFF\xFF\xFE\xFF\xFF8\xFF
+$Varabfinamedi init&rlig,
+" "$&TKBW\xFF\xFF(\xE2C\\xD9_<\xF5\xC8\xF4f8\xC8\xFF\xFA\xFF\xFA\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFEf
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (176371 => 176372)


--- trunk/Source/WebCore/ChangeLog	2014-11-20 01:23:38 UTC (rev 176371)
+++ trunk/Source/WebCore/ChangeLog	2014-11-20 01:35:09 UTC (rev 176372)
@@ -1,3 +1,20 @@
+2014-11-19  Myles C. Maxfield  <[email protected]>
+
+        [OS X] Upright vertical text is completely broken for multi-code-unit codepoints
+        https://bugs.webkit.org/show_bug.cgi?id=138891
+
+        Reviewed by Dan Bernstein.
+
+        We were assuming that we can use the string index (in UTF-16) as the glyph
+        index. This falls down when a single codepoint (and glyph) contians
+        multiple code units.
+
+        Test: platform/mac/fast/text/multiple-codeunit-vertical-upright.html
+
+        * platform/graphics/GlyphPage.h:
+        * platform/graphics/mac/GlyphPageTreeNodeMac.cpp:
+        (WebCore::GlyphPage::fill):
+
 2014-11-19  Daniel Bates  <[email protected]>
 
         Attempt to fix the Apple Internal Mavericks build after <https://trac.webkit.org/changeset/176347>

Modified: trunk/Source/WebCore/platform/graphics/GlyphPage.h (176371 => 176372)


--- trunk/Source/WebCore/platform/graphics/GlyphPage.h	2014-11-20 01:23:38 UTC (rev 176371)
+++ trunk/Source/WebCore/platform/graphics/GlyphPage.h	2014-11-20 01:35:09 UTC (rev 176372)
@@ -98,6 +98,7 @@
     ~GlyphPage() { }
 
     static const size_t size = 256; // Covers Latin-1 in a single page.
+    static_assert((!(0xD800 % size)) && (!(0xDC00 % size)) && (!(0xE000 % size)), "GlyphPages must never straddle code-unit length boundaries");
     static unsigned indexForCharacter(UChar32 c) { return c % GlyphPage::size; }
 
     ALWAYS_INLINE GlyphData glyphDataForCharacter(UChar32 c) const

Modified: trunk/Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp (176371 => 176372)


--- trunk/Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp	2014-11-20 01:23:38 UTC (rev 176371)
+++ trunk/Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp	2014-11-20 01:35:09 UTC (rev 176372)
@@ -84,6 +84,7 @@
                : CTFontGetGlyphsForCharacters(fontData->platformData().ctFont(), buffer, glyphs.data(), bufferLength))) {
         // When buffer consists of surrogate pairs, CTFontGetVerticalGlyphsForCharacters and CTFontGetGlyphsForCharacters
         // place the glyphs at indices corresponding to the first character of each pair.
+        ASSERT(!(bufferLength % length) && (bufferLength / length == 1 || bufferLength / length == 2));
         unsigned glyphStep = bufferLength / length;
         for (unsigned i = 0; i < length; ++i) {
             if (!glyphs[i * glyphStep])
@@ -141,14 +142,18 @@
                     stringIndices = indexVector.data();
                 }
 
+                // When buffer consists of surrogate pairs, CTRunGetStringIndicesPtr and CTRunGetStringIndices
+                // place the glyphs at indices corresponding to the first character of each pair.
+                ASSERT(!(bufferLength % length) && (bufferLength / length == 1 || bufferLength / length == 2));
+                unsigned glyphStep = bufferLength / length;
                 if (gotBaseFont) {
                     for (CFIndex i = 0; i < glyphCount; ++i) {
-                        if (stringIndices[i] >= static_cast<CFIndex>(length)) {
+                        if (stringIndices[i] >= static_cast<CFIndex>(bufferLength)) {
                             done = true;
                             break;
                         }
                         if (glyphs[i]) {
-                            setGlyphDataForIndex(offset + stringIndices[i], glyphs[i], fontData);
+                            setGlyphDataForIndex(offset + (stringIndices[i] / glyphStep), glyphs[i], fontData);
                             haveGlyphs = true;
                         }
                     }
@@ -157,12 +162,12 @@
                     const SimpleFontData* runSimple = fontData->getCompositeFontReferenceFontData((NSFont *)runFont);
                     if (runSimple) {
                         for (CFIndex i = 0; i < glyphCount; ++i) {
-                            if (stringIndices[i] >= static_cast<CFIndex>(length)) {
+                            if (stringIndices[i] >= static_cast<CFIndex>(bufferLength)) {
                                 done = true;
                                 break;
                             }
                             if (glyphs[i]) {
-                                setGlyphDataForIndex(offset + stringIndices[i], glyphs[i], runSimple);
+                                setGlyphDataForIndex(offset + (stringIndices[i] / glyphStep), glyphs[i], runSimple);
                                 haveGlyphs = true;
                             }
                         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to