Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkFontMgr_example.cpp
Go to the documentation of this file.
1// Copyright 2020 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(SkFontMgr_example, 1280, 512, true, 0) {
5const char* tostr(SkFontStyle::Slant s) {
6 switch (s) {
7 case SkFontStyle::kUpright_Slant: return "SkFontStyle::kUpright_Slant";
8 case SkFontStyle::kItalic_Slant: return "SkFontStyle::kItalic_Slant";
9 case SkFontStyle::kOblique_Slant: return "SkFontStyle::kOblique_Slant";
10 default: return "";
11 }
12}
13
14void draw(SkCanvas* canvas) {
15 SkDebugf("Using a platform specific fontMgr;\n\n");
16
17 for (int i = 0; i < fontMgr->countFamilies(); ++i) {
18 SkString familyName;
19 fontMgr->getFamilyName(i, &familyName);
21 int N = styleSet->count();
22 for (int j = 0; j < N; ++j) {
23 SkFontStyle fontStyle;
24 SkString style;
25 styleSet->getStyle(j, &fontStyle, &style);
27 "SkFont font(fontMgr->legacyMakeTypeface(\"%s\",\n"
28 " SkFontStyle(%3d, %1d, %-27s));\n",
29 familyName.c_str(),
30 fontStyle.weight(),
31 fontStyle.width(),
32 tostr(fontStyle.slant()));
33 }
34 SkDebugf("\n");
35 }
36}
37} // END FIDDLE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
#define N
Definition beziers.cpp:19
sk_sp< SkFontStyleSet > createStyleSet(int index) const
void getFamilyName(int index, SkString *familyName) const
Definition SkFontMgr.cpp:97
int countFamilies() const
Definition SkFontMgr.cpp:93
Slant slant() const
Definition SkFontStyle.h:64
int width() const
Definition SkFontStyle.h:63
int weight() const
Definition SkFontStyle.h:62
const char * c_str() const
Definition SkString.h:133
sk_sp< SkFontMgr > fontMgr
Definition examples.cpp:32
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
struct MyStruct s