Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
SkFontMgr_example.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (SkFontMgr_example, 1280, 512, true, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( SkFontMgr_example  ,
1280  ,
512  ,
true  ,
 
)

Definition at line 4 of file SkFontMgr_example.cpp.

4 {
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
struct MyStruct s