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

Side by Side Diff: gm/fontscaler.cpp

Issue 1027373002: Font variations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | include/core/SkTypeface.h » ('j') | include/core/SkTypeface.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "gm.h" 7 #include "gm.h"
8 #include "SkTypeface.h" 8 #include "SkTypeface.h"
9 #include <SkFontMgr.h>
9 10
10 namespace skiagm { 11 namespace skiagm {
11 12
12 class FontScalerGM : public GM { 13 class FontScalerGM : public GM {
13 public: 14 public:
14 FontScalerGM() { 15 FontScalerGM() {
15 this->setBGColor(0xFFFFFFFF); 16 this->setBGColor(0xFFFFFFFF);
16 } 17 }
17 18
18 virtual ~FontScalerGM() { 19 virtual ~FontScalerGM() {
(...skipping 18 matching lines...) Expand all
37 } 38 }
38 39
39 void onDraw(SkCanvas* canvas) SK_OVERRIDE { 40 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
40 SkPaint paint; 41 SkPaint paint;
41 42
42 paint.setAntiAlias(true); 43 paint.setAntiAlias(true);
43 paint.setLCDRenderText(true); 44 paint.setLCDRenderText(true);
44 //With freetype the default (normal hinting) can be really ugly. 45 //With freetype the default (normal hinting) can be really ugly.
45 //Most distros now set slight (vertical hinting only) in any event. 46 //Most distros now set slight (vertical hinting only) in any event.
46 paint.setHinting(SkPaint::kSlight_Hinting); 47 paint.setHinting(SkPaint::kSlight_Hinting);
47 sk_tool_utils::set_portable_typeface(&paint, "Times Roman", SkTypeface:: kNormal); 48 //sk_tool_utils::set_portable_typeface(&paint, "Times Roman", SkTypeface ::kNormal);
49 //SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFile("/usr/loc al/google/home/bungeman/skia/font/Distortable.ttf"));
50 SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
48 51
49 const char* text = "Hamburgefons ooo mmm"; 52 const char* text = "abc";
50 const size_t textLen = strlen(text); 53 const size_t textLen = strlen(text);
51 54
52 for (int j = 0; j < 2; ++j) { 55 for (int j = 0; j < 2; ++j) {
53 // This used to do 6 iterations but it causes the N4 to crash in the MSAA4 config. 56 // This used to do 6 iterations but it causes the N4 to crash in the MSAA4 config.
54 for (int i = 0; i < 5; ++i) { 57 for (int i = 0; i < 5; ++i) {
55 SkScalar x = SkIntToScalar(10); 58 SkScalar x = SkIntToScalar(10);
56 SkScalar y = SkIntToScalar(20); 59 SkScalar y = SkIntToScalar(20);
57 60
61 /* Added the following to /system/etc/fonts.xml
bungeman-skia 2015/03/23 21:59:04 This is just a hacked-up example to show that it w
62
63 <family name="mm">
64 <font weight="100" style="normal" axis="32768">Distortable.ttf</font>
65 <font weight="200" style="normal" axis="40000">Distortable.ttf</font>
66 <font weight="300" style="normal" axis="50000">Distortable.ttf</font>
67 <font weight="400" style="normal" axis="65536">Distortable.ttf</font>
68 <font weight="500" style="normal" axis="80000">Distortable.ttf</font>
69 <font weight="600" style="normal" axis="90000">Distortable.ttf</font>
70 <font weight="700" style="normal" axis="100000">Distortable.ttf</font>
71 <font weight="800" style="normal" axis="110000">Distortable.ttf</font>
72 <font weight="900" style="normal" axis="131072">Distortable.ttf</font>
73 </family>
74
75 and pushed resources/Distortable.ttf to /system/fonts */
76 SkAutoTUnref<SkTypeface> typeface(fm->matchFamilyStyle("mm", SkF ontStyle((100 * i) + (500 * j), SkFontStyle::kNormal_Width, SkFontStyle::kUprigh t_Slant)));
77 paint.setTypeface(typeface);
78
58 SkAutoCanvasRestore acr(canvas, true); 79 SkAutoCanvasRestore acr(canvas, true);
59 canvas->translate(SkIntToScalar(50 + i * 230), 80 canvas->translate(SkIntToScalar(50 + i * 230),
60 SkIntToScalar(20)); 81 SkIntToScalar(20));
61 rotate_about(canvas, SkIntToScalar(i * 5), x, y * 10); 82 rotate_about(canvas, SkIntToScalar(i * 5), x, y * 10);
62 83
63 { 84 {
64 SkPaint p; 85 SkPaint p;
65 p.setAntiAlias(true); 86 p.setAntiAlias(true);
66 SkRect r; 87 SkRect r;
67 r.set(x - SkIntToScalar(3), SkIntToScalar(15), 88 r.set(x - SkIntToScalar(3), SkIntToScalar(15),
(...skipping 15 matching lines...) Expand all
83 private: 104 private:
84 typedef GM INHERITED; 105 typedef GM INHERITED;
85 }; 106 };
86 107
87 ////////////////////////////////////////////////////////////////////////////// 108 //////////////////////////////////////////////////////////////////////////////
88 109
89 static GM* MyFactory(void*) { return new FontScalerGM; } 110 static GM* MyFactory(void*) { return new FontScalerGM; }
90 static GMRegistry reg(MyFactory); 111 static GMRegistry reg(MyFactory);
91 112
92 } 113 }
OLDNEW
« no previous file with comments | « no previous file | include/core/SkTypeface.h » ('j') | include/core/SkTypeface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698