Index: gm/typeface.cpp |
diff --git a/gm/typeface.cpp b/gm/typeface.cpp |
index 5ddc338449cad4671b732ea5b52e4b110f1d7dbf..b8f54abe3720c5455ab92ede1627ac2138a760a3 100644 |
--- a/gm/typeface.cpp |
+++ b/gm/typeface.cpp |
@@ -11,75 +11,6 @@ |
#include "SkTypeface.h" |
#include "SkTypes.h" |
-static const char* gFaces[] = { |
- "Times Roman", |
- "Hiragino Maru Gothic Pro", |
- "Papyrus", |
- "Helvetica", |
- "Courier New" |
-}; |
- |
-class TypefaceGM : public skiagm::GM { |
-public: |
- TypefaceGM() |
- : fFaces(NULL) { |
- } |
- |
- virtual ~TypefaceGM() { |
- if (fFaces) { |
- for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) { |
- SkSafeUnref(fFaces[i]); |
- } |
- delete [] fFaces; |
- } |
- } |
- |
-protected: |
- void onOnceBeforeDraw() override { |
- fFaces = new SkTypeface*[SK_ARRAY_COUNT(gFaces)]; |
- for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) { |
- fFaces[i] = sk_tool_utils::create_portable_typeface(gFaces[i], SkTypeface::kNormal); |
- } |
- } |
- |
- SkString onShortName() override { |
- return SkString("typeface"); |
- } |
- |
- SkISize onISize() override { |
- return SkISize::Make(640, 480); |
- } |
- |
- void onDraw(SkCanvas* canvas) override { |
- SkString text("Typefaces are fun!"); |
- SkScalar y = 0; |
- |
- SkPaint paint; |
- paint.setAntiAlias(true); |
- for (int i = 0; i < (int)SK_ARRAY_COUNT(gFaces); i++) { |
- this->drawWithFace(text, i, y, paint, canvas); |
- } |
- // Now go backwards |
- for (int i = SK_ARRAY_COUNT(gFaces) - 1; i >= 0; i--) { |
- this->drawWithFace(text, i, y, paint, canvas); |
- } |
- } |
- |
-private: |
- void drawWithFace(const SkString& text, int i, SkScalar& y, SkPaint& paint, |
- SkCanvas* canvas) { |
- paint.setTypeface(fFaces[i]); |
- y += paint.getFontMetrics(NULL); |
- canvas->drawText(text.c_str(), text.size(), 0, y, paint); |
- } |
- |
- SkTypeface** fFaces; |
- |
- typedef skiagm::GM INHERITED; |
-}; |
- |
-/////////////////////////////////////////////////////////////////////////////// |
- |
static void getGlyphPositions(const SkPaint& paint, const uint16_t glyphs[], |
int count, SkScalar x, SkScalar y, SkPoint pos[]) { |
SkASSERT(SkPaint::kGlyphID_TextEncoding == paint.getTextEncoding()); |
@@ -177,8 +108,8 @@ public: |
protected: |
void onOnceBeforeDraw() override { |
for (int i = 0; i < gFaceStylesCount; i++) { |
- fFaces[i] = sk_tool_utils::create_portable_typeface(gFaceStyles[i].fName, |
- gFaceStyles[i].fStyle); |
+ fFaces[i] = SkTypeface::CreateFromName( |
+ sk_tool_utils::platform_font_name(gFaceStyles[i].fName), gFaceStyles[i].fStyle); |
} |
} |
@@ -187,6 +118,7 @@ protected: |
if (fApplyKerning) { |
name.append("_kerning"); |
} |
+ name.append(sk_tool_utils::major_platform_os_name()); |
return name; |
} |
@@ -227,6 +159,5 @@ private: |
/////////////////////////////////////////////////////////////////////////////// |
-DEF_GM( return new TypefaceGM; ) |
DEF_GM( return new TypefaceStylesGM(false); ) |
DEF_GM( return new TypefaceStylesGM(true); ) |