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 18 matching lines...) Expand all Loading... |
29 { "serif", SkTypeface::kNormal }, | 29 { "serif", SkTypeface::kNormal }, |
30 { "serif", SkTypeface::kBold }, | 30 { "serif", SkTypeface::kBold }, |
31 { "serif", SkTypeface::kItalic }, | 31 { "serif", SkTypeface::kItalic }, |
32 { "serif", SkTypeface::kBoldItalic }, | 32 { "serif", SkTypeface::kBoldItalic }, |
33 { "monospace", SkTypeface::kNormal } | 33 { "monospace", SkTypeface::kNormal } |
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 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::CreateFromName(gFaces[i].fName, |
| 45 gFaces[i].fStyle); |
45 } | 46 } |
46 // this->setBGColor(0xFFDDDDDD); | 47 // this->setBGColor(0xFFDDDDDD); |
47 } | 48 } |
48 | 49 |
| 50 virtual ~FontScalerTestView() { |
| 51 for (int i = 0; i < gFaceCount; i++) { |
| 52 SkSafeUnref(fFaces[i]); |
| 53 } |
| 54 } |
| 55 |
49 protected: | 56 protected: |
50 // overrides from SkEventSink | 57 // overrides from SkEventSink |
51 virtual bool onQuery(SkEvent* evt) { | 58 virtual bool onQuery(SkEvent* evt) { |
52 if (SampleCode::TitleQ(*evt)) { | 59 if (SampleCode::TitleQ(*evt)) { |
53 SampleCode::TitleR(evt, "FontScaler Test"); | 60 SampleCode::TitleR(evt, "FontScaler Test"); |
54 return true; | 61 return true; |
55 } | 62 } |
56 return this->INHERITED::onQuery(evt); | 63 return this->INHERITED::onQuery(evt); |
57 } | 64 } |
58 | 65 |
(...skipping 19 matching lines...) Expand all Loading... |
78 | 85 |
79 SkPath path; | 86 SkPath path; |
80 path.moveTo(pts[0]); | 87 path.moveTo(pts[0]); |
81 path.cubicTo(pts[1], pts[2], pts[3]); | 88 path.cubicTo(pts[1], pts[2], pts[3]); |
82 canvas->drawPath(path, paint); | 89 canvas->drawPath(path, paint); |
83 } | 90 } |
84 | 91 |
85 // paint.setSubpixelText(true); | 92 // paint.setSubpixelText(true); |
86 paint.setAntiAlias(true); | 93 paint.setAntiAlias(true); |
87 paint.setLCDRenderText(true); | 94 paint.setLCDRenderText(true); |
88 paint.setTypeface(SkTypeface::MakeFromName("Times Roman", SkTypeface::kN
ormal)); | 95 SkSafeUnref(paint.setTypeface(SkTypeface::CreateFromName("Times Roman",
SkTypeface::kNormal))); |
89 | 96 |
90 // const char* text = "abcdefghijklmnopqrstuvwxyz"; | 97 // const char* text = "abcdefghijklmnopqrstuvwxyz"; |
91 const char* text = "Hamburgefons ooo mmm"; | 98 const char* text = "Hamburgefons ooo mmm"; |
92 const size_t textLen = strlen(text); | 99 const size_t textLen = strlen(text); |
93 | 100 |
94 for (int j = 0; j < 2; ++j) { | 101 for (int j = 0; j < 2; ++j) { |
95 for (int i = 0; i < 6; ++i) { | 102 for (int i = 0; i < 6; ++i) { |
96 SkScalar x = SkIntToScalar(10); | 103 SkScalar x = SkIntToScalar(10); |
97 SkScalar y = SkIntToScalar(20); | 104 SkScalar y = SkIntToScalar(20); |
98 | 105 |
(...skipping 24 matching lines...) Expand all Loading... |
123 } | 130 } |
124 | 131 |
125 private: | 132 private: |
126 typedef SkView INHERITED; | 133 typedef SkView INHERITED; |
127 }; | 134 }; |
128 | 135 |
129 ////////////////////////////////////////////////////////////////////////////// | 136 ////////////////////////////////////////////////////////////////////////////// |
130 | 137 |
131 static SkView* MyFactory() { return new FontScalerTestView; } | 138 static SkView* MyFactory() { return new FontScalerTestView; } |
132 static SkViewRegister reg(MyFactory); | 139 static SkViewRegister reg(MyFactory); |
OLD | NEW |