Flutter Engine
The Flutter Engine
Public Types | Static Public Member Functions | List of all members
SkTextUtils Class Reference

#include <SkTextUtils.h>

Public Types

enum  Align { kLeft_Align , kCenter_Align , kRight_Align }
 

Static Public Member Functions

static void Draw (SkCanvas *, const void *text, size_t size, SkTextEncoding, SkScalar x, SkScalar y, const SkFont &, const SkPaint &, Align=kLeft_Align)
 
static void DrawString (SkCanvas *canvas, const char text[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint, Align align=kLeft_Align)
 
static void GetPath (const void *text, size_t length, SkTextEncoding, SkScalar x, SkScalar y, const SkFont &, SkPath *)
 

Detailed Description

Definition at line 23 of file SkTextUtils.h.

Member Enumeration Documentation

◆ Align

Enumerator
kLeft_Align 
kCenter_Align 
kRight_Align 

Definition at line 25 of file SkTextUtils.h.

25 {
29 };

Member Function Documentation

◆ Draw()

void SkTextUtils::Draw ( SkCanvas canvas,
const void *  text,
size_t  size,
SkTextEncoding  encoding,
SkScalar  x,
SkScalar  y,
const SkFont font,
const SkPaint paint,
Align  align = kLeft_Align 
)
static

Definition at line 24 of file SkTextUtils.cpp.

26 {
27 if (align != kLeft_Align) {
28 SkScalar width = font.measureText(text, size, encoding);
29 if (align == kCenter_Align) {
30 width *= 0.5f;
31 }
32 x -= width;
33 }
34
35 canvas->drawTextBlob(SkTextBlob::MakeFromText(text, size, font, encoding), x, y, paint);
36}
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
static sk_sp< SkTextBlob > MakeFromText(const void *text, size_t byteLength, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
Definition: SkTextBlob.cpp:788
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
std::u16string text
double y
double x
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
font
Font Metadata and Metrics.
int32_t width

◆ DrawString()

static void SkTextUtils::DrawString ( SkCanvas canvas,
const char  text[],
SkScalar  x,
SkScalar  y,
const SkFont font,
const SkPaint paint,
Align  align = kLeft_Align 
)
inlinestatic

Definition at line 34 of file SkTextUtils.h.

35 {
36 Draw(canvas, text, strlen(text), SkTextEncoding::kUTF8, x, y, font, paint, align);
37 }
@ kUTF8
uses bytes to represent UTF-8 or ASCII
static void Draw(SkCanvas *, const void *text, size_t size, SkTextEncoding, SkScalar x, SkScalar y, const SkFont &, const SkPaint &, Align=kLeft_Align)
Definition: SkTextUtils.cpp:24

◆ GetPath()

void SkTextUtils::GetPath ( const void *  text,
size_t  length,
SkTextEncoding  encoding,
SkScalar  x,
SkScalar  y,
const SkFont font,
SkPath path 
)
static

Definition at line 38 of file SkTextUtils.cpp.

39 {
40 SkAutoToGlyphs ag(font, text, length, encoding);
41 AutoTArray<SkPoint> pos(ag.count());
42 font.getPos(ag.glyphs(), ag.count(), pos.get(), {x, y});
43
44 struct Rec {
45 SkPath* fDst;
46 const SkPoint* fPos;
47 } rec = { path, pos.get() };
48
49 path->reset();
50 font.getPaths(ag.glyphs(), ag.count(), [](const SkPath* src, const SkMatrix& mx, void* ctx) {
51 Rec* rec = (Rec*)ctx;
52 if (src) {
53 SkMatrix m(mx);
54 m.postTranslate(rec->fPos->fX, rec->fPos->fY);
55 rec->fDst->addPath(*src, m);
56 }
57 rec->fPos += 1;
58 }, &rec);
59}
SkPoint pos
SkRect fDst
Definition: LatticeOp.cpp:381
Definition: SkPath.h:59
size_t length
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57

The documentation for this class was generated from the following files: