Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: gm/androidfallback.cpp

Issue 24364008: Update PDF backend to support fallback fonts on Android. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: testing more fallbacks Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9
10 namespace skiagm {
11
12 class AndroidFallbackGM : public GM {
13 public:
14 AndroidFallbackGM() {
15 this->setBGColor(0xFFCCCCCC);
16 }
17
18 protected:
19 virtual SkString onShortName() SK_OVERRIDE {
20 return SkString("android_paint");
21 }
22
23 virtual SkISize onISize() SK_OVERRIDE {
24 return make_isize(500, 500);
25 }
26
27 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
28
29 SkPaint paint;
30 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
31 paint.setTextSize(24);
32
33 #if SK_BUILD_FOR_ANDROID
34 SkPaintOptionsAndroid options = paint.getPaintOptionsAndroid();
35 options.setUseFontFallbacks(true);
36 paint.setPaintOptionsAndroid(options);
37 #endif
38
39 // "ื foo ๅ…่ˆŒ bar เค•"
40 const uint16_t unicodeStr[] = {0x05D0, 0x0020, 0x0066, 0x006F, 0x006F, 0 x0020, 0x514D,
41 0x820c, 0x0020, 0x0062, 0x0061, 0x0072, 0 x0020, 0x0915};
42 const int strLength = sizeof(unicodeStr) / sizeof(uint16_t);
43 const int strByteLength = sizeof(unicodeStr);
44
45 SkScalar posX[strLength];
46 SkPoint posXY[strLength];
47
48 for (int i = 0; i < strLength; ++i) {
49 posX[i] = SkIntToScalar(i * 24);
50 posXY[i].fX = posX[i];
51 posXY[i].fY = SkIntToScalar(24 + i);
52 }
53
54 canvas->translate(SkIntToScalar(10), SkIntToScalar(25));
55 // This currently causes the PDF backend to assert
56 // canvas->drawText(unicodeStr, strByteLength, 0, 0, paint);
57
58 canvas->translate(0, SkIntToScalar(75));
59 canvas->drawPosTextH(unicodeStr, strByteLength, posX, 0, paint);
60
61 #if SK_BUILD_FOR_ANDROID
62 options.setLanguage("ja");
63 paint.setPaintOptionsAndroid(options);
64 #endif
65
66 canvas->translate(0, SkIntToScalar(75));
67 canvas->drawPosText(unicodeStr, strByteLength, posXY, paint);
68
69 SkPath path;
70 path.moveTo(0, 0);
71 path.quadTo(50.0f, 100.0f, 250.0f, 150.0f);
72
73 canvas->translate(0, SkIntToScalar(75));
74 canvas->drawTextOnPath(unicodeStr, strByteLength, path, NULL, paint);
75 }
76
77 private:
78 typedef GM INHERITED;
79 };
80
81 //////////////////////////////////////////////////////////////////////////////
82
83 #if SK_BUILD_FOR_ANDROID
84 DEF_GM( return SkNEW(AndroidFallbackGM); )
85 #endif
86
87 }
OLDNEW
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698