[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

hyatt at apple.com hyatt at apple.com
Wed Dec 22 15:49:53 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 82727982ccdaf382e69c90fc066f43131ec06af8
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Nov 13 18:45:12 2010 +0000

    https://bugs.webkit.org/show_bug.cgi?id=49464
    
    Reviewed by Dan Bernstein.
    
    Fix bugs with the orientation of fonts when the font is brought in via fallback, when the font contains no
    vertical tables, or when the font is loaded via font-face in both horizontal and vertical forms.
    
    (1) Include orientation as part of the @font-face hashtables so that the fonts are treated as
    distinct when used in horizontal and vertical forms.
    
    (2) Let the orientation member of FontPlatformData represent the desired orientation rather than
    the supported one.  Add an orientation member to SimpleFontData that represents the actual
    supported orientation of the font.
    
    (3) For fonts with no vertical tables, add a brokenIdeographicsFont accessor that is invoked when
    CJK ideographs are encountered.  This is essentially identical to the small caps fallback mechanism
    but invoked only for ideographs.  The special ideograph font locks the orientation to vertical and
    renders the glyphs upright even when the font has no vertical tables.  Punctuation and such will
    still look funny, and really this is a bug in the font, but at least this way it will be apparent
    that the font is to blame.
    
    Added fast/blockflow/broken-ideographic-font.html and fast/blockflow/vertical-font-fallback.html.
    
    WebCore:
    
    * css/CSSFontFaceSource.cpp:
    (WebCore::CSSFontFaceSource::getFontData):
    * css/CSSSegmentedFontFace.cpp:
    (WebCore::CSSSegmentedFontFace::getFontData):
    * platform/graphics/Font.cpp:
    (WebCore::Font::isCJKIdeograph):
    * platform/graphics/Font.h:
    * platform/graphics/FontFastPath.cpp:
    (WebCore::Font::glyphDataForCharacter):
    * platform/graphics/SimpleFontData.cpp:
    (WebCore::SimpleFontData::SimpleFontData):
    (WebCore::SimpleFontData::~SimpleFontData):
    (WebCore::SimpleFontData::brokenIdeographFontData):
    * platform/graphics/SimpleFontData.h:
    (WebCore::SimpleFontData::orientation):
    * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
    (WebCore::FontPlatformData::FontPlatformData):
    * platform/graphics/mac/FontMac.mm:
    (WebCore::showGlyphsWithAdvances):
    * platform/graphics/mac/SimpleFontDataMac.mm:
    (WebCore::SimpleFontData::platformInit):
    (WebCore::SimpleFontData::platformBoundsForGlyph):
    (WebCore::SimpleFontData::platformWidthForGlyph):
    
    LayoutTests:
    
    * fast/blockflow/broken-ideographic-font.html: Added.
    * fast/blockflow/resources/MakibaFont13.ttf: Added.
    * fast/blockflow/vertical-font-fallback.html: Added.
    * platform/mac/fast/blockflow/broken-ideographic-font-expected.checksum: Added.
    * platform/mac/fast/blockflow/broken-ideographic-font-expected.png: Added.
    * platform/mac/fast/blockflow/broken-ideographic-font-expected.txt: Added.
    * platform/mac/fast/blockflow/vertical-font-fallback-expected.checksum: Added.
    * platform/mac/fast/blockflow/vertical-font-fallback-expected.png: Added.
    * platform/mac/fast/blockflow/vertical-font-fallback-expected.txt: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71970 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index fe44412..6491fda 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,38 @@
+2010-11-13  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        https://bugs.webkit.org/show_bug.cgi?id=49464
+        
+        Fix bugs with the orientation of fonts when the font is brought in via fallback, when the font contains no
+        vertical tables, or when the font is loaded via font-face in both horizontal and vertical forms.
+        
+        (1) Include orientation as part of the @font-face hashtables so that the fonts are treated as
+        distinct when used in horizontal and vertical forms.
+        
+        (2) Let the orientation member of FontPlatformData represent the desired orientation rather than
+        the supported one.  Add an orientation member to SimpleFontData that represents the actual
+        supported orientation of the font.
+        
+        (3) For fonts with no vertical tables, add a brokenIdeographicsFont accessor that is invoked when
+        CJK ideographs are encountered.  This is essentially identical to the small caps fallback mechanism
+        but invoked only for ideographs.  The special ideograph font locks the orientation to vertical and
+        renders the glyphs upright even when the font has no vertical tables.  Punctuation and such will
+        still look funny, and really this is a bug in the font, but at least this way it will be apparent
+        that the font is to blame.
+
+        Added fast/blockflow/broken-ideographic-font.html and fast/blockflow/vertical-font-fallback.html.
+
+        * fast/blockflow/broken-ideographic-font.html: Added.
+        * fast/blockflow/resources/MakibaFont13.ttf: Added.
+        * fast/blockflow/vertical-font-fallback.html: Added.
+        * platform/mac/fast/blockflow/broken-ideographic-font-expected.checksum: Added.
+        * platform/mac/fast/blockflow/broken-ideographic-font-expected.png: Added.
+        * platform/mac/fast/blockflow/broken-ideographic-font-expected.txt: Added.
+        * platform/mac/fast/blockflow/vertical-font-fallback-expected.checksum: Added.
+        * platform/mac/fast/blockflow/vertical-font-fallback-expected.png: Added.
+        * platform/mac/fast/blockflow/vertical-font-fallback-expected.txt: Added.
+
 2010-11-13  Rob Buis  <rwlbuis at gmail.com>
 
         Reviewed by Dirk Schulze.
diff --git a/LayoutTests/fast/blockflow/broken-ideographic-font.html b/LayoutTests/fast/blockflow/broken-ideographic-font.html
new file mode 100644
index 0000000..5e7f341
--- /dev/null
+++ b/LayoutTests/fast/blockflow/broken-ideographic-font.html
@@ -0,0 +1,72 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Broken Ideographic Font</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  
+<style type="text/css">
+ at font-face {
+    src: url(resources/MakibaFont13.ttf);
+    font-family: MakibaFace;
+}
+
+body {
+  margin: 50px;
+  font-size: 20px;
+  font-family: MakibaFace;
+}
+
+.lrblock {
+  writing-mode: tb-lr;  /* IE */
+  -webkit-writing-mode: vertical-lr;
+  height: 275px;
+  margin-bottom: 50px;
+  padding: 1px;
+  background-color: #eee;
+}
+
+.basic {
+  width: 275px;
+  margin: 0;
+  padding: 1px;
+  writing-mode: lr-tb;  /* IE */
+  -webkit-writing-mode: horizontal-tb;
+}
+
+div.d0 {
+  background-color: #fee;
+}
+
+div.d1 {
+  background-color: #ffe;
+}
+p {
+  margin: 10% 5% 10% 5%;
+  background-color: #faa;
+  border-left: 20px solid #f88;
+  border-right: 20px solid #f88;
+  line-height: 1em;
+  padding: 1px;
+}
+
+.vert {
+  writing-mode: tb-rl;  /* IE */
+  -webkit-writing-mode: vertical-rl;
+}
+
+</style>
+  
+<script type="text/javascript">
+
+</script>
+  
+</head>
+<body>
+
+<div class="lrblock">
+<div class="basic d0"><p>第一段落 paragraph 1</p><p>第二段落 paragraph 2</p></div>
+<div class="basic d1 vert"><p>第一段落 paragraph 1</p><p>第二段落 paragraph 2</p></div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/blockflow/resources/MakibaFont13.ttf b/LayoutTests/fast/blockflow/resources/MakibaFont13.ttf
new file mode 100644
index 0000000..e571aa9
Binary files /dev/null and b/LayoutTests/fast/blockflow/resources/MakibaFont13.ttf differ
diff --git a/LayoutTests/fast/blockflow/vertical-font-fallback.html b/LayoutTests/fast/blockflow/vertical-font-fallback.html
new file mode 100644
index 0000000..b526fd3
--- /dev/null
+++ b/LayoutTests/fast/blockflow/vertical-font-fallback.html
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Vertical Font Fallback</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  
+<style type="text/css">
+
+body {
+  margin: 50px;
+  font-size: 20px;
+  font-family: Times;
+}
+
+.lrblock {
+  writing-mode: tb-lr;  /* IE */
+  -webkit-writing-mode: vertical-lr;
+  height: 275px;
+  margin-bottom: 50px;
+  padding: 1px;
+  background-color: #eee;
+}
+
+.basic {
+  width: 275px;
+  margin: 0;
+  padding: 1px;
+  writing-mode: lr-tb;  /* IE */
+  -webkit-writing-mode: horizontal-tb;
+}
+
+div.d0 {
+  background-color: #fee;
+}
+
+div.d1 {
+  background-color: #ffe;
+}
+
+p {
+  margin: 10% 5% 10% 5%;
+  background-color: #faa;
+  border-left: 20px solid #f88;
+  border-right: 20px solid #f88;
+  line-height: 1em;
+  padding: 1px;
+}
+
+.vert {
+  writing-mode: tb-rl;  /* IE */
+  -webkit-writing-mode: vertical-rl;
+}
+
+</style>
+</head>
+<body>
+
+<div class="lrblock">
+<div class="basic d0"><p>第一段落 paragraph 1</p><p>第二段落 paragraph 2</p></div>
+<div class="basic d1 vert"><p>第一段落 paragraph 1</p><p>第二段落 paragraph 2</p></div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/blockflow/broken-ideographic-font-expected.checksum b/LayoutTests/platform/mac/fast/blockflow/broken-ideographic-font-expected.checksum
new file mode 100644
index 0000000..13e64a0
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/broken-ideographic-font-expected.checksum
@@ -0,0 +1 @@
+1155d728a7fdadecde500275b2dfb3c6
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/blockflow/broken-ideographic-font-expected.png b/LayoutTests/platform/mac/fast/blockflow/broken-ideographic-font-expected.png
new file mode 100644
index 0000000..a4134a7
Binary files /dev/null and b/LayoutTests/platform/mac/fast/blockflow/broken-ideographic-font-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/blockflow/broken-ideographic-font-expected.txt b/LayoutTests/platform/mac/fast/blockflow/broken-ideographic-font-expected.txt
new file mode 100644
index 0000000..30344ec
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/broken-ideographic-font-expected.txt
@@ -0,0 +1,20 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x377
+  RenderBlock {HTML} at (0,0) size 800x377
+    RenderBody {BODY} at (50,50) size 700x277
+      RenderBlock {DIV} at (0,0) size 556x277 [bgcolor=#EEEEEE]
+        RenderBlock {DIV} at (1,1) size 277x127 [bgcolor=#FFEEEE]
+          RenderBlock {P} at (14,28) size 249x22 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]
+            RenderText {#text} at (21,1) size 200x20
+              text run at (21,1) width 200: "\x{7B2C}\x{4E00}\x{6BB5}\x{843D} paragraph 1"
+          RenderBlock {P} at (14,77) size 249x22 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]
+            RenderText {#text} at (21,1) size 200x20
+              text run at (21,1) width 200: "\x{7B2C}\x{4E8C}\x{6BB5}\x{843D} paragraph 2"
+        RenderBlock {DIV} at (278,1) size 277x275 [bgcolor=#FFFFEE]
+          RenderBlock {P} at (14,28) size 62x219 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]
+            RenderText {#text} at (21,1) size 20x200
+              text run at (21,1) width 200: "\x{7B2C}\x{4E00}\x{6BB5}\x{843D} paragraph 1"
+          RenderBlock {P} at (89,28) size 62x219 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]
+            RenderText {#text} at (21,1) size 20x200
+              text run at (21,1) width 200: "\x{7B2C}\x{4E8C}\x{6BB5}\x{843D} paragraph 2"
diff --git a/LayoutTests/platform/mac/fast/blockflow/vertical-font-fallback-expected.checksum b/LayoutTests/platform/mac/fast/blockflow/vertical-font-fallback-expected.checksum
new file mode 100644
index 0000000..779002d
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/vertical-font-fallback-expected.checksum
@@ -0,0 +1 @@
+b953ab6d677ffcd6f0158f365cac4e0c
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/blockflow/vertical-font-fallback-expected.png b/LayoutTests/platform/mac/fast/blockflow/vertical-font-fallback-expected.png
new file mode 100644
index 0000000..65061dd
Binary files /dev/null and b/LayoutTests/platform/mac/fast/blockflow/vertical-font-fallback-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/blockflow/vertical-font-fallback-expected.txt b/LayoutTests/platform/mac/fast/blockflow/vertical-font-fallback-expected.txt
new file mode 100644
index 0000000..aa82914
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/vertical-font-fallback-expected.txt
@@ -0,0 +1,20 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x377
+  RenderBlock {HTML} at (0,0) size 800x377
+    RenderBody {BODY} at (50,50) size 700x277
+      RenderBlock {DIV} at (0,0) size 556x277 [bgcolor=#EEEEEE]
+        RenderBlock {DIV} at (1,1) size 277x129 [bgcolor=#FFEEEE]
+          RenderBlock {P} at (14,28) size 249x23 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]
+            RenderText {#text} at (21,1) size 181x23
+              text run at (21,1) width 181: "\x{7B2C}\x{4E00}\x{6BB5}\x{843D} paragraph 1"
+          RenderBlock {P} at (14,78) size 249x23 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]
+            RenderText {#text} at (21,1) size 181x23
+              text run at (21,1) width 181: "\x{7B2C}\x{4E8C}\x{6BB5}\x{843D} paragraph 2"
+        RenderBlock {DIV} at (278,1) size 277x275 [bgcolor=#FFFFEE]
+          RenderBlock {P} at (14,28) size 63x219 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]
+            RenderText {#text} at (21,1) size 23x185
+              text run at (21,1) width 185: "\x{7B2C}\x{4E00}\x{6BB5}\x{843D} paragraph 1"
+          RenderBlock {P} at (90,28) size 63x219 [bgcolor=#FFAAAA] [border: (20px solid #FF8888) none (20px solid #FF8888)]
+            RenderText {#text} at (21,1) size 23x185
+              text run at (21,1) width 185: "\x{7B2C}\x{4E8C}\x{6BB5}\x{843D} paragraph 2"
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e1a4843..9ec4755 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,52 @@
+2010-11-13  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        https://bugs.webkit.org/show_bug.cgi?id=49464
+        
+        Fix bugs with the orientation of fonts when the font is brought in via fallback, when the font contains no
+        vertical tables, or when the font is loaded via font-face in both horizontal and vertical forms.
+        
+        (1) Include orientation as part of the @font-face hashtables so that the fonts are treated as
+        distinct when used in horizontal and vertical forms.
+        
+        (2) Let the orientation member of FontPlatformData represent the desired orientation rather than
+        the supported one.  Add an orientation member to SimpleFontData that represents the actual
+        supported orientation of the font.
+        
+        (3) For fonts with no vertical tables, add a brokenIdeographicsFont accessor that is invoked when
+        CJK ideographs are encountered.  This is essentially identical to the small caps fallback mechanism
+        but invoked only for ideographs.  The special ideograph font locks the orientation to vertical and
+        renders the glyphs upright even when the font has no vertical tables.  Punctuation and such will
+        still look funny, and really this is a bug in the font, but at least this way it will be apparent
+        that the font is to blame.
+
+        Added fast/blockflow/broken-ideographic-font.html and fast/blockflow/vertical-font-fallback.html.
+
+        * css/CSSFontFaceSource.cpp:
+        (WebCore::CSSFontFaceSource::getFontData):
+        * css/CSSSegmentedFontFace.cpp:
+        (WebCore::CSSSegmentedFontFace::getFontData):
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::isCJKIdeograph):
+        * platform/graphics/Font.h:
+        * platform/graphics/FontFastPath.cpp:
+        (WebCore::Font::glyphDataForCharacter):
+        * platform/graphics/SimpleFontData.cpp:
+        (WebCore::SimpleFontData::SimpleFontData):
+        (WebCore::SimpleFontData::~SimpleFontData):
+        (WebCore::SimpleFontData::brokenIdeographFontData):
+        * platform/graphics/SimpleFontData.h:
+        (WebCore::SimpleFontData::orientation):
+        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+        (WebCore::FontPlatformData::FontPlatformData):
+        * platform/graphics/mac/FontMac.mm:
+        (WebCore::showGlyphsWithAdvances):
+        * platform/graphics/mac/SimpleFontDataMac.mm:
+        (WebCore::SimpleFontData::platformInit):
+        (WebCore::SimpleFontData::platformBoundsForGlyph):
+        (WebCore::SimpleFontData::platformWidthForGlyph):
+
 2010-11-13  Rob Buis  <rwlbuis at gmail.com>
 
         Reviewed by Dirk Schulze.
diff --git a/WebCore/css/CSSFontFaceSource.cpp b/WebCore/css/CSSFontFaceSource.cpp
index 4fdcc03..29e0481 100644
--- a/WebCore/css/CSSFontFaceSource.cpp
+++ b/WebCore/css/CSSFontFaceSource.cpp
@@ -115,7 +115,7 @@ SimpleFontData* CSSFontFaceSource::getFontData(const FontDescription& fontDescri
     }
 
     // See if we have a mapping in our FontData cache.
-    unsigned hashKey = fontDescription.computedPixelSize() << 2 | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0);
+    unsigned hashKey = fontDescription.computedPixelSize() << 3 | (fontDescription.orientation() == Vertical ? 4 : 0) | (syntheticBold ? 2 : 0) | (syntheticItalic ? 1 : 0);
     if (SimpleFontData* cachedData = m_fontDataTable.get(hashKey))
         return cachedData;
 
diff --git a/WebCore/css/CSSSegmentedFontFace.cpp b/WebCore/css/CSSSegmentedFontFace.cpp
index bda29f0..cdabec1 100644
--- a/WebCore/css/CSSSegmentedFontFace.cpp
+++ b/WebCore/css/CSSSegmentedFontFace.cpp
@@ -88,7 +88,7 @@ FontData* CSSSegmentedFontFace::getFontData(const FontDescription& fontDescripti
         return 0;
 
     FontTraitsMask desiredTraitsMask = fontDescription.traitsMask();
-    unsigned hashKey = fontDescription.computedPixelSize() << FontTraitsMaskWidth | desiredTraitsMask;
+    unsigned hashKey = (fontDescription.computedPixelSize() << (FontTraitsMaskWidth + 1)) | ((fontDescription.orientation() == Vertical ? 1 : 0) << FontTraitsMaskWidth) | desiredTraitsMask;
 
     SegmentedFontData* fontData = m_fontDataTable.get(hashKey);
     if (fontData)
diff --git a/WebCore/platform/graphics/Font.cpp b/WebCore/platform/graphics/Font.cpp
index a0cf5a4..6bbf3d7 100644
--- a/WebCore/platform/graphics/Font.cpp
+++ b/WebCore/platform/graphics/Font.cpp
@@ -336,4 +336,73 @@ Font::CodePath Font::codePath(const TextRun& run) const
     return result;
 }
 
+bool Font::isCJKIdeograph(UChar32 c)
+{
+    // The basic CJK Unified Ideographs block.
+    if (c >= 0x4E00 && c <= 0x9FFF)
+        return true;
+    
+    // CJK Unified Ideographs Extension A.
+    if (c >= 0x3400 && c <= 0x4DBF)
+        return true;
+    
+    // CJK Radicals Supplement.
+    if (c >= 0x2E80 && c <= 0x2EFF)
+        return true;
+    
+    // Kangxi Radicals.
+    if (c >= 0x2F00 && c <= 0x2FDF)
+        return true;
+    
+    // Ideographic Description Characters.
+    if (c >= 0x2FF0 && c <= 0x2FFF)
+        return true;
+    
+    // CJK Symbols and Punctuation.
+    if (c >= 0x3000 && c <= 0x303F)
+        return true;
+    
+    // CJK Strokes.
+    if (c >= 0x31C0 && c <= 0x31EF)
+        return true;
+    
+    // Enclosed CJK Letters and Months.
+    if (c >= 0x3200 && c <= 0x32FF)
+        return true;
+    
+    // CJK Compatibility.
+    if (c >= 0x3300 && c <= 0x33FF)
+        return true;
+    
+    // CJK Compatibility Ideographs.
+    if (c >= 0xF900 && c <= 0xFAFF)
+        return true;
+    
+    // CJK Compatibility Forms.
+    if (c >= 0xFE30 && c <= 0xFE4F)
+        return true;
+
+    // Emoji.
+    if (c >= 0x1F200 && c <= 0x1F6F)
+        return true;
+
+    // CJK Unified Ideographs Extension B.
+    if (c >= 0x20000 && c <= 0x2A6DF)
+        return true;
+        
+    // CJK Unified Ideographs Extension C.
+    if (c >= 0x2A700 && c <= 0x2B73F)
+        return true;
+    
+    // CJK Unified Ideographs Extension D.
+    if (c >= 0x2B740 && c <= 0x2B81F)
+        return true;
+    
+    // CJK Compatibility Ideographs Supplement.
+    if (c >= 0x2F800 && c <= 0x2FA1F)
+        return true;
+
+    return false;
+}
+
 }
diff --git a/WebCore/platform/graphics/Font.h b/WebCore/platform/graphics/Font.h
index 1a321bd..73c955e 100644
--- a/WebCore/platform/graphics/Font.h
+++ b/WebCore/platform/graphics/Font.h
@@ -143,6 +143,8 @@ public:
     // Used for complex text, and does not utilize the glyph map cache.
     const FontData* fontDataForCharacters(const UChar*, int length) const;
 
+    static bool isCJKIdeograph(UChar32);
+    
 #if PLATFORM(QT)
     QFont font() const;
 #endif
diff --git a/WebCore/platform/graphics/FontFastPath.cpp b/WebCore/platform/graphics/FontFastPath.cpp
index 82f970f..f0dd33e 100644
--- a/WebCore/platform/graphics/FontFastPath.cpp
+++ b/WebCore/platform/graphics/FontFastPath.cpp
@@ -74,8 +74,23 @@ GlyphData Font::glyphDataForCharacter(UChar32 c, bool mirror, bool forceSmallCap
             page = node->page();
             if (page) {
                 GlyphData data = page->glyphDataForCharacter(c);
-                if (data.fontData)
+                if (data.fontData) {
+                    if (data.fontData->platformData().orientation() == Vertical && data.fontData->orientation() == Horizontal && Font::isCJKIdeograph(c)) {
+                        const SimpleFontData* ideographFontData = data.fontData->brokenIdeographFontData();
+                        GlyphPageTreeNode* ideographNode = GlyphPageTreeNode::getRootChild(ideographFontData, pageNumber);
+                        const GlyphPage* ideographPage = ideographNode->page();
+                        if (ideographPage) {
+                            GlyphData data = ideographPage->glyphDataForCharacter(c);
+                            if (data.fontData)
+                                return data;
+                        }
+                        
+                        // Shouldn't be possible to even reach this point.
+                        ASSERT_NOT_REACHED();
+                    }
                     return data;
+                }
+
                 if (node->isSystemFallback())
                     break;
             }
diff --git a/WebCore/platform/graphics/SimpleFontData.cpp b/WebCore/platform/graphics/SimpleFontData.cpp
index 7980643..15598d8 100644
--- a/WebCore/platform/graphics/SimpleFontData.cpp
+++ b/WebCore/platform/graphics/SimpleFontData.cpp
@@ -51,11 +51,14 @@ SimpleFontData::SimpleFontData(const FontPlatformData& platformData, bool isCust
     : m_maxCharWidth(-1)
     , m_avgCharWidth(-1)
     , m_unitsPerEm(defaultUnitsPerEm)
+    , m_orientation(platformData.orientation())
     , m_platformData(platformData)
     , m_treatAsFixedPitch(false)
     , m_isCustomFont(isCustomFont)
     , m_isLoading(isLoading)
+    , m_isBrokenIdeographFont(false)
     , m_smallCapsFontData(0)
+    , m_brokenIdeographFontData(0)
 {
     platformInit();
     platformGlyphInit();
@@ -64,12 +67,15 @@ SimpleFontData::SimpleFontData(const FontPlatformData& platformData, bool isCust
 
 #if ENABLE(SVG_FONTS)
 SimpleFontData::SimpleFontData(PassOwnPtr<SVGFontData> svgFontData, int size, bool syntheticBold, bool syntheticItalic)
-    : m_platformData(FontPlatformData(size, syntheticBold, syntheticItalic))
+    : m_orientation(Horizontal)
+    , m_platformData(FontPlatformData(size, syntheticBold, syntheticItalic))
     , m_treatAsFixedPitch(false)
     , m_svgFontData(svgFontData)
     , m_isCustomFont(true)
     , m_isLoading(false)
+    , m_isBrokenIdeographFont(false)
     , m_smallCapsFontData(0)
+    , m_brokenIdeographFontData(0)
 {
     SVGFontFaceElement* svgFontFaceElement = m_svgFontData->svgFontFaceElement();
     m_unitsPerEm = svgFontFaceElement->unitsPerEm();
@@ -183,6 +189,8 @@ SimpleFontData::~SimpleFontData()
             fontCache()->releaseFontData(m_smallCapsFontData);
         GlyphPageTreeNode::pruneTreeFontData(this);
     }
+    
+    delete m_brokenIdeographFontData;
 }
 
 const SimpleFontData* SimpleFontData::fontDataForCharacter(UChar32) const
@@ -195,6 +203,16 @@ bool SimpleFontData::isSegmented() const
     return false;
 }
 
+SimpleFontData* SimpleFontData::brokenIdeographFontData() const
+{
+    if (!m_brokenIdeographFontData) {
+        m_brokenIdeographFontData = new SimpleFontData(m_platformData, isCustomFont(), false);
+        m_brokenIdeographFontData->m_orientation = Vertical;
+        m_brokenIdeographFontData->m_isBrokenIdeographFont = true;
+    }
+    return m_brokenIdeographFontData;
+}
+
 #ifndef NDEBUG
 String SimpleFontData::description() const
 {
diff --git a/WebCore/platform/graphics/SimpleFontData.h b/WebCore/platform/graphics/SimpleFontData.h
index 7bd58ad..6e06a70 100644
--- a/WebCore/platform/graphics/SimpleFontData.h
+++ b/WebCore/platform/graphics/SimpleFontData.h
@@ -77,6 +77,8 @@ public:
     const FontPlatformData& platformData() const { return m_platformData; }
     SimpleFontData* smallCapsFontData(const FontDescription& fontDescription) const;
 
+    SimpleFontData* brokenIdeographFontData() const;
+    
     // vertical metrics
     int ascent() const { return m_ascent; }
     int descent() const { return m_descent; }
@@ -162,6 +164,8 @@ public:
     wxFont* getWxFont() const { return m_platformData.font(); }
 #endif
 
+    FontOrientation orientation() const { return m_orientation; }
+
 private:
     void platformInit();
     void platformGlyphInit();
@@ -188,6 +192,9 @@ private:
     float m_avgCharWidth;
     float m_xHeight;
     unsigned m_unitsPerEm;
+    
+    FontOrientation m_orientation; // This is our supported orientation according to the tables in the font.  FontPlatformData will just always have the desired orientation.
+                                   // This value represents what we actually support.
 
     FontPlatformData m_platformData;
 
@@ -202,6 +209,7 @@ private:
 
     bool m_isCustomFont;  // Whether or not we are custom font loaded via @font-face
     bool m_isLoading; // Whether or not this custom font is still in the act of loading.
+    bool m_isBrokenIdeographFont;
 
     Glyph m_spaceGlyph;
     float m_spaceWidth;
@@ -213,6 +221,8 @@ private:
 
     mutable SimpleFontData* m_smallCapsFontData;
 
+    mutable SimpleFontData* m_brokenIdeographFontData;
+
 #if PLATFORM(CG) || PLATFORM(CAIRO) || PLATFORM(WX)
     float m_syntheticBoldOffset;
 #endif
diff --git a/WebCore/platform/graphics/cg/FontPlatformData.h b/WebCore/platform/graphics/cg/FontPlatformData.h
index 08da69f..e21b444 100644
--- a/WebCore/platform/graphics/cg/FontPlatformData.h
+++ b/WebCore/platform/graphics/cg/FontPlatformData.h
@@ -24,6 +24,7 @@
 #ifndef FontPlatformData_h
 #define FontPlatformData_h
 
+#include "FontOrientation.h"
 #include "RefCountedGDIHandle.h"
 #include "StringImpl.h"
 #include <wtf/Forward.h>
@@ -66,6 +67,8 @@ public:
     bool syntheticOblique() const { return m_syntheticOblique; }
     bool useGDI() const { return m_useGDI; }
 
+    FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
+
     unsigned hash() const
     {
         return m_font->hash();
diff --git a/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.h b/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.h
index c59cb56..b6ebb2e 100644
--- a/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.h
+++ b/WebCore/platform/graphics/chromium/FontPlatformDataChromiumWin.h
@@ -34,6 +34,7 @@
 
 #include "config.h"
 
+#include "FontOrientation.h"
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -69,6 +70,8 @@ public:
     HFONT hfont() const { return m_font ? m_font->hfont() : 0; }
     float size() const { return m_size; }
 
+    FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
+
     unsigned hash() const
     { 
         return m_font ? m_font->hash() : NULL;
diff --git a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h
index 363e55f..694a945 100644
--- a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h
+++ b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h
@@ -31,6 +31,7 @@
 #ifndef FontPlatformDataLinux_h
 #define FontPlatformDataLinux_h
 
+#include "FontOrientation.h"
 #include "FontRenderStyle.h"
 #include <wtf/Forward.h>
 #include <wtf/RefPtr.h>
@@ -105,6 +106,8 @@ public:
     unsigned hash() const;
     float size() const { return m_textSize; }
 
+    FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
+
     bool operator==(const FontPlatformData&) const;
     FontPlatformData& operator=(const FontPlatformData&);
     bool isHashTableDeletedValue() const { return m_typeface == hashTableDeletedFontValue(); }
diff --git a/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm b/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
index dbfec5f..c57d7a3 100644
--- a/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
+++ b/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
@@ -62,24 +62,6 @@ FontPlatformData::FontPlatformData(NSFont *nsFont, bool syntheticBold, bool synt
     
     CGFontRef cgFont = 0;
     loadFont(nsFont, m_size, m_font, cgFont, m_atsuFontID);
-    
-    if (orientation == Vertical) {
-        // Ignore vertical orientation when the font doesn't support vertical metrics.
-        // The check doesn't look neat but this is what AppKit does for vertical writing...
-        RetainPtr<CFArrayRef> tableTags(AdoptCF, CTFontCopyAvailableTables(ctFont(), kCTFontTableOptionExcludeSynthetic));
-        CFIndex numTables = CFArrayGetCount(tableTags.get());
-        bool found = false;
-        for (CFIndex index = 0; index < numTables; ++index) {
-            CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);
-            if (tag == kCTFontTableVhea || tag == kCTFontTableVORG) {
-                found = true;
-                break;
-            }
-        }
-
-        if (found == false)
-            orientation = Horizontal;
-    }
 
     m_orientation = orientation;
 
diff --git a/WebCore/platform/graphics/freetype/FontPlatformData.h b/WebCore/platform/graphics/freetype/FontPlatformData.h
index 016489e..0793746 100644
--- a/WebCore/platform/graphics/freetype/FontPlatformData.h
+++ b/WebCore/platform/graphics/freetype/FontPlatformData.h
@@ -27,6 +27,7 @@
 #define FontPlatformDataFreeType_h
 
 #include "FontDescription.h"
+#include "FontOrientation.h"
 #include "GlyphBuffer.h"
 #include "HashFunctions.h"
 #include "RefPtrCairo.h"
@@ -68,6 +69,8 @@ public:
     bool syntheticBold() const { return m_syntheticBold; }
     bool syntheticOblique() const { return m_syntheticOblique; }
 
+    FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
+
     cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
 
     unsigned hash() const
diff --git a/WebCore/platform/graphics/mac/FontMac.mm b/WebCore/platform/graphics/mac/FontMac.mm
index d760f5a..8dc741b 100644
--- a/WebCore/platform/graphics/mac/FontMac.mm
+++ b/WebCore/platform/graphics/mac/FontMac.mm
@@ -52,7 +52,7 @@ static void showGlyphsWithAdvances(const SimpleFontData* font, CGContextRef cont
     const FontPlatformData& platformData = font->platformData();
     if (!platformData.isColorBitmapFont()) {
         CGAffineTransform savedMatrix;
-        bool isVertical = platformData.orientation() == Vertical;
+        bool isVertical = font->orientation() == Vertical;
 
         if (isVertical) {
             CGAffineTransform rotateLeftTransform = CGAffineTransformMake(0, -1, 1, 0, 0, 0);
diff --git a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
index fd57630..e72565d 100644
--- a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
+++ b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
@@ -260,6 +260,24 @@ void SimpleFontData::platformInit()
         m_descent = 3;
     }
     
+    if (m_orientation == Vertical) {
+        // Ignore vertical orientation when the font doesn't support vertical metrics.
+        // The check doesn't look neat but this is what AppKit does for vertical writing...
+        RetainPtr<CFArrayRef> tableTags(AdoptCF, CTFontCopyAvailableTables(m_platformData.ctFont(), kCTFontTableOptionExcludeSynthetic));
+        CFIndex numTables = CFArrayGetCount(tableTags.get());
+        bool found = false;
+        for (CFIndex index = 0; index < numTables; ++index) {
+            CTFontTableTag tag = (CTFontTableTag)(uintptr_t)CFArrayGetValueAtIndex(tableTags.get(), index);
+            if (tag == kCTFontTableVhea || tag == kCTFontTableVORG) {
+                found = true;
+                break;
+            }
+        }
+
+        if (found == false)
+            m_orientation = Horizontal;
+    }
+
     // Measure the actual character "x", because AppKit synthesizes X height rather than getting it from the font.
     // Unfortunately, NSFont will round this for us so we don't quite get the right value.
     GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
@@ -423,7 +441,7 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
     FloatRect boundingBox;
 #ifndef BUILDING_ON_TIGER
     boundingBox = CTFontGetBoundingRectsForGlyphs(m_platformData.ctFont(),
-                    m_platformData.orientation() == Vertical ? kCTFontVerticalOrientation : kCTFontHorizontalOrientation, &glyph, 0, 1);
+                    orientation() == Vertical ? kCTFontVerticalOrientation : kCTFontHorizontalOrientation, &glyph, 0, 1);
     boundingBox.setY(-boundingBox.bottom());
 #else
     // FIXME: Custom fonts don't have NSFonts, so this function doesn't compute correct bounds for these on Tiger.
@@ -441,7 +459,7 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
 float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
 {
     CGSize advance;
-    if (m_platformData.orientation() == Horizontal) {
+    if (orientation() == Horizontal || m_isBrokenIdeographFont) {
         NSFont* font = platformData().font();
         float pointSize = platformData().m_size;
         CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
diff --git a/WebCore/platform/graphics/pango/FontPlatformData.h b/WebCore/platform/graphics/pango/FontPlatformData.h
index c42af7f..2929a3f 100644
--- a/WebCore/platform/graphics/pango/FontPlatformData.h
+++ b/WebCore/platform/graphics/pango/FontPlatformData.h
@@ -26,6 +26,7 @@
 #define FontPlatformDataPango_h
 
 #include "FontDescription.h"
+#include "FontOrientation.h"
 #include "GlyphBuffer.h"
 #include <cairo.h>
 #include <pango/pangocairo.h>
@@ -66,6 +67,8 @@ public:
     bool syntheticBold() const { return m_syntheticBold; }
     bool syntheticOblique() const { return m_syntheticOblique; }
 
+    FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
+
     cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
 
     unsigned hash() const
diff --git a/WebCore/platform/graphics/qt/FontPlatformData.h b/WebCore/platform/graphics/qt/FontPlatformData.h
index 79daa6b..2201f18 100644
--- a/WebCore/platform/graphics/qt/FontPlatformData.h
+++ b/WebCore/platform/graphics/qt/FontPlatformData.h
@@ -26,6 +26,7 @@
 
 #include <wtf/Forward.h>
 #include "FontDescription.h"
+#include "FontOrientation.h"
 #include <QFont>
 #include <QHash>
 
@@ -153,6 +154,9 @@ public:
             return m_data->font.pixelSize();
         return 0;
     }
+    
+    FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
+
     unsigned hash() const;
 
 #ifndef NDEBUG
diff --git a/WebCore/platform/graphics/wince/FontPlatformData.h b/WebCore/platform/graphics/wince/FontPlatformData.h
index 4a174f0..e73a7b2 100644
--- a/WebCore/platform/graphics/wince/FontPlatformData.h
+++ b/WebCore/platform/graphics/wince/FontPlatformData.h
@@ -26,6 +26,7 @@
 #define FontPlatformData_h
 
 #include "FontDescription.h"
+#include "FontOrientation.h"
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/text/StringImpl.h>
@@ -77,6 +78,8 @@ namespace WebCore {
         static const String& defaultFontFamily();
         static LONG adjustedGDIFontWeight(LONG gdiFontWeight, const String& family);
 
+        FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
+
 #ifndef NDEBUG
         String description() const;
 #endif
diff --git a/WebCore/platform/graphics/wx/FontPlatformData.h b/WebCore/platform/graphics/wx/FontPlatformData.h
index b328545..9ae8b54 100644
--- a/WebCore/platform/graphics/wx/FontPlatformData.h
+++ b/WebCore/platform/graphics/wx/FontPlatformData.h
@@ -30,6 +30,7 @@
 #define FontPlatformData_h
 
 #include "FontDescription.h"
+#include "FontOrientation.h"
 #include "StringImpl.h"
 #include <wtf/Forward.h>
 #include <wtf/RefPtr.h>
@@ -147,6 +148,8 @@ public:
     
     bool allowsLigatures() const { return false; }
     
+    FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
+
 #if OS(WINDOWS)
     bool useGDI() const;
     HFONT hfont() const;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list