Chromium Code Reviews| Index: gm/fontscaler.cpp |
| diff --git a/gm/fontscaler.cpp b/gm/fontscaler.cpp |
| index 3fefd56080e6e99041b807228fa9c0fcfb85a116..60a208b8a51b43acd4a64d5907ed195d466b9ba1 100644 |
| --- a/gm/fontscaler.cpp |
| +++ b/gm/fontscaler.cpp |
| @@ -6,6 +6,7 @@ |
| */ |
| #include "gm.h" |
| #include "SkTypeface.h" |
| +#include <SkFontMgr.h> |
| namespace skiagm { |
| @@ -44,9 +45,11 @@ protected: |
| //With freetype the default (normal hinting) can be really ugly. |
| //Most distros now set slight (vertical hinting only) in any event. |
| paint.setHinting(SkPaint::kSlight_Hinting); |
| - sk_tool_utils::set_portable_typeface(&paint, "Times Roman", SkTypeface::kNormal); |
| + //sk_tool_utils::set_portable_typeface(&paint, "Times Roman", SkTypeface::kNormal); |
| + //SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFile("/usr/local/google/home/bungeman/skia/font/Distortable.ttf")); |
| + SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| - const char* text = "Hamburgefons ooo mmm"; |
| + const char* text = "abc"; |
| const size_t textLen = strlen(text); |
| for (int j = 0; j < 2; ++j) { |
| @@ -55,6 +58,24 @@ protected: |
| SkScalar x = SkIntToScalar(10); |
| SkScalar y = SkIntToScalar(20); |
| +/* 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
|
| + |
| + <family name="mm"> |
| + <font weight="100" style="normal" axis="32768">Distortable.ttf</font> |
| + <font weight="200" style="normal" axis="40000">Distortable.ttf</font> |
| + <font weight="300" style="normal" axis="50000">Distortable.ttf</font> |
| + <font weight="400" style="normal" axis="65536">Distortable.ttf</font> |
| + <font weight="500" style="normal" axis="80000">Distortable.ttf</font> |
| + <font weight="600" style="normal" axis="90000">Distortable.ttf</font> |
| + <font weight="700" style="normal" axis="100000">Distortable.ttf</font> |
| + <font weight="800" style="normal" axis="110000">Distortable.ttf</font> |
| + <font weight="900" style="normal" axis="131072">Distortable.ttf</font> |
| + </family> |
| + |
| +and pushed resources/Distortable.ttf to /system/fonts */ |
| + SkAutoTUnref<SkTypeface> typeface(fm->matchFamilyStyle("mm", SkFontStyle((100 * i) + (500 * j), SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant))); |
| + paint.setTypeface(typeface); |
| + |
| SkAutoCanvasRestore acr(canvas, true); |
| canvas->translate(SkIntToScalar(50 + i * 230), |
| SkIntToScalar(20)); |