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

Unified Diff: gm/fontscalerdistortable.cpp

Issue 1027373002: Font variations. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 5 years, 7 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 | gyp/freetype.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/fontscalerdistortable.cpp
diff --git a/gm/fontscaler.cpp b/gm/fontscalerdistortable.cpp
similarity index 62%
copy from gm/fontscaler.cpp
copy to gm/fontscalerdistortable.cpp
index c3b2c87af255965bd0d1b645de0a625981a04d8e..715f32169c75e7a8c4b57b090c71293f4c6202a9 100644
--- a/gm/fontscaler.cpp
+++ b/gm/fontscalerdistortable.cpp
@@ -1,36 +1,37 @@
/*
- * Copyright 2011 Google Inc.
+ * Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
+#include "Resources.h"
+#include "SkFixed.h"
+#include "SkFontDescriptor.h"
+#include "SkFontMgr.h"
#include "SkTypeface.h"
namespace skiagm {
-class FontScalerGM : public GM {
+class FontScalerDistortableGM : public GM {
public:
- FontScalerGM() {
+ FontScalerDistortableGM() {
this->setBGColor(0xFFFFFFFF);
}
- virtual ~FontScalerGM() {
- }
+ virtual ~FontScalerDistortableGM() { }
protected:
SkString onShortName() override {
- return SkString("fontscaler");
+ return SkString("fontscalerdistortable");
}
SkISize onISize() override {
- return SkISize::Make(1450, 750);
+ return SkISize::Make(550, 700);
}
- static void rotate_about(SkCanvas* canvas,
- SkScalar degrees,
- SkScalar px, SkScalar py) {
+ static void rotate_about(SkCanvas* canvas, SkScalar degrees, SkScalar px, SkScalar py) {
canvas->translate(px, py);
canvas->rotate(degrees);
canvas->translate(-px, -py);
@@ -38,26 +39,28 @@ protected:
void onDraw(SkCanvas* canvas) override {
SkPaint paint;
-
paint.setAntiAlias(true);
paint.setLCDRenderText(true);
- //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);
- const char* text = "Hamburgefons ooo mmm";
+ SkAutoTDelete<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Distortable.ttf"));
+ if (!distortable) {
+ return;
+ }
+ const char* text = "abc";
const size_t textLen = strlen(text);
for (int j = 0; j < 2; ++j) {
- // This used to do 6 iterations but it causes the N4 to crash in the MSAA4 config.
for (int i = 0; i < 5; ++i) {
SkScalar x = SkIntToScalar(10);
SkScalar y = SkIntToScalar(20);
+ SkFixed axis = SkDoubleToFixed(0.5 + (5*j + i) * ((2.0 - 0.5) / (2 * 5)));
+ SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFontData(
+ new SkFontData(distortable->duplicate(), 0, &axis, 1)));
+ paint.setTypeface(typeface);
+
SkAutoCanvasRestore acr(canvas, true);
- canvas->translate(SkIntToScalar(50 + i * 230),
- SkIntToScalar(20));
+ canvas->translate(SkIntToScalar(30 + i * 100), SkIntToScalar(20));
rotate_about(canvas, SkIntToScalar(i * 5), x, y * 10);
{
@@ -86,7 +89,7 @@ private:
//////////////////////////////////////////////////////////////////////////////
-static GM* MyFactory(void*) { return new FontScalerGM; }
+static GM* MyFactory(void*) { return new FontScalerDistortableGM; }
static GMRegistry reg(MyFactory);
}
« no previous file with comments | « no previous file | gyp/freetype.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698