#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 {
// This is the largest VDMX table which we'll try to load and parse.
m_fontMetrics.setLineGap(lineGap);
m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
+ float underlineThickness = SkScalarToFloat(metrics.fUnderlineThickness);
+ m_fontMetrics.setUnderlineThickness(underlineThickness);
+
+ float underlinePosition = SkScalarToFloat(metrics.fUnderlinePosition);
+ m_fontMetrics.setUnderlineThickness(underlinePosition);
+
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');
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);
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- SkPaint paint;
- static const unsigned maxBufferCount = 64;
- uint16_t glyphs[maxBufferCount];
-
- m_platformData.setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
- while (length > 0) {
- int n = SkMin32(length, SK_ARRAY_COUNT(glyphs));
-
- // textToGlyphs takes a byte count so we double the character count.
- int count = paint.textToGlyphs(characters, n * 2, glyphs);
- for (int i = 0; i < count; i++) {
- if (!glyphs[i])
- return false; // missing glyph
- }
-
- characters += n;
- length -= n;
- }
-
- return true;
+ return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize), isCustomFont() ? CustomFontData::create() : nullptr);
}
void SimpleFontData::determinePitch()
WTF::HashMap<String, bool>::AddResult addResult = m_combiningCharacterSequenceSupport->add(String(characters, length), false);
if (!addResult.isNewEntry)
- return addResult.iterator->value;
+ return addResult.storedValue->value;
UErrorCode error = U_ZERO_ERROR;
Vector<UChar, 4> normalizedCharacters(length);
m_platformData.setupPaint(&paint);
paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) {
- addResult.iterator->value = true;
+ addResult.storedValue->value = true;
return true;
}
return false;
}
#endif
+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 WebCore