SkScalar y = SkFloatToScalar(point.y());
const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from);
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();
SkCanvas* canvas = gc->platformContext()->mCanvas;
localCount * sizeof(uint16_t),
&pos[localIndex], paint);
} else {
+ bool isVertical = font->platformData().orientation() == Vertical;
for (int i = 0; i < numGlyphs; i++) {
pos[i].set(x, y);
- x += SkFloatToScalar(adv[i].width());
y += SkFloatToScalar(adv[i].height());
+ if (isVertical) {
+ SkScalar myWidth = SkFloatToScalar(adv[i].width());
+ vPosBegin[i].set(x + myWidth, y);
+ vPosEnd[i].set(x + myWidth, y - myWidth);
+ x += myWidth;
+
+ SkPath path;
+ path.reset();
+ path.moveTo(vPosBegin[i]);
+ path.lineTo(vPosEnd[i]);
+ canvas->drawTextOnPath(glyphs + i, 2, path, 0, paint);
+ }
+ else {
+ x += SkFloatToScalar(adv[i].width());
+ }
}
- canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
+ if (!isVertical)
+ canvas->drawPosText(glyphs, numGlyphs * sizeof(uint16_t), pos, paint);
}
}
result = new FontPlatformData(tf, fontDescription.computedSize(),
(style & SkTypeface::kBold) && !tf->isBold(),
- (style & SkTypeface::kItalic) && !tf->isItalic());
+ (style & SkTypeface::kItalic) && !tf->isItalic(),
+ fontDescription.orientation(),
+ fontDescription.textOrientation());
}
tf->unref();
// the unref is enough to release the font data...
}
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant, FontRenderingMode)
+FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic,
+ FontOrientation fontOrientation, TextOrientation textOrientation, FontWidthVariant, FontRenderingMode)
{
// turn bold/italic into fakeBold/fakeItalic
if (m_typeface != NULL) {
if (m_typeface->isItalic() == italic)
italic = false;
}
- return FontPlatformData(m_typeface, size, bold, italic);
+ return FontPlatformData(m_typeface, size, bold, italic, fontOrientation, textOrientation);
}
FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
#include "SimpleFontData.h"
#include "FloatRect.h"
#include "FontDescription.h"
+#include "SkFontHost.h"
#include "SkPaint.h"
#include "SkTypeface.h"
#include "SkTime.h"
m_fontMetrics.setXHeight(SkScalarToFloat(-skiaFontMetrics.fAscent) * 0.56f); // hack I stole from the window's port
m_fontMetrics.setLineSpacing(a + d);
m_fontMetrics.setLineGap(SkScalarToFloat(skiaFontMetrics.fLeading));
+
+ if (platformData().orientation() == Vertical && !isTextOrientationFallback()) {
+ static const uint32_t vheaTag = SkSetFourByteTag('v', 'h', 'e', 'a');
+ static const uint32_t vorgTag = SkSetFourByteTag('V', 'O', 'R', 'G');
+ const SkFontID fontID = m_platformData.uniqueID();
+ size_t vheaSize = SkFontHost::GetTableSize(fontID, vheaTag);
+ size_t vorgSize = SkFontHost::GetTableSize(fontID, vorgTag);
+ if ((vheaSize > 0) || (vorgSize > 0))
+ m_hasVerticalGlyphs = true;
+ }
}
void SimpleFontData::platformCharWidthInit()
#define FontPlatformData_h
#include "FontOrientation.h"
+#include "TextOrientation.h"
#include <wtf/text/StringImpl.h>
#ifndef NDEBUG
FontPlatformData();
FontPlatformData(const FontPlatformData&);
- FontPlatformData(SkTypeface*, float textSize, bool fakeBold, bool fakeItalic);
+ FontPlatformData(SkTypeface*, float textSize, bool fakeBold, bool fakeItalic,
+ FontOrientation = Horizontal, TextOrientation = TextOrientationVerticalRight);
FontPlatformData(const FontPlatformData& src, float textSize);
FontPlatformData(float size, bool syntheticBold, bool syntheticOblique);
FontPlatformData(const FontPlatformData& src, SkTypeface* typeface);
return mTypeface == hashTableDeletedFontValue();
}
- FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
- void setOrientation(FontOrientation) { } // FIXME: Implement.
-
+ FontOrientation orientation() const { return mOrientation; }
+ void setOrientation(FontOrientation orientation) { mOrientation = orientation; }
FontPlatformData& operator=(const FontPlatformData&);
bool operator==(const FontPlatformData& a) const;
float mTextSize;
bool mFakeBold;
bool mFakeItalic;
+ FontOrientation mOrientation;
+ TextOrientation mTextOrientation;
mutable RefPtr<RefCountedHarfbuzzFace> m_harfbuzzFace;
static SkTypeface* hashTableDeletedFontValue() {
mFakeBold = src.mFakeBold;
mFakeItalic = src.mFakeItalic;
m_harfbuzzFace = src.m_harfbuzzFace;
+ mOrientation = src.mOrientation;
+ mTextOrientation = src.mTextOrientation;
inc_count();
trace(2);
}
-FontPlatformData::FontPlatformData(SkTypeface* tf, float textSize, bool fakeBold, bool fakeItalic)
- : mTypeface(tf), mTextSize(textSize), mFakeBold(fakeBold), mFakeItalic(fakeItalic)
+FontPlatformData::FontPlatformData(SkTypeface* tf, float textSize, bool fakeBold, bool fakeItalic,
+ FontOrientation orientation, TextOrientation textOrientation)
+ : mTypeface(tf), mTextSize(textSize), mFakeBold(fakeBold), mFakeItalic(fakeItalic),
+ mOrientation(orientation), mTextOrientation(textOrientation)
{
if (hashTableDeletedFontValue() != mTypeface) {
SkSafeRef(mTypeface);
FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
: mTypeface(src.mTypeface), mTextSize(textSize), mFakeBold(src.mFakeBold), mFakeItalic(src.mFakeItalic),
- m_harfbuzzFace(src.m_harfbuzzFace)
+ m_harfbuzzFace(src.m_harfbuzzFace), mOrientation(src.mOrientation), mTextOrientation(src.mTextOrientation)
{
if (hashTableDeletedFontValue() != mTypeface) {
SkSafeRef(mTypeface);
FontPlatformData::FontPlatformData(const FontPlatformData& src, SkTypeface* tf)
: mTypeface(tf), mTextSize(src.mTextSize), mFakeBold(src.mFakeBold),
- mFakeItalic(src.mFakeItalic)
+ mFakeItalic(src.mFakeItalic), mOrientation(src.mOrientation),
+ mTextOrientation(src.mTextOrientation)
{
if (hashTableDeletedFontValue() != mTypeface) {
SkSafeRef(mTypeface);
mFakeBold = src.mFakeBold;
mFakeItalic = src.mFakeItalic;
m_harfbuzzFace = src.m_harfbuzzFace;
+ mOrientation = src.mOrientation;
+ mTextOrientation = src.mTextOrientation;
return *this;
}
return mTypeface == a.mTypeface &&
mTextSize == a.mTextSize &&
mFakeBold == a.mFakeBold &&
- mFakeItalic == a.mFakeItalic;
+ mFakeItalic == a.mFakeItalic &&
+ mOrientation == a.mOrientation &&
+ mTextOrientation == a.mTextOrientation;
}
unsigned FontPlatformData::hash() const
uint32_t sizeAsInt = *reinterpret_cast<const uint32_t*>(&mTextSize);
- h ^= 0x01010101 * (((int)mFakeBold << 1) | (int)mFakeItalic);
+ h ^= 0x01010101 * ((static_cast<int>(mTextOrientation) << 3) | (static_cast<int>(mOrientation) << 2) |
+ ((int)mFakeBold << 1) | (int)mFakeItalic);
h ^= sizeAsInt;
return h;
}