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
diff --git a/gm/bigtext.cpp b/gm/bigtext.cpp
index 9c2682c..eabad14 100644
--- a/gm/bigtext.cpp
+++ b/gm/bigtext.cpp
@@ -34,6 +34,7 @@
     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 2774f3a..1d6dfad 100644
--- a/gm/colortype.cpp
+++ b/gm/colortype.cpp
@@ -26,8 +26,8 @@
         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 cb698c1..35c4426 100644
--- a/gm/convexpolyclip.cpp
+++ b/gm/convexpolyclip.cpp
@@ -150,6 +150,7 @@
         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 68d143d..f171522 100644
--- a/gm/cubicpaths.cpp
+++ b/gm/cubicpaths.cpp
@@ -280,6 +280,7 @@
         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 @@
                     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 92a3d51..073e4f7 100644
--- a/gm/deviceproperties.cpp
+++ b/gm/deviceproperties.cpp
@@ -55,7 +55,7 @@
         //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 f24c92b..4cde4bd 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 9c6fa3b..fd205f5 100644
--- a/gm/drawbitmaprect.cpp
+++ b/gm/drawbitmaprect.cpp
@@ -111,6 +111,7 @@
         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 67e280e..a1b55bb 100644
--- a/gm/drawlooper.cpp
+++ b/gm/drawlooper.cpp
@@ -40,6 +40,7 @@
 
         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 ec849b2..a22ec43 100644
--- a/gm/dropshadowimagefilter.cpp
+++ b/gm/dropshadowimagefilter.cpp
@@ -39,6 +39,7 @@
     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 6b93222..87e1cc5 100644
--- a/gm/emptypath.cpp
+++ b/gm/emptypath.cpp
@@ -63,6 +63,7 @@
         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 @@
                 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 0d4b4b4..26a1886 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 cb73e91..74ec18a 100644
--- a/gm/fontcache.cpp
+++ b/gm/fontcache.cpp
@@ -59,8 +59,8 @@
         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 8a97e69..8aef8f0 100644
--- a/gm/fontscaler.cpp
+++ b/gm/fontscaler.cpp
@@ -47,7 +47,7 @@
         //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 f10680e..cdc37fa 100644
--- a/gm/gammatext.cpp
+++ b/gm/gammatext.cpp
@@ -26,7 +26,7 @@
 }
 
 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 0f66a97..a411520 100644
--- a/gm/getpostextpath.cpp
+++ b/gm/getpostextpath.cpp
@@ -42,6 +42,7 @@
 
         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 b045101..ecb9963 100644
--- a/gm/glyph_pos.cpp
+++ b/gm/glyph_pos.cpp
@@ -52,7 +52,7 @@
 
     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 54bf175..96ce59f 100644
--- a/gm/gradtext.cpp
+++ b/gm/gradtext.cpp
@@ -47,6 +47,7 @@
     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 @@
     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 @@
 
     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 88c1db5..ff184d1 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -158,6 +158,7 @@
 
         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 b8e1971..2e85678 100644
--- a/gm/imageblur.cpp
+++ b/gm/imageblur.cpp
@@ -44,6 +44,7 @@
         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 0580405..ed4ae6c 100644
--- a/gm/imageblurtiled.cpp
+++ b/gm/imageblurtiled.cpp
@@ -50,6 +50,7 @@
                 };
                 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 c270e67..bbcb7ce 100644
--- a/gm/imagefiltersbase.cpp
+++ b/gm/imagefiltersbase.cpp
@@ -113,6 +113,7 @@
     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 a128c6b..e7d3790 100644
--- a/gm/imagefilterscropped.cpp
+++ b/gm/imagefilterscropped.cpp
@@ -45,6 +45,7 @@
     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 af3ebb7..6500824 100644
--- a/gm/imagefiltersgraph.cpp
+++ b/gm/imagefiltersgraph.cpp
@@ -99,6 +99,7 @@
         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 23847e6..e2847b4 100644
--- a/gm/imagemagnifier.cpp
+++ b/gm/imagemagnifier.cpp
@@ -44,6 +44,7 @@
                 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 ec60274..d09fd27 100644
--- a/gm/imageresizetiled.cpp
+++ b/gm/imageresizetiled.cpp
@@ -57,6 +57,7 @@
                 };
                 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 7e5ce62..3ba3052 100644
--- a/gm/internal_links.cpp
+++ b/gm/internal_links.cpp
@@ -61,6 +61,7 @@
         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 f48dc9e..b4db0ff 100644
--- a/gm/lcdtext.cpp
+++ b/gm/lcdtext.cpp
@@ -49,6 +49,7 @@
         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 50698fa..e7842a9 100644
--- a/gm/lighting.cpp
+++ b/gm/lighting.cpp
@@ -34,6 +34,7 @@
         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 ea4fdc8..53a9327 100644
--- a/gm/linepaths.cpp
+++ b/gm/linepaths.cpp
@@ -85,6 +85,7 @@
         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 @@
                     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 @@
         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 @@
                     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 4414093..521a61b 100644
--- a/gm/lumafilter.cpp
+++ b/gm/lumafilter.cpp
@@ -18,6 +18,7 @@
 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 592489c..aff3850 100644
