blob: 4b8da0b37212b0f866253248ab412403d047d224 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001#if 0 // Disabled until updated to use current API.
2// Copyright 2019 Google LLC.
3// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05004#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04005// HASH=e9d4eb8ece521b1329e7433d4b243fdf
Hal Canarya7181e7c2019-03-18 16:06:34 -04006REG_FIDDLE(TextBlob_getIntercepts, 256, 143, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04007void draw(SkCanvas* canvas) {
8 SkFont font;
9 font.setSize(120);
10 SkPoint textPos = { 20, 110 };
11 int len = 3;
12 SkTextBlobBuilder textBlobBuilder;
13 const SkTextBlobBuilder::RunBuffer& run =
14 textBlobBuilder.allocRun(font, len, textPos.fX, textPos.fY);
15 run.glyphs[0] = 10;
16 run.glyphs[1] = 20;
17 run.glyphs[2] = 30;
18 sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
19 SkPaint paint;
20 SkScalar bounds[] = { 116, 134 };
21 int count = blob->getIntercepts(bounds, nullptr);
22 std::vector<SkScalar> intervals;
23 intervals.resize(count);
24 (void) paint.getTextBlobIntercepts(blob.get(), bounds, &intervals.front());
25 canvas->drawTextBlob(blob.get(), 0, 0, paint);
26 paint.setColor(0xFFFF7777);
27 SkScalar x = textPos.fX;
28 for (int i = 0; i < count; i+= 2) {
29 canvas->drawRect({x, bounds[0], intervals[i], bounds[1]}, paint);
30 x = intervals[i + 1];
31 }
32 canvas->drawRect({intervals[count - 1], bounds[0], 180, bounds[1]}, paint);
33}
34} // END FIDDLE
35#endif // Disabled until updated to use current API.