fix textblob doc examples

TBR=reed@google.com
NOTRY=true

Bug: skia:
Change-Id: I85e3712dac621f1714cda2ecb86980ff9305c43c
Reviewed-on: https://skia-review.googlesource.com/c/172742
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
diff --git a/docs/SkCanvas_Reference.bmh b/docs/SkCanvas_Reference.bmh
index 468a903..46d5336 100644
--- a/docs/SkCanvas_Reference.bmh
+++ b/docs/SkCanvas_Reference.bmh
@@ -4096,27 +4096,29 @@
 #Example
 #Height 120
 void draw(SkCanvas* canvas) {
-    SkTextBlobBuilder textBlobBuilder;
-    const char bunny[] = "/(^x^)\\";
-    const int len = sizeof(bunny) - 1;
-    uint16_t glyphs[len];
-    SkPaint paint;
-    paint.textToGlyphs(bunny, len, glyphs);
-    paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-    int runs[] = { 3, 1, 3 };
-    SkPoint textPos = { 20, 100 };
-    int glyphIndex = 0;
-    for (auto runLen : runs) {
-        paint.setTextSize(1 == runLen ? 20 : 50);
-        const SkTextBlobBuilder::RunBuffer& run =
-                textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY);
-        memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);
-        textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);
-        glyphIndex += runLen;
-    }
-    sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
-    paint.reset();
-    canvas->drawTextBlob(blob.get(), 0, 0, paint);
+    SkTextBlobBuilder textBlobBuilder;

+    const char bunny[] = "/(^x^)\\";

+    const int len = sizeof(bunny) - 1;

+    uint16_t glyphs[len];

+    SkPaint paint;

+    paint.textToGlyphs(bunny, len, glyphs);

+    paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);

+    SkFont font;

+    int runs[] = { 3, 1, 3 };

+    SkPoint textPos = { 20, 100 };

+    int glyphIndex = 0;

+    for (auto runLen : runs) {

+        font.setSize(1 == runLen ? 20 : 50);

+        const SkTextBlobBuilder::RunBuffer& run =

+                textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);

+        memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);

+        paint.setTextSize(1 == runLen ? 20 : 50);

+        textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);

+        glyphIndex += runLen;

+    }

+    sk_sp<const SkTextBlob> blob = textBlobBuilder.make();

+    paint.reset();

+    canvas->drawTextBlob(blob.get(), 0, 0, paint);

 }
 ##
 
@@ -4146,19 +4148,17 @@
 #Example
 #Height 120
 #Description
