341 float Font::floatWidthForComplexText(const TextRun& run,
HashSet<const SimpleFontData*>*,
GlyphOverflow*) const
342 {
343 SkPaint paint;
344
345 primaryFont()->platformData().setupPaint(&paint);
346
347
348
349 SkScalar width = paint.measureText(run.characters(), run.length() << 1);
350 return SkScalarToFloat(width);
351 }
254 inline const SimpleFontData* Font::primaryFont() const
255 {
256 ASSERT(m_fontList);
257 return m_fontList->primarySimpleFontData(this);
258 }
58 const SimpleFontData* primarySimpleFontData(const Font* f)
59 {
60 ASSERT(isMainThread());
61 if (!m_cachedPrimarySimpleFontData)
62 m_cachedPrimarySimpleFontData = primaryFontData(f)->fontDataForCharacter(' ');
63 return m_cachedPrimarySimpleFontData;
64 }
203 void FontPlatformData::setupPaint(SkPaint* paint) const
204 {
205 if (hashTableDeletedFontValue() == m_typeface)
206 paint->setTypeface(0);
207 else
208 paint->setTypeface(m_typeface);
209
210 paint->setAntiAlias(true);
211 paint->setSubpixelText(true);
212 paint->setHinting(SkPaint::kSlight_Hinting);
213 paint->setTextSize(SkFloatToScalar(m_textSize));
214 paint->setFakeBoldText(m_fakeBold);
215 paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1/4 : 0);
216 paint->setLanguage(s_defaultLanguage);
217 #ifndef SUPPORT_COMPLEX_SCRIPTS
218 paint->setTextEncoding(SkPaint::kUTF16_TextEncoding);
219 #endif
220 }
131 static SkTypeface* hashTableDeletedFontValue() {
132 return reinterpret_cast<SkTypeface*>(-1);
133 }