[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
tkent at chromium.org
tkent at chromium.org
Wed Dec 22 18:44:51 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 0428c07d74ea220204abbd4a416a5754f5b576e3
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 17 05:19:32 2010 +0000
2010-12-16 Koan-Sin Tan <koansin.tan at gmail.com>
Reviewed by Kent Tamura.
Glyphs in vertical text tests are rotated 90 degrees clockwise on Chromium Linux
https://bugs.webkit.org/show_bug.cgi?id=50365
No new tests. But this makes Chromimium Linux show
fast/blockflow/japanese-*-text.html and other vertical
writing text correctly as on WebKit and Chromimum for Mac.
* platform/graphics/chromium/FontCacheLinux.cpp:
(WebCore::FontCache::createFontPlatformData):
* platform/graphics/chromium/FontLinux.cpp:
(WebCore::Font::drawGlyphs):
* platform/graphics/chromium/FontPlatformDataLinux.cpp:
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::operator=):
(WebCore::FontPlatformData::operator==):
(WebCore::FontPlatformData::hash):
* platform/graphics/chromium/FontPlatformDataLinux.h:
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::orientation):
* platform/graphics/chromium/SimpleFontDataLinux.cpp:
(WebCore::SimpleFontData::platformInit):
* platform/graphics/skia/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
* platform/graphics/skia/GlyphPageTreeNodeSkia.cpp:
(WebCore::substituteWithVerticalGlyphs):
(WebCore::GlyphPage::fill):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74232 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index fe869ef..1744ea5 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,34 @@
+2010-12-16 Koan-Sin Tan <koansin.tan at gmail.com>
+
+ Reviewed by Kent Tamura.
+
+ Glyphs in vertical text tests are rotated 90 degrees clockwise on Chromium Linux
+ https://bugs.webkit.org/show_bug.cgi?id=50365
+
+ No new tests. But this makes Chromimium Linux show
+ fast/blockflow/japanese-*-text.html and other vertical
+ writing text correctly as on WebKit and Chromimum for Mac.
+
+ * platform/graphics/chromium/FontCacheLinux.cpp:
+ (WebCore::FontCache::createFontPlatformData):
+ * platform/graphics/chromium/FontLinux.cpp:
+ (WebCore::Font::drawGlyphs):
+ * platform/graphics/chromium/FontPlatformDataLinux.cpp:
+ (WebCore::FontPlatformData::FontPlatformData):
+ (WebCore::FontPlatformData::operator=):
+ (WebCore::FontPlatformData::operator==):
+ (WebCore::FontPlatformData::hash):
+ * platform/graphics/chromium/FontPlatformDataLinux.h:
+ (WebCore::FontPlatformData::FontPlatformData):
+ (WebCore::FontPlatformData::orientation):
+ * platform/graphics/chromium/SimpleFontDataLinux.cpp:
+ (WebCore::SimpleFontData::platformInit):
+ * platform/graphics/skia/FontCustomPlatformData.cpp:
+ (WebCore::FontCustomPlatformData::fontPlatformData):
+ * platform/graphics/skia/GlyphPageTreeNodeSkia.cpp:
+ (WebCore::substituteWithVerticalGlyphs):
+ (WebCore::GlyphPage::fill):
+
2010-12-16 Yi Shen <yi.4.shen at nokia.com>, Tor Arne Vestbo <tor.arne.vestbo at nokia.com>
Reviewed by Eric Carlson.
diff --git a/WebCore/platform/graphics/chromium/FontCacheLinux.cpp b/WebCore/platform/graphics/chromium/FontCacheLinux.cpp
index 4399d35..bd33927 100644
--- a/WebCore/platform/graphics/chromium/FontCacheLinux.cpp
+++ b/WebCore/platform/graphics/chromium/FontCacheLinux.cpp
@@ -150,7 +150,8 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
name,
fontDescription.computedSize(),
(style & SkTypeface::kBold) && !tf->isBold(),
- (style & SkTypeface::kItalic) && !tf->isItalic());
+ (style & SkTypeface::kItalic) && !tf->isItalic(),
+ fontDescription.orientation());
tf->unref();
return result;
}
diff --git a/WebCore/platform/graphics/chromium/FontLinux.cpp b/WebCore/platform/graphics/chromium/FontLinux.cpp
index 4a4e53f..5e3e5b2 100644
--- a/WebCore/platform/graphics/chromium/FontLinux.cpp
+++ b/WebCore/platform/graphics/chromium/FontLinux.cpp
@@ -91,12 +91,20 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
// patches may be upstreamed to WebKit so we always use the slower path
// here.
const GlyphBufferAdvance* adv = glyphBuffer.advances(from);
- SkAutoSTMalloc<32, SkPoint> storage(numGlyphs);
+ SkAutoSTMalloc<32, SkPoint> storage(numGlyphs), storage2(numGlyphs), storage3(numGlyphs);
SkPoint* pos = storage.get();
+ SkPoint* vPosBegin = storage2.get();
+ SkPoint* vPosEnd = storage3.get();
+ bool isVertical = font->orientation() == Vertical;
for (int i = 0; i < numGlyphs; i++) {
+ SkScalar myWidth = SkFloatToScalar(adv[i].width());
pos[i].set(x, y);
- x += SkFloatToScalar(adv[i].width());
+ if (isVertical) {
+ vPosBegin[i].set(x + myWidth, y);
+ vPosEnd[i].set(x + myWidth, y - myWidth);
+ }
+ x += myWidth;
y += SkFloatToScalar(adv[i].height());
}
@@ -113,7 +121,17 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
adjustTextRenderMode(&paint, gc->platformContext());
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
paint.setColor(gc->fillColor().rgb());
- canvas->drawPosText(glyphs, numGlyphs << 1, pos, paint);
+
+ if (isVertical) {
+ SkPath path;
+ for (int i = 0; i < numGlyphs; ++i) {
+ path.reset();
+ path.moveTo(vPosBegin[i]);
+ path.lineTo(vPosEnd[i]);
+ canvas->drawTextOnPath(glyphs + i, 2, path, 0, paint);
+ }
+ } else
+ canvas->drawPosText(glyphs, numGlyphs << 1, pos, paint);
}
if ((textMode & TextModeStroke)
@@ -133,7 +151,16 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
SkSafeUnref(paint.setLooper(0));
}
- canvas->drawPosText(glyphs, numGlyphs << 1, pos, paint);
+ if (isVertical) {
+ SkPath path;
+ for (int i = 0; i < numGlyphs; ++i) {
+ path.reset();
+ path.moveTo(vPosBegin[i]);
+ path.lineTo(vPosEnd[i]);
+ canvas->drawTextOnPath(glyphs + i, 2, path, 0, paint);
+ }
+ } else
+ canvas->drawPosText(glyphs, numGlyphs << 1, pos, paint);
}
}
diff --git a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp
index 3944775..42942cc 100644
--- a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp
+++ b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp
@@ -73,18 +73,20 @@ FontPlatformData::FontPlatformData(const FontPlatformData& src)
, m_textSize(src.m_textSize)
, m_fakeBold(src.m_fakeBold)
, m_fakeItalic(src.m_fakeItalic)
+ , m_orientation(src.m_orientation)
, m_style(src.m_style)
, m_harfbuzzFace(src.m_harfbuzzFace)
{
SkSafeRef(m_typeface);
}
-FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float textSize, bool fakeBold, bool fakeItalic)
+FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float textSize, bool fakeBold, bool fakeItalic, FontOrientation orientation)
: m_typeface(tf)
, m_family(family)
, m_textSize(textSize)
, m_fakeBold(fakeBold)
, m_fakeItalic(fakeItalic)
+ , m_orientation(orientation)
{
SkSafeRef(m_typeface);
querySystemForRenderStyle();
@@ -116,6 +118,7 @@ FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
m_fakeBold = src.m_fakeBold;
m_fakeItalic = src.m_fakeItalic;
m_harfbuzzFace = src.m_harfbuzzFace;
+ m_orientation = src.m_orientation;
m_style = src.m_style;
return *this;
@@ -179,13 +182,14 @@ bool FontPlatformData::operator==(const FontPlatformData& a) const
&& m_textSize == a.m_textSize
&& m_fakeBold == a.m_fakeBold
&& m_fakeItalic == a.m_fakeItalic
+ && m_orientation == a.m_orientation
&& m_style == a.m_style;
}
unsigned FontPlatformData::hash() const
{
unsigned h = SkTypeface::UniqueID(m_typeface);
- h ^= 0x01010101 * ((static_cast<int>(m_fakeBold) << 1) | static_cast<int>(m_fakeItalic));
+ h ^= 0x01010101 * ((static_cast<int>(m_orientation) << 2) | (static_cast<int>(m_fakeBold) << 1) | static_cast<int>(m_fakeItalic));
// This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing
// rules. Memcpy is generally optimized enough so that performance doesn't
diff --git a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h
index 694a945..43771d7 100644
--- a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h
+++ b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.h
@@ -72,6 +72,7 @@ public:
, m_textSize(0)
, m_fakeBold(false)
, m_fakeItalic(false)
+ , m_orientation(Horizontal)
{ }
FontPlatformData(float textSize, bool fakeBold, bool fakeItalic)
@@ -79,10 +80,11 @@ public:
, m_textSize(textSize)
, m_fakeBold(fakeBold)
, m_fakeItalic(fakeItalic)
+ , m_orientation(Horizontal)
{ }
FontPlatformData(const FontPlatformData&);
- FontPlatformData(SkTypeface*, const char* name, float textSize, bool fakeBold, bool fakeItalic);
+ FontPlatformData(SkTypeface*, const char* name, float textSize, bool fakeBold, bool fakeItalic, FontOrientation orientation = Horizontal);
FontPlatformData(const FontPlatformData& src, float textSize);
~FontPlatformData();
@@ -106,7 +108,7 @@ public:
unsigned hash() const;
float size() const { return m_textSize; }
- FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
+ FontOrientation orientation() const { return m_orientation; }
bool operator==(const FontPlatformData&) const;
FontPlatformData& operator=(const FontPlatformData&);
@@ -153,6 +155,7 @@ private:
float m_textSize;
bool m_fakeBold;
bool m_fakeItalic;
+ FontOrientation m_orientation;
FontRenderStyle m_style;
mutable RefPtr<RefCountedHarfbuzzFace> m_harfbuzzFace;
diff --git a/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp b/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp
index 2a197b5..355d837 100644
--- a/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp
+++ b/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp
@@ -109,6 +109,15 @@ void SimpleFontData::platformInit()
m_lineGap = SkScalarRound(metrics.fLeading);
m_lineSpacing = m_ascent + m_descent + m_lineGap;
+ if (m_orientation == Vertical) {
+ static const uint32_t vheaTag = SkSetFourByteTag('v', 'h', 'e', 'a');
+ static const uint32_t vorgTag = SkSetFourByteTag('V', 'O', 'R', 'G');
+ size_t vheaSize = SkFontHost::GetTableSize(fontID, vheaTag);
+ size_t vorgSize = SkFontHost::GetTableSize(fontID, vorgTag);
+ if ((vheaSize <= 0) && (vorgSize <= 0))
+ m_orientation = Horizontal;
+ }
+
// In WebKit/WebCore/platform/graphics/SimpleFontData.cpp, m_spaceWidth is
// calculated for us, but we need to calculate m_maxCharWidth and
// m_avgCharWidth in order for text entry widgets to be sized correctly.
diff --git a/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp b/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp
index 2ea568b..161fee9 100644
--- a/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp
+++ b/WebCore/platform/graphics/skia/FontCustomPlatformData.cpp
@@ -65,7 +65,7 @@ FontCustomPlatformData::~FontCustomPlatformData()
#endif
}
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontRenderingMode mode)
+FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, FontRenderingMode mode)
{
#if OS(WINDOWS)
ASSERT(m_fontReference);
@@ -102,7 +102,7 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b
return FontPlatformData(hfont, size);
#elif OS(LINUX) || OS(FREEBSD) || PLATFORM(BREWMP)
ASSERT(m_fontReference);
- return FontPlatformData(m_fontReference, "", size, bold && !m_fontReference->isBold(), italic && !m_fontReference->isItalic());
+ return FontPlatformData(m_fontReference, "", size, bold && !m_fontReference->isBold(), italic && !m_fontReference->isItalic(), orientation);
#else
notImplemented();
return FontPlatformData();
diff --git a/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp b/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp
index 6024d43..66e6839 100644
--- a/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp
+++ b/WebCore/platform/graphics/skia/GlyphPageTreeNodeSkia.cpp
@@ -32,6 +32,7 @@
#include "GlyphPageTreeNode.h"
#include "Font.h"
+#include "HarfbuzzSkia.h"
#include "SimpleFontData.h"
#include "SkTemplates.h"
@@ -40,6 +41,36 @@
namespace WebCore {
+static int substituteWithVerticalGlyphs(const SimpleFontData* fontData, uint16_t* glyphs, unsigned bufferLength)
+{
+ HB_FaceRec_* hbFace = fontData->platformData().harfbuzzFace();
+ if (!hbFace->gsub) {
+ // if there is no GSUB table, treat it as not covered
+ return 0Xffff;
+ }
+
+ HB_Buffer buffer;
+ hb_buffer_new(&buffer);
+ for (unsigned i = 0; i < bufferLength; ++i)
+ hb_buffer_add_glyph(buffer, glyphs[i], 0, i);
+
+ HB_UShort scriptIndex;
+ HB_UShort featureIndex;
+
+ HB_GSUB_Select_Script(hbFace->gsub, HB_MAKE_TAG('D', 'F', 'L', 'T'), &scriptIndex);
+ HB_GSUB_Select_Feature(hbFace->gsub, HB_MAKE_TAG('v', 'e', 'r', 't'), scriptIndex, 0xffff, &featureIndex);
+ HB_GSUB_Add_Feature(hbFace->gsub, featureIndex, 1);
+ HB_GSUB_Select_Feature(hbFace->gsub, HB_MAKE_TAG('v', 'r', 't', '2'), scriptIndex, 0xffff, &featureIndex);
+ HB_GSUB_Add_Feature(hbFace->gsub, featureIndex, 1);
+
+ int error = HB_GSUB_Apply_String(hbFace->gsub, buffer);
+ if (!error) {
+ for (unsigned i = 0; i < bufferLength; ++i)
+ glyphs[i] = static_cast<Glyph>(buffer->out_string[i].gindex);
+ }
+ return error;
+}
+
bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
{
if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) {
@@ -60,6 +91,18 @@ bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned b
return false;
}
+ if ((fontData->orientation() == Vertical) && (!fontData->isBrokenIdeographFont())) {
+ bool lookVariants = false;
+ for (unsigned i = 0; i < bufferLength; ++i) {
+ if (!Font::isCJKIdeograph(buffer[i])) {
+ lookVariants = true;
+ continue;
+ }
+ }
+ if (lookVariants)
+ substituteWithVerticalGlyphs(fontData, glyphs, bufferLength);
+ }
+
unsigned allGlyphs = 0; // track if any of the glyphIDs are non-zero
for (unsigned i = 0; i < length; i++) {
setGlyphDataForIndex(offset + i, glyphs[i], glyphs[i] ? fontData : NULL);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list