-Paint attributes unrelated to text, like color, have no effect on paint in allocated Text_Blob.
 Paint attributes related to text, like text size, have no effect on paint passed to drawTextBlob.
 ##
     void draw(SkCanvas* canvas) {
         SkTextBlobBuilder textBlobBuilder;
-        SkPaint paint;
-        paint.setTextSize(50);
-        paint.setColor(SK_ColorRED);
-        paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+        SkFont font;
+        font.setSize(50);
         const SkTextBlobBuilder::RunBuffer& run =
-                textBlobBuilder.allocRun(paint, 1, 20, 100);
+                textBlobBuilder.allocRun(font, 1, 20, 100);
         run.glyphs[0] = 20;
         sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
+        SkPaint paint;
         paint.setTextSize(10);
         paint.setColor(SK_ColorBLUE);
         canvas->drawTextBlob(blob.get(), 0, 0, paint);
diff --git a/docs/SkPaint_Reference.bmh b/docs/SkPaint_Reference.bmh
index 9ae82cd..007504d 100644
--- a/docs/SkPaint_Reference.bmh
+++ b/docs/SkPaint_Reference.bmh
@@ -3619,32 +3619,31 @@
 #Example
     #Height 143
         void draw(SkCanvas* canvas) {
-            SkPaint paint;
-            paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-            paint.setTextSize(120);
-            SkPoint textPos = { 20, 110 };
-            int len = 3;
-            SkTextBlobBuilder textBlobBuilder;
-            const SkTextBlobBuilder::RunBuffer& run =
-                    textBlobBuilder.allocRun(paint, len, textPos.fX, textPos.fY);
-            run.glyphs[0] = 10;
-            run.glyphs[1] = 20;
-            run.glyphs[2] = 30;
-            sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
-            canvas->drawTextBlob(blob.get(), textPos.fX, textPos.fY, paint);
-            SkScalar bounds[] = { 116, 134 };
-            int count = paint.getTextBlobIntercepts(blob.get(), bounds, nullptr);
-            std::vector<SkScalar> intervals;
-            intervals.resize(count);
-            (void) paint.getTextBlobIntercepts(blob.get(), bounds, &intervals.front());
-            canvas->drawTextBlob(blob.get(), 0, 0, paint);
-            paint.setColor(0xFFFF7777);
-            SkScalar x = textPos.fX;
-            for (int i = 0; i < count; i+= 2) {
-                canvas->drawRect({x, bounds[0], intervals[i], bounds[1]}, paint);
-                x = intervals[i + 1];
-            }
-            canvas->drawRect({intervals[count - 1], bounds[0], 180, bounds[1]}, paint);
+            SkFont font;

+            font.setSize(120);

+            SkPoint textPos = { 20, 110 };

+            int len = 3;

+            SkTextBlobBuilder textBlobBuilder;

+            const SkTextBlobBuilder::RunBuffer& run =

+                    textBlobBuilder.allocRun(font, len, textPos.fX, textPos.fY);

+            run.glyphs[0] = 10;

+            run.glyphs[1] = 20;

+            run.glyphs[2] = 30;

+            sk_sp<const SkTextBlob> blob = textBlobBuilder.make();

+            SkPaint paint;

+            SkScalar bounds[] = { 116, 134 };

+            int count = paint.getTextBlobIntercepts(blob.get(), bounds, nullptr);

+            std::vector<SkScalar> intervals;

+            intervals.resize(count);

+            (void) paint.getTextBlobIntercepts(blob.get(), bounds, &intervals.front());

+            canvas->drawTextBlob(blob.get(), 0, 0, paint);

+            paint.setColor(0xFFFF7777);

+            SkScalar x = textPos.fX;

+            for (int i = 0; i < count; i+= 2) {

+                canvas->drawRect({x, bounds[0], intervals[i], bounds[1]}, paint);

+                x = intervals[i + 1];

+            }

+            canvas->drawRect({intervals[count - 1], bounds[0], 180, bounds[1]}, paint);

         }
     ##
 
diff --git a/docs/SkTextBlobBuilder_Reference.bmh b/docs/SkTextBlobBuilder_Reference.bmh
index 1e9fd92..7874313 100644
--- a/docs/SkTextBlobBuilder_Reference.bmh
+++ b/docs/SkTextBlobBuilder_Reference.bmh
@@ -106,7 +106,8 @@
     SkDebugf("blob " "%s" " nullptr\n", blob == nullptr ? "equals" : "does not equal");
     SkPaint paint;
     paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-    paint.textToGlyphs("x", 1, builder.allocRun(paint, 1, 20, 20).glyphs);
+    SkFont font;
+    paint.textToGlyphs("x", 1, builder.allocRun(font, 1, 20, 20).glyphs);
     blob = builder.make();
     SkDebugf("blob " "%s" " nullptr\n", blob == nullptr ? "equals" : "does not equal");
     blob = builder.make();
diff --git a/docs/SkTextBlob_Reference.bmh b/docs/SkTextBlob_Reference.bmh
index f727457..cb076b9 100644
--- a/docs/SkTextBlob_Reference.bmh
+++ b/docs/SkTextBlob_Reference.bmh
@@ -20,29 +20,30 @@
 
 #Example
 #Height 70
-    SkTextBlobBuilder textBlobBuilder;
-    const char bunny[] = "/(^x^)\\";
-    const int len = sizeof(bunny) - 1;
-    uint16_t glyphs[len];
-    SkPaint paint;
-    paint.textToGlyphs(bunny, len, glyphs);
-    paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-    int runs[] = { 3, 1, 3 };
-    SkPoint textPos = { 20, 50 };
-    int glyphIndex = 0;
-    for (auto runLen : runs) {
-        paint.setTextSize(1 == runLen ? 20 : 50);
-        const SkTextBlobBuilder::RunBuffer& run =
-                textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY);
-        memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);
-        textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);
-        glyphIndex += runLen;
-    }
-    sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
-    paint.reset();
-    canvas->drawTextBlob(blob.get(), 0, 0, paint);
-    paint.setStyle(SkPaint::kStroke_Style);
-    canvas->drawRect(blob->bounds(), paint);
+    SkTextBlobBuilder textBlobBuilder;

