41 SkString getName()
const override {
return SkString(
"fontscalerdistortable"); }
46 bool fOverride =
false;
50 bool onGetControls(
SkMetaData* controls)
override {
51 controls->
setBool(
"Override", fOverride);
55 void onSetControls(
const SkMetaData& controls)
override {
56 bool oldOverride = fOverride;
57 controls.
findBool(
"Override", &fOverride);
58 if (fOverride != oldOverride) {
62 return fVariationSliders.
readControls(controls, &fDirty);
72 void onOnceBeforeDraw()
override {
83 if (!fInfo.distortable) {
90 inline static constexpr int rows = 2;
91 inline static constexpr int cols = 5;
94 void updateTypefaces() {
97 std::unique_ptr<SkStreamAsset> distortableStream( fInfo.distortable
98 ? fInfo.distortable->openStream(
nullptr)
100 for (
int row = 0; row < rows; ++row) {
101 for (
int col = 0; col < cols; ++col) {
104 Coordinate coordinates[2];
108 position = {user_coordinates.
data(),
static_cast<int>(user_coordinates.
size())};
111 const int coordinateCount = 2;
113 SkScalar(row*cols + col) / (rows*cols));
114 coordinates[0] = {fInfo.axisTag, styleValue};
115 coordinates[1] = {fInfo.axisTag, styleValue};
116 position = {coordinates,
static_cast<int>(coordinateCount)};
120 if (row == 0 && fInfo.distortable) {
121 return fInfo.distortable->makeClone(
124 if (distortableStream) {
137 this->updateTypefaces();
141 paint.setAntiAlias(
true);
145 const char*
text =
"abc";
146 const size_t textLen = strlen(
text);
148 for (
int row = 0; row < rows; ++row) {
149 for (
int col = 0; col < cols; ++col) {
153 font.setTypeface(typeface[row][col] ? typeface[row][col] :
162 p.setAntiAlias(
true);
168 for (
int ps = 6; ps <= 22; ps++) {
171 y +=
font.getMetrics(
nullptr);
175 font.setSubpixel(
true);
176 font.setLinearMetrics(
true);
177 font.setBaselineSnap(
false);
185DEF_GM(
return new FontScalerDistortableGM; )
@ kUTF8
uses bytes to represent UTF-8 or ASCII
static SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t)
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 rotate(SkScalar degrees)
sk_sp< SkTypeface > makeFromStream(std::unique_ptr< SkStreamAsset >, int ttcIndex=0) const
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
constexpr T * data() const
constexpr size_t size() const
FontScalerDistortableGM()
skiagm::DrawResult DrawResult
sk_sp< SkFontMgr > fontMgr
font
Font Metadata and Metrics.
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
SkFontArguments & setVariationDesignPosition(VariationPosition position)
static constexpr SkISize Make(int32_t w, int32_t h)
void setLTRB(float left, float top, float right, float bottom)