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