@@ -4018,10 +4018,8 @@ void draw(SkCanvas* canvas) {
4018
4018
const char bunny[] = "/(^x^)\\";
4019
4019
const int len = sizeof(bunny) - 1;
4020
4020
uint16_t glyphs[len];
4021
- SkPaint paint;
4022
- paint.textToGlyphs(bunny, len, glyphs);
4023
- paint.setTextEncoding(kGlyphID_SkTextEncoding);
4024
4021
SkFont font;
4022
+ font.textToGlyphs(bunny, len, SkTextEncoding::kUTF8, glyphs, len);
4025
4023
int runs[] = { 3, 1, 3 };
4026
4024
SkPoint textPos = { 20, 100 };
4027
4025
int glyphIndex = 0;
@@ -4030,13 +4028,13 @@ void draw(SkCanvas* canvas) {
4030
4028
const SkTextBlobBuilder::RunBuffer& run =
4031
4029
textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);
4032
4030
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);
4035
4034
glyphIndex += runLen;
4036
4035
}
4037
4036
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());
4040
4038
}
4041
4039
##
4042
4040
@@ -4595,8 +4593,8 @@ void draw(SkCanvas* canvas) {
4595
4593
const char text[] = "Click this link!";
4596
4594
SkRect bounds;
4597
4595
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);
4600
4598
const char url[] = "https://www.google.com/";
4601
4599
sk_sp<SkData> urlData(SkData::MakeWithCString(url));
4602
4600
canvas->drawAnnotation(bounds, "url_key", urlData.get());
@@ -4616,8 +4614,8 @@ void draw(SkCanvas* canvas) {
4616
4614
const char text[] = "Click this link!";
4617
4615
SkRect bounds;
4618
4616
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);
4621
4619
const char url[] = "https://www.google.com/";
4622
4620
sk_sp<SkData> urlData(SkData::MakeWithCString(url));
4623
4621
canvas->drawAnnotation(bounds, "url_key", urlData.get());
0 commit comments