Index: gm/fontscaler.cpp |
diff --git a/gm/fontscaler.cpp b/gm/fontscaler.cpp |
index c3b2c87af255965bd0d1b645de0a625981a04d8e..d96af4c8a923ab386cd6cb4c7f9ea3d4ff140318 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,13 @@ 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<SkTypeface> typeface(SkTypeface::CreateFromName("Skia", SkTypeface::kNormal)); |
+ //paint.setTypeface(typeface); |
+ 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 +60,24 @@ protected: |
SkScalar x = SkIntToScalar(10); |
SkScalar y = SkIntToScalar(20); |
+/* Added the following to /system/etc/fonts.xml |
+ |
+ <family name="mm"> |
+ <font weight="100" style="normal"><axis tag="wght" stylevalue="0.5"/>Distortable.ttf</font> |
+ <font weight="200" style="normal"><axis tag="wght" stylevalue="0.7"/>Distortable.ttf</font> |
+ <font weight="300" style="normal"><axis tag="wght" stylevalue="0.9"/>Distortable.ttf</font> |
+ <font weight="400" style="normal"><axis tag="wght" stylevalue="1.0"/>Distortable.ttf</font> |
+ <font weight="500" style="normal"><axis tag="wght" stylevalue="1.2"/>Distortable.ttf</font> |
+ <font weight="600" style="normal"><axis tag="wght" stylevalue="1.4"/>Distortable.ttf</font> |
+ <font weight="700" style="normal"><axis tag="wght" stylevalue="1.6"/>Distortable.ttf</font> |
+ <font weight="800" style="normal"><axis tag="wght" stylevalue="1.8"/>Distortable.ttf</font> |
+ <font weight="900" style="normal"><axis tag="wght" stylevalue="2.0"/>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)); |