Index: gm/dftext.cpp |
diff --git a/gm/dftext.cpp b/gm/dftext.cpp |
index 6f75c4671391af834412f8be0d87cd26bb10a6ec..350e9ab57148f2bcf22ead3a0e380165f2fbbff7 100755 |
--- a/gm/dftext.cpp |
+++ b/gm/dftext.cpp |
@@ -5,6 +5,9 @@ |
* found in the LICENSE file. |
*/ |
#include "gm.h" |
+#include "Resources.h" |
+#include "SkCanvas.h" |
+#include "SkStream.h" |
#include "SkSurface.h" |
#include "SkTypeface.h" |
@@ -14,12 +17,25 @@ class DFTextGM : public GM { |
public: |
DFTextGM() { |
this->setBGColor(0xFFFFFFFF); |
+ fTypeface = NULL; |
} |
virtual ~DFTextGM() { |
+ SkSafeUnref(fTypeface); |
} |
protected: |
+ virtual void onOnceBeforeDraw() SK_OVERRIDE { |
+ SkString filename = GetResourcePath("/Funkster.ttf"); |
+ SkAutoTUnref<SkFILEStream> stream(new SkFILEStream(filename.c_str())); |
+ if (!stream->isValid()) { |
+ SkDebugf("Could not find Funkster.ttf, please set --resourcePath correctly.\n"); |
+ return; |
+ } |
+ |
+ fTypeface = SkTypeface::CreateFromStream(stream); |
+ } |
+ |
virtual uint32_t onGetFlags() const SK_OVERRIDE { |
return kGPUOnly_Flag; |
} |
@@ -185,6 +201,10 @@ protected: |
y += paint.getFontMetrics(NULL); |
} |
+ // check color emoji |
+ paint.setTypeface(fTypeface); |
+ canvas->drawText(text, textLen, 670, 100, paint); |
+ |
#if SK_SUPPORT_GPU |
// render offscreen buffer |
if (surface) { |
@@ -199,6 +219,8 @@ protected: |
} |
private: |
+ SkTypeface* fTypeface; |
+ |
typedef GM INHERITED; |
}; |