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

Go to the source code of this file.

Functions

 REG_FIDDLE (measure_text_bounds, 256, 128, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( measure_text_bounds  ,
256  ,
128  ,
false  ,
 
)

Definition at line 4 of file measure_text_bounds.cpp.

4 {
5void draw(SkCanvas* canvas) {
6 canvas->clear(SK_ColorWHITE);
7
9 paint.setAntiAlias(true);
10 SkFont font(fontMgr->matchFamilyStyle(nullptr, {}), 64, 1.25f, -0.25f);
11
12 float x = 32.0f;
13 float y = 88.0f;
14 const char text[] = "Skia";
15
17 (void)font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
18
19 canvas->drawRect(bounds.makeOffset(x, y), paint);
20
21 paint.setColor(SK_ColorWHITE);
22 canvas->drawString(text, x, y, font, paint);
23}
24} // END FIDDLE
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
@ kUTF8
uses bytes to represent UTF-8 or ASCII
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void drawRect(const SkRect &rect, const SkPaint &paint)
void clear(SkColor color)
Definition SkCanvas.h:1199
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
const Paint & paint
sk_sp< SkFontMgr > fontMgr
Definition examples.cpp:32
std::u16string text
double y
double x
Optional< SkRect > bounds
Definition SkRecords.h:189
font
Font Metadata and Metrics.