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

Side by Side Diff: samplecode/SampleFontScalerTest.cpp

Issue 1818043002: SkTypeface::MakeFromName to take SkFontStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Android fix + nit fix Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | samplecode/SampleSlides.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "SampleCode.h" 7 #include "SampleCode.h"
8 #include "SkView.h" 8 #include "SkView.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkTypeface.h" 10 #include "SkTypeface.h"
(...skipping 23 matching lines...) Expand all
34 }; 34 };
35 35
36 static const int gFaceCount = SK_ARRAY_COUNT(gFaces); 36 static const int gFaceCount = SK_ARRAY_COUNT(gFaces);
37 37
38 class FontScalerTestView : public SampleView { 38 class FontScalerTestView : public SampleView {
39 sk_sp<SkTypeface> fFaces[gFaceCount]; 39 sk_sp<SkTypeface> fFaces[gFaceCount];
40 40
41 public: 41 public:
42 FontScalerTestView() { 42 FontScalerTestView() {
43 for (int i = 0; i < gFaceCount; i++) { 43 for (int i = 0; i < gFaceCount; i++) {
44 fFaces[i] = SkTypeface::MakeFromName(gFaces[i].fName, gFaces[i].fSty le); 44 fFaces[i] = SkTypeface::MakeFromName(
45 gFaces[i].fName, SkFontStyle::FromOldStyle(gFaces[i].fStyle));
45 } 46 }
46 // this->setBGColor(0xFFDDDDDD); 47 // this->setBGColor(0xFFDDDDDD);
47 } 48 }
48 49
49 protected: 50 protected:
50 // overrides from SkEventSink 51 // overrides from SkEventSink
51 virtual bool onQuery(SkEvent* evt) { 52 virtual bool onQuery(SkEvent* evt) {
52 if (SampleCode::TitleQ(*evt)) { 53 if (SampleCode::TitleQ(*evt)) {
53 SampleCode::TitleR(evt, "FontScaler Test"); 54 SampleCode::TitleR(evt, "FontScaler Test");
54 return true; 55 return true;
(...skipping 23 matching lines...) Expand all
78 79
79 SkPath path; 80 SkPath path;
80 path.moveTo(pts[0]); 81 path.moveTo(pts[0]);
81 path.cubicTo(pts[1], pts[2], pts[3]); 82 path.cubicTo(pts[1], pts[2], pts[3]);
82 canvas->drawPath(path, paint); 83 canvas->drawPath(path, paint);
83 } 84 }
84 85
85 // paint.setSubpixelText(true); 86 // paint.setSubpixelText(true);
86 paint.setAntiAlias(true); 87 paint.setAntiAlias(true);
87 paint.setLCDRenderText(true); 88 paint.setLCDRenderText(true);
88 paint.setTypeface(SkTypeface::MakeFromName("Times Roman", SkTypeface::kN ormal)); 89 paint.setTypeface(SkTypeface::MakeFromName("Times Roman", SkFontStyle()) );
89 90
90 // const char* text = "abcdefghijklmnopqrstuvwxyz"; 91 // const char* text = "abcdefghijklmnopqrstuvwxyz";
91 const char* text = "Hamburgefons ooo mmm"; 92 const char* text = "Hamburgefons ooo mmm";
92 const size_t textLen = strlen(text); 93 const size_t textLen = strlen(text);
93 94
94 for (int j = 0; j < 2; ++j) { 95 for (int j = 0; j < 2; ++j) {
95 for (int i = 0; i < 6; ++i) { 96 for (int i = 0; i < 6; ++i) {
96 SkScalar x = SkIntToScalar(10); 97 SkScalar x = SkIntToScalar(10);
97 SkScalar y = SkIntToScalar(20); 98 SkScalar y = SkIntToScalar(20);
98 99
(...skipping 24 matching lines...) Expand all
123 } 124 }
124 125
125 private: 126 private:
126 typedef SkView INHERITED; 127 typedef SkView INHERITED;
127 }; 128 };
128 129
129 ////////////////////////////////////////////////////////////////////////////// 130 //////////////////////////////////////////////////////////////////////////////
130 131
131 static SkView* MyFactory() { return new FontScalerTestView; } 132 static SkView* MyFactory() { return new FontScalerTestView; }
132 static SkViewRegister reg(MyFactory); 133 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | samplecode/SampleSlides.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698