Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: gm/poly2poly.cpp

Issue 1257773002: rename portable_typeface_always to portable_typeface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove unncessary change to path test Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/pixelsnap.cpp ('k') | gm/samplerstress.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/poly2poly.cpp
diff --git a/gm/poly2poly.cpp b/gm/poly2poly.cpp
index 72ab7276e134a0399c351fa9e218a6d3e4cfa60a..c1d9b7e9e5657408a2e4b2f8ae8162433daab5e5 100644
--- a/gm/poly2poly.cpp
+++ b/gm/poly2poly.cpp
@@ -6,6 +6,8 @@
*/
#include "gm.h"
+#include "Resources.h"
+#include "SkTypeface.h"
class SkJSCanvas {
public:
@@ -215,19 +217,22 @@ protected:
paint->setStyle(SkPaint::kFill_Style);
SkScalar x = D/2;
SkScalar y = D/2 - (fm.fAscent + fm.fDescent)/2;
- SkString str;
- str.appendS32(count);
- canvas->drawText(str.c_str(), str.size(), x, y, *paint);
-
+ uint16_t glyphID = 3; // X
+ canvas->drawText((void*) &glyphID, sizeof(glyphID), x, y, *paint);
canvas->restore();
}
+ void onOnceBeforeDraw() override {
+ fEmFace.reset(GetResourceAsTypeface("/fonts/Em.ttf"));
+ }
+
void onDraw(SkCanvas* canvas) override {
if (false) { test_stroke(canvas); return; }
SkPaint paint;
paint.setAntiAlias(true);
- sk_tool_utils::set_portable_typeface(&paint);
+ paint.setTypeface(fEmFace);
+ paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
paint.setStrokeWidth(SkIntToScalar(4));
paint.setTextSize(SkIntToScalar(40));
paint.setTextAlign(SkPaint::kCenter_Align);
@@ -267,6 +272,7 @@ protected:
private:
typedef skiagm::GM INHERITED;
+ SkAutoTUnref<SkTypeface> fEmFace;
};
//////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « gm/pixelsnap.cpp ('k') | gm/samplerstress.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698