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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/core/SkTypeface.h » ('j') | include/core/SkTypeface.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« 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