#include "SkPath.h"
#include "SkTypeface.h"
#include "SkTypes.h"
+#include "SkUtils.h"
#include "platform/fonts/FontDescription.h"
+#include "platform/fonts/GlyphPage.h"
#include "platform/fonts/VDMXParser.h"
#include "platform/geometry/FloatRect.h"
#include "wtf/unicode/Unicode.h"
-#if OS(WIN)
-#include "platform/win/HWndDC.h"
-#endif
-
-namespace WebCore {
+namespace blink {
// This is the largest VDMX table which we'll try to load and parse.
static const size_t maxVDMXTableSize = 1024 * 1024; // 1 MB
m_fontMetrics.setLineGap(lineGap);
m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
- // For now Skia does not support underline Thickness, once patch is comitted we can uncomment following
- // code, till then setting Underline Thickness to Zero so that default calculation is done.
- // float underlineThickness = SkScalarToFloat(metrics.fUnderlineThickness);
- // m_fontMetrics.setUnderlineThickness(underlineThickness);
- m_fontMetrics.setUnderlineThickness(0.f);
-
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');
// m_avgCharWidth in order for text entry widgets to be sized correctly.
#if OS(WIN)
m_maxCharWidth = SkScalarRoundToInt(metrics.fMaxCharWidth);
+
+ // Older version of the DirectWrite API doesn't implement support for max
+ // char width. Fall back on a multiple of the ascent. This is entirely
+ // arbitrary but comes pretty close to the expected value in most cases.
+ if (m_maxCharWidth < 1)
+ m_maxCharWidth = ascent * 2;
#else
// FIXME: This seems incorrect and should probably use fMaxCharWidth as
// the code path above.
PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
{
const float scaledSize = lroundf(fontDescription.computedSize() * scaleFactor);
- return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize), isCustomFont() ? CustomFontData::create(false) : 0);
+ return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize), isCustomFont() ? CustomFontData::create() : nullptr);
}
void SimpleFontData::determinePitch()
return SkScalarToFloat(width);
}
-#if USE(HARFBUZZ)
bool SimpleFontData::canRenderCombiningCharacterSequence(const UChar* characters, size_t length) const
{
if (!m_combiningCharacterSequenceSupport)
}
return false;
}
-#endif
-} // namespace WebCore
+bool SimpleFontData::fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength) const
+{
+ if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) {
+ SkDebugf("%s last char is high-surrogate", __FUNCTION__);
+ return false;
+ }
+
+ SkAutoSTMalloc<GlyphPage::size, uint16_t> glyphStorage(length);
+
+ uint16_t* glyphs = glyphStorage.get();
+ SkTypeface* typeface = platformData().typeface();
+ typeface->charsToGlyphs(buffer, SkTypeface::kUTF16_Encoding, glyphs, length);
+
+ bool haveGlyphs = false;
+ for (unsigned i = 0; i < length; i++) {
+ if (glyphs[i]) {
+ pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this);
+ haveGlyphs = true;
+ }
+ }
+
+ return haveGlyphs;
+}
+
+} // namespace blink