Complex spaces with synthetic bold are too wide
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Sep 2011 17:05:22 +0000 (17:05 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Sep 2011 17:05:22 +0000 (17:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69033

Patch by Ned Holbrook <nholbrook@apple.com> on 2011-09-30
Reviewed by Dan Bernstein.

Source/WebCore:

Test: fast/text/complex-synthetic-bold-space-width.html

* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::adjustGlyphsAndAdvances): Subtract synthetic bold offset from spaceWidth.
* platform/graphics/win/UniscribeController.cpp:
(WebCore::UniscribeController::shapeAndPlaceItem): Ditto.

LayoutTests:

* fast/text/complex-synthetic-bold-space-width.html: Added.
* platform/mac/fast/text/atsui-multiple-renderers-expected.png:
* platform/mac/fast/text/atsui-multiple-renderers-expected.txt:
* platform/mac/fast/text/complex-synthetic-bold-space-width-expected.png: Added.
* platform/mac/fast/text/complex-synthetic-bold-space-width-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/complex-synthetic-bold-space-width.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/atsui-multiple-renderers-expected.png
LayoutTests/platform/mac/fast/text/atsui-multiple-renderers-expected.txt
LayoutTests/platform/mac/fast/text/complex-synthetic-bold-space-width-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/complex-synthetic-bold-space-width-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
Source/WebCore/platform/graphics/win/UniscribeController.cpp

index f4acd33..ff14dad 100644 (file)
@@ -1,3 +1,16 @@
+2011-09-30  Ned Holbrook  <nholbrook@apple.com>
+
+        Complex spaces with synthetic bold are too wide
+        https://bugs.webkit.org/show_bug.cgi?id=69033
+
+        Reviewed by Dan Bernstein.
+
+        * fast/text/complex-synthetic-bold-space-width.html: Added.
+        * platform/mac/fast/text/atsui-multiple-renderers-expected.png:
+        * platform/mac/fast/text/atsui-multiple-renderers-expected.txt:
+        * platform/mac/fast/text/complex-synthetic-bold-space-width-expected.png: Added.
+        * platform/mac/fast/text/complex-synthetic-bold-space-width-expected.txt: Added.
+
 2011-09-30  Antaryami Pandia  <antaryami.pandia@motorola.com>
 
         LayoutTests: Rewrite fast/dom/HTMLInputElement/input-size-attribute.html
 2011-09-30  Antaryami Pandia  <antaryami.pandia@motorola.com>
 
         LayoutTests: Rewrite fast/dom/HTMLInputElement/input-size-attribute.html
diff --git a/LayoutTests/fast/text/complex-synthetic-bold-space-width.html b/LayoutTests/fast/text/complex-synthetic-bold-space-width.html
new file mode 100644 (file)
index 0000000..3bb8d87
--- /dev/null
@@ -0,0 +1,2 @@
+These lines should have the same width:
+<div style="font-family: geneva; font-weight: bold;">. . . . . . . . a<br>. . . . . . . . a&#x0300</div>
index d6604b3..daaee52 100644 (file)
Binary files a/LayoutTests/platform/mac/fast/text/atsui-multiple-renderers-expected.png and b/LayoutTests/platform/mac/fast/text/atsui-multiple-renderers-expected.png differ
index 9da6ea6..ba4c81e 100644 (file)
@@ -35,11 +35,11 @@ layer at (0,0) size 800x600
               RenderText {#text} at (0,0) size 0x0
           RenderTableRow {TR} at (0,30) size 262x30
             RenderTableCell {TD} at (0,30) size 131x30 [border: (1px solid #008000)] [r=1 c=0 rs=1 cs=1]
               RenderText {#text} at (0,0) size 0x0
           RenderTableRow {TR} at (0,30) size 262x30
             RenderTableCell {TD} at (0,30) size 131x30 [border: (1px solid #008000)] [r=1 c=0 rs=1 cs=1]
-              RenderText {#text} at (2,3) size 76x25
-                text run at (2,3) width 76: "Lore\x{300}m "
+              RenderText {#text} at (2,3) size 75x25
+                text run at (2,3) width 75: "Lore\x{300}m "
               RenderInline {SPAN} at (0,0) size 53x23
               RenderInline {SPAN} at (0,0) size 53x23
-                RenderText {#text} at (78,5) size 53x23
-                  text run at (78,5) width 53: "ipsu\x{308}m"
+                RenderText {#text} at (77,5) size 53x23
+                  text run at (77,5) width 53: "ipsu\x{308}m"
               RenderText {#text} at (0,0) size 0x0
             RenderTableCell {TD} at (131,30) size 131x30 [border: (1px solid #008000)] [r=1 c=1 rs=1 cs=1]
               RenderText {#text} at (2,3) size 75x25
               RenderText {#text} at (0,0) size 0x0
             RenderTableCell {TD} at (131,30) size 131x30 [border: (1px solid #008000)] [r=1 c=1 rs=1 cs=1]
               RenderText {#text} at (2,3) size 75x25
@@ -65,11 +65,11 @@ layer at (0,0) size 800x600
               RenderText {#text} at (0,0) size 0x0
           RenderTableRow {TR} at (0,90) size 262x30
             RenderTableCell {TD} at (0,90) size 131x30 [border: (1px solid #008000)] [r=3 c=0 rs=1 cs=1]
               RenderText {#text} at (0,0) size 0x0
           RenderTableRow {TR} at (0,90) size 262x30
             RenderTableCell {TD} at (0,90) size 131x30 [border: (1px solid #008000)] [r=3 c=0 rs=1 cs=1]
-              RenderText {#text} at (2,3) size 76x25
-                text run at (2,3) width 76: "Lore\x{300}m "
+              RenderText {#text} at (2,3) size 75x25
+                text run at (2,3) width 75: "Lore\x{300}m "
               RenderInline {SPAN} at (0,0) size 51x23
               RenderInline {SPAN} at (0,0) size 51x23
-                RenderText {#text} at (78,5) size 51x23
-                  text run at (78,5) width 51: "ipsu\x{308}m"
+                RenderText {#text} at (77,5) size 51x23
+                  text run at (77,5) width 51: "ipsu\x{308}m"
               RenderText {#text} at (0,0) size 0x0
             RenderTableCell {TD} at (131,90) size 131x30 [border: (1px solid #008000)] [r=3 c=1 rs=1 cs=1]
               RenderText {#text} at (2,3) size 75x25
               RenderText {#text} at (0,0) size 0x0
             RenderTableCell {TD} at (131,90) size 131x30 [border: (1px solid #008000)] [r=3 c=1 rs=1 cs=1]
               RenderText {#text} at (2,3) size 75x25
diff --git a/LayoutTests/platform/mac/fast/text/complex-synthetic-bold-space-width-expected.png b/LayoutTests/platform/mac/fast/text/complex-synthetic-bold-space-width-expected.png
new file mode 100644 (file)
index 0000000..8bad0bb
Binary files /dev/null and b/LayoutTests/platform/mac/fast/text/complex-synthetic-bold-space-width-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/text/complex-synthetic-bold-space-width-expected.txt b/LayoutTests/platform/mac/fast/text/complex-synthetic-bold-space-width-expected.txt
new file mode 100644 (file)
index 0000000..cb2657b
--- /dev/null
@@ -0,0 +1,14 @@
+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 784x584
+      RenderBlock (anonymous) at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 254x18
+          text run at (0,0) width 254: "These lines should have the same width:"
+      RenderBlock {DIV} at (0,18) size 784x42
+        RenderText {#text} at (0,0) size 106x20
+          text run at (0,0) width 106: ". . . . . . . . a"
+        RenderBR {BR} at (106,16) size 0x0
+        RenderText {#text} at (0,21) size 106x20
+          text run at (0,21) width 106: ". . . . . . . . a\x{300}"
index 4b9ec9b..aad1d80 100644 (file)
@@ -1,3 +1,17 @@
+2011-09-30  Ned Holbrook  <nholbrook@apple.com>
+
+        Complex spaces with synthetic bold are too wide
+        https://bugs.webkit.org/show_bug.cgi?id=69033
+
+        Reviewed by Dan Bernstein.
+
+        Test: fast/text/complex-synthetic-bold-space-width.html
+
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::adjustGlyphsAndAdvances): Subtract synthetic bold offset from spaceWidth.
+        * platform/graphics/win/UniscribeController.cpp:
+        (WebCore::UniscribeController::shapeAndPlaceItem): Ditto.
+
 2011-09-30  Pavel Feldman  <pfeldman@google.com>
 
         Web Inspector: [chromium] expose inspector protocol version to the embedder.
 2011-09-30  Pavel Feldman  <pfeldman@google.com>
 
         Web Inspector: [chromium] expose inspector protocol version to the embedder.
index 6a09364..cc5fb86 100644 (file)
@@ -477,7 +477,8 @@ void ComplexTextController::adjustGlyphsAndAdvances()
 
         bool lastRun = r + 1 == runCount;
         bool roundsAdvances = !m_font.isPrinterFont() && fontData->platformData().roundsGlyphAdvances();
 
         bool lastRun = r + 1 == runCount;
         bool roundsAdvances = !m_font.isPrinterFont() && fontData->platformData().roundsGlyphAdvances();
-        CGFloat roundedSpaceWidth = roundCGFloat(fontData->spaceWidth());
+        float spaceWidth = fontData->spaceWidth() - fontData->syntheticBoldOffset();
+        CGFloat roundedSpaceWidth = roundCGFloat(spaceWidth);
         const UChar* cp = complexTextRun.characters();
         CGPoint glyphOrigin = CGPointZero;
         CFIndex lastCharacterIndex = m_run.ltr() ? numeric_limits<CFIndex>::min() : numeric_limits<CFIndex>::max();
         const UChar* cp = complexTextRun.characters();
         CGPoint glyphOrigin = CGPointZero;
         CFIndex lastCharacterIndex = m_run.ltr() ? numeric_limits<CFIndex>::min() : numeric_limits<CFIndex>::max();
@@ -504,7 +505,7 @@ void ComplexTextController::adjustGlyphsAndAdvances()
 
             bool treatAsSpace = Font::treatAsSpace(ch);
             CGGlyph glyph = treatAsSpace ? fontData->spaceGlyph() : glyphs[i];
 
             bool treatAsSpace = Font::treatAsSpace(ch);
             CGGlyph glyph = treatAsSpace ? fontData->spaceGlyph() : glyphs[i];
-            CGSize advance = treatAsSpace ? CGSizeMake(fontData->spaceWidth(), advances[i].height) : advances[i];
+            CGSize advance = treatAsSpace ? CGSizeMake(spaceWidth, advances[i].height) : advances[i];
 
             if (ch == '\t' && m_run.allowTabs()) {
                 float tabWidth = m_font.tabWidth(*fontData);
 
             if (ch == '\t' && m_run.allowTabs()) {
                 float tabWidth = m_font.tabWidth(*fontData);
index 75c19bb..67e34a7 100644 (file)
@@ -266,8 +266,8 @@ bool UniscribeController::shapeAndPlaceItem(const UChar* cp, unsigned i, const S
     spaceCharacters.fill(-1);
 
     const float cLogicalScale = fontData->platformData().useGDI() ? 1.0f : 32.0f;
     spaceCharacters.fill(-1);
 
     const float cLogicalScale = fontData->platformData().useGDI() ? 1.0f : 32.0f;
-    unsigned logicalSpaceWidth = fontData->spaceWidth() * cLogicalScale;
-    float spaceWidth = fontData->spaceWidth();
+    float spaceWidth = fontData->spaceWidth() - fontData->syntheticBoldOffset();
+    unsigned logicalSpaceWidth = spaceWidth * cLogicalScale;
 
     for (int k = 0; k < len; k++) {
         UChar ch = *(str + k);
 
     for (int k = 0; k < len; k++) {
         UChar ch = *(str + k);