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

Unified Diff: gm/typeface.cpp

Issue 1256903002: make fontscalar gammatext lcdtext typeface verttext2 gm portable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove useless gm; fix nit 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/lcdtext.cpp ('k') | gm/verttext2.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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); )
« no previous file with comments | « gm/lcdtext.cpp ('k') | gm/verttext2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698