Skip to content

Commit 26d173f

Browse files
Cary ClarkSkia Commit-Bot
Cary Clark
authored and
Skia Commit-Bot
committed
fix bookmaker
Illustrations calling SkTextUtils::DrawString must pass font as well as paint. [email protected],[email protected] Docs-Preview: https://skia.org/?cl=181562 Bug: skia: Change-Id: I907c1c69026d3dc40282545b492a790b2349a8a0 Reviewed-on: https://skia-review.googlesource.com/c/181562 Commit-Queue: Cary Clark <[email protected]> Reviewed-by: Cary Clark <[email protected]> Reviewed-by: Joe Gregorio <[email protected]> Reviewed-by: Mike Reed <[email protected]>
1 parent a3efc72 commit 26d173f

File tree

10 files changed

+540
-660
lines changed

10 files changed

+540
-660
lines changed

docs/SkCanvas_Reference.bmh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,10 +4018,8 @@ void draw(SkCanvas* canvas) {
40184018
const char bunny[] = "/(^x^)\\";
40194019
const int len = sizeof(bunny) - 1;
40204020
uint16_t glyphs[len];
4021-
SkPaint paint;
4022-
paint.textToGlyphs(bunny, len, glyphs);
4023-
paint.setTextEncoding(kGlyphID_SkTextEncoding);
40244021
SkFont font;
4022+
font.textToGlyphs(bunny, len, SkTextEncoding::kUTF8, glyphs, len);
40254023
int runs[] = { 3, 1, 3 };
40264024
SkPoint textPos = { 20, 100 };
40274025
int glyphIndex = 0;
@@ -4030,13 +4028,13 @@ void draw(SkCanvas* canvas) {
40304028
const SkTextBlobBuilder::RunBuffer& run =
40314029
textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);
40324030
memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);
4033-
paint.setTextSize(1 == runLen ? 20 : 50);
4034-
textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);
4031+
font.setSize(1 == runLen ? 20 : 50);
4032+
textPos.fX += font.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen,
4033+
SkTextEncoding::kGlyphID);
40354034
glyphIndex += runLen;
40364035
}
40374036
sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
4038-
paint.reset();
4039-
canvas->drawTextBlob(blob.get(), 0, 0, paint);
4037+
canvas->drawTextBlob(blob.get(), 0, 0, SkPaint());
40404038
}
40414039
##
40424040

@@ -4595,8 +4593,8 @@ void draw(SkCanvas* canvas) {
45954593
const char text[] = "Click this link!";
45964594
SkRect bounds;
45974595
SkPaint paint;
4598-
paint.setTextSize(40);
4599-
(void)paint.measureText(text, strlen(text), &bounds);
4596+
SkFont font(nullptr, 40);
4597+
(void)font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
46004598
const char url[] = "https://www.google.com/";
46014599
sk_sp<SkData> urlData(SkData::MakeWithCString(url));
46024600
canvas->drawAnnotation(bounds, "url_key", urlData.get());
@@ -4616,8 +4614,8 @@ void draw(SkCanvas* canvas) {
46164614
const char text[] = "Click this link!";
46174615
SkRect bounds;
46184616
SkPaint paint;
4619-
paint.setTextSize(40);
4620-
(void)paint.measureText(text, strlen(text), &bounds);
4617+
SkFont font(nullptr, 40);
4618+
(void)font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
46214619
const char url[] = "https://www.google.com/";
46224620
sk_sp<SkData> urlData(SkData::MakeWithCString(url));
46234621
canvas->drawAnnotation(bounds, "url_key", urlData.get());

0 commit comments

Comments
 (0)