Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 5 of file Canvas_drawText.cpp.

5 {
6void draw(SkCanvas* canvas) {
8 SkFont defaultFont = SkFont(fontMgr->matchFamilyStyle(nullptr, {}));
9 float textSizes[] = { 12, 18, 24, 36 };
10 for (auto size: textSizes ) {
11 defaultFont.setSize(size);
12 canvas->drawString("Aa", 10, 20, defaultFont, paint);
13 canvas->translate(0, size * 2);
14 }
15 defaultFont = SkFont(fontMgr->matchFamilyStyle(nullptr, {}));
16 float yPos = 20;
17 for (auto size: textSizes ) {
18 float scale = size / 12.f;
19 canvas->resetMatrix();
20 canvas->translate(100, 0);
21 canvas->scale(scale, scale);
22 canvas->drawString("Aa", 10 / scale, yPos / scale, defaultFont, paint);
23 yPos += size * 2;
24 }
25}
26} // END FIDDLE
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void translate(SkScalar dx, SkScalar dy)
void resetMatrix()
void scale(SkScalar sx, SkScalar sy)
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
void setSize(SkScalar textSize)
Definition SkFont.cpp:129
const Paint & paint
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