aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2017-07-27 10:45:29 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-27 21:30:45 +0000
commit713195071dc7bdeddec2d1c9fab9b3720f049f07 (patch)
tree1bc2d47ec9e66f81a14d626eb5ad8185dbecca27 /gm
parent23890a9ac89005a15967fe8af8aaafc0edda5e32 (diff)
Remove internal use of SkTypeface::Style.
Change-Id: I71cf04b12be95a54b7fb47d048ba1f8672ed9a8f Reviewed-on: https://skia-review.googlesource.com/27760 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'gm')
-rw-r--r--gm/all_bitmap_configs.cpp2
-rw-r--r--gm/coloremoji_blendmodes.cpp2
-rw-r--r--gm/colorwheel.cpp3
-rw-r--r--gm/downsamplebitmap.cpp6
-rw-r--r--gm/filterbitmap.cpp8
-rw-r--r--gm/fontcache.cpp6
-rw-r--r--gm/gammatext.cpp3
-rw-r--r--gm/lightingshader2.cpp3
-rw-r--r--gm/textblobrandomfont.cpp2
-rw-r--r--gm/typeface.cpp30
-rw-r--r--gm/variedtext.cpp6
-rw-r--r--gm/verttext.cpp20
12 files changed, 42 insertions, 49 deletions
diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp
index d9735b2d3d..32fb86c9cd 100644
--- a/gm/all_bitmap_configs.cpp
+++ b/gm/all_bitmap_configs.cpp
@@ -81,7 +81,7 @@ static void color_wheel_native(SkCanvas* canvas) {
const SkScalar D = 0.3f * SkIntToScalar(SCALE);
const SkScalar X = SkDoubleToScalar(D * sqrt_3_over_2);
const SkScalar Y = D * SK_ScalarHalf;
- sk_tool_utils::set_portable_typeface(&p, nullptr, SkFontStyle::FromOldStyle(SkTypeface::kBold));
+ sk_tool_utils::set_portable_typeface(&p, nullptr, SkFontStyle::Bold());
p.setTextSize(0.28125f * SCALE);
draw_center_letter('K', &p, SK_ColorBLACK, Z, Z, canvas);
draw_center_letter('R', &p, SK_ColorRED, Z, D, canvas);
diff --git a/gm/coloremoji_blendmodes.cpp b/gm/coloremoji_blendmodes.cpp
index ee3db7671d..b93c6b4e45 100644
--- a/gm/coloremoji_blendmodes.cpp
+++ b/gm/coloremoji_blendmodes.cpp
@@ -35,7 +35,7 @@ protected:
0, &local));
sk_sp<SkTypeface> orig(sk_tool_utils::create_portable_typeface("serif",
- SkFontStyle::FromOldStyle(SkTypeface::kBold)));
+ SkFontStyle::Bold()));
if (nullptr == orig) {
orig = SkTypeface::MakeDefault();
}
diff --git a/gm/colorwheel.cpp b/gm/colorwheel.cpp
index b938cd5088..b8a08951f5 100644
--- a/gm/colorwheel.cpp
+++ b/gm/colorwheel.cpp
@@ -40,8 +40,7 @@ DEF_SIMPLE_GM(colorwheel, canvas, 256, 256) {
DEF_SIMPLE_GM(colorwheelnative, canvas, 128, 28) {
SkPaint paint;
- sk_tool_utils::set_portable_typeface(&paint, "sans-serif",
- SkFontStyle::FromOldStyle(SkTypeface::kBold));
+ sk_tool_utils::set_portable_typeface(&paint, "sans-serif", SkFontStyle::Bold());
paint.setTextSize(18.0f);
canvas->clear(sk_tool_utils::color_to_565(SK_ColorLTGRAY));
diff --git a/gm/downsamplebitmap.cpp b/gm/downsamplebitmap.cpp
index fefc94bd57..e142bde112 100644
--- a/gm/downsamplebitmap.cpp
+++ b/gm/downsamplebitmap.cpp
@@ -128,11 +128,11 @@ class DownsampleBitmapTextGM: public DownsampleBitmapGM {
setTypeface(&paint, "serif", SkFontStyle());
canvas.drawString("Hamburgefons", fTextSize/2, 1.2f*fTextSize, paint);
- setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBold));
+ setTypeface(&paint, "serif", SkFontStyle::Bold());
canvas.drawString("Hamburgefons", fTextSize/2, 2.4f*fTextSize, paint);
- setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kItalic));
+ setTypeface(&paint, "serif", SkFontStyle::Italic());
canvas.drawString("Hamburgefons", fTextSize/2, 3.6f*fTextSize, paint);
- setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic));
+ setTypeface(&paint, "serif", SkFontStyle::BoldItalic());
canvas.drawString("Hamburgefons", fTextSize/2, 4.8f*fTextSize, paint);
}
private:
diff --git a/gm/filterbitmap.cpp b/gm/filterbitmap.cpp
index 92aeddc788..a630662976 100644
--- a/gm/filterbitmap.cpp
+++ b/gm/filterbitmap.cpp
@@ -124,13 +124,13 @@ class FilterBitmapTextGM: public FilterBitmapGM {
paint.setSubpixelText(true);
paint.setTextSize(fTextSize);
- setTypeface(&paint, "serif", SkFontStyle());
+ setTypeface(&paint, "serif", SkFontStyle::Normal());
canvas.drawString("Hamburgefons", fTextSize/2, 1.2f*fTextSize, paint);
- setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBold));
+ setTypeface(&paint, "serif", SkFontStyle::Bold());
canvas.drawString("Hamburgefons", fTextSize/2, 2.4f*fTextSize, paint);
- setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kItalic));
+ setTypeface(&paint, "serif", SkFontStyle::Italic());
canvas.drawString("Hamburgefons", fTextSize/2, 3.6f*fTextSize, paint);
- setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBoldItalic));
+ setTypeface(&paint, "serif", SkFontStyle::BoldItalic());
canvas.drawString("Hamburgefons", fTextSize/2, 4.8f*fTextSize, paint);
}
private:
diff --git a/gm/fontcache.cpp b/gm/fontcache.cpp
index f3f891073c..a8c5b768c3 100644
--- a/gm/fontcache.cpp
+++ b/gm/fontcache.cpp
@@ -33,10 +33,8 @@ protected:
}
void onOnceBeforeDraw() override {
- fTypefaces[0] = sk_tool_utils::create_portable_typeface("serif",
- SkFontStyle::FromOldStyle(SkTypeface::kItalic));
- fTypefaces[1] = sk_tool_utils::create_portable_typeface("sans-serif",
- SkFontStyle::FromOldStyle(SkTypeface::kItalic));
+ fTypefaces[0] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Italic());
+ fTypefaces[1] = sk_tool_utils::create_portable_typeface("sans-serif",SkFontStyle::Italic());
}
void onDraw(SkCanvas* canvas) override {
diff --git a/gm/gammatext.cpp b/gm/gammatext.cpp
index 43b07200ee..f8f2aa6004 100644
--- a/gm/gammatext.cpp
+++ b/gm/gammatext.cpp
@@ -105,8 +105,7 @@ static sk_sp<SkShader> make_gradient(SkColor c) {
}
static void set_face(SkPaint* paint) {
- paint->setTypeface(SkTypeface::MakeFromName("serif",
- SkFontStyle::FromOldStyle(SkTypeface::kItalic)));
+ paint->setTypeface(SkTypeface::MakeFromName("serif", SkFontStyle::Italic()));
}
static void draw_pair(SkCanvas* canvas, SkPaint* paint, const sk_sp<SkShader>& shader) {
diff --git a/gm/lightingshader2.cpp b/gm/lightingshader2.cpp
index edec063dd1..b0c7beec46 100644
--- a/gm/lightingshader2.cpp
+++ b/gm/lightingshader2.cpp
@@ -140,8 +140,7 @@ protected:
constexpr SkScalar LABEL_SIZE = 10.0f;
SkPaint labelPaint;
- labelPaint.setTypeface(sk_tool_utils::create_portable_typeface("sans-serif",
- SkFontStyle()));
+ labelPaint.setTypeface(sk_tool_utils::create_portable_typeface("sans-serif",SkFontStyle()));
labelPaint.setAntiAlias(true);
labelPaint.setTextSize(LABEL_SIZE);
diff --git a/gm/textblobrandomfont.cpp b/gm/textblobrandomfont.cpp
index e00b299403..8dd77c51f0 100644
--- a/gm/textblobrandomfont.cpp
+++ b/gm/textblobrandomfont.cpp
@@ -41,7 +41,7 @@ protected:
// Setup our random scaler context
sk_sp<SkTypeface> orig(sk_tool_utils::create_portable_typeface(
- "sans-serif", SkFontStyle::FromOldStyle(SkTypeface::kBold)));
+ "sans-serif", SkFontStyle::Bold()));
if (nullptr == orig) {
orig = SkTypeface::MakeDefault();
}
diff --git a/gm/typeface.cpp b/gm/typeface.cpp
index 807b49c883..b0db62b05a 100644
--- a/gm/typeface.cpp
+++ b/gm/typeface.cpp
@@ -9,6 +9,7 @@
#include "sk_tool_utils.h"
#include "Resources.h"
#include "SkCanvas.h"
+#include "SkFontStyle.h"
#include "SkString.h"
#include "SkSurfaceProps.h"
#include "SkTypeface.h"
@@ -74,20 +75,20 @@ static void drawKernText(SkCanvas* canvas, const void* text, size_t len,
constexpr struct {
const char* fName;
- SkTypeface::Style fStyle;
+ SkFontStyle fStyle;
} gFaceStyles[] = {
- { "sans-serif", SkTypeface::kNormal },
- { "sans-serif", SkTypeface::kBold },
- { "sans-serif", SkTypeface::kItalic },
- { "sans-serif", SkTypeface::kBoldItalic },
- { "serif", SkTypeface::kNormal },
- { "serif", SkTypeface::kBold },
- { "serif", SkTypeface::kItalic },
- { "serif", SkTypeface::kBoldItalic },
- { "monospace", SkTypeface::kNormal },
- { "monospace", SkTypeface::kBold },
- { "monospace", SkTypeface::kItalic },
- { "monospace", SkTypeface::kBoldItalic },
+ { "sans-serif", SkFontStyle::Normal() },
+ { "sans-serif", SkFontStyle::Bold() },
+ { "sans-serif", SkFontStyle::Italic() },
+ { "sans-serif", SkFontStyle::BoldItalic() },
+ { "serif", SkFontStyle::Normal() },
+ { "serif", SkFontStyle::Bold() },
+ { "serif", SkFontStyle::Italic() },
+ { "serif", SkFontStyle::BoldItalic() },
+ { "monospace", SkFontStyle::Normal() },
+ { "monospace", SkFontStyle::Bold() },
+ { "monospace", SkFontStyle::Italic() },
+ { "monospace", SkFontStyle::BoldItalic() },
};
constexpr int gFaceStylesCount = SK_ARRAY_COUNT(gFaceStyles);
@@ -106,8 +107,7 @@ protected:
void onOnceBeforeDraw() override {
for (int i = 0; i < gFaceStylesCount; i++) {
fFaces[i] = SkTypeface::MakeFromName(
- sk_tool_utils::platform_font_name(
- gFaceStyles[i].fName), SkFontStyle::FromOldStyle(gFaceStyles[i].fStyle));
+ sk_tool_utils::platform_font_name(gFaceStyles[i].fName), gFaceStyles[i].fStyle);
}
}
diff --git a/gm/variedtext.cpp b/gm/variedtext.cpp
index c0f6cbf8c7..e8e1c29632 100644
--- a/gm/variedtext.cpp
+++ b/gm/variedtext.cpp
@@ -54,11 +54,9 @@ protected:
static_assert(4 == SK_ARRAY_COUNT(fTypefaces), "typeface_cnt");
fTypefaces[0] = sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle());
- fTypefaces[1] = sk_tool_utils::create_portable_typeface("sans-serif",
- SkFontStyle::FromOldStyle(SkTypeface::kBold));
+ fTypefaces[1] = sk_tool_utils::create_portable_typeface("sans-serif", SkFontStyle::Bold());
fTypefaces[2] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle());
- fTypefaces[3] = sk_tool_utils::create_portable_typeface("serif",
- SkFontStyle::FromOldStyle(SkTypeface::kBold));
+ fTypefaces[3] = sk_tool_utils::create_portable_typeface("serif", SkFontStyle::Bold());
SkRandom random;
for (int i = 0; i < kCnt; ++i) {
diff --git a/gm/verttext.cpp b/gm/verttext.cpp
index 9c9ddb0e11..c729271c05 100644
--- a/gm/verttext.cpp
+++ b/gm/verttext.cpp
@@ -28,20 +28,20 @@ constexpr size_t gLen = sizeof(gText) - sizeof(gText[0]);
class VertTextGM : public GM {
public:
VertTextGM()
- // : fFace(SkTypeface::CreateFromName("unifont", SkTypeface::kNormal))
- // : fFace(SkTypeface::CreateFromFile("MotoyaL04Mincho_3.ttf"))
+ // : fFace(SkTypeface::MakeFromName("unifont", SkFontStyle::Normal()))
+ // : fFace(SkTypeface::MakeFromFile("MotoyaL04Mincho_3.ttf"))
// Bitmap fonts on OS X.
- // : fFace(SkTypeface::CreateFromName("GB18030 Bitmap", SkTypeface::kNormal))
- // : fFace(SkTypeface::CreateFromName("Apple Color Emoji", SkTypeface::kNormal))
+ // : fFace(SkTypeface::MakeFromName("GB18030 Bitmap", SkFontStyle::Normal()))
+ // : fFace(SkTypeface::MakeFromName("Apple Color Emoji", SkFontStyle::Normal()))
// OTF CFF fonts on OS X.
- // : fFace(SkTypeface::CreateFromName("Hiragino Mincho ProN", SkTypeface::kNormal))
- // : fFace(SkTypeface::CreateFromName("Hiragino Kaku Gothic Pro", SkTypeface::kNormal))
- // : fFace(SkTypeface::CreateFromName("Hiragino Sans GB", SkTypeface::kNormal))
- // : fFace(SkTypeface::CreateFromName("STIXGeneral", SkTypeface::kNormal))
- // : fFace(SkTypeface::CreateFromName("Yuppy SC", SkTypeface::kNormal))
- // : fFace(SkTypeface::CreateFromName("Yuppy TC", SkTypeface::kNormal))
+ // : fFace(SkTypeface::MakeFromName("Hiragino Mincho ProN", SkFontStyle::Normal()))
+ // : fFace(SkTypeface::MakeFromName("Hiragino Kaku Gothic Pro", SkFontStyle::Normal()))
+ // : fFace(SkTypeface::MakeFromName("Hiragino Sans GB", SkFontStyle::Normal()))
+ // : fFace(SkTypeface::MakeFromName("STIXGeneral", SkFontStyle::Normal()))
+ // : fFace(SkTypeface::MakeFromName("Yuppy SC", SkFontStyle::Normal()))
+ // : fFace(SkTypeface::MakeFromName("Yuppy TC", SkFontStyle::Normal()))
{
}