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=6e12cceca981ddabc0fc18c380543f34 6cb93a386Sopenharmony_ciREG_FIDDLE(TextBlob_uniqueID, 256, 256, false, 0) { 7cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 8cb93a386Sopenharmony_ci for (int index = 0; index < 2; ++index) { 9cb93a386Sopenharmony_ci SkTextBlobBuilder textBlobBuilder; 10cb93a386Sopenharmony_ci const char bunny[] = "/(^x^)\\"; 11cb93a386Sopenharmony_ci const int len = sizeof(bunny) - 1; 12cb93a386Sopenharmony_ci uint16_t glyphs[len]; 13cb93a386Sopenharmony_ci SkPaint paint; 14cb93a386Sopenharmony_ci paint.textToGlyphs(bunny, len, glyphs); 15cb93a386Sopenharmony_ci paint.setTextEncoding(SkTextEncoding::kGlyphID); 16cb93a386Sopenharmony_ci paint.setTextScaleX(0.5); 17cb93a386Sopenharmony_ci SkFont font; 18cb93a386Sopenharmony_ci font.setScaleX(0.5); 19cb93a386Sopenharmony_ci int runs[] = { 3, 1, 3 }; 20cb93a386Sopenharmony_ci SkPoint textPos = { 20, 50 }; 21cb93a386Sopenharmony_ci int glyphIndex = 0; 22cb93a386Sopenharmony_ci for (auto runLen : runs) { 23cb93a386Sopenharmony_ci font.setSize(1 == runLen ? 20 : 50); 24cb93a386Sopenharmony_ci paint.setTextSize(1 == runLen ? 20 : 50); 25cb93a386Sopenharmony_ci const SkTextBlobBuilder::RunBuffer& run = 26cb93a386Sopenharmony_ci textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY); 27cb93a386Sopenharmony_ci memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen); 28cb93a386Sopenharmony_ci textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr); 29cb93a386Sopenharmony_ci glyphIndex += runLen; 30cb93a386Sopenharmony_ci } 31cb93a386Sopenharmony_ci sk_sp<const SkTextBlob> blob = textBlobBuilder.make(); 32cb93a386Sopenharmony_ci paint.reset(); 33cb93a386Sopenharmony_ci canvas->drawTextBlob(blob.get(), 0, 0, paint); 34cb93a386Sopenharmony_ci std::string id = "unique ID:" + std::to_string(blob->uniqueID()); 35cb93a386Sopenharmony_ci canvas->drawString(id.c_str(), 30, blob->bounds().fBottom + 15, paint); 36cb93a386Sopenharmony_ci canvas->translate(blob->bounds().fRight + 10, 0); 37cb93a386Sopenharmony_ci } 38cb93a386Sopenharmony_ci} 39cb93a386Sopenharmony_ci} // END FIDDLE 40cb93a386Sopenharmony_ci#endif // Disabled until updated to use current API. 41