OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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); |
OLD | NEW |