37#define MAX_FAMILIES 30
47 const char* fontName,
const char* bcp47[],
int bcp47Count,
55 font.setTypeface(typeface);
58 if (
nullptr == typeface) {
71static const char*
zh =
"zh";
72static const char*
ja =
"ja";
77 void onOnceBeforeDraw()
override {
84 SkISize getISize()
override {
return {1536, 768}; }
90 font.setSubpixel(
true);
96 *errorMsg =
"No families in SkFontMgr";
109 for (
int j = 0; j <
set->count(); ++j) {
112 set->getStyle(j, &fs, &sname);
133 void onOnceBeforeDraw()
override {
140 SkISize getISize()
override {
return {640, 1024}; }
146 for (
int j = 0; j < fset->
count(); ++j) {
163 for (
int weight = 100; weight <= 900; weight += 200) {
170 f.setTypeface(std::move(face));
181 font.setSubpixel(
true);
184 const char* gNames[] = {
185 "Helvetica Neue",
"Arial",
"sans"
191 if (fset->
count() > 0) {
195 if (!fset || fset->
count() == 0) {
196 *errorMsg =
"No SkFontStyleSet";
201 this->exploreFamily(canvas,
font, fset.
get());
203 this->iterateFamily(canvas,
font, fset.
get());
214 if (fScaleX != 1 || fSkewX != 0) {
222 bool onGetControls(
SkMetaData* controls)
override {
223 controls->
setBool(
"Label Bounds", fLabelBounds);
227 void onSetControls(
const SkMetaData& controls)
override {
228 controls.
findBool(
"Label Bounds", &fLabelBounds);
232 SkColor boundsColor,
bool labelBounds)
238 int numGlyphs =
font.getTypeface()->countGlyphs();
239 for (
int i = 0;
i < numGlyphs; ++
i) {
242 font.getBounds(&glyphId, 1, &cur,
nullptr);
253 drawBounds.
join(fontBounds);
262 canvas->
drawRect(fontBounds, boundsPaint);
264 const SkScalar intervals[] = { 10.f, 10.f };
269 font.getMetrics(&fm);
270 SkPaint metricsPaint(boundsPaint);
272 metricsPaint.setAlphaf(0.25f);
278 canvas->
drawRect(underline, metricsPaint);
286 canvas->
drawRect(strikeout, metricsPaint);
293 } glyphsToDraw [] = {
296 {top, {
min.centerX(),
min.top() }, 0},
297 {bottom, {
min.centerX(),
min.bottom() }, 180},
306 font.getTypeface()->getFamilyName(&
name);
309 for (
const GlyphToDraw& glyphToDraw : glyphsToDraw) {
311 font.getPath(glyphToDraw.id, &
path);
320 canvas->
translate(glyphToDraw.location.fX, glyphToDraw.location.fY);
321 canvas->
rotate(glyphToDraw.rotation);
331 SkISize getISize()
override {
return {1024, 850}; }
336 font.setSubpixel(
true);
338 font.setScaleX(fScaleX);
339 font.setSkewX(fSkewX);
346 *errorMsg =
"No families in SkFontMgr under test.";
357 for (
int j = 0; j <
set->count() && j < 3; ++j) {
365 x += drawBounds.
width() + 20;
383 bool fLabelBounds =
false;
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
@ kUTF8
uses bytes to represent UTF-8 or ASCII
@ kGlyphID
uses two byte words to represent glyph indices
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
#define SK_ScalarInfinity
#define SK_ScalarNegativeInfinity
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
FontMgrBoundsGM(float scale, float skew)
void drawRect(const SkRect &rect, const SkPaint &paint)
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void rotate(SkScalar degrees)
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
sk_sp< SkFontStyleSet > createStyleSet(int index) const
sk_sp< SkTypeface > matchFamilyStyleCharacter(const char familyName[], const SkFontStyle &, const char *bcp47[], int bcp47Count, SkUnichar character) const
void getFamilyName(int index, SkString *familyName) const
sk_sp< SkFontStyleSet > matchFamily(const char familyName[]) const
int countFamilies() const
sk_sp< SkTypeface > legacyMakeTypeface(const char familyName[], SkFontStyle style) const
static SkRect GetFontBounds(const SkFont &)
virtual sk_sp< SkTypeface > createTypeface(int index)=0
virtual sk_sp< SkTypeface > matchStyle(const SkFontStyle &pattern)=0
virtual void getStyle(int index, SkFontStyle *, SkString *style)=0
void setTypeface(sk_sp< SkTypeface > tf)
void setEdging(Edging edging)
@ kAntiAlias
may have transparent pixels on glyph edges
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
static size_t SetFontCacheLimit(size_t bytes)
void setStyle(Style style)
void setColor(SkColor color)
void setAntiAlias(bool aa)
@ kStroke_Style
set to stroke geometry
@ kFill_Style
set to fill geometry
void setPathEffect(sk_sp< SkPathEffect > pathEffect)
void appendUnichar(SkUnichar uni)
void printf(const char format[],...) SK_PRINTF_LIKE(2
void appendS32(int32_t value)
const char * c_str() const
void void void appendf(const char format[],...) SK_PRINTF_LIKE(2
void getFamilyName(SkString *name) const
SkFontStyle fontStyle() const
skiagm::DrawResult DrawResult
static SkScalar drawString(SkCanvas *canvas, const SkString &text, SkScalar x, SkScalar y, const SkFont &font)
static SkScalar drawCharacter(SkCanvas *canvas, uint32_t character, SkScalar x, SkScalar y, const SkFont &origFont, SkFontMgr *fm, const char *fontName, const char *bcp47[], int bcp47Count, const SkFontStyle &fontStyle)
static float min(float r, float g, float b)
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
DEF_SWITCHES_START aot vmservice shared library name
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
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
font
Font Metadata and Metrics.
SkScalar fStrikeoutPosition
distance from baseline to bottom of stroke, typically negative
SkScalar fStrikeoutThickness
strikeout thickness
uint32_t fFlags
FontMetricsFlags indicating which metrics are valid.
SkScalar fUnderlineThickness
underline thickness
@ kStrikeoutPositionIsValid_Flag
set if fStrikeoutPosition is valid
@ kStrikeoutThicknessIsValid_Flag
set if fStrikeoutThickness is valid
@ kUnderlinePositionIsValid_Flag
set if fUnderlinePosition is valid
@ kUnderlineThicknessIsValid_Flag
set if fUnderlineThickness is valid
SkScalar fUnderlinePosition
distance from baseline to top of stroke, typically positive
SkScalar fBottom
larger y-axis bounds
constexpr float left() const
SkScalar fLeft
smaller x-axis bounds
SkScalar fRight
larger x-axis bounds
constexpr float width() const
void join(const SkRect &r)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
SkScalar fTop
smaller y-axis bounds