OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
9 #include "sk_tool_utils_flags.h" | 9 #include "sk_tool_utils_flags.h" |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 if (FLAGS_portableFonts) { | 39 if (FLAGS_portableFonts) { |
40 face = create_font(name, style); | 40 face = create_font(name, style); |
41 } else if (FLAGS_resourceFonts) { | 41 } else if (FLAGS_resourceFonts) { |
42 face = resource_font(name, style); | 42 face = resource_font(name, style); |
43 } else { | 43 } else { |
44 face = SkTypeface::CreateFromName(name, style); | 44 face = SkTypeface::CreateFromName(name, style); |
45 } | 45 } |
46 return face; | 46 return face; |
47 } | 47 } |
48 | 48 |
| 49 SkTypeface* create_portable_typeface_always(const char* name, SkTypeface::Style
style) { |
| 50 return create_font(name, style); |
| 51 } |
| 52 |
49 void set_portable_typeface(SkPaint* paint, const char* name, SkTypeface::Style s
tyle) { | 53 void set_portable_typeface(SkPaint* paint, const char* name, SkTypeface::Style s
tyle) { |
50 SkTypeface* face = create_portable_typeface(name, style); | 54 SkTypeface* face = create_portable_typeface(name, style); |
51 SkSafeUnref(paint->setTypeface(face)); | 55 SkSafeUnref(paint->setTypeface(face)); |
52 } | 56 } |
53 | 57 |
| 58 void set_portable_typeface_always(SkPaint* paint, const char* name, SkTypeface::
Style style) { |
| 59 SkTypeface* face = create_font(name, style); |
| 60 SkSafeUnref(paint->setTypeface(face)); |
| 61 } |
| 62 |
54 void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y, | 63 void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y, |
55 SkColorType colorType, SkAlphaType alphaType) { | 64 SkColorType colorType, SkAlphaType alphaType) { |
56 SkBitmap tmp(bitmap); | 65 SkBitmap tmp(bitmap); |
57 tmp.lockPixels(); | 66 tmp.lockPixels(); |
58 | 67 |
59 const SkImageInfo info = SkImageInfo::Make(tmp.width(), tmp.height(), colorT
ype, alphaType); | 68 const SkImageInfo info = SkImageInfo::Make(tmp.width(), tmp.height(), colorT
ype, alphaType); |
60 | 69 |
61 canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y); | 70 canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y); |
62 } | 71 } |
63 | 72 |
(...skipping 24 matching lines...) Expand all Loading... |
88 paint.textToGlyphs(text, len, glyphs.begin()); | 97 paint.textToGlyphs(text, len, glyphs.begin()); |
89 | 98 |
90 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); | 99 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
91 const SkTextBlobBuilder::RunBuffer& run = builder->allocRun(paint, glyphs.co
unt(), x, y, | 100 const SkTextBlobBuilder::RunBuffer& run = builder->allocRun(paint, glyphs.co
unt(), x, y, |
92 NULL); | 101 NULL); |
93 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t)); | 102 memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t)); |
94 } | 103 } |
95 | 104 |
96 | 105 |
97 } // namespace sk_tool_utils | 106 } // namespace sk_tool_utils |
OLD | NEW |