Flutter Engine
The Flutter Engine
Functions
Canvas_drawText.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (Canvas_drawText, 256, 200, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( Canvas_drawText  ,
256  ,
200  ,
false  ,
 
)

Definition at line 4 of file Canvas_drawText.cpp.

4 {
5void draw(SkCanvas* canvas) {
7 SkFont defaultFont = SkFont(fontMgr->matchFamilyStyle(nullptr, {}));
8 float textSizes[] = { 12, 18, 24, 36 };
9 for (auto size: textSizes ) {
10 defaultFont.setSize(size);
11 canvas->drawString("Aa", 10, 20, defaultFont, paint);
12 canvas->translate(0, size * 2);
13 }
14 defaultFont = SkFont(fontMgr->matchFamilyStyle(nullptr, {}));
15 float yPos = 20;
16 for (auto size: textSizes ) {
17 float scale = size / 12.f;
18 canvas->resetMatrix();
19 canvas->translate(100, 0);
20 canvas->scale(scale, scale);
21 canvas->drawString("Aa", 10 / scale, yPos / scale, defaultFont, paint);
22 yPos += size * 2;
23 }
24}
25} // END FIDDLE
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void resetMatrix()
Definition: SkCanvas.cpp:1355
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
Definition: SkCanvas.h:1803
sk_sp< SkTypeface > matchFamilyStyle(const char familyName[], const SkFontStyle &) const
Definition: SkFontMgr.cpp:109
Definition: SkFont.h:35
void setSize(SkScalar textSize)
Definition: SkFont.cpp:129
const Paint & paint
Definition: color_source.cc:38
sk_sp< SkFontMgr > fontMgr
Definition: examples.cpp:32
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
const Scalar scale