Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 3d311a9

Browse files
rphilliSkia Commit-Bot
authored andcommitted
Switch some GMs over to using create_portable_typeface
This is in response to some Win7 vs Win10 font selection diffs on the compositor_quads_filter GM. Change-Id: I9564d8a305b0bf773ddb31597b29878e0bc3323d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/287796 Reviewed-by: Michael Ludwig <[email protected]> Commit-Queue: Robert Phillips <[email protected]>
1 parent 7094159 commit 3d311a9

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

gm/compositor_quads.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "include/private/SkTArray.h"
4040
#include "src/core/SkLineClipper.h"
4141
#include "tools/Resources.h"
42+
#include "tools/ToolUtils.h"
4243
#include "tools/gpu/YUVUtils.h"
4344

4445
#include <array>
@@ -187,7 +188,8 @@ static void draw_clipping_boundaries(SkCanvas* canvas, const SkMatrix& local) {
187188
}
188189

189190
static void draw_text(SkCanvas* canvas, const char* text) {
190-
canvas->drawString(text, 0, 0, SkFont(nullptr, 12), SkPaint());
191+
SkFont font(ToolUtils::create_portable_typeface(), 12);
192+
canvas->drawString(text, 0, 0, font, SkPaint());
191193
}
192194

193195
/////////////////////////////////////////////////////////////////////////////////////////////////

gm/drawquadset.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "src/gpu/GrPaint.h"
3030
#include "src/gpu/GrRenderTargetContext.h"
3131
#include "src/gpu/SkGr.h"
32+
#include "tools/ToolUtils.h"
3233

3334
#include <utility>
3435

@@ -39,7 +40,8 @@ static constexpr int kRowCount = 4;
3940
static constexpr int kColCount = 3;
4041

4142
static void draw_text(SkCanvas* canvas, const char* text) {
42-
canvas->drawString(text, 0, 0, SkFont(nullptr, 12), SkPaint());
43+
SkFont font(ToolUtils::create_portable_typeface(), 12);
44+
canvas->drawString(text, 0, 0, font, SkPaint());
4345
}
4446

4547
static void draw_gradient_tiles(SkCanvas* canvas, bool alignGradients) {

gm/gradients_degenerate.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "include/core/SkTileMode.h"
2121
#include "include/core/SkTypes.h"
2222
#include "include/effects/SkGradientShader.h"
23+
#include "tools/ToolUtils.h"
2324

2425
// NOTE: The positions define hardstops for the red and green borders. For the repeating degenerate
2526
// gradients, that means the red and green are never visible, so the average color used should only
@@ -46,8 +47,9 @@ typedef sk_sp<SkShader> (*GradientFactory)(SkTileMode tm);
4647
static void draw_tile_header(SkCanvas* canvas) {
4748
canvas->save();
4849

50+
SkFont font(ToolUtils::create_portable_typeface(), 12);
4951
for (int i = 0; i < TILE_MODE_CT; ++i) {
50-
canvas->drawString(TILE_NAMES[i], 0, 0, SkFont(), SkPaint());
52+
canvas->drawString(TILE_NAMES[i], 0, 0, font, SkPaint());
5153
canvas->translate(TILE_SIZE + TILE_GAP, 0);
5254
}
5355

@@ -63,8 +65,10 @@ static void draw_row(SkCanvas* canvas, const char* desc, GradientFactory factory
6365
SkPaint text;
6466
text.setAntiAlias(true);
6567

68+
SkFont font(ToolUtils::create_portable_typeface(), 12);
69+
6670
canvas->translate(0, TILE_GAP);
67-
canvas->drawString(desc, 0, 0, SkFont(), text);
71+
canvas->drawString(desc, 0, 0, font, text);
6872
canvas->translate(0, TILE_GAP);
6973

7074
SkPaint paint;

0 commit comments

Comments
 (0)