22const SkScalar kTextSizes[] = {12, 18, 30, 120};
23const char kReportFontName[] =
"fonts/Roboto-Regular.ttf";
33 SkFont(reportTypeface, kDumpFontSize),
37void dumpLocalizedStrings(
SkCanvas* canvas,
43 while (family_names->next(&famName)) {
46 dumpToCanvas(canvas, localizedName, reportTypeface);
47 canvas->
translate(0, kDumpFontSize * 1.2);
49 family_names->unref();
57 dumpToCanvas(canvas, glyphCount, reportTypeface);
60void dumpFamilyAndPostscriptName(
SkCanvas* canvas,
66 nameDump.
printf(
"Family name: %s\n",
name.c_str());
67 dumpToCanvas(canvas, nameDump, reportTypeface);
70 canvas->
translate(0, kDumpFontSize * 1.2);
71 nameDump.
printf(
"PS Name: %s\n",
name.c_str());
72 dumpToCanvas(canvas, nameDump, reportTypeface);
74 canvas->
translate(0, kDumpFontSize * 1.2);
75 nameDump.
printf(
"No Postscript name.");
76 dumpToCanvas(canvas, nameDump, reportTypeface);
85 kMakeWithFontArguments,
86 kCloneWithFontArguments,
89 const char* testFontFilename,
90 std::initializer_list<SkFontArguments::VariationPosition::Coordinate>
94 , fTestFontFilename(testFontFilename)
95 , fConstruction(construction) {
98 fCoordinates = std::make_unique<SkFontArguments::VariationPosition::Coordinate[]>(
99 specifiedVariations.size());
100 for (
size_t i = 0;
i < specifiedVariations.size(); ++
i) {
101 fCoordinates[
i] =
std::data(specifiedVariations)[
i];
104 fVariationPosition.
coordinates = fCoordinates.get();
117 fVariationPosition));
133 if (!fTestTypeface) {
134 *errorMsg =
"Unable to initialize typeface.";
139 const char32_t testText[] =
U"abc";
144 for (
SkScalar textSize : kTextSizes) {
145 font.setSize(textSize);
146 y +=
font.getSpacing();
158 dumpGlyphCount(canvas, fTestTypeface, fReportTypeface);
159 canvas->
translate(0, kDumpFontSize * 1.2);
160 dumpLocalizedStrings(canvas, fTestTypeface, fReportTypeface);
161 canvas->
translate(0, kDumpFontSize * 1.2);
162 dumpFamilyAndPostscriptName(canvas, fTestTypeface, fReportTypeface);
168 using INHERITED =
GM;
171 const char* fTestFontFilename;
175 std::unique_ptr<SkFontArguments::VariationPosition::Coordinate[]> fCoordinates;
185DEF_GM(
return new FontationsTypefaceGM(
"roboto",
"fonts/Roboto-Regular.ttf", {});)
188 "fonts/Distortable.ttf",
190DEF_GM(
return new FontationsTypefaceGM(
192 "fonts/Distortable.ttf",
std::unique_ptr< SkStreamAsset > GetResourceAsStream(const char *resource, bool useFileStream)
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorGREEN
constexpr SkColor SK_ColorWHITE
@ kUTF8
uses bytes to represent UTF-8 or ASCII
@ kUTF32
uses four byte words to represent all of Unicode
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
SK_API sk_sp< SkTypeface > SkTypeface_Make_Fontations(std::unique_ptr< SkStreamAsset > fontData, const SkFontArguments &args)
static constexpr SkFourByteTag SkSetFourByteTag(char a, char b, char c, char d)
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 printf(const char format[],...) SK_PRINTF_LIKE(2
const char * c_str() const
LocalizedStrings * createFamilyNameIterator() const
void getFamilyName(SkString *name) const
bool getPostScriptName(SkString *name) const
sk_sp< SkTypeface > makeClone(const SkFontArguments &) const
SkString getName() const override
void onOnceBeforeDraw() override
@ kCloneWithFontArguments
FontationsTypefaceGM(const char *testName, const char *testFontFilename, std::initializer_list< SkFontArguments::VariationPosition::Coordinate > specifiedVariations, TypefaceConstruction construction=TypefaceConstruction::kMakeWithFontArguments)
DrawResult onDraw(SkCanvas *canvas, SkString *errorMsg) override
SkISize getISize() override
GM(SkColor backgroundColor=SK_ColorWHITE)
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
font
Font Metadata and Metrics.
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
const Coordinate * coordinates
static constexpr SkISize Make(int32_t w, int32_t h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
std::shared_ptr< const fml::Mapping > data