+    const char bunny[] = "/(^x^)\\";

+    const int len = sizeof(bunny) - 1;

+    uint16_t glyphs[len];

+    SkPaint paint;

+    paint.textToGlyphs(bunny, len, glyphs);

+    paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);

+    SkFont font;

+    int runs[] = { 3, 1, 3 };

+    SkPoint textPos = { 20, 50 };

+    int glyphIndex = 0;

+    for (auto runLen : runs) {

+        font.setSize(1 == runLen ? 20 : 50);

+        paint.setTextSize(1 == runLen ? 20 : 50);

+        const SkTextBlobBuilder::RunBuffer& run =

+                textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);

+        memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);

+        textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);

+        glyphIndex += runLen;

+    }

+    sk_sp<const SkTextBlob> blob = textBlobBuilder.make();

+    canvas->drawTextBlob(blob.get(), 0, 0, paint);

+    paint.setStyle(SkPaint::kStroke_Style);

+    canvas->drawRect(blob->bounds(), paint);

 ##
 
 #SeeAlso SkPath::getBounds
@@ -57,33 +58,36 @@
 #Populate
 
 #Example
-for (int index = 0; index < 2; ++index) {
-    SkTextBlobBuilder textBlobBuilder;
-    const char bunny[] = "/(^x^)\\";
-    const int len = sizeof(bunny) - 1;
-    uint16_t glyphs[len];
-    SkPaint paint;
-    paint.textToGlyphs(bunny, len, glyphs);
-    paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-    paint.setTextScaleX(0.5);
-    int runs[] = { 3, 1, 3 };
-    SkPoint textPos = { 20, 50 };
-    int glyphIndex = 0;
-    for (auto runLen : runs) {
-        paint.setTextSize(1 == runLen ? 20 : 50);
-        const SkTextBlobBuilder::RunBuffer& run =
-                textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY);
-        memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);
-        textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);
-        glyphIndex += runLen;
-    }
-    sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
-    paint.reset();
-    canvas->drawTextBlob(blob.get(), 0, 0, paint);
-    std::string id = "unique ID:" + std::to_string(blob->uniqueID());
-    canvas->drawString(id.c_str(), 30, blob->bounds().fBottom + 15, paint);
-    canvas->translate(blob->bounds().fRight + 10, 0);
-}
+for (int index = 0; index < 2; ++index) {

+    SkTextBlobBuilder textBlobBuilder;

+    const char bunny[] = "/(^x^)\\";

+    const int len = sizeof(bunny) - 1;

+    uint16_t glyphs[len];

+    SkPaint paint;

+    paint.textToGlyphs(bunny, len, glyphs);

+    paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);

+    paint.setTextScaleX(0.5);

+    SkFont font;

+    font.setScaleX(0.5);

+    int runs[] = { 3, 1, 3 };

+    SkPoint textPos = { 20, 50 };

+    int glyphIndex = 0;

+    for (auto runLen : runs) {

+        font.setSize(1 == runLen ? 20 : 50);

+        paint.setTextSize(1 == runLen ? 20 : 50);

+        const SkTextBlobBuilder::RunBuffer& run =

+                textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);

+        memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);

+        textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);

+        glyphIndex += runLen;

+    }

+    sk_sp<const SkTextBlob> blob = textBlobBuilder.make();

+    paint.reset();

+    canvas->drawTextBlob(blob.get(), 0, 0, paint);

+    std::string id = "unique ID:" + std::to_string(blob->uniqueID());

+    canvas->drawString(id.c_str(), 30, blob->bounds().fBottom + 15, paint);

+    canvas->translate(blob->bounds().fRight + 10, 0);

+}

 ##
 
 #SeeAlso SkRefCnt