25class TypefaceSlide :
public Slide {
27 TypefaceSlide() {
fName =
"Typeface Viewer"; }
33 fCurrentTypeface = fBaseTypeface;
36 fPathDirectionIndicator.reset();
37 fPathDirectionIndicator.moveTo(0, -3);
38 fPathDirectionIndicator.lineTo(3, 0);
39 fPathDirectionIndicator.lineTo(0, 3);
40 fPathDirectionIndicator.close();
43 fPathDirectionIndicatorPaint.setStroke(
true);
44 fPathDirectionIndicatorPaint.setStrokeWidth(0);
50 fBaseTypeface =
nullptr;
51 fCurrentTypeface =
nullptr;
55 if (fDrawArea.isEmpty()) {
56 TypefaceSlide&
self = *
const_cast<TypefaceSlide*
>(
this);
63 void updateCurrentTypeface() {
68 fVariationSliders.getCoordinates();
70 static_cast<int>(coords.
size())};
72 args.setVariationDesignPosition(varPos);
73 fCurrentTypeface = fBaseTypeface->makeClone(
args);
74 fCurrentTypefaceDirty =
false;
80 paint.setStroke(
true);
81 paint.setStrokeWidth(0);
84 if (fCurrentTypefaceDirty) {
85 this->updateCurrentTypeface();
89 font.getMetrics(&metrics);
101 int numGlyphs = fCurrentTypeface->countGlyphs();
102 if (numGlyphs == 0) {
103 fDrawArea.setEmpty();
107 for (
SkGlyphID glyph = 0;
true; ++glyph) {
109 SkRect beginLineGlyphBounds;
112 if (glyph !=
line.firstGlyph) {
113 newLineBounds.
fRight += 10;
117 font.getWidths(&glyph, 1, &advance, &glyphBounds);
119 SkRect glyphAndAdvanceBounds = glyphBounds;
120 glyphAndAdvanceBounds.
join(advanceBounds);
121 beginLineGlyphBounds = glyphAndAdvanceBounds;
122 beginLineGlyphBounds.
offset(-beginLineGlyphBounds.
fLeft, 0);
125 if (
line.number == -1) {
130 newLineBounds.
join(glyphDrawBounds);
131 if (newLineBounds.
width() < fWindowSize.width()) {
132 line.lastGlyph = glyph;
133 line.bounds = newLineBounds;
134 if (glyph != lastGlyph) {
141 position.fY -=
line.bounds.top();
143 if (gid !=
line.firstGlyph) {
148 font.getWidths(&gid, 1, &advance, &glyphBounds);
150 SkRect glyphAndAdvanceBounds = glyphBounds;
151 glyphAndAdvanceBounds.
join(advanceBounds);
153 position.fX -= glyphAndAdvanceBounds.
left();
155 if (fDrawGlyphMetrics) {
167 if (fOutline &&
font.getPath(gid, &glyphPath)) {
170 while ((
contour = iter.next())) {
173 if (
contour->getPosTan(0, &contourStart, &tangent)) {
174 contourStart += position;
177 matrix.setSinCos(tangent.
y(), tangent.
x(), 0, 0);
178 matrix.postTranslate(contourStart.
x(), contourStart.
y());
180 canvas->
drawPath(fPathDirectionIndicator, fPathDirectionIndicatorPaint);
185 position.fX += glyphAndAdvanceBounds.
right();
187 if (
line.lastGlyph == lastGlyph) {
190 drawBounds.
join(
line.bounds.makeOffset(-
line.bounds.fLeft, position.fY));
192 position.fY +=
line.bounds.bottom() + 10;
193 line.bounds = beginLineGlyphBounds;
194 line.firstGlyph = glyph;
195 line.lastGlyph = glyph;
199 fDrawArea = drawBounds.
roundOut().size();
202 bool onGetControls(
SkMetaData* controls)
override {
214 controls->
setBool(
"Glyph Metrics", fDrawGlyphMetrics);
217 controls->
setBool(
"Outline", fOutline);
219 return fVariationSliders.writeControls(controls);
222 void onSetControls(
const SkMetaData& controls)
override {
224 int numReturnedScalars = 0;
227 if (fFontSize !=
size[0]) {
229 fDrawArea.setEmpty();
232 controls.
findBool(
"Glyph Metrics", &fDrawGlyphMetrics);
233 controls.
findBool(
"Outline", &fOutline);
235 fVariationSliders.readControls(controls, &fCurrentTypefaceDirty);
242 std::unique_ptr<SkFontArguments::VariationPosition::Coordinate[]> fCoordinates;
245 bool fCurrentTypefaceDirty =
true;
247 bool fOutline =
false;
248 bool fDrawGlyphMetrics =
false;
253 SkPath fPathDirectionIndicator;
254 SkPaint fPathDirectionIndicatorPaint;
#define SkASSERT_RELEASE(cond)
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
void drawRect(const SkRect &rect, const SkPaint &paint)
void drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint positions[], const uint32_t clusters[], int textByteCount, const char utf8text[], SkPoint origin, const SkFont &font, const SkPaint &paint)
void drawPath(const SkPath &path, const SkPaint &paint)
void concat(const SkMatrix &matrix)
void setColor(SkColor color)
constexpr T * data() const
constexpr size_t size() const
virtual void resize(SkScalar winWidth, SkScalar winHeight)
virtual SkISize getDimensions() const
virtual void load(SkScalar winWidth, SkScalar winHeight)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
unsigned useCenter Optional< SkMatrix > matrix
Optional< SkRect > bounds
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.
constexpr float y() const
constexpr float x() const
constexpr float left() const
constexpr SkRect makeOffset(float dx, float dy) const
SkScalar fLeft
smaller x-axis bounds
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
SkScalar fRight
larger x-axis bounds
void roundOut(SkIRect *dst) const
void offset(float dx, float dy)
constexpr float right() const
constexpr float width() const
void join(const SkRect &r)
static constexpr SkRect MakeWH(float w, float h)