diff options
author | Cary Clark <caryclark@google.com> | 2014-07-31 08:58:44 -0400 |
---|---|---|
committer | Cary Clark <caryclark@google.com> | 2014-07-31 08:58:44 -0400 |
commit | 992c7b03ef7914a18bfd78e965b0b4c99a5f5672 (patch) | |
tree | 2158c7f9db5da4989dc591f0aabe4a6302f3bb63 /gm | |
parent | 3f22e8c44a16d93377c0a3881f936e692b5b3320 (diff) |
Add standard fonts to all GMs.
Allow GM results to be compared across machines and platforms by
standardizing the fonts used by all tests.
This adds runtime flags to DM to use either the system font context (the
default), the fonts in the resources directory ( --resourceFonts ) or a set
of canonical paths generated from the fonts ( --portableFonts ).
This CL should leave the current DM results unchanged by default.
If the portable font data or resource font is missing when DM is run, it
falls back to using the system font context.
The create_test_font tool generates the paths and metrics read by DM
with the --portableFonts flag set, and generates the font substitution
tables read by DM with the --resourceFonts flag set.
If DM is run in SkDebug mode with the --reportUsedChars flag set, it
generates the corresponding data compiled into the create_test_font tool.
All GM tests set their typeface information by calling either
sk_tool_utils::set_portable_typeface or
sk_tool_utils::portable_typeface .
(The former takes the paint, the latter returns a SkTypeface.) These calls
can be removed in the future when the Font Manager can be superceded.
BUG=skia:2687
R=mtklein@google.com
Review URL: https://codereview.chromium.org/407183003
Diffstat (limited to 'gm')
57 files changed, 86 insertions, 27 deletions
diff --git a/gm/bigtext.cpp b/gm/bigtext.cpp index 9c2682c15b..eabad14d0c 100644 --- a/gm/bigtext.cpp +++ b/gm/bigtext.cpp @@ -34,6 +34,7 @@ protected: virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(1500); SkRect r; diff --git a/gm/colortype.cpp b/gm/colortype.cpp index 2774f3a5ff..1d6dfad469 100644 --- a/gm/colortype.cpp +++ b/gm/colortype.cpp @@ -26,8 +26,8 @@ public: paint.setAntiAlias(true); paint.setShader(s)->unref(); - SkTypeface* orig = SkTypeface::CreateFromName("Times", - SkTypeface::kBold); + SkTypeface* orig = sk_tool_utils::create_portable_typeface("Times", + SkTypeface::kBold); if (NULL == orig) { orig = SkTypeface::RefDefault(); } diff --git a/gm/convexpolyclip.cpp b/gm/convexpolyclip.cpp index cb698c162b..35c4426f36 100644 --- a/gm/convexpolyclip.cpp +++ b/gm/convexpolyclip.cpp @@ -150,6 +150,7 @@ protected: SkPaint txtPaint; txtPaint.setTextSize(23.f); txtPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&txtPaint); txtPaint.setColor(SK_ColorDKGRAY); SkScalar textW = txtPaint.measureText(kTxt, SK_ARRAY_COUNT(kTxt)-1); diff --git a/gm/cubicpaths.cpp b/gm/cubicpaths.cpp index 68d143df60..f171522caa 100644 --- a/gm/cubicpaths.cpp +++ b/gm/cubicpaths.cpp @@ -280,6 +280,7 @@ protected: SkPaint titlePaint; titlePaint.setColor(SK_ColorBLACK); titlePaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&titlePaint); titlePaint.setLCDRenderText(true); titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Cubic Closed Drawn Into Rectangle Clips With " @@ -324,6 +325,7 @@ protected: SkPaint labelPaint; labelPaint.setColor(color); labelPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setLCDRenderText(true); labelPaint.setTextSize(10 * SK_Scalar1); canvas->drawText(gStyles[style].fName, diff --git a/gm/deviceproperties.cpp b/gm/deviceproperties.cpp index 92a3d51bb7..073e4f7e4d 100644 --- a/gm/deviceproperties.cpp +++ b/gm/deviceproperties.cpp @@ -55,7 +55,7 @@ protected: //With freetype the default (normal hinting) can be really ugly. //Most distros now set slight (vertical hinting only) in any event. paint.setHinting(SkPaint::kSlight_Hinting); - SkSafeUnref(paint.setTypeface(SkTypeface::CreateFromName("Times Roman", SkTypeface::kNormal))); + sk_tool_utils::set_portable_typeface(&paint, "Times Roman", SkTypeface::kNormal); const char* text = "Hamburgefons ooo mmm"; const size_t textLen = strlen(text); diff --git a/gm/downsamplebitmap.cpp b/gm/downsamplebitmap.cpp index f24c92b6e5..4cde4bda71 100644 --- a/gm/downsamplebitmap.cpp +++ b/gm/downsamplebitmap.cpp @@ -15,7 +15,7 @@ #include "SkPaint.h" static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style style) { - SkSafeUnref(paint->setTypeface(SkTypeface::CreateFromName(name, style))); + sk_tool_utils::set_portable_typeface(paint, name, style); } class DownsampleBitmapGM : public skiagm::GM { diff --git a/gm/drawbitmaprect.cpp b/gm/drawbitmaprect.cpp index 9c6fa3b027..fd205f5337 100644 --- a/gm/drawbitmaprect.cpp +++ b/gm/drawbitmaprect.cpp @@ -111,6 +111,7 @@ protected: blackPaint.setColor(SK_ColorBLACK); blackPaint.setTextSize(titleHeight); blackPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&blackPaint); SkString title; title.printf("Bitmap size: %d x %d", kBmpSize, kBmpSize); canvas->drawText(title.c_str(), title.size(), 0, diff --git a/gm/drawlooper.cpp b/gm/drawlooper.cpp index 67e280e4c4..a1b55bbc3f 100644 --- a/gm/drawlooper.cpp +++ b/gm/drawlooper.cpp @@ -40,6 +40,7 @@ protected: SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(SkIntToScalar(72)); paint.setLooper(fLooper); diff --git a/gm/dropshadowimagefilter.cpp b/gm/dropshadowimagefilter.cpp index ec849b244d..a22ec43722 100644 --- a/gm/dropshadowimagefilter.cpp +++ b/gm/dropshadowimagefilter.cpp @@ -39,6 +39,7 @@ static void draw_text(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { paint.setImageFilter(imf); paint.setColor(SK_ColorGREEN); paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(r.height()/2); paint.setTextAlign(SkPaint::kCenter_Align); canvas->save(); diff --git a/gm/emptypath.cpp b/gm/emptypath.cpp index 6b9322292e..87e1cc554e 100644 --- a/gm/emptypath.cpp +++ b/gm/emptypath.cpp @@ -63,6 +63,7 @@ protected: SkPaint titlePaint; titlePaint.setColor(SK_ColorBLACK); titlePaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&titlePaint); titlePaint.setLCDRenderText(true); titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Empty Paths Drawn Into Rectangle Clips With " @@ -105,6 +106,7 @@ protected: SkPaint labelPaint; labelPaint.setColor(color); labelPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setLCDRenderText(true); labelPaint.setTextSize(12 * SK_Scalar1); canvas->drawText(gStyles[style].fName, diff --git a/gm/filterbitmap.cpp b/gm/filterbitmap.cpp index 0d4b4b4a4b..26a1886bf4 100644 --- a/gm/filterbitmap.cpp +++ b/gm/filterbitmap.cpp @@ -14,7 +14,7 @@ #include "SkTypeface.h" static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style style) { - SkSafeUnref(paint->setTypeface(SkTypeface::CreateFromName(name, style))); + sk_tool_utils::set_portable_typeface(paint, name, style); } static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { diff --git a/gm/fontcache.cpp b/gm/fontcache.cpp index cb73e91377..74ec18a450 100644 --- a/gm/fontcache.cpp +++ b/gm/fontcache.cpp @@ -59,8 +59,8 @@ protected: int typefaceCount = 0; for (size_t i = 0; i < SK_ARRAY_COUNT(gFamilyNames); ++i) { for (size_t j = 0; j < SK_ARRAY_COUNT(gStyles); ++j) { - fTypefaces[typefaceCount++] = SkTypeface::CreateFromName(gFamilyNames[i], - gStyles[j]); + fTypefaces[typefaceCount++] = sk_tool_utils::create_portable_typeface(gFamilyNames[i], + gStyles[j]); } } } diff --git a/gm/fontscaler.cpp b/gm/fontscaler.cpp index 8a97e69970..8aef8f0ebe 100644 --- a/gm/fontscaler.cpp +++ b/gm/fontscaler.cpp @@ -47,7 +47,7 @@ protected: //With freetype the default (normal hinting) can be really ugly. //Most distros now set slight (vertical hinting only) in any event. paint.setHinting(SkPaint::kSlight_Hinting); - SkSafeUnref(paint.setTypeface(SkTypeface::CreateFromName("Times Roman", SkTypeface::kNormal))); + sk_tool_utils::set_portable_typeface(&paint, "Times Roman", SkTypeface::kNormal); const char* text = "Hamburgefons ooo mmm"; const size_t textLen = strlen(text); diff --git a/gm/gammatext.cpp b/gm/gammatext.cpp index f10680e567..cdc37fac93 100644 --- a/gm/gammatext.cpp +++ b/gm/gammatext.cpp @@ -26,7 +26,7 @@ static SkShader* make_heatGradient(const SkPoint pts[2]) { } static bool setFont(SkPaint* paint, const char name[]) { - SkTypeface* tf = SkTypeface::CreateFromName(name, SkTypeface::kNormal); + SkTypeface* tf = sk_tool_utils::create_portable_typeface(name, SkTypeface::kNormal); if (tf) { paint->setTypeface(tf)->unref(); return true; diff --git a/gm/getpostextpath.cpp b/gm/getpostextpath.cpp index 0f66a976b5..a411520258 100644 --- a/gm/getpostextpath.cpp +++ b/gm/getpostextpath.cpp @@ -42,6 +42,7 @@ protected: SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(SkIntToScalar(48)); canvas->translate(SkIntToScalar(10), SkIntToScalar(64)); diff --git a/gm/glyph_pos.cpp b/gm/glyph_pos.cpp index b0451016ac..ecb9963799 100644 --- a/gm/glyph_pos.cpp +++ b/gm/glyph_pos.cpp @@ -52,7 +52,7 @@ protected: virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { if (!fProp) { - fProp.reset(SkTypeface::CreateFromName("Helvetica", SkTypeface::kNormal)); + fProp.reset(sk_tool_utils::create_portable_typeface("Helvetica", SkTypeface::kNormal)); } // There's a black pixel at 40, 40 for reference. diff --git a/gm/gradtext.cpp b/gm/gradtext.cpp index 54bf175e51..96ce59f841 100644 --- a/gm/gradtext.cpp +++ b/gm/gradtext.cpp @@ -47,6 +47,7 @@ protected: virtual SkISize onISize() { return SkISize::Make(500, 480); } virtual void onDraw(SkCanvas* canvas) { SkPaint paint; + sk_tool_utils::set_portable_typeface(&paint); SkRect r = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); canvas->clipRect(r); @@ -75,6 +76,7 @@ protected: virtual SkISize onISize() { return SkISize::Make(500, 480); } virtual void onDraw(SkCanvas* canvas) { SkPaint paint; + sk_tool_utils::set_portable_typeface(&paint); paint.setStyle(SkPaint::kFill_Style); canvas->drawText("Normal Fill Text", 16, 0, 50, paint); @@ -127,6 +129,7 @@ protected: virtual void onDraw(SkCanvas* canvas) { SkPaint paint; + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(SkIntToScalar(26)); const SkISize& size = this->getISize(); diff --git a/gm/image.cpp b/gm/image.cpp index 88c1db523e..ff184d18b3 100644 --- a/gm/image.cpp +++ b/gm/image.cpp @@ -158,6 +158,7 @@ protected: SkPaint textPaint; textPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&textPaint); textPaint.setTextSize(8); canvas->drawText(kLabel1, strlen(kLabel1), 10, 60, textPaint); diff --git a/gm/imageblur.cpp b/gm/imageblur.cpp index b8e1971711..2e856781d3 100644 --- a/gm/imageblur.cpp +++ b/gm/imageblur.cpp @@ -44,6 +44,7 @@ protected: SkRandom rand; SkPaint textPaint; textPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&textPaint); for (int i = 0; i < 25; ++i) { int x = rand.nextULessThan(WIDTH); int y = rand.nextULessThan(HEIGHT); diff --git a/gm/imageblurtiled.cpp b/gm/imageblurtiled.cpp index 0580405dfe..ed4ae6cef3 100644 --- a/gm/imageblurtiled.cpp +++ b/gm/imageblurtiled.cpp @@ -50,6 +50,7 @@ protected: }; SkPaint textPaint; textPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&textPaint); textPaint.setTextSize(SkIntToScalar(100)); int posY = 0; for (unsigned i = 0; i < SK_ARRAY_COUNT(str); i++) { diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp index c270e67ee3..bbcb7ce2b5 100644 --- a/gm/imagefiltersbase.cpp +++ b/gm/imagefiltersbase.cpp @@ -113,6 +113,7 @@ static void draw_text(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { paint.setImageFilter(imf); paint.setColor(SK_ColorCYAN); paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(r.height()/2); paint.setTextAlign(SkPaint::kCenter_Align); canvas->drawText("Text", 4, r.centerX(), r.centerY(), paint); diff --git a/gm/imagefilterscropped.cpp b/gm/imagefilterscropped.cpp index a128c6b116..e7d37901d8 100644 --- a/gm/imagefilterscropped.cpp +++ b/gm/imagefilterscropped.cpp @@ -45,6 +45,7 @@ static void draw_text(SkCanvas* canvas, const SkRect& r, SkImageFilter* imf) { paint.setImageFilter(imf); paint.setColor(SK_ColorGREEN); paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(r.height()/2); paint.setTextAlign(SkPaint::kCenter_Align); canvas->save(); diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp index af3ebb7bc1..6500824b02 100644 --- a/gm/imagefiltersgraph.cpp +++ b/gm/imagefiltersgraph.cpp @@ -99,6 +99,7 @@ protected: canvas.clear(0x00000000); SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setColor(0xFFFFFFFF); paint.setTextSize(SkIntToScalar(96)); const char* str = "e"; diff --git a/gm/imagemagnifier.cpp b/gm/imagemagnifier.cpp index 23847e6f15..e2847b4c67 100644 --- a/gm/imagemagnifier.cpp +++ b/gm/imagemagnifier.cpp @@ -44,6 +44,7 @@ protected: 100))->unref(); canvas->saveLayer(NULL, &paint); paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); const char* str = "The quick brown fox jumped over the lazy dog."; SkRandom rand; for (int i = 0; i < 25; ++i) { diff --git a/gm/imageresizetiled.cpp b/gm/imageresizetiled.cpp index ec602749ac..d09fd27829 100644 --- a/gm/imageresizetiled.cpp +++ b/gm/imageresizetiled.cpp @@ -57,6 +57,7 @@ protected: }; SkPaint textPaint; textPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&textPaint); textPaint.setTextSize(SkIntToScalar(100)); int posY = 0; for (unsigned i = 0; i < SK_ARRAY_COUNT(str); i++) { diff --git a/gm/internal_links.cpp b/gm/internal_links.cpp index 7e5ce62b02..3ba3052c6a 100644 --- a/gm/internal_links.cpp +++ b/gm/internal_links.cpp @@ -61,6 +61,7 @@ private: canvas->drawRect(rect, paint); paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(SkIntToScalar(25)); paint.setColor(SK_ColorBLACK); canvas->drawText(text, strlen(text), x, y, paint); diff --git a/gm/lcdtext.cpp b/gm/lcdtext.cpp index f48dc9e2f3..b4db0ff12a 100644 --- a/gm/lcdtext.cpp +++ b/gm/lcdtext.cpp @@ -49,6 +49,7 @@ protected: paint.setColor(SK_ColorBLACK); paint.setDither(true); paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setSubpixelText(subpixelTextEnabled); paint.setLCDRenderText(lcdRenderTextEnabled); paint.setTextSize(textHeight); diff --git a/gm/lighting.cpp b/gm/lighting.cpp index 50698fadfc..e7842a9c81 100644 --- a/gm/lighting.cpp +++ b/gm/lighting.cpp @@ -34,6 +34,7 @@ protected: canvas.clear(0x00000000); SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setColor(0xFFFFFFFF); paint.setTextSize(SkIntToScalar(96)); const char* str = "e"; diff --git a/gm/linepaths.cpp b/gm/linepaths.cpp index ea4fdc887f..53a9327878 100644 --- a/gm/linepaths.cpp +++ b/gm/linepaths.cpp @@ -85,6 +85,7 @@ protected: SkPaint titlePaint; titlePaint.setColor(SK_ColorBLACK); titlePaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&titlePaint); titlePaint.setLCDRenderText(true); titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Line Drawn Into Rectangle Clips With " @@ -129,6 +130,7 @@ protected: SkPaint labelPaint; labelPaint.setColor(color); labelPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setLCDRenderText(true); labelPaint.setTextSize(10 * SK_Scalar1); canvas->drawText(gStyles[style].fName, @@ -227,6 +229,7 @@ protected: SkPaint titlePaint; titlePaint.setColor(SK_ColorBLACK); titlePaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&titlePaint); titlePaint.setLCDRenderText(true); titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Line Closed Drawn Into Rectangle Clips With " @@ -271,6 +274,7 @@ protected: SkPaint labelPaint; labelPaint.setColor(color); labelPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setLCDRenderText(true); labelPaint.setTextSize(10 * SK_Scalar1); canvas->drawText(gStyles[style].fName, diff --git a/gm/lumafilter.cpp b/gm/lumafilter.cpp index 4414093c9b..521a61bc28 100644 --- a/gm/lumafilter.cpp +++ b/gm/lumafilter.cpp @@ -18,6 +18,7 @@ static SkColor kColor2 = SkColorSetARGB(0xff, 0x80, 0xff, 0); static void draw_label(SkCanvas* canvas, const char* label, const SkPoint& offset) { SkPaint paint; + sk_tool_utils::set_portable_typeface(&paint); size_t len = strlen(label); SkScalar width = paint.measureText(label, len); diff --git a/gm/matrixconvolution.cpp b/gm/matrixconvolution.cpp index 592489c6e8..aff3850d6a 100644 --- a/gm/matrixconvolution.cpp +++ b/gm/matrixconvolution.cpp @@ -33,6 +33,7 @@ protected: canvas.clear(0x00000000); SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setColor(0xFFFFFFFF); paint.setTextSize(SkIntToScalar(180)); SkPoint pts[2] = { SkPoint::Make(0, 0), diff --git a/gm/morphology.cpp b/gm/morphology.cpp index ff6c1bac6c..cb321c6efd 100644 --- a/gm/morphology.cpp +++ b/gm/morphology.cpp @@ -31,6 +31,7 @@ protected: canvas.clear(0x0); SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); const char* str1 = "ABC"; const char* str2 = "XYZ"; paint.setColor(0xFFFFFFFF); diff --git a/gm/offsetimagefilter.cpp b/gm/offsetimagefilter.cpp index ca8a80997e..7fcbe0a04d 100644 --- a/gm/offsetimagefilter.cpp +++ b/gm/offsetimagefilter.cpp @@ -32,6 +32,7 @@ protected: canvas.clear(0x00000000); SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setColor(0xD000D000); paint.setTextSize(SkIntToScalar(96)); const char* str = "e"; diff --git a/gm/pathreverse.cpp b/gm/pathreverse.cpp index 77687f4e4a..fd13404198 100644 --- a/gm/pathreverse.cpp +++ b/gm/pathreverse.cpp @@ -52,8 +52,7 @@ static void test_rev(SkCanvas* canvas) { SkPaint paint; paint.setTextSize(SkIntToScalar(100)); - SkTypeface* hira = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro", SkTypeface::kNormal); - SkSafeUnref(paint.setTypeface(hira)); + sk_tool_utils::set_portable_typeface(&paint, "Hiragino Maru Gothic Pro"); path.reset(); paint.getTextPath("e", 1, 50, 50, &path); canvas->translate(0, 100); @@ -103,8 +102,7 @@ protected: SkPaint paint; paint.setTextSize(SkIntToScalar(100)); - SkTypeface* hira = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro", SkTypeface::kNormal); - SkSafeUnref(paint.setTypeface(hira)); + sk_tool_utils::set_portable_typeface(&paint, "Hiragino Maru Gothic Pro"); path.reset(); paint.getTextPath("e", 1, 50, 50, &path); canvas->translate(0, 100); diff --git a/gm/pictureimagefilter.cpp b/gm/pictureimagefilter.cpp index b0fd057235..4e169f77da 100644 --- a/gm/pictureimagefilter.cpp +++ b/gm/pictureimagefilter.cpp @@ -28,6 +28,7 @@ protected: canvas->clear(0x00000000); SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setColor(0xFFFFFFFF); paint.setTextSize(SkIntToScalar(96)); const char* str = "e"; diff --git a/gm/poly2poly.cpp b/gm/poly2poly.cpp index 9e58d9d036..191bb0eaea 100644 --- a/gm/poly2poly.cpp +++ b/gm/poly2poly.cpp @@ -37,6 +37,7 @@ private: SkJSCanvas::SkJSCanvas(SkCanvas* target) : fTarget(target) { fFillPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&fFillPaint); fStrokePaint.setAntiAlias(true); fStrokePaint.setStyle(SkPaint::kStroke_Style); fStrokePaint.setStrokeWidth(SK_Scalar1); @@ -229,6 +230,7 @@ protected: SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setStrokeWidth(SkIntToScalar(4)); paint.setTextSize(SkIntToScalar(40)); paint.setTextAlign(SkPaint::kCenter_Align); diff --git a/gm/quadpaths.cpp b/gm/quadpaths.cpp index f21fdd98e1..f2c4cf1fc8 100644 --- a/gm/quadpaths.cpp +++ b/gm/quadpaths.cpp @@ -86,6 +86,7 @@ protected: SkPaint titlePaint; titlePaint.setColor(SK_ColorBLACK); titlePaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&titlePaint); titlePaint.setLCDRenderText(true); titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Quad Drawn Into Rectangle Clips With " @@ -130,6 +131,7 @@ protected: SkPaint labelPaint; labelPaint.setColor(color); labelPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setLCDRenderText(true); labelPaint.setTextSize(10 * SK_Scalar1); canvas->drawText(gStyles[style].fName, @@ -233,6 +235,7 @@ protected: SkPaint titlePaint; titlePaint.setColor(SK_ColorBLACK); titlePaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&titlePaint); titlePaint.setLCDRenderText(true); titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Quad Closed Drawn Into Rectangle Clips With " @@ -277,6 +280,7 @@ protected: SkPaint labelPaint; labelPaint.setColor(color); labelPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setLCDRenderText(true); labelPaint.setTextSize(10 * SK_Scalar1); canvas->drawText(gStyles[style].fName, diff --git a/gm/samplerstress.cpp b/gm/samplerstress.cpp index 12f93cc785..9e0843e071 100644 --- a/gm/samplerstress.cpp +++ b/gm/samplerstress.cpp @@ -97,6 +97,7 @@ protected: // stipple mask with a round rect soft clip SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(72); paint.setShader(fShader.get()); paint.setMaskFilter(fMaskFilter.get()); @@ -123,6 +124,7 @@ protected: SkPaint paint2; paint2.setColor(SK_ColorBLACK); paint2.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint2); paint2.setTextSize(72); paint2.setStyle(SkPaint::kStroke_Style); paint2.setStrokeWidth(1); diff --git a/gm/shadertext.cpp b/gm/shadertext.cpp index ac858468f6..468c12b6df 100644 --- a/gm/shadertext.cpp +++ b/gm/shadertext.cpp @@ -155,6 +155,7 @@ protected: SkPaint paint; paint.setDither(true); paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(SkIntToScalar(pointSize)); canvas->save(); diff --git a/gm/shadertext2.cpp b/gm/shadertext2.cpp index f625d6c02a..d73fb6f8f3 100644 --- a/gm/shadertext2.cpp +++ b/gm/shadertext2.cpp @@ -90,11 +90,13 @@ protected: SkPaint fillPaint; fillPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&fillPaint); fillPaint.setTextSize(SkIntToScalar(kPointSize)); fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel); SkPaint outlinePaint; outlinePaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&outlinePaint); outlinePaint.setTextSize(SkIntToScalar(kPointSize)); outlinePaint.setStyle(SkPaint::kStroke_Style); outlinePaint.setStrokeWidth(0.f); @@ -110,6 +112,7 @@ protected: SkPaint labelPaint; labelPaint.setColor(0xff000000); labelPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&labelPaint); labelPaint.setTextSize(12.f); canvas->translate(15.f, 15.f); diff --git a/gm/shadertext3.cpp b/gm/shadertext3.cpp index 78efe87524..ca8dd1154d 100644 --- a/gm/shadertext3.cpp +++ b/gm/shadertext3.cpp @@ -76,6 +76,7 @@ protected: SkPaint outlinePaint; outlinePaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&outlinePaint); outlinePaint.setTextSize(SkIntToScalar(kPointSize)); outlinePaint.setStyle(SkPaint::kStroke_Style); outlinePaint.setStrokeWidth(0.f); @@ -109,6 +110,7 @@ protected: SkPaint fillPaint; fillPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&fillPaint); fillPaint.setTextSize(SkIntToScalar(kPointSize)); fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel); fillPaint.setShader(shader); diff --git a/gm/simpleaaclip.cpp b/gm/simpleaaclip.cpp index 863ee88c2c..950a1c025e 100644 --- a/gm/simpleaaclip.cpp +++ b/gm/simpleaaclip.cpp @@ -154,6 +154,7 @@ protected: SkPaint textPaint; textPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&textPaint); textPaint.setTextSize(SK_Scalar1*24); int xOff = 0; diff --git a/gm/srcmode.cpp b/gm/srcmode.cpp index a8e02017e1..85a3561de2 100644 --- a/gm/srcmode.cpp +++ b/gm/srcmode.cpp @@ -80,6 +80,7 @@ protected: canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); SkPaint paint; + sk_tool_utils::set_portable_typeface(&paint); paint.setColor(0x80FF0000); const Proc procs[] = { diff --git a/gm/strokefill.cpp b/gm/strokefill.cpp index 5f943df6ce..4566eea9ad 100644 --- a/gm/strokefill.cpp +++ b/gm/strokefill.cpp @@ -48,12 +48,10 @@ protected: paint.setTextSize(SkIntToScalar(100)); paint.setStrokeWidth(SkIntToScalar(5)); - SkTypeface* face = SkTypeface::CreateFromName("Papyrus", SkTypeface::kNormal); - SkSafeUnref(paint.setTypeface(face)); + sk_tool_utils::set_portable_typeface(&paint, "Papyrus"); show_bold(canvas, "Hello", 5, x, y, paint); - face = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro", SkTypeface::kNormal); - SkSafeUnref(paint.setTypeface(face)); + sk_tool_utils::set_portable_typeface(&paint, "Hiragino Maru Gothic Pro"); const unsigned char hyphen[] = { 0xE3, 0x83, 0xBC }; show_bold(canvas, hyphen, SK_ARRAY_COUNT(hyphen), x + SkIntToScalar(300), y, paint); diff --git a/gm/stroketext.cpp b/gm/stroketext.cpp index 13c64fa4cc..8ca1402975 100644 --- a/gm/stroketext.cpp +++ b/gm/stroketext.cpp @@ -87,6 +87,7 @@ protected: if (true) { test_nulldev(canvas); } SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(kBelowThreshold_TextSize); draw_text_set(canvas, paint); diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp index 7e6bee42c8..5bdaf9b86e 100644 --- a/gm/texteffects.cpp +++ b/gm/texteffects.cpp @@ -188,6 +188,7 @@ protected: SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setTextSize(SkIntToScalar(56)); SkScalar x = SkIntToScalar(20); diff --git a/gm/tileimagefilter.cpp b/gm/tileimagefilter.cpp index 210a646a6f..7d1a3f08c3 100644 --- a/gm/tileimagefilter.cpp +++ b/gm/tileimagefilter.cpp @@ -34,6 +34,7 @@ protected: canvas.clear(0xFF000000); SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setColor(0xD000D000); paint.setTextSize(SkIntToScalar(50)); const char* str = "e"; diff --git a/gm/tilemodes.cpp b/gm/tilemodes.cpp index 99d3a4708b..a912cba5e7 100644 --- a/gm/tilemodes.cpp +++ b/gm/tilemodes.cpp @@ -100,6 +100,7 @@ protected: SkPaint p; SkString str; p.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&p); p.setDither(true); str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); @@ -139,6 +140,7 @@ protected: SkPaint p; SkString str; p.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&p); str.printf("%s, %s", gConfigNames[i], gFilterNames[j]); canvas->drawText(str.c_str(), str.size(), x, y + r.height() * 2 / 3, p); } @@ -221,6 +223,7 @@ protected: SkPaint p; p.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&p); p.setTextAlign(SkPaint::kCenter_Align); for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { diff --git a/gm/tilemodes_scaled.cpp b/gm/tilemodes_scaled.cpp index 9b1fb613ea..360539ca49 100644 --- a/gm/tilemodes_scaled.cpp +++ b/gm/tilemodes_scaled.cpp @@ -110,6 +110,7 @@ protected: SkPaint p; SkString str; p.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&p); p.setDither(true); p.setLooper(fLooper); str.printf("[%s,%s]", gModeNames[kx], gModeNames[ky]); @@ -151,6 +152,7 @@ protected: SkPaint p; SkString str; p.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&p); p.setLooper(fLooper); str.printf("%s, %s", gColorTypeNames[i], gFilterNames[j]); canvas->drawText(str.c_str(), str.size(), scale*x, scale*(y + r.height() * 2 / 3), p); @@ -234,6 +236,7 @@ protected: SkPaint p; p.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&p); p.setTextAlign(SkPaint::kCenter_Align); for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) { diff --git a/gm/twopointradial.cpp b/gm/twopointradial.cpp index 902c7aed31..f1a27d3f83 100644 --- a/gm/twopointradial.cpp +++ b/gm/twopointradial.cpp @@ -30,6 +30,7 @@ static void drawGrad(SkCanvas* canvas, const SkScalar d0[], const SkScalar d1[]) SkColor colors[] = { SK_ColorGREEN, SK_ColorRED }; SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); SkString str; str.printf("%g,%g,%g %g,%g,%g", diff --git a/gm/typeface.cpp b/gm/typeface.cpp index f2c56a591e..c329395b86 100644 --- a/gm/typeface.cpp +++ b/gm/typeface.cpp @@ -24,7 +24,7 @@ public: TypefaceGM() { fFaces = new SkTypeface*[SK_ARRAY_COUNT(gFaces)]; for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) { - fFaces[i] = SkTypeface::CreateFromName(gFaces[i], SkTypeface::kNormal); + fFaces[i] = sk_tool_utils::create_portable_typeface(gFaces[i], SkTypeface::kNormal); } } @@ -159,8 +159,8 @@ class TypefaceStylesGM : public skiagm::GM { public: TypefaceStylesGM(bool applyKerning) : fApplyKerning(applyKerning) { for (int i = 0; i < gFaceStylesCount; i++) { - fFaces[i] = SkTypeface::CreateFromName(gFaceStyles[i].fName, - gFaceStyles[i].fStyle); + fFaces[i] = sk_tool_utils::create_portable_typeface(gFaceStyles[i].fName, + gFaceStyles[i].fStyle); } } diff --git a/gm/variedtext.cpp b/gm/variedtext.cpp index e174796780..ebb3c3be5b 100644 --- a/gm/variedtext.cpp +++ b/gm/variedtext.cpp @@ -59,10 +59,10 @@ protected: SkScalar h = SkIntToScalar(size.fHeight); SK_COMPILE_ASSERT(4 == SK_ARRAY_COUNT(fTypefacesToUnref), typeface_cnt); - fTypefacesToUnref[0] = SkTypeface::CreateFromName("sans-serif", SkTypeface::kNormal); - fTypefacesToUnref[1] = SkTypeface::CreateFromName("sans-serif", SkTypeface::kBold); - fTypefacesToUnref[2] = SkTypeface::CreateFromName("serif", SkTypeface::kNormal); - fTypefacesToUnref[3] = SkTypeface::CreateFromName("serif", SkTypeface::kBold); + fTypefacesToUnref[0] = sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::kNormal); + fTypefacesToUnref[1] = sk_tool_utils::create_portable_typeface("sans-serif", SkTypeface::kBold); + fTypefacesToUnref[2] = sk_tool_utils::create_portable_typeface("serif", SkTypeface::kNormal); + fTypefacesToUnref[3] = sk_tool_utils::create_portable_typeface("serif", SkTypeface::kBold); SkRandom random; for (int i = 0; i < kCnt; ++i) { diff --git a/gm/verttext2.cpp b/gm/verttext2.cpp index b0375eeb64..0ccdec19ca 100644 --- a/gm/verttext2.cpp +++ b/gm/verttext2.cpp @@ -21,8 +21,8 @@ public: VertText2GM() { const int pointSize = 24; textHeight = SkIntToScalar(pointSize); - fProp = SkTypeface::CreateFromName("Helvetica", SkTypeface::kNormal); - fMono = SkTypeface::CreateFromName("Courier New", SkTypeface::kNormal); + fProp = sk_tool_utils::create_portable_typeface("Helvetica", SkTypeface::kNormal); + fMono = sk_tool_utils::create_portable_typeface("Courier New", SkTypeface::kNormal); } virtual ~VertText2GM() { diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp index 584e60b194..03121413a4 100644 --- a/gm/xfermodeimagefilter.cpp +++ b/gm/xfermodeimagefilter.cpp @@ -34,6 +34,7 @@ protected: canvas.clear(0x00000000); SkPaint paint; paint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&paint); paint.setColor(0xD000D000); paint.setTextSize(SkIntToScalar(96)); const char* str = "e"; diff --git a/gm/xfermodes.cpp b/gm/xfermodes.cpp index c9299b374b..721a76e695 100644 --- a/gm/xfermodes.cpp +++ b/gm/xfermodes.cpp @@ -225,6 +225,7 @@ protected: SkPaint labelP; labelP.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&labelP); labelP.setTextAlign(SkPaint::kCenter_Align); const int W = 5; diff --git a/gm/xfermodes2.cpp b/gm/xfermodes2.cpp index 0f3735e2ab..b1dd6d8fc0 100644 --- a/gm/xfermodes2.cpp +++ b/gm/xfermodes2.cpp @@ -34,6 +34,7 @@ protected: SkPaint labelP; labelP.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&labelP); labelP.setTextAlign(SkPaint::kCenter_Align); const int W = 6; diff --git a/gm/xfermodes3.cpp b/gm/xfermodes3.cpp index 50b92c8694..e3e1629298 100644 --- a/gm/xfermodes3.cpp +++ b/gm/xfermodes3.cpp @@ -46,6 +46,7 @@ protected: SkPaint labelP; labelP.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&labelP); static const SkColor kSolidColors[] = { SK_ColorTRANSPARENT, |