diff options
Diffstat (limited to 'tools/fonts')
-rw-r--r-- | tools/fonts/SkTestTypeface.cpp | 57 | ||||
-rw-r--r-- | tools/fonts/SkTestTypeface.h | 1 |
2 files changed, 9 insertions, 49 deletions
diff --git a/tools/fonts/SkTestTypeface.cpp b/tools/fonts/SkTestTypeface.cpp index 52751c9f59..c2d220154c 100644 --- a/tools/fonts/SkTestTypeface.cpp +++ b/tools/fonts/SkTestTypeface.cpp @@ -98,16 +98,6 @@ SkTestTypeface::SkTestTypeface(sk_sp<SkTestFont> testFont, const SkFontStyle& st } void SkTestTypeface::getAdvance(SkGlyph* glyph) { - // TODO(benjaminwagner): Update users to use floats. - glyph->fAdvanceX = SkFixedToFloat(fTestFont->fWidths[glyph->getGlyphID()]); - glyph->fAdvanceY = 0; -} - -void SkTestTypeface::getFontMetrics(SkPaint::FontMetrics* metrics) { - *metrics = fTestFont->fMetrics; -} - -void SkTestTypeface::getMetrics(SkGlyph* glyph) { SkGlyphID glyphID = glyph->getGlyphID(); glyphID = glyphID < fTestFont->fCharCodesCount ? glyphID : 0; @@ -116,6 +106,10 @@ void SkTestTypeface::getMetrics(SkGlyph* glyph) { glyph->fAdvanceY = 0; } +void SkTestTypeface::getFontMetrics(SkPaint::FontMetrics* metrics) { + *metrics = fTestFont->fMetrics; +} + void SkTestTypeface::getPath(SkGlyphID glyphID, SkPath* path) { glyphID = glyphID < fTestFont->fCharCodesCount ? glyphID : 0; *path = *fTestFont->fPaths[glyphID]; @@ -211,46 +205,13 @@ protected: } void generateMetrics(SkGlyph* glyph) override { - this->getTestTypeface()->getMetrics(glyph); - - const SkVector advance = fMatrix.mapXY(SkFloatToScalar(glyph->fAdvanceX), - SkFloatToScalar(glyph->fAdvanceY)); - glyph->fAdvanceX = SkScalarToFloat(advance.fX); - glyph->fAdvanceY = SkScalarToFloat(advance.fY); - - SkPath path; - this->getTestTypeface()->getPath(glyph->getGlyphID(), &path); - path.transform(fMatrix); - - SkRect storage; - const SkPaint paint; - const SkRect& newBounds = paint.doComputeFastBounds(path.getBounds(), - &storage, - SkPaint::kFill_Style); - SkIRect ibounds; - newBounds.roundOut(&ibounds); - glyph->fLeft = ibounds.fLeft; - glyph->fTop = ibounds.fTop; - glyph->fWidth = ibounds.width(); - glyph->fHeight = ibounds.height(); + glyph->zeroMetrics(); + this->generateAdvance(glyph); + // Always generates from paths, so SkScalerContext::getMetrics will figure the bounds. } - void generateImage(const SkGlyph& glyph) override { - SkPath path; - this->getTestTypeface()->getPath(glyph.getGlyphID(), &path); - - SkBitmap bm; - bm.installPixels(SkImageInfo::MakeN32Premul(glyph.fWidth, glyph.fHeight), - glyph.fImage, glyph.rowBytes()); - bm.eraseColor(0); - - SkCanvas canvas(bm); - canvas.translate(-SkIntToScalar(glyph.fLeft), - -SkIntToScalar(glyph.fTop)); - canvas.concat(fMatrix); - SkPaint paint; - paint.setAntiAlias(true); - canvas.drawPath(path, paint); + void generateImage(const SkGlyph&) override { + SK_ABORT("Should have generated from path."); } void generatePath(SkGlyphID glyph, SkPath* path) override { diff --git a/tools/fonts/SkTestTypeface.h b/tools/fonts/SkTestTypeface.h index b520fb6e5c..d3365f972a 100644 --- a/tools/fonts/SkTestTypeface.h +++ b/tools/fonts/SkTestTypeface.h @@ -66,7 +66,6 @@ public: SkTestTypeface(sk_sp<SkTestFont>, const SkFontStyle& style); void getAdvance(SkGlyph* glyph); void getFontMetrics(SkPaint::FontMetrics* metrics); - void getMetrics(SkGlyph* glyph); void getPath(SkGlyphID glyph, SkPath* path); protected: SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, |