Changeset 70569 in webkit


Ignore:
Timestamp:
Oct 26, 2010 1:47:13 PM (14 years ago)
Author:
hyatt@apple.com
Message:

Advances are wrong and glyphs are rotated improperly in vertical writing
https://bugs.webkit.org/show_bug.cgi?id=48315

Patch by takano takumi <takano1@asia.apple.com> on 2010-10-26
Reviewed by Dave Hyatt.

WebCore:

We shouldn't use vertical metrics for Roman fonts. Also, we should rotate vertical variant
glyphs back on drawing as the whole run has already been rotated beforehand.

  • platform/graphics/cocoa/FontPlatformDataCocoa.mm:

(WebCore::FontPlatformData::FontPlatformData): Changed to ignore vertical orientation when the font doesn't support vertical metrics.

  • platform/graphics/mac/FontMac.mm:

(WebCore::showGlyphsWithAdvances): Changed to rotate glyphs -90 degree for vertical variants.
(WebCore::Font::drawGlyphs):

LayoutTests:

Changed tests to check more glyphs and updated results.

  • fast/text/international/vertical-text-glyph-test.html:
  • fast/text/international/vertical-text-metrics-test.html:
  • platform/mac/fast/text/international/vertical-text-glyph-test-expected.checksum:
  • platform/mac/fast/text/international/vertical-text-glyph-test-expected.png:
  • platform/mac/fast/text/international/vertical-text-glyph-test-expected.txt:
  • platform/mac/fast/text/international/vertical-text-metrics-test-expected.txt:
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r70563 r70569  
     12010-10-26  takano takumi  <takano1@asia.apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        Advances are wrong and glyphs are rotated improperly in vertical writing
     6        https://bugs.webkit.org/show_bug.cgi?id=48315
     7
     8        Changed tests to check more glyphs and updated results.
     9
     10        * fast/text/international/vertical-text-glyph-test.html:
     11        * fast/text/international/vertical-text-metrics-test.html:
     12        * platform/mac/fast/text/international/vertical-text-glyph-test-expected.checksum:
     13        * platform/mac/fast/text/international/vertical-text-glyph-test-expected.png:
     14        * platform/mac/fast/text/international/vertical-text-glyph-test-expected.txt:
     15        * platform/mac/fast/text/international/vertical-text-metrics-test-expected.txt:
     16
    1172010-10-26  Dimitri Glazkov  <dglazkov@chromium.org>
    218
  • trunk/LayoutTests/fast/text/international/vertical-text-glyph-test.html

    r70260 r70569  
    77body {
    88    font-family: "HiraMinPro-W3";
    9     font-size: large;
     9    font-size: 16pt;
    1010}
    1111#horizontal_TB {
     
    4141<body>
    4242<p>Simple text path</p>
    43 <span id="vertical_RL">abあ「」。</span><br>
    44 <br>
     43<span id="vertical_RL">string「あ、変っ!」。</span>
    4544<hr>
    4645<p>Complex text path</p>
    47 <span id="vertical_RL_complex">abあ「」。1⃝</span><br>
    48 <br>
    49 <hr>
     46<span id="vertical_RL_complex">string「あ、変っ!」。</span>
    5047</body>
    5148</html>
  • trunk/LayoutTests/fast/text/international/vertical-text-metrics-test.html

    r70250 r70569  
    2727body {
    2828    font-family: "HiraMinPro-W3";
    29     font-size: large;
     29    font-size: 16pt;
    3030}
    3131#horizontal_TB {
     
    6161<body onload="test()">
    6262<p>Simple text path</p>
    63 <span id="horizontal_TB">abあ「」。</span><br>
    64 <span id="horizontal_BT">abあ「」。</span><br>
    65 <span id="vertical_RL">abあ「」。</span><br>
    66 <span id="vertical_LR">abあ「」。</span><br>
     63<span id="horizontal_TB">string「あ、変っ!」。</span><br>
     64<span id="horizontal_BT">string「あ、変っ!」。</span><br>
     65<span id="vertical_RL">string「あ、変っ!」。</span><br>
     66<span id="vertical_LR">string「あ、変っ!」。</span><br>
    6767<br>
    6868<hr>
    6969<p>Complex text path</p>
    70 <span id="horizontal_TB_complex">abあ「」。1⃝</span><br>
    71 <span id="horizontal_BT_complex">abあ「」。1⃝</span><br>
    72 <span id="vertical_RL_complex">abあ「」。1⃝</span><br>
    73 <span id="vertical_LR_complex">abあ「」。1⃝</span><br>
     70<span id="horizontal_TB_complex">string「あ、変っ!」。</span><br>
     71<span id="horizontal_BT_complex">string「あ、変っ!」。</span><br>
     72<span id="vertical_RL_complex">string「あ、変っ!」。</span><br>
     73<span id="vertical_LR_complex">string「あ、変っ!」。</span><br>
    7474<br>
    7575<hr>
  • trunk/LayoutTests/platform/mac/fast/blockflow/english-lr-text-expected.checksum

    r70268 r70569  
    1 9a4b832e0b5772ba0e59914f3c59214f
     1f877c89d5f5032abe0650a578dc81375
  • trunk/LayoutTests/platform/mac/fast/blockflow/english-lr-text-expected.txt

    r70268 r70569  
    44  RenderBlock {HTML} at (0,0) size 800x600
    55    RenderBody {BODY} at (8,8) size 784x584
    6       RenderBlock {DIV} at (0,0) size 242x500
    7         RenderInline {SPAN} at (0,0) size 456x22
    8           RenderText {#text} at (0,0) size 456x22
    9             text run at (0,0) width 456: "This text should be rotated 90 degrees and"
    10             text run at (22,0) width 122: "underlined."
    11         RenderText {#text} at (22,122) size 5x22
    12           text run at (22,122) width 5: " "
    13         RenderBR {BR} at (27,127) size 0x0
    14         RenderInline {SPAN} at (0,0) size 456x22
    15           RenderText {#text} at (44,0) size 456x22
    16             text run at (44,0) width 456: "This text should be rotated 90 degrees and"
    17             text run at (66,0) width 108: "overlined."
    18         RenderText {#text} at (66,108) size 5x22
    19           text run at (66,108) width 5: " "
    20         RenderBR {BR} at (71,113) size 0x0
    21         RenderInline {SPAN} at (0,0) size 456x22
    22           RenderText {#text} at (88,0) size 456x22
    23             text run at (88,0) width 456: "This text should be rotated 90 degrees and"
    24             text run at (110,0) width 162: "struck through."
    25         RenderText {#text} at (110,162) size 5x22
    26           text run at (110,162) width 5: " "
    27         RenderBR {BR} at (115,167) size 0x0
    28         RenderInline {SPAN} at (0,0) size 448x22
    29           RenderText {#text} at (132,0) size 448x22
    30             text run at (132,0) width 448: "This text should have a red shadow that is"
    31             text run at (154,0) width 225: "offset horizontally."
    32         RenderText {#text} at (154,225) size 5x22
    33           text run at (154,225) width 5: " "
    34         RenderBR {BR} at (159,230) size 0x0
    35         RenderBR {BR} at (176,0) size 0x22
    36         RenderInline {SPAN} at (0,0) size 407x22
    37           RenderText {#text} at (198,0) size 407x22
    38             text run at (198,0) width 407: "This text should have an overline plus"
    39             text run at (220,0) width 251: "horizontal green shadow"
     6      RenderBlock {DIV} at (0,0) size 132x500
     7        RenderInline {SPAN} at (0,0) size 395x22
     8          RenderText {#text} at (0,0) size 395x22
     9            text run at (0,0) width 395: "This text should be rotated 90 degrees and underlined."
     10        RenderText {#text} at (0,395) size 5x22
     11          text run at (0,395) width 5: " "
     12        RenderBR {BR} at (5,400) size 0x0
     13        RenderInline {SPAN} at (0,0) size 386x22
     14          RenderText {#text} at (22,0) size 386x22
     15            text run at (22,0) width 386: "This text should be rotated 90 degrees and overlined."
     16        RenderText {#text} at (22,386) size 5x22
     17          text run at (22,386) width 5: " "
     18        RenderBR {BR} at (27,391) size 0x0
     19        RenderInline {SPAN} at (0,0) size 423x22
     20          RenderText {#text} at (44,0) size 423x22
     21            text run at (44,0) width 423: "This text should be rotated 90 degrees and struck through."
     22        RenderText {#text} at (44,423) size 5x22
     23          text run at (44,423) width 5: " "
     24        RenderBR {BR} at (49,428) size 0x0
     25        RenderInline {SPAN} at (0,0) size 449x22
     26          RenderText {#text} at (66,0) size 449x22
     27            text run at (66,0) width 449: "This text should have a red shadow that is offset horizontally."
     28        RenderText {#text} at (66,449) size 5x22
     29          text run at (66,449) width 5: " "
     30        RenderBR {BR} at (71,454) size 0x0
     31        RenderBR {BR} at (88,0) size 0x22
     32        RenderInline {SPAN} at (0,0) size 460x22
     33          RenderText {#text} at (110,0) size 460x22
     34            text run at (110,0) width 460: "This text should have an overline plus horizontal green shadow"
  • trunk/LayoutTests/platform/mac/fast/blockflow/english-rl-text-expected.checksum

    r70546 r70569  
    1 e8dc37381cc28ada4722d8e2aaf824c7
     186bce170b6e5c4eac8bb00675512383d
  • trunk/LayoutTests/platform/mac/fast/blockflow/english-rl-text-expected.txt

    r70546 r70569  
    66      RenderBlock {DIV} at (18,2) size 204x580 [border: (2px solid #800000)]
    77        RenderBlock (floating) {DIV} at (2,478) size 100x100 [bgcolor=#00FF00]
    8         RenderText {#text} at (2,2) size 417x18
    9           text run at (2,2) width 417: "Here is some text in a vertical-rl block flow. "
    10           text run at (2,419) width 34: "The"
    11           text run at (20,2) width 318: "block direction is right-to-left."
    12         RenderBR {BR} at (34,320) size 0x0
    13         RenderText {#text} at (38,2) size 324x18
    14           text run at (38,2) width 324: "This line should also be vertical."
     8        RenderText {#text} at (2,2) size 280x18
     9          text run at (2,2) width 280: "Here is some text in a vertical-rl block flow. "
     10          text run at (2,282) width 192: "The block direction is right-to-"
     11          text run at (20,2) width 24: "left."
     12        RenderBR {BR} at (34,26) size 0x0
     13        RenderText {#text} at (38,2) size 203x18
     14          text run at (38,2) width 203: "This line should also be vertical."
  • trunk/LayoutTests/platform/mac/fast/text/international/vertical-text-glyph-test-expected.checksum

    r70263 r70569  
    1 386f323eb617f371186afe888df1ce4e
     197299ec70f0a6a19601d0cfd36516b65
  • trunk/LayoutTests/platform/mac/fast/text/international/vertical-text-glyph-test-expected.txt

    r70260 r70569  
    1 layer at (0,0) size 800x600
    2   RenderView at (0,0) size 800x600
    3 layer at (0,0) size 800x442
    4   RenderBlock {HTML} at (0,0) size 800x442
    5     RenderBody {BODY} at (8,18) size 784x415
    6       RenderBlock {P} at (0,0) size 784x27
    7         RenderText {#text} at (0,4) size 139x19
    8           text run at (0,4) width 139: "Simple text path"
    9       RenderBlock (anonymous) at (0,45) size 784x129
    10         RenderBlock {SPAN} at (0,0) size 27x95
    11           RenderText {#text} at (4,0) size 95x19
    12             text run at (4,0) width 95: "ab\x{3042}\x{300C}\x{300D}\x{3002}"
    13         RenderBR {BR} at (27,79) size 0x19
    14         RenderBR {BR} at (0,106) size 0x19
    15       RenderBlock {HR} at (0,183) size 784x2 [border: (1px inset #000000)]
    16       RenderBlock {P} at (0,203) size 784x27
    17         RenderText {#text} at (0,4) size 157x19
    18           text run at (0,4) width 157: "Complex text path"
    19       RenderBlock (anonymous) at (0,248) size 784x156
    20         RenderBlock {SPAN} at (0,0) size 27x122
    21           RenderText {#text} at (4,0) size 122x19
    22             text run at (4,0) width 122: "ab\x{3042}\x{300C}\x{300D}\x{3002}1\x{20DD}"
    23         RenderBR {BR} at (27,106) size 0x19
    24         RenderBR {BR} at (0,133) size 0x19
    25       RenderBlock {HR} at (0,413) size 784x2 [border: (1px inset #000000)]
     1layer at (0,0) size 785x635
     2  RenderView at (0,0) size 785x600
     3layer at (0,0) size 785x635
     4  RenderBlock {HTML} at (0,0) size 785x635
     5    RenderBody {BODY} at (8,21) size 769x606
     6      RenderBlock {P} at (0,0) size 769x32
     7        RenderText {#text} at (0,5) size 161x21
     8          text run at (0,5) width 161: "Simple text path"
     9      RenderBlock (anonymous) at (0,53) size 769x235
     10        RenderBlock {SPAN} at (0,0) size 32x226
     11          RenderText {#text} at (5,0) size 226x21
     12            text run at (5,0) width 226: "string\x{300C}\x{3042}\x{3001}\x{5909}\x{3063}\x{FF01}\x{300D}\x{3002}"
     13        RenderText {#text} at (0,0) size 0x0
     14      RenderBlock {HR} at (0,298) size 769x2 [border: (1px inset #000000)]
     15      RenderBlock {P} at (0,321) size 769x32
     16        RenderText {#text} at (0,5) size 181x21
     17          text run at (0,5) width 181: "Complex text path"
     18      RenderBlock (anonymous) at (0,374) size 769x232
     19        RenderBlock {SPAN} at (0,0) size 32x223
     20          RenderText {#text} at (5,0) size 223x21
     21            text run at (5,0) width 223: "string\x{300C}\x{3042}\x{3001}\x{5909}\x{3063}\x{FF01}\x{300D}\x{3002}"
     22        RenderText {#text} at (0,0) size 0x0
  • trunk/LayoutTests/platform/mac/fast/text/international/vertical-text-metrics-test-expected.txt

    r70250 r70569  
    11Simple text path
    22
    3 abあ「」。
    4 abあ「」。
    5 abあ「」。
    6 abあ「」。
     3string「あ、変っ!」。
     4string「あ、変っ!」。
     5string「あ、変っ!」。
     6string「あ、変っ!」。
    77
    88Complex text path
    99
    10 abあ「」。1⃝
    11 abあ「」。1⃝
    12 abあ「」。1⃝
    13 abあ「」。1⃝
     10string「あ、変っ!」。
     11string「あ、変っ!」。
     12string「あ、変っ!」。
     13string「あ、変っ!」。
    1414
    15 width=93
    16 width=93
    17 width=27
    18 width=27
    19 width=103
    20 width=103
    21 width=27
    22 width=27
     15width=223
     16width=223
     17width=32
     18width=32
     19width=223
     20width=223
     21width=32
     22width=32
    2323
  • trunk/WebCore/ChangeLog

    r70567 r70569  
     12010-10-26  takano takumi  <takano1@asia.apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        Advances are wrong and glyphs are rotated improperly in vertical writing
     6        https://bugs.webkit.org/show_bug.cgi?id=48315
     7
     8        We shouldn't use vertical metrics for Roman fonts. Also, we should rotate vertical variant
     9        glyphs back on drawing as the whole run has already been rotated beforehand.
     10
     11        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
     12        (WebCore::FontPlatformData::FontPlatformData): Changed to ignore vertical orientation when the font doesn't support vertical metrics.
     13        * platform/graphics/mac/FontMac.mm:
     14        (WebCore::showGlyphsWithAdvances): Changed to rotate glyphs -90 degree for vertical variants.
     15        (WebCore::Font::drawGlyphs):
     16
    1172010-10-26  Satish Sampath  <satish@chromium.org>
    218
  • trunk/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm

    r70250 r70569  
    4848    : m_syntheticBold(syntheticBold)
    4949    , m_syntheticOblique(syntheticOblique)
    50     , m_orientation(orientation)
    5150    , m_font(nsFont)
    5251#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
     
    6564    loadFont(nsFont, m_size, m_font, cgFont, m_atsuFontID);
    6665   
     66    if (orientation == Vertical) {
     67        // Ignore vertical orientation when the font doesn't support vertical metrics.
     68        // The check doesn't look neat but this is what AppKit does for vertical writing...
     69        RetainPtr<CFArrayRef> tableTags(AdoptCF, CTFontCopyAvailableTables(ctFont(), kCTFontTableOptionExcludeSynthetic));
     70        CFIndex numTables = CFArrayGetCount(tableTags.get());
     71        bool found = false;
     72        for (CFIndex index = 0; index < numTables; ++index) {
     73            CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);
     74            if (tag == kCTFontTableVhea || tag == kCTFontTableVORG) {
     75                found = true;
     76                break;
     77            }
     78        }
     79
     80        if (found == false)
     81            orientation = Horizontal;
     82    }
     83
     84    m_orientation = orientation;
     85
    6786    if (m_font)
    6887        CFRetain(m_font);
  • trunk/WebCore/platform/graphics/mac/FontMac.mm

    r66082 r70569  
    4848}
    4949
    50 static void showGlyphsWithAdvances(const FontPlatformData& font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, size_t count)
     50static void showGlyphsWithAdvances(const SimpleFontData* font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, size_t count)
    5151{
    52     if (!font.isColorBitmapFont())
     52    const FontPlatformData& platformData = font->platformData();
     53    if (!platformData.isColorBitmapFont()) {
     54        CGAffineTransform savedMatrix;
     55        bool isVertical = platformData.orientation() == Vertical;
     56
     57        if (isVertical) {
     58            static const CGAffineTransform rotateLeftTransform = {0.0, -1.0, 1.0, 0.0, 0.0, 0.0};
     59
     60            savedMatrix = CGContextGetTextMatrix(context);
     61            CGAffineTransform runMatrix = CGAffineTransformConcat(savedMatrix, rotateLeftTransform);
     62            // Move start point to put glyphs into original region.
     63            runMatrix.tx = savedMatrix.tx + font->ascent();
     64            runMatrix.ty = savedMatrix.ty + font->descent();
     65            CGContextSetTextMatrix(context, runMatrix);
     66        }
     67
    5368        CGContextShowGlyphsWithAdvances(context, glyphs, advances, count);
     69
     70        if (isVertical)
     71            CGContextSetTextMatrix(context, savedMatrix);
     72    }
    5473#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
    5574    else {
     
    6584            positions[i].y = positions[i - 1].y + advance.height;
    6685        }
    67         CTFontDrawGlyphs(font.ctFont(), glyphs, positions.data(), count, context);
     86        CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);
    6887    }
    6988#endif
     
    150169        context->setFillColor(shadowFillColor, fillColorSpace);
    151170        CGContextSetTextPosition(cgContext, point.x() + shadowOffset.width(), point.y() + shadowOffset.height());
    152         showGlyphsWithAdvances(platformData, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
     171        showGlyphsWithAdvances(font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
    153172        if (font->syntheticBoldOffset()) {
    154173            CGContextSetTextPosition(cgContext, point.x() + shadowOffset.width() + font->syntheticBoldOffset(), point.y() + shadowOffset.height());
    155             showGlyphsWithAdvances(platformData, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
     174            showGlyphsWithAdvances(font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
    156175        }
    157176        context->setFillColor(fillColor, fillColorSpace);
     
    159178
    160179    CGContextSetTextPosition(cgContext, point.x(), point.y());
    161     showGlyphsWithAdvances(platformData, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
     180    showGlyphsWithAdvances(font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
    162181    if (font->syntheticBoldOffset()) {
    163182        CGContextSetTextPosition(cgContext, point.x() + font->syntheticBoldOffset(), point.y());
    164         showGlyphsWithAdvances(platformData, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
     183        showGlyphsWithAdvances(font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
    165184    }
    166185
Note: See TracChangeset for help on using the changeset viewer.