1cb93a386Sopenharmony_ci#if 0  // Disabled until updated to use current API.
2cb93a386Sopenharmony_ci// Copyright 2019 Google LLC.
3cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
5cb93a386Sopenharmony_ci// HASH=fb8b2502bbe52d2029aecdf569dd9fdb
6cb93a386Sopenharmony_ciREG_FIDDLE(TextBlob_bounds, 256, 70, false, 0) {
7cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
8cb93a386Sopenharmony_ci    SkTextBlobBuilder textBlobBuilder;
9cb93a386Sopenharmony_ci    const char bunny[] = "/(^x^)\\";
10cb93a386Sopenharmony_ci    const int len = sizeof(bunny) - 1;
11cb93a386Sopenharmony_ci    uint16_t glyphs[len];
12cb93a386Sopenharmony_ci    SkPaint paint;
13cb93a386Sopenharmony_ci    paint.textToGlyphs(bunny, len, glyphs);
14cb93a386Sopenharmony_ci    paint.setTextEncoding(SkTextEncoding::kGlyphID);
15cb93a386Sopenharmony_ci    SkFont font;
16cb93a386Sopenharmony_ci    int runs[] = { 3, 1, 3 };
17cb93a386Sopenharmony_ci    SkPoint textPos = { 20, 50 };
18cb93a386Sopenharmony_ci    int glyphIndex = 0;
19cb93a386Sopenharmony_ci    for (auto runLen : runs) {
20cb93a386Sopenharmony_ci        font.setSize(1 == runLen ? 20 : 50);
21cb93a386Sopenharmony_ci        paint.setTextSize(1 == runLen ? 20 : 50);
22cb93a386Sopenharmony_ci        const SkTextBlobBuilder::RunBuffer& run =
23cb93a386Sopenharmony_ci                textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);
24cb93a386Sopenharmony_ci        memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);
25cb93a386Sopenharmony_ci        textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);
26cb93a386Sopenharmony_ci        glyphIndex += runLen;
27cb93a386Sopenharmony_ci    }
28cb93a386Sopenharmony_ci    sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
29cb93a386Sopenharmony_ci    canvas->drawTextBlob(blob.get(), 0, 0, paint);
30cb93a386Sopenharmony_ci    paint.setStyle(SkPaint::kStroke_Style);
31cb93a386Sopenharmony_ci    canvas->drawRect(blob->bounds(), paint);
32cb93a386Sopenharmony_ci}
33cb93a386Sopenharmony_ci}  // END FIDDLE
34cb93a386Sopenharmony_ci#endif  // Disabled until updated to use current API.
35