| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 | 7 |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 paint.setTypeface(fTypeface); | 52 paint.setTypeface(fTypeface); |
| 53 paint.setEmbeddedBitmapText(true); | 53 paint.setEmbeddedBitmapText(true); |
| 54 | 54 |
| 55 const char* text = "hamburgerfons"; | 55 const char* text = "hamburgerfons"; |
| 56 | 56 |
| 57 // draw text at different point sizes | 57 // draw text at different point sizes |
| 58 const int textSize[] = { 10, 30, 50 }; | 58 const int textSize[] = { 10, 30, 50 }; |
| 59 const int textYOffset[] = { 10, 40, 100}; | 59 const int textYOffset[] = { 10, 40, 100}; |
| 60 SkASSERT(sizeof(textSize) == sizeof(textYOffset)); | 60 SkASSERT(sizeof(textSize) == sizeof(textYOffset)); |
| 61 for (size_t y = 0; y < sizeof(textSize) / sizeof(int); ++y) { | 61 for (size_t y = 0; y < sizeof(textSize) / sizeof(int); ++y) { |
| 62 paint.setTextSize(textSize[y]); | 62 paint.setTextSize(SkIntToScalar(textSize[y])); |
| 63 canvas->drawText(text, strlen(text), 10, textYOffset[y], paint); | 63 canvas->drawText(text, strlen(text), 10, SkIntToScalar(textYOffset[y
]), paint); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // setup work needed to draw text with different clips | 66 // setup work needed to draw text with different clips |
| 67 canvas->translate(10, 160); | 67 canvas->translate(10, 160); |
| 68 paint.setTextSize(40); | 68 paint.setTextSize(40); |
| 69 | 69 |
| 70 // compute the bounds of the text | 70 // compute the bounds of the text |
| 71 SkRect bounds; | 71 SkRect bounds; |
| 72 paint.measureText(text, strlen(text), &bounds); | 72 paint.measureText(text, strlen(text), &bounds); |
| 73 | 73 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 103 } | 103 } |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 SkTypeface* fTypeface; | 106 SkTypeface* fTypeface; |
| 107 | 107 |
| 108 typedef GM INHERITED; | 108 typedef GM INHERITED; |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 ////////////////////////////////////////////////////////////////////////////// | 111 ////////////////////////////////////////////////////////////////////////////// |
| 112 | 112 |
| 113 #if !defined(SK_BUILD_FOR_ANDROID) |
| 114 // fail for now until the appropriate freetype changes are submitted |
| 113 static GM* MyFactory(void*) { return new ColorEmojiGM; } | 115 static GM* MyFactory(void*) { return new ColorEmojiGM; } |
| 114 static GMRegistry reg(MyFactory); | 116 static GMRegistry reg(MyFactory); |
| 117 #endif |
| 115 | 118 |
| 116 } | 119 } |
| OLD | NEW |