--- a/gm/matrixconvolution.cpp
+++ b/gm/matrixconvolution.cpp
@@ -33,6 +33,7 @@
         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 ff6c1ba..cb321c6 100644
--- a/gm/morphology.cpp
+++ b/gm/morphology.cpp
@@ -31,6 +31,7 @@
         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 ca8a809..7fcbe0a 100644
--- a/gm/offsetimagefilter.cpp
+++ b/gm/offsetimagefilter.cpp
@@ -32,6 +32,7 @@
         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 77687f4..fd13404 100644
--- a/gm/pathreverse.cpp
+++ b/gm/pathreverse.cpp
@@ -52,8 +52,7 @@
 
     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 @@
 
         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 b0fd057..4e169f7 100644
--- a/gm/pictureimagefilter.cpp
+++ b/gm/pictureimagefilter.cpp
@@ -28,6 +28,7 @@
         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 9e58d9d..191bb0e 100644
--- a/gm/poly2poly.cpp
+++ b/gm/poly2poly.cpp
@@ -37,6 +37,7 @@
 
 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 @@
 
         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 f21fdd9..f2c4cf1 100644
--- a/gm/quadpaths.cpp
+++ b/gm/quadpaths.cpp
@@ -86,6 +86,7 @@
         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 @@
                     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 @@
         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 @@
                     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 12f93cc..9e0843e 100644
--- a/gm/samplerstress.cpp
+++ b/gm/samplerstress.cpp
@@ -97,6 +97,7 @@
         // 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 @@
         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 ac85846..468c12b 100644
--- a/gm/shadertext.cpp
+++ b/gm/shadertext.cpp
@@ -155,6 +155,7 @@
         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 f625d6c..d73fb6f 100644
--- a/gm/shadertext2.cpp
+++ b/gm/shadertext2.cpp
@@ -90,11 +90,13 @@
 
         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 @@
         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 78efe87..ca8dd11 100644
--- a/gm/shadertext3.cpp
+++ b/gm/shadertext3.cpp
@@ -76,6 +76,7 @@
 
         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 @@
 
                 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 863ee88..950a1c0 100644
--- a/gm/simpleaaclip.cpp
+++ b/gm/simpleaaclip.cpp
@@ -154,6 +154,7 @@
 
         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 a8e0201..85a3561 100644
--- a/gm/srcmode.cpp
+++ b/gm/srcmode.cpp
@@ -80,6 +80,7 @@
         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 5f943df..4566eea 100644
--- a/gm/strokefill.cpp
+++ b/gm/strokefill.cpp
@@ -48,12 +48,10 @@
         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 13c64fa..8ca1402 100644
--- a/gm/stroketext.cpp
+++ b/gm/stroketext.cpp
@@ -87,6 +87,7 @@
         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 7e6bee4..5bdaf9b 100644
--- a/gm/texteffects.cpp
+++ b/gm/texteffects.cpp
@@ -188,6 +188,7 @@
 
         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 210a646..7d1a3f0 100644
--- a/gm/tileimagefilter.cpp
+++ b/gm/tileimagefilter.cpp
@@ -34,6 +34,7 @@
         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 99d3a47..a912cba 100644
--- a/gm/tilemodes.cpp
+++ b/gm/tilemodes.cpp
@@ -100,6 +100,7 @@
                 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 @@
                     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 @@
 
         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 9b1fb61..360539c 100644
--- a/gm/tilemodes_scaled.cpp
+++ b/gm/tilemodes_scaled.cpp
@@ -110,6 +110,7 @@
                 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 @@
                     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 @@
 
         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 902c7ae..f1a27d3 100644
--- a/gm/twopointradial.cpp
+++ b/gm/twopointradial.cpp
@@ -30,6 +30,7 @@
     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 f2c56a5..c329395 100644
--- a/gm/typeface.cpp
+++ b/gm/typeface.cpp
@@ -24,7 +24,7 @@
     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 @@
 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 e174796..ebb3c3b 100644
--- a/gm/variedtext.cpp
+++ b/gm/variedtext.cpp
@@ -59,10 +59,10 @@
         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 b0375ee..0ccdec1 100644
--- a/gm/verttext2.cpp
+++ b/gm/verttext2.cpp
@@ -21,8 +21,8 @@
     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 584e60b..0312141 100644
--- a/gm/xfermodeimagefilter.cpp
+++ b/gm/xfermodeimagefilter.cpp
@@ -34,6 +34,7 @@
         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 c9299b3..721a76e 100644
--- a/gm/xfermodes.cpp
+++ b/gm/xfermodes.cpp
@@ -225,6 +225,7 @@
 
         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 0f3735e..b1dd6d8 100644
--- a/gm/xfermodes2.cpp
+++ b/gm/xfermodes2.cpp
@@ -34,6 +34,7 @@
 
         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 50b92c8..e3e1629 100644
--- a/gm/xfermodes3.cpp
+++ b/gm/xfermodes3.cpp
@@ -46,6 +46,7 @@
 
         SkPaint labelP;
         labelP.setAntiAlias(true);
+        sk_tool_utils::set_portable_typeface(&labelP);
 
         static const SkColor kSolidColors[] = {
             SK_ColorTRANSPARENT,