Use SkTextEncoding enum instead of macros.

Change-Id: I4b6259590fa0693ee0522b4999a1c0fe250b173d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212504
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2019-05-07 15:38:46 -04:00 committed by Skia Commit-Bot
parent 354ecf3693
commit 51e15a69ce
111 changed files with 314 additions and 309 deletions

View File

@ -40,7 +40,7 @@ protected:
font.setSize(random.nextRangeScalar(12, 96));
SkScalar x = random.nextRangeScalar(0, (SkScalar)size.fWidth),
y = random.nextRangeScalar(0, (SkScalar)size.fHeight);
auto blob = SkTextBlob::MakeFromText(text, len, font, kUTF8_SkTextEncoding);
auto blob = SkTextBlob::MakeFromText(text, len, font, SkTextEncoding::kUTF8);
for (int j = 0; j < 1000; ++j) {
canvas->drawTextBlob(blob, x, y, paint);
}

View File

@ -34,7 +34,7 @@ static void textToGlyphs_proc(const Rec& r) {
SkASSERT(r.fCount <= NGLYPHS);
for (int i = 0; i < r.fLoops; ++i) {
r.fFont.textToGlyphs(r.fText, r.fCount*4, kUTF32_SkTextEncoding, glyphs, NGLYPHS);
r.fFont.textToGlyphs(r.fText, r.fCount*4, SkTextEncoding::kUTF32, glyphs, NGLYPHS);
}
}

View File

@ -41,7 +41,7 @@ protected:
SkFont font;
font.setSize(SkIntToScalar(96));
canvas.drawSimpleText("g", 1, kUTF8_SkTextEncoding, SkIntToScalar(15), SkIntToScalar(55), font, paint);
canvas.drawSimpleText("g", 1, SkTextEncoding::kUTF8, SkIntToScalar(15), SkIntToScalar(55), font, paint);
}
void makeCheckerboard() {

View File

@ -43,7 +43,7 @@ protected:
while (*array != gUniqueGlyphIDs_Sentinel) {
int count = count_glyphs(array);
for (int i = 0; i < loops; ++i) {
(void)font.measureText(array, count * sizeof(uint16_t), kGlyphID_SkTextEncoding);
(void)font.measureText(array, count * sizeof(uint16_t), SkTextEncoding::kGlyphID);
}
array += count + 1; // skip the sentinel
}

View File

@ -24,7 +24,7 @@ static sk_sp<SkImage> make_bitmap() {
paint.setColor(0xFF884422);
SkFont font;
font.setSize(SkIntToScalar(96));
surface->getCanvas()->drawSimpleText("g", 1, kUTF8_SkTextEncoding, 15, 55, font, paint);
surface->getCanvas()->drawSimpleText("g", 1, SkTextEncoding::kUTF8, 15, 55, font, paint);
return surface->makeImageSnapshot();
}

View File

@ -33,10 +33,10 @@ public:
// This text seems representative in both length and letter frequency.
const char* text = "Keep your sentences short, but not overly so.";
fGlyphs.setCount(fFont.countText(text, strlen(text), kUTF8_SkTextEncoding));
fGlyphs.setCount(fFont.countText(text, strlen(text), SkTextEncoding::kUTF8));
fXPos.setCount(fGlyphs.count());
fFont.textToGlyphs(text, strlen(text), kUTF8_SkTextEncoding, fGlyphs.begin(), fGlyphs.count());
fFont.textToGlyphs(text, strlen(text), SkTextEncoding::kUTF8, fGlyphs.begin(), fGlyphs.count());
fFont.getXPos(&fGlyphs[0], fGlyphs.count(), fXPos.begin());
}

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
uint16_t glyphs[len];
SkPaint paint;
paint.textToGlyphs(bunny, len, glyphs);
paint.setTextEncoding(kGlyphID_SkTextEncoding);
paint.setTextEncoding(SkTextEncoding::kGlyphID);
SkFont font;
int runs[] = { 3, 1, 3 };
SkPoint textPos = { 20, 100 };

View File

@ -14,7 +14,7 @@ void draw(SkCanvas* canvas) {
SkScalar measuredWidth;
SkFont font;
font.setSize(50);
int partialBytes = font.breakText(str, count, kUTF8_SkTextEncoding,
int partialBytes = font.breakText(str, count, SkTextEncoding::kUTF8,
100, &measuredWidth);
canvas->drawText(str, partialBytes, 25, 100, paint);
canvas->drawLine(25, 60, 25 + 100, 60, paint);

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
const uint16_t goodGlyph = 511;
const uint16_t zeroGlyph = 0;
const uint16_t badGlyph = 65535; // larger than glyph count in font
paint.setTextEncoding(kGlyphID_SkTextEncoding);
paint.setTextEncoding(SkTextEncoding::kGlyphID);
SkDebugf("0x%04x %c= has glyph\n", goodGlyph,
paint.containsText(&goodGlyph, 2) ? '=' : '!');
SkDebugf("0x%04x %c= has glyph\n", zeroGlyph,

View File

@ -6,11 +6,11 @@
REG_FIDDLE(Paint_getTextEncoding, 256, 256, true, 0) {
void draw(SkCanvas* canvas) {
SkPaint paint;
SkDebugf("kUTF8_SkTextEncoding %c= text encoding\n",
kUTF8_SkTextEncoding == paint.getTextEncoding() ? '=' : '!');
paint.setTextEncoding(kGlyphID_SkTextEncoding);
SkDebugf("kGlyphID_SkTextEncoding %c= text encoding\n",
kGlyphID_SkTextEncoding == paint.getTextEncoding() ? '=' : '!');
SkDebugf("SkTextEncoding::kUTF8 %c= text encoding\n",
SkTextEncoding::kUTF8 == paint.getTextEncoding() ? '=' : '!');
paint.setTextEncoding(SkTextEncoding::kGlyphID);
SkDebugf("SkTextEncoding::kGlyphID %c= text encoding\n",
SkTextEncoding::kGlyphID == paint.getTextEncoding() ? '=' : '!');
}
} // END FIDDLE
#endif // Disabled until updated to use current API.

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
int count = paint.textToGlyphs(utf8, sizeof(utf8), nullptr);
glyphs.resize(count);
(void) paint.textToGlyphs(utf8, sizeof(utf8), &glyphs.front());
paint.setTextEncoding(kGlyphID_SkTextEncoding);
paint.setTextEncoding(SkTextEncoding::kGlyphID);
paint.setTextSize(32);
canvas->drawText(&glyphs.front(), glyphs.size() * sizeof(SkGlyphID), 10, 40, paint);
}

View File

@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) {
sk_sp<SkTextBlob> blob = builder.make();
SkDebugf("blob " "%s" " nullptr\n", blob == nullptr ? "equals" : "does not equal");
SkPaint paint;
paint.setTextEncoding(kGlyphID_SkTextEncoding);
paint.setTextEncoding(SkTextEncoding::kGlyphID);
SkFont font;
paint.textToGlyphs("x", 1, builder.allocRun(font, 1, 20, 20).glyphs);
blob = builder.make();

View File

@ -11,7 +11,7 @@ void draw(SkCanvas* canvas) {
uint16_t glyphs[len];
SkPaint paint;
paint.textToGlyphs(bunny, len, glyphs);
paint.setTextEncoding(kGlyphID_SkTextEncoding);
paint.setTextEncoding(SkTextEncoding::kGlyphID);
SkFont font;
int runs[] = { 3, 1, 3 };
SkPoint textPos = { 20, 50 };

View File

@ -12,7 +12,7 @@ void draw(SkCanvas* canvas) {
uint16_t glyphs[len];
SkPaint paint;
paint.textToGlyphs(bunny, len, glyphs);
paint.setTextEncoding(kGlyphID_SkTextEncoding);
paint.setTextEncoding(SkTextEncoding::kGlyphID);
paint.setTextScaleX(0.5);
SkFont font;
font.setScaleX(0.5);

View File

@ -11,13 +11,13 @@ void draw(SkCanvas* canvas) {
const uint32_t hello32[] = { 'H', 'e', 'l', 'l', 'o', 0x263A };
paint.setTextSize(24);
canvas->drawText(hello8, sizeof(hello8) - 1, 10, 30, paint);
paint.setTextEncoding(kUTF16_SkTextEncoding);
paint.setTextEncoding(SkTextEncoding::kUTF16);
canvas->drawText(hello16, sizeof(hello16), 10, 60, paint);
paint.setTextEncoding(kUTF32_SkTextEncoding);
paint.setTextEncoding(SkTextEncoding::kUTF32);
canvas->drawText(hello32, sizeof(hello32), 10, 90, paint);
uint16_t glyphs[SK_ARRAY_COUNT(hello32)];
paint.textToGlyphs(hello32, sizeof(hello32), glyphs);
paint.setTextEncoding(kGlyphID_SkTextEncoding);
paint.setTextEncoding(SkTextEncoding::kGlyphID);
canvas->drawText(glyphs, sizeof(glyphs), 10, 120, paint);
}
} // END FIDDLE

View File

@ -99,7 +99,7 @@ void HelloWorld::onPaint(SkSurface* surface) {
canvas->rotate(fRotationAngle);
// Draw the text
canvas->drawSimpleText(message, strlen(message), kUTF8_SkTextEncoding, 0, 0, font, paint);
canvas->drawSimpleText(message, strlen(message), SkTextEncoding::kUTF8, 0, 0, font, paint);
canvas->restore();
}

View File

@ -900,7 +900,7 @@ constexpr int kMaxGlyphCount = 30;
static SkTDArray<uint8_t> make_fuzz_text(Fuzz* fuzz, const SkFont& font, SkTextEncoding encoding) {
SkTDArray<uint8_t> array;
if (kGlyphID_SkTextEncoding == encoding) {
if (SkTextEncoding::kGlyphID == encoding) {
int glyphRange = font.getTypefaceOrDefault()->countGlyphs();
if (glyphRange == 0) {
// Some fuzzing environments have no fonts, so empty array is the best
@ -941,7 +941,7 @@ static SkTDArray<uint8_t> make_fuzz_text(Fuzz* fuzz, const SkFont& font, SkTextE
}
}
switch (encoding) {
case kUTF8_SkTextEncoding: {
case SkTextEncoding::kUTF8: {
size_t utf8len = 0;
for (int j = 0; j < length; ++j) {
utf8len += SkUTF::ToUTF8(buffer[j], nullptr);
@ -951,7 +951,7 @@ static SkTDArray<uint8_t> make_fuzz_text(Fuzz* fuzz, const SkFont& font, SkTextE
ptr += SkUTF::ToUTF8(buffer[j], ptr);
}
} break;
case kUTF16_SkTextEncoding: {
case SkTextEncoding::kUTF16: {
size_t utf16len = 0;
for (int j = 0; j < length; ++j) {
utf16len += SkUTF::ToUTF16(buffer[j]);
@ -961,7 +961,7 @@ static SkTDArray<uint8_t> make_fuzz_text(Fuzz* fuzz, const SkFont& font, SkTextE
ptr += SkUTF::ToUTF16(buffer[j], ptr);
}
} break;
case kUTF32_SkTextEncoding:
case SkTextEncoding::kUTF32:
memcpy(array.append(length * sizeof(SkUnichar)), buffer, length * sizeof(SkUnichar));
break;
default:

View File

@ -74,8 +74,8 @@ static SkBitmap make_bitmap(SkColorType ct) {
static void draw_center_letter(char c, const SkFont& font, SkColor color,
SkScalar x, SkScalar y, SkCanvas* canvas) {
SkRect bounds;
font.measureText(&c, 1, kUTF8_SkTextEncoding, &bounds);
canvas->drawSimpleText(&c, 1, kUTF8_SkTextEncoding,
font.measureText(&c, 1, SkTextEncoding::kUTF8, &bounds);
canvas->drawSimpleText(&c, 1, SkTextEncoding::kUTF8,
x - bounds.centerX(), y - bounds.centerY(),
font, SkPaint(SkColor4f::FromColor(color)));
}
@ -122,7 +122,7 @@ static void draw(SkCanvas* canvas,
const char text[]) {
SkASSERT(src.colorType() == colorType);
canvas->drawBitmap(src, 0.0f, 0.0f);
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, 0.0f, 12.0f, font, p);
canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, 0.0f, 12.0f, font, p);
}
DEF_SIMPLE_GM(all_bitmap_configs, canvas, SCALE, 6 * SCALE) {

View File

@ -24,14 +24,14 @@ static void draw_url_annotated_text_with_box(
SkScalar x, SkScalar y, const SkFont& font, const char* url) {
size_t byteLength = strlen(static_cast<const char*>(text));
SkRect bounds;
(void)font.measureText(text, byteLength, kUTF8_SkTextEncoding, &bounds);
(void)font.measureText(text, byteLength, SkTextEncoding::kUTF8, &bounds);
bounds.offset(x, y);
sk_sp<SkData> urlData(SkData::MakeWithCString(url));
SkAnnotateRectWithURL(canvas, bounds, urlData.get());
SkPaint shade;
shade.setColor(0x80346180);
canvas->drawRect(bounds, shade);
canvas->drawSimpleText(text, byteLength, kUTF8_SkTextEncoding, x, y, font, SkPaint());
canvas->drawSimpleText(text, byteLength, SkTextEncoding::kUTF8, x, y, font, SkPaint());
}
DEF_SIMPLE_GM(annotated_text, canvas, 512, 512) {

View File

@ -74,7 +74,7 @@ static void show_k_text(SkCanvas* canvas, SkScalar x, SkScalar y, const SkScalar
for (int i = 0; i < 4; ++i) {
SkString str;
str.appendScalar(k[i]);
SkScalar width = font.measureText(str.c_str(), str.size(), kUTF8_SkTextEncoding);
SkScalar width = font.measureText(str.c_str(), str.size(), SkTextEncoding::kUTF8);
canvas->drawString(str, x, y + font.getSize(), font, paint);
x += width + SkIntToScalar(10);
}

View File

@ -43,17 +43,17 @@ protected:
SkFont font(ToolUtils::create_portable_typeface(), 1500);
SkRect r;
(void)font.measureText("/", 1, kUTF8_SkTextEncoding, &r);
(void)font.measureText("/", 1, SkTextEncoding::kUTF8, &r);
SkPoint pos = {
this->width()/2 - r.centerX(),
this->height()/2 - r.centerY()
};
paint.setColor(SK_ColorRED);
canvas->drawSimpleText("/", 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint);
canvas->drawSimpleText("/", 1, SkTextEncoding::kUTF8, pos.fX, pos.fY, font, paint);
paint.setColor(SK_ColorBLUE);
canvas->drawSimpleText("\\", 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint);
canvas->drawSimpleText("\\", 1, SkTextEncoding::kUTF8, pos.fX, pos.fY, font, paint);
}
private:

View File

@ -111,7 +111,7 @@ protected:
}
for (unsigned i = 0; i < NUM_CONFIGS; i++) {
const char* name = color_type_name(src.colorType());
SkScalar textWidth = font.measureText(name, strlen(name), kUTF8_SkTextEncoding);
SkScalar textWidth = font.measureText(name, strlen(name), SkTextEncoding::kUTF8);
if (textWidth > width) {
width = textWidth;
}
@ -124,10 +124,10 @@ protected:
canvas->save();
// Draw destination config name
const char* name = color_type_name(fDst[i].colorType());
SkScalar textWidth = font.measureText(name, strlen(name), kUTF8_SkTextEncoding);
SkScalar textWidth = font.measureText(name, strlen(name), SkTextEncoding::kUTF8);
SkScalar x = (width - textWidth) / SkScalar(2);
SkScalar y = font.getSpacing() / SkScalar(2);
canvas->drawSimpleText(name, strlen(name), kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(name, strlen(name), SkTextEncoding::kUTF8, x, y, font, paint);
// Draw destination bitmap
canvas->translate(0, vertOffset);

View File

@ -92,7 +92,8 @@ protected:
canvas->drawColor(SK_ColorGRAY);
SkFont font(emojiFont.typeface);
const char* text = emojiFont.text;
char const * const text = emojiFont.text;
size_t textLen = strlen(text);
// draw text at different point sizes
constexpr SkScalar textSizes[] = { 10, 30, 50, };
@ -104,7 +105,8 @@ protected:
font.setSize(textSize);
font.getMetrics(&metrics);
y += -metrics.fAscent;
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, 10, y, font, SkPaint());
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8,
10, y, font, SkPaint());
y += metrics.fDescent + metrics.fLeading;
}
}
@ -141,7 +143,7 @@ protected:
shaderFont.setSize(30);
shaderFont.getMetrics(&metrics);
y += -metrics.fAscent;
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, 380, y,
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, 380, y,
shaderFont, shaderPaint);
y += metrics.fDescent + metrics.fLeading;
}
@ -155,7 +157,7 @@ protected:
// compute the bounds of the text
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, textLen, SkTextEncoding::kUTF8, &bounds);
const SkScalar boundsHalfWidth = bounds.width() * SK_ScalarHalf;
const SkScalar boundsHalfHeight = bounds.height() * SK_ScalarHalf;
@ -181,10 +183,10 @@ protected:
canvas->save();
canvas->drawRect(clipRect, clipHairline);
paint.setAlpha(0x20);
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, 0, 0, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, 0, 0, font, paint);
canvas->clipRect(clipRect);
paint.setAlphaf(1.0f);
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, 0, 0, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, 0, 0, font, paint);
canvas->restore();
canvas->translate(0, SkIntToScalar(25));
}

View File

@ -147,13 +147,13 @@ protected:
const char* text = ToolUtils::emoji_sample_text();
SkUnichar unichar = SkUTF::NextUTF8(&text, text + strlen(text));
SkASSERT(unichar >= 0);
canvas->drawSimpleText(&unichar, 4, kUTF32_SkTextEncoding, x+ w/10.f, y + 7.f*h/8.f,
textFont, textP);
canvas->drawSimpleText(&unichar, 4, SkTextEncoding::kUTF32,
x+ w/10.f, y + 7.f*h/8.f, textFont, textP);
}
#if 1
const char* label = SkBlendMode_Name(gModes[i]);
SkTextUtils::DrawString(canvas, label, x + w/2, y - labelFont.getSize()/2, labelFont, SkPaint(),
SkTextUtils::kCenter_Align);
SkTextUtils::DrawString(canvas, label, x + w/2, y - labelFont.getSize()/2,
labelFont, SkPaint(), SkTextUtils::kCenter_Align);
#endif
x += w + SkIntToScalar(10);
if ((i % W) == W - 1) {

View File

@ -152,15 +152,15 @@ protected:
SkScalar txtX = 45;
paint.setColor(gClipAColor);
const char* aTxt = doInvA ? "InvA " : "A ";
canvas->drawSimpleText(aTxt, strlen(aTxt), kUTF8_SkTextEncoding, txtX, 220, font, paint);
txtX += font.measureText(aTxt, strlen(aTxt), kUTF8_SkTextEncoding);
canvas->drawSimpleText(aTxt, strlen(aTxt), SkTextEncoding::kUTF8, txtX, 220, font, paint);
txtX += font.measureText(aTxt, strlen(aTxt), SkTextEncoding::kUTF8);
paint.setColor(SK_ColorBLACK);
canvas->drawSimpleText(gOps[op].fName, strlen(gOps[op].fName), kUTF8_SkTextEncoding, txtX, 220,
canvas->drawSimpleText(gOps[op].fName, strlen(gOps[op].fName), SkTextEncoding::kUTF8, txtX, 220,
font, paint);
txtX += font.measureText(gOps[op].fName, strlen(gOps[op].fName), kUTF8_SkTextEncoding);
txtX += font.measureText(gOps[op].fName, strlen(gOps[op].fName), SkTextEncoding::kUTF8);
paint.setColor(gClipBColor);
const char* bTxt = doInvB ? "InvB " : "B ";
canvas->drawSimpleText(bTxt, strlen(bTxt), kUTF8_SkTextEncoding, txtX, 220, font, paint);
canvas->drawSimpleText(bTxt, strlen(bTxt), SkTextEncoding::kUTF8, txtX, 220, font, paint);
canvas->translate(250,0);
}

View File

@ -145,7 +145,7 @@ protected:
SkRect inputLabelBounds;
// get the bounds of the text in order to position it
labelFont.measureText(inputLabel.c_str(), inputLabel.size(),
kUTF8_SkTextEncoding, &inputLabelBounds);
SkTextEncoding::kUTF8, &inputLabelBounds);
canvas->drawString(inputLabel, renderRect.fRight + kPad, -inputLabelBounds.fTop,
labelFont, labelPaint);
// update the bounds to reflect the offset we used to draw it.
@ -153,7 +153,7 @@ protected:
SkRect procLabelBounds;
labelFont.measureText(procLabel.c_str(), procLabel.size(),
kUTF8_SkTextEncoding, &procLabelBounds);
SkTextEncoding::kUTF8, &procLabelBounds);
canvas->drawString(procLabel, renderRect.fRight + kPad,
inputLabelBounds.fBottom + 2.f - procLabelBounds.fTop,
labelFont, labelPaint);

View File

@ -79,12 +79,12 @@ static SkBitmap make_bmp(int w, int h) {
paint.setColor(SK_ColorLTGRAY);
constexpr char kTxt[] = "Skia";
SkPoint texPos = { wScalar / 17, hScalar / 2 + font.getSize() / 2.5f };
canvas.drawSimpleText(kTxt, SK_ARRAY_COUNT(kTxt)-1, kUTF8_SkTextEncoding,
canvas.drawSimpleText(kTxt, SK_ARRAY_COUNT(kTxt)-1, SkTextEncoding::kUTF8,
texPos.fX, texPos.fY, font, paint);
paint.setColor(SK_ColorBLACK);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(SK_Scalar1);
canvas.drawSimpleText(kTxt, SK_ARRAY_COUNT(kTxt)-1, kUTF8_SkTextEncoding,
canvas.drawSimpleText(kTxt, SK_ARRAY_COUNT(kTxt)-1, SkTextEncoding::kUTF8,
texPos.fX, texPos.fY, font, paint);
return bmp;
}
@ -166,7 +166,7 @@ protected:
constexpr char kTxt[] = "Clip Me!";
SkFont font(ToolUtils::create_portable_typeface(), 23);
SkScalar textW = font.measureText(kTxt, SK_ARRAY_COUNT(kTxt)-1, kUTF8_SkTextEncoding);
SkScalar textW = font.measureText(kTxt, SK_ARRAY_COUNT(kTxt)-1, SkTextEncoding::kUTF8);
SkPaint txtPaint;
txtPaint.setColor(SK_ColorDKGRAY);
@ -217,7 +217,7 @@ protected:
canvas->drawPath(closedClipPath, clipOutlinePaint);
clip->setOnCanvas(canvas, kIntersect_SkClipOp, SkToBool(aa));
canvas->scale(1.f, 1.8f);
canvas->drawSimpleText(kTxt, SK_ARRAY_COUNT(kTxt)-1, kUTF8_SkTextEncoding,
canvas->drawSimpleText(kTxt, SK_ARRAY_COUNT(kTxt)-1, SkTextEncoding::kUTF8,
0, 1.5f * font.getSize(), font, txtPaint);
canvas->restore();
x += textW + 2 * kMargin;

View File

@ -90,7 +90,7 @@ protected:
canvas->translate(x, y);
canvas->scale(scales[i], scales[i]);
font.setSize(textSizes[i]);
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, 0, 0, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, 0, 0, font, paint);
y += font.getMetrics(nullptr)*scales[i];
}
@ -104,7 +104,7 @@ protected:
canvas->rotate(SkIntToScalar(i * 5), rotX, rotY);
for (int ps = 6; ps <= 32; ps += 3) {
font.setSize(SkIntToScalar(ps));
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, rotX, rotY, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, rotX, rotY, font, paint);
rotY += font.getMetrics(nullptr);
}
}
@ -120,7 +120,7 @@ protected:
SkScalar scaleFactor = SkScalarInvert(scales[arraySize - i - 1]);
canvas->scale(scaleFactor, scaleFactor);
font.setSize(textSizes[i]);
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, 0, 0, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, 0, 0, font, paint);
y += font.getMetrics(nullptr)*scaleFactor;
}
@ -131,13 +131,13 @@ protected:
canvas->scale(2.0f, 2.0f);
SkAutoTArray<SkGlyphID> glyphs(SkToInt(textLen));
int count = font.textToGlyphs(text, textLen, kUTF8_SkTextEncoding, glyphs.get(), textLen);
int count = font.textToGlyphs(text, textLen, SkTextEncoding::kUTF8, glyphs.get(), textLen);
SkAutoTArray<SkPoint> pos(count);
font.setSize(textSizes[0]);
font.getPos(glyphs.get(), count, pos.get(), {340, 75});
auto blob = SkTextBlob::MakeFromPosText(glyphs.get(), count * sizeof(SkGlyphID),
pos.get(), font, kGlyphID_SkTextEncoding);
pos.get(), font, SkTextEncoding::kGlyphID);
canvas->drawTextBlob(blob, 0, 0, paint);
}
@ -160,7 +160,7 @@ protected:
for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
paint.setColor(fg[i]);
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, x, y, font, paint);
y += font.getMetrics(nullptr);
}
@ -174,7 +174,7 @@ protected:
for (size_t i = 0; i < SK_ARRAY_COUNT(fg); ++i) {
paint.setColor(fg[i]);
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, x, y, font, paint);
y += font.getMetrics(nullptr);
}
@ -184,14 +184,14 @@ protected:
SkAutoCanvasRestore acr(canvas, true);
canvas->skew(0.0f, 0.151515f);
font.setSize(SkIntToScalar(32));
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, 745, 70, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, 745, 70, font, paint);
}
{
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
SkAutoCanvasRestore acr(canvas, true);
canvas->skew(0.5f, 0.0f);
font.setSize(SkIntToScalar(32));
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, 580, 125, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, 580, 125, font, paint);
}
// check perspective
@ -205,7 +205,7 @@ protected:
canvas->concat(persp);
canvas->translate(1100, -295);
font.setSize(37.5f);
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, 0, 0, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, 0, 0, font, paint);
}
{
font.setSubpixel(false);
@ -219,7 +219,7 @@ protected:
canvas->translate(1075, -245);
canvas->scale(375, 375);
font.setSize(0.1f);
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, 0, 0, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, 0, 0, font, paint);
}
// check color emoji
@ -228,7 +228,7 @@ protected:
emoiFont.setSubpixel(true);
emoiFont.setTypeface(fEmojiTypeface);
emoiFont.setSize(SkIntToScalar(19));
canvas->drawSimpleText(fEmojiText, strlen(fEmojiText), kUTF8_SkTextEncoding, 670, 90, emoiFont, paint);
canvas->drawSimpleText(fEmojiText, strlen(fEmojiText), SkTextEncoding::kUTF8, 670, 90, emoiFont, paint);
}
// render offscreen buffer

View File

@ -132,7 +132,7 @@ static void draw_text_on_path(SkCanvas* canvas, const void* text, size_t length,
float baseline_offset) {
SkPathMeasure meas(path, false);
int count = font.countText(text, length, kUTF8_SkTextEncoding);
int count = font.countText(text, length, SkTextEncoding::kUTF8);
size_t size = count * (sizeof(SkRSXform) + sizeof(SkScalar));
SkAutoSMalloc<512> storage(size);
SkRSXform* xform = (SkRSXform*)storage.get();
@ -145,7 +145,7 @@ static void draw_text_on_path(SkCanvas* canvas, const void* text, size_t length,
const SkRect bounds = path.getBounds().makeOutset(max, max);
SkAutoTArray<SkGlyphID> glyphs(count);
font.textToGlyphs(text, length, kUTF8_SkTextEncoding, glyphs.get(), count);
font.textToGlyphs(text, length, SkTextEncoding::kUTF8, glyphs.get(), count);
font.getWidths(glyphs.get(), count, widths);
for (int i = 0; i < count; ++i) {
@ -166,7 +166,7 @@ static void draw_text_on_path(SkCanvas* canvas, const void* text, size_t length,
}
canvas->drawTextBlob(SkTextBlob::MakeFromRSXform(glyphs.get(), count * sizeof(SkGlyphID),
&xform[0], font, kGlyphID_SkTextEncoding),
&xform[0], font, SkTextEncoding::kGlyphID),
0, 0, paint);
if (true) {
@ -202,7 +202,7 @@ static void drawTextPath(SkCanvas* canvas, bool doStroke) {
SkScalar x = 0;
for (int i = 0; i < N; ++i) {
pos[i].set(x, 0);
x += font.measureText(&text0[i], 1, kUTF8_SkTextEncoding, nullptr, &paint);
x += font.measureText(&text0[i], 1, SkTextEncoding::kUTF8, nullptr, &paint);
}
SkPath path;

View File

@ -90,7 +90,7 @@ static sk_sp<SkImage> make_text_image(GrContext* context, const char* text, SkCo
font.setSize(32);
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
const SkMatrix mat = SkMatrix::MakeRectToRect(bounds, SkRect::MakeWH(kLabelSize, kLabelSize),
SkMatrix::kFill_ScaleToFit);
@ -101,7 +101,7 @@ static sk_sp<SkImage> make_text_image(GrContext* context, const char* text, SkCo
canvas->clear(SK_ColorWHITE);
canvas->concat(mat);
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, 0, 0, font, paint);
canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, 0, 0, font, paint);
sk_sp<SkImage> image = surf->makeImageSnapshot();

View File

@ -32,7 +32,7 @@ static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x,
SkScalar y, const SkFont& font) {
SkPaint paint;
canvas->drawString(text, x, y, font, paint);
return x + font.measureText(text.c_str(), text.size(), kUTF8_SkTextEncoding);
return x + font.measureText(text.c_str(), text.size(), SkTextEncoding::kUTF8);
}
class FontCacheGM : public skiagm::GpuGM {

View File

@ -36,7 +36,7 @@
static SkScalar drawString(SkCanvas* canvas, const SkString& text, SkScalar x,
SkScalar y, const SkFont& font) {
canvas->drawString(text, x, y, font, SkPaint());
return x + font.measureText(text.c_str(), text.size(), kUTF8_SkTextEncoding);
return x + font.measureText(text.c_str(), text.size(), SkTextEncoding::kUTF8);
}
static SkScalar drawCharacter(SkCanvas* canvas, uint32_t character, SkScalar x,
@ -309,7 +309,7 @@ public:
SkPaint::Style style = path.isEmpty() ? SkPaint::kFill_Style : SkPaint::kStroke_Style;
SkPaint glyphPaint;
glyphPaint.setStyle(style);
canvas->drawSimpleText(&str[i], sizeof(str[0]), kGlyphID_SkTextEncoding, x, y, font, glyphPaint);
canvas->drawSimpleText(&str[i], sizeof(str[0]), SkTextEncoding::kGlyphID, x, y, font, glyphPaint);
if (labelBounds) {
SkString glyphStr;

View File

@ -67,7 +67,7 @@ protected:
for (int ps = 6; ps <= 22; ps++) {
font.setSize(SkIntToScalar(ps));
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, x, y, font, SkPaint());
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, x, y, font, SkPaint());
y += font.getMetrics(nullptr);
}
}

View File

@ -96,7 +96,7 @@ protected:
for (int ps = 6; ps <= 22; ps++) {
font.setSize(SkIntToScalar(ps));
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, x, y, font, paint);
y += font.getMetrics(nullptr);
}
}

View File

@ -80,7 +80,7 @@ DEF_SIMPLE_GM(gamma, canvas, 850, 200) {
};
auto drawString = [&](const char str[], SkScalar x, SkScalar y) {
canvas->drawSimpleText(str, strlen(str), kUTF8_SkTextEncoding, x, y, font, textPaint);
canvas->drawSimpleText(str, strlen(str), SkTextEncoding::kUTF8, x, y, font, textPaint);
};
auto nextRect = [&](const char* label, const char* label2) {

View File

@ -45,12 +45,12 @@ DEF_SIMPLE_GM(getpostextpath, canvas, 480, 780) {
canvas->translate(SkIntToScalar(10), SkIntToScalar(64));
canvas->drawSimpleText(text, len, kUTF8_SkTextEncoding, 0, 0, font, paint);
ToolUtils::get_text_path(font, text, len, kUTF8_SkTextEncoding, &path, nullptr);
canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 0, 0, font, paint);
ToolUtils::get_text_path(font, text, len, SkTextEncoding::kUTF8, &path, nullptr);
strokePath(canvas, path);
path.reset();
SkAutoToGlyphs atg(font, text, len, kUTF8_SkTextEncoding);
SkAutoToGlyphs atg(font, text, len, SkTextEncoding::kUTF8);
const int count = atg.count();
SkAutoTArray<SkPoint> pos(count);
SkAutoTArray<SkScalar> widths(count);
@ -67,6 +67,6 @@ DEF_SIMPLE_GM(getpostextpath, canvas, 480, 780) {
canvas->translate(0, SkIntToScalar(64));
canvas->drawTextBlob(SkTextBlob::MakeFromPosText(text, len, &pos[0], font), 0, 0, paint);
ToolUtils::get_text_path(font, text, len, kUTF8_SkTextEncoding, &path, &pos[0]);
ToolUtils::get_text_path(font, text, len, SkTextEncoding::kUTF8, &path, &pos[0]);
strokePath(canvas, path);
}

View File

@ -104,7 +104,7 @@ static void drawTestCase(SkCanvas* canvas,
SkRect bounds;
if (drawRef) {
SkScalar advance = font.measureText(kText, sizeof(kText) - 1, kUTF8_SkTextEncoding,
SkScalar advance = font.measureText(kText, sizeof(kText) - 1, SkTextEncoding::kUTF8,
&bounds, &paint);
paint.setStrokeWidth(0.0f);
@ -123,12 +123,13 @@ static void drawTestCase(SkCanvas* canvas,
paint.setColor(SK_ColorBLACK);
paint.setStrokeWidth(strokeWidth);
paint.setStyle(strokeStyle);
canvas->drawSimpleText(kText, sizeof(kText) - 1, kUTF8_SkTextEncoding, 0.0f, 0.0f, font, paint);
canvas->drawSimpleText(kText, sizeof(kText) - 1, SkTextEncoding::kUTF8,
0.0f, 0.0f, font, paint);
if (drawRef) {
const size_t len = sizeof(kText) - 1;
SkGlyphID glyphs[len];
const int count = font.textToGlyphs(kText, len, kUTF8_SkTextEncoding, glyphs, len);
const int count = font.textToGlyphs(kText, len, SkTextEncoding::kUTF8, glyphs, len);
SkScalar widths[len]; // len is conservative. we really only need 'count'
font.getWidthsBounds(glyphs, count, widths, nullptr, &paint);

View File

@ -42,7 +42,7 @@ static void draw_failure_message(SkCanvas* canvas, const char format[], ...) {
canvas->drawColor(SkColorSetRGB(200,0,0));
SkFont font;
SkRect bounds;
font.measureText(failureMsg.c_str(), failureMsg.size(), kUTF8_SkTextEncoding, &bounds);
font.measureText(failureMsg.c_str(), failureMsg.size(), SkTextEncoding::kUTF8, &bounds);
SkPaint textPaint(SkColors::kWhite);
canvas->drawString(failureMsg, kOffset, bounds.height() + kOffset, font, textPaint);
}

View File

@ -55,8 +55,8 @@ static void draw_label(SkCanvas* canvas, const SkHighContrastConfig& config) {
size_t len = strlen(labelBuffer);
SkScalar width = font.measureText(labelBuffer, len, kUTF8_SkTextEncoding);
canvas->drawSimpleText(labelBuffer, len, kUTF8_SkTextEncoding, 0.5f - width / 2, 0.16f, font, SkPaint());
SkScalar width = font.measureText(labelBuffer, len, SkTextEncoding::kUTF8);
canvas->drawSimpleText(labelBuffer, len, SkTextEncoding::kUTF8, 0.5f - width / 2, 0.16f, font, SkPaint());
}
static void draw_scene(SkCanvas* canvas, const SkHighContrastConfig& config) {

View File

@ -38,6 +38,6 @@ DEF_SIMPLE_GM(largeglyphblur, canvas, 1920, 600) {
canvas->drawTextBlob(blob, 10, 200, SkPaint());
size_t len = strlen(text);
canvas->drawSimpleText(text, len, kUTF8_SkTextEncoding, 10, 500, font, blurPaint);
canvas->drawSimpleText(text, len, kUTF8_SkTextEncoding, 10, 500, font, SkPaint());
canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 10, 500, font, blurPaint);
canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, 10, 500, font, SkPaint());
}

View File

@ -41,8 +41,8 @@ static void draw_label(SkCanvas* canvas, const char* label,
size_t len = strlen(label);
SkScalar width = font.measureText(label, len, kUTF8_SkTextEncoding);
canvas->drawSimpleText(label, len, kUTF8_SkTextEncoding, offset.x() - width / 2, offset.y(),
SkScalar width = font.measureText(label, len, SkTextEncoding::kUTF8);
canvas->drawSimpleText(label, len, SkTextEncoding::kUTF8, offset.x() - width / 2, offset.y(),
font, SkPaint());
}

View File

@ -169,7 +169,7 @@ DEF_SIMPLE_GM(macaa_colors, canvas, 800, 500) {
font.setHinting(h);
y += font.getSpacing() + 2;
canvas->drawSimpleText(str, len, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(str, len, SkTextEncoding::kUTF8, x, y, font, paint);
}
}
y += 8;

View File

@ -61,7 +61,7 @@ protected:
const char* text = "O";
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
SkScalar yOffset = bounds.height();
ToolUtils::add_to_text_blob(&builder, text, font, 10, yOffset);
@ -79,7 +79,7 @@ protected:
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
font.setSubpixel(true);
text = "LCD!!!!!";
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
ToolUtils::add_to_text_blob(&builder,
text,
font,
@ -91,7 +91,7 @@ protected:
font.setEdging(SkFont::Edging::kAlias);
font.setSubpixel(false);
font.setTypeface(fEmojiTypeface);
font.measureText(fEmojiText, strlen(fEmojiText), kUTF8_SkTextEncoding, &bounds);
font.measureText(fEmojiText, strlen(fEmojiText), SkTextEncoding::kUTF8, &bounds);
ToolUtils::add_to_text_blob(&builder, fEmojiText, font, xOffset, yOffset);
}

View File

@ -24,10 +24,10 @@ static void excercise_draw_pos_text(SkCanvas* canvas,
SkScalar x, SkScalar y,
const SkFont& font,
const SkPaint& paint) {
const int count = font.countText(text, strlen(text), kUTF8_SkTextEncoding);
const int count = font.countText(text, strlen(text), SkTextEncoding::kUTF8);
SkTextBlobBuilder builder;
auto rec = builder.allocRunPos(font, count);
font.textToGlyphs(text, strlen(text), kUTF8_SkTextEncoding, rec.glyphs, count);
font.textToGlyphs(text, strlen(text), SkTextEncoding::kUTF8, rec.glyphs, count);
font.getPos(rec.glyphs, count, rec.points());
canvas->drawTextBlob(builder.make(), x, y, paint);
}
@ -61,7 +61,7 @@ DEF_SIMPLE_GM_CAN_FAIL(pdf_never_embed, canvas, errorMsg, 512, 512) {
canvas->scale(1.0, 0.5);
p.setColor(0xF0000080);
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, 30, 700, font, p);
canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, 30, 700, font, p);
return skiagm::DrawResult::kOk;
}

View File

@ -53,14 +53,14 @@ static void draw_vector_logo(SkCanvas* canvas, const SkRect& viewBox) {
SkPath path;
SkRect iBox, skiBox, skiaBox;
SkTextUtils::GetPath("SKI", 3, kUTF8_SkTextEncoding, 0, 0, font, &path);
SkTextUtils::GetPath("SKI", 3, SkTextEncoding::kUTF8, 0, 0, font, &path);
TightBounds(path, &skiBox);
SkTextUtils::GetPath("I", 1, kUTF8_SkTextEncoding, 0, 0, font, &path);
SkTextUtils::GetPath("I", 1, SkTextEncoding::kUTF8, 0, 0, font, &path);
TightBounds(path, &iBox);
iBox.offsetTo(skiBox.fRight - iBox.width(), iBox.fTop);
const size_t textLen = strlen(kSkiaStr);
SkTextUtils::GetPath(kSkiaStr, textLen, kUTF8_SkTextEncoding, 0, 0, font, &path);
SkTextUtils::GetPath(kSkiaStr, textLen, SkTextEncoding::kUTF8, 0, 0, font, &path);
TightBounds(path, &skiaBox);
skiaBox.outset(0, 2 * iBox.width() * (kVerticalSpacing + 1));
@ -112,7 +112,7 @@ static void draw_vector_logo(SkCanvas* canvas, const SkRect& viewBox) {
SkASSERT(SK_ARRAY_COUNT(pos2) == SK_ARRAY_COUNT(colors2));
paint.setShader(SkGradientShader::MakeLinear(pts2, colors2, pos2, SK_ARRAY_COUNT(pos2),
SkTileMode::kClamp));
canvas->drawSimpleText(kSkiaStr, textLen, kUTF8_SkTextEncoding, 0, 0, font, paint);
canvas->drawSimpleText(kSkiaStr, textLen, SkTextEncoding::kUTF8, 0, 0, font, paint);
}
// This GM exercises SkPictureImageGenerator features

View File

@ -67,7 +67,7 @@ protected:
SkScalar x = D/2;
SkScalar y = D/2 - (fm.fAscent + fm.fDescent)/2;
uint16_t glyphID = 3; // X
SkTextUtils::Draw(canvas, &glyphID, sizeof(glyphID), kGlyphID_SkTextEncoding, x, y,
SkTextUtils::Draw(canvas, &glyphID, sizeof(glyphID), SkTextEncoding::kGlyphID, x, y,
font, *paint, SkTextUtils::kCenter_Align);
canvas->restore();
}

View File

@ -73,7 +73,7 @@ protected:
SkString label;
label.printf("%d", i);
SkRect labelBounds;
font.measureText(label.c_str(), label.size(), kUTF8_SkTextEncoding, &labelBounds);
font.measureText(label.c_str(), label.size(), SkTextEncoding::kUTF8, &labelBounds);
SkScalar labelX = 0.5f * kPosterSize - 0.5f * labelBounds.width();
SkScalar labelY = 0.5f * kPosterSize + 0.5f * labelBounds.height();

View File

@ -76,7 +76,7 @@ protected:
font.setSize(textSize);
font.getMetrics(&metrics);
y += -metrics.fAscent;
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, 10, y, font, paint);
canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, 10, y, font, paint);
y += metrics.fDescent + metrics.fLeading;
}

View File

@ -65,7 +65,7 @@ protected:
font.setSubpixel(true);
y += -metrics.fAscent;
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding,
canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8,
10, y, font, paint);
y += metrics.fDescent + metrics.fLeading;
}

View File

@ -122,7 +122,7 @@ protected:
constexpr char kText[] = "B";
canvas->drawString(kText, 0, 0, font, fillPaint);
canvas->drawString(kText, 0, 0, font, outlinePaint);
SkScalar w = font.measureText(kText, strlen(kText), kUTF8_SkTextEncoding);
SkScalar w = font.measureText(kText, strlen(kText), SkTextEncoding::kUTF8);
canvas->translate(w + 10.f, 0.f);
++i;
if (!(i % 2)) {

View File

@ -44,10 +44,10 @@ static void exercise_draw_pos_text(SkCanvas* canvas,
const char* text,
SkScalar x, SkScalar y,
const SkFont& font, const SkPaint& paint) {
const int count = font.countText(text, strlen(text), kUTF8_SkTextEncoding);
const int count = font.countText(text, strlen(text), SkTextEncoding::kUTF8);
SkTextBlobBuilder builder;
auto rec = builder.allocRunPos(font, count);
font.textToGlyphs(text, strlen(text), kUTF8_SkTextEncoding, rec.glyphs, count);
font.textToGlyphs(text, strlen(text), SkTextEncoding::kUTF8, rec.glyphs, count);
font.getPos(rec.glyphs, count, rec.points(), {x, y});
canvas->drawTextBlob(builder.make(), 0, 0, paint);
}
@ -56,10 +56,10 @@ static void exercise_draw_pos_text_h(SkCanvas* canvas,
const char* text,
SkScalar x, SkScalar y,
const SkFont& font, const SkPaint& paint) {
const int count = font.countText(text, strlen(text), kUTF8_SkTextEncoding);
const int count = font.countText(text, strlen(text), SkTextEncoding::kUTF8);
SkTextBlobBuilder builder;
auto rec = builder.allocRunPosH(font, count, 0);
font.textToGlyphs(text, strlen(text), kUTF8_SkTextEncoding, rec.glyphs, count);
font.textToGlyphs(text, strlen(text), SkTextEncoding::kUTF8, rec.glyphs, count);
font.getXPos(rec.glyphs, count, rec.pos);
canvas->drawTextBlob(builder.make(), x, y, paint);
}
@ -71,7 +71,7 @@ static void test_text(SkCanvas* canvas, SkScalar size,
SkPaint type;
type.setColor(color);
const char text[] = "HELLO WORLD";
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, 32, size / 2 + Y,
canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, 32, size / 2 + Y,
font, type);
SkScalar lineSpacing = font.getSpacing();
exercise_draw_pos_text(canvas, text, 32, size / 2 + Y + lineSpacing, font, type);

View File

@ -26,14 +26,14 @@ DEF_SIMPLE_GM(skbug_5321, canvas, 128, 128) {
SkScalar x = 20, y = 45;
size_t byteLength = strlen(text);
canvas->drawSimpleText(text, byteLength, kUTF8_SkTextEncoding, x, y, font, SkPaint());
canvas->drawSimpleText(text, byteLength, SkTextEncoding::kUTF8, x, y, font, SkPaint());
y += font.getMetrics(nullptr);
int glyph_count = font.countText(text, byteLength, kUTF8_SkTextEncoding);
int glyph_count = font.countText(text, byteLength, SkTextEncoding::kUTF8);
SkTextBlobBuilder builder;
auto rec = builder.allocRunPosH(font, glyph_count, y);
font.textToGlyphs(text, byteLength, kUTF8_SkTextEncoding, rec.glyphs, glyph_count);
font.textToGlyphs(text, byteLength, SkTextEncoding::kUTF8, rec.glyphs, glyph_count);
font.getWidths(rec.glyphs, glyph_count, rec.pos);
for (int i = 0; i < glyph_count; ++i) {

View File

@ -44,7 +44,7 @@ static void draw_text_stroked(SkCanvas* canvas, const SkPaint& paint, const SkFo
if (strokeWidth > 0) {
p.setStyle(SkPaint::kFill_Style);
canvas->drawSimpleText("P", 1, kUTF8_SkTextEncoding, loc.fX, loc.fY - 225, font, p);
canvas->drawSimpleText("P", 1, SkTextEncoding::kUTF8, loc.fX, loc.fY - 225, font, p);
canvas->drawTextBlob(SkTextBlob::MakeFromPosText("P", 1, &loc, font), 0, 0, p);
}
@ -52,7 +52,7 @@ static void draw_text_stroked(SkCanvas* canvas, const SkPaint& paint, const SkFo
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(strokeWidth);
canvas->drawSimpleText("P", 1, kUTF8_SkTextEncoding, loc.fX, loc.fY - 225, font, p);
canvas->drawSimpleText("P", 1, SkTextEncoding::kUTF8, loc.fX, loc.fY - 225, font, p);
canvas->drawTextBlob(SkTextBlob::MakeFromPosText("P", 1, &loc, font), 0, 0, p);
}

View File

@ -89,10 +89,10 @@ protected:
fTypeface = ToolUtils::create_portable_typeface("serif", SkFontStyle());
SkFont font(fTypeface);
size_t txtLen = strlen(fText);
int glyphCount = font.countText(fText, txtLen, kUTF8_SkTextEncoding);
int glyphCount = font.countText(fText, txtLen, SkTextEncoding::kUTF8);
fGlyphs.append(glyphCount);
font.textToGlyphs(fText, txtLen, kUTF8_SkTextEncoding, fGlyphs.begin(), glyphCount);
font.textToGlyphs(fText, txtLen, SkTextEncoding::kUTF8, fGlyphs.begin(), glyphCount);
}
SkString onShortName() override {

View File

@ -41,7 +41,7 @@ protected:
const char* text = "AB";
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
SkScalar yOffset = bounds.height();
ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset - 30);

View File

@ -42,7 +42,7 @@ protected:
const char* text = "AB";
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
SkScalar yOffset = bounds.height();
ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset - 30);
@ -50,7 +50,7 @@ protected:
// A8
font.setSize(28);
text = "The quick brown fox jumps over the lazy dog.";
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset - 8);
// build

View File

@ -52,8 +52,8 @@ static void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const
SkTDArray<uint16_t> glyphs;
size_t len = strlen(text);
glyphs.append(font.countText(text, len, kUTF8_SkTextEncoding));
font.textToGlyphs(text, len, kUTF8_SkTextEncoding, glyphs.begin(), glyphs.count());
glyphs.append(font.countText(text, len, SkTextEncoding::kUTF8));
font.textToGlyphs(text, len, SkTextEncoding::kUTF8, glyphs.begin(), glyphs.count());
const SkScalar advanceX = font.getSize() * 0.85f;
const SkScalar advanceY = font.getSize() * 1.5f;

View File

@ -55,35 +55,35 @@ protected:
// large
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
SkScalar yOffset = bounds.height();
font.setSize(162);
ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset);
// Medium
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
yOffset += bounds.height();
font.setSize(72);
ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset);
// Small
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
yOffset += bounds.height();
font.setSize(32);
ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset);
// micro (will fall out of distance field text even if distance field text is enabled)
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
yOffset += bounds.height();
font.setSize(14);
ToolUtils::add_to_text_blob(&builder, text, font, 0, yOffset);
// Zero size.
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
yOffset += bounds.height();
font.setSize(0);

View File

@ -63,7 +63,7 @@ protected:
SkScalar y = 0;
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
y -= bounds.fTop;
ToolUtils::add_to_text_blob(&builder, text, font, 0, y);
y += bounds.fBottom;
@ -74,12 +74,12 @@ protected:
font.setSize(160);
font.setSubpixel(false);
font.setEdging(SkFont::Edging::kAntiAlias);
font.measureText(bigtext1, strlen(bigtext1), kUTF8_SkTextEncoding, &bounds);
font.measureText(bigtext1, strlen(bigtext1), SkTextEncoding::kUTF8, &bounds);
y -= bounds.fTop;
ToolUtils::add_to_text_blob(&builder, bigtext1, font, 0, y);
y += bounds.fBottom;
font.measureText(bigtext2, strlen(bigtext2), kUTF8_SkTextEncoding, &bounds);
font.measureText(bigtext2, strlen(bigtext2), SkTextEncoding::kUTF8, &bounds);
y -= bounds.fTop;
ToolUtils::add_to_text_blob(&builder, bigtext2, font, 0, y);
y += bounds.fBottom;
@ -88,7 +88,7 @@ protected:
if (sk_sp<SkTypeface> origEmoji = ToolUtils::emoji_typeface()) {
font.setTypeface(sk_make_sp<SkRandomTypeface>(origEmoji, paint, false));
const char* emojiText = ToolUtils::emoji_sample_text();
font.measureText(emojiText, strlen(emojiText), kUTF8_SkTextEncoding, &bounds);
font.measureText(emojiText, strlen(emojiText), SkTextEncoding::kUTF8, &bounds);
y -= bounds.fTop;
ToolUtils::add_to_text_blob(&builder, emojiText, font, 0, y);
y += bounds.fBottom;

View File

@ -39,8 +39,8 @@ private:
SkFont font(ToolUtils::create_portable_typeface());
const char* txt = "Blobber";
size_t txtLen = strlen(txt);
fGlyphs.append(font.countText(txt, txtLen, kUTF8_SkTextEncoding));
font.textToGlyphs(txt, txtLen, kUTF8_SkTextEncoding, fGlyphs.begin(), fGlyphs.count());
fGlyphs.append(font.countText(txt, txtLen, SkTextEncoding::kUTF8));
font.textToGlyphs(txt, txtLen, SkTextEncoding::kUTF8, fGlyphs.begin(), fGlyphs.count());
}
SkFont font;

View File

@ -38,7 +38,7 @@ protected:
const char* text = "A";
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
ToolUtils::add_to_text_blob(&builder, text, font, 0, 0);
// Medium
@ -47,7 +47,7 @@ protected:
text = "B";
ToolUtils::add_to_text_blob(&builder, text, font, xOffset, 0);
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
SkScalar yOffset = bounds.height();
// Small

View File

@ -51,9 +51,9 @@ namespace {
sk_sp<SkTextBlob> MakeFancyBlob(const SkPaint& paint, const SkFont& font, const char* text) {
const size_t textLen = strlen(text);
const int glyphCount = font.countText(text, textLen, kUTF8_SkTextEncoding);
const int glyphCount = font.countText(text, textLen, SkTextEncoding::kUTF8);
SkAutoTArray<SkGlyphID> glyphs(glyphCount);
font.textToGlyphs(text, textLen, kUTF8_SkTextEncoding, glyphs.get(), glyphCount);
font.textToGlyphs(text, textLen, SkTextEncoding::kUTF8, glyphs.get(), glyphCount);
SkAutoTArray<SkScalar> widths(glyphCount);
font.getWidths(glyphs.get(), glyphCount, widths.get());
@ -150,7 +150,7 @@ DEF_SIMPLE_GM(fancyblobunderline, canvas, 1480, 1380) {
static sk_sp<SkTextBlob> make_text(const SkFont& font, const SkGlyphID glyphs[], int count) {
return SkTextBlob::MakeFromText(glyphs, count * sizeof(SkGlyphID), font,
kGlyphID_SkTextEncoding);
SkTextEncoding::kGlyphID);
}
static sk_sp<SkTextBlob> make_posh(const SkFont& font, const SkGlyphID glyphs[], int count,
@ -161,7 +161,7 @@ static sk_sp<SkTextBlob> make_posh(const SkFont& font, const SkGlyphID glyphs[],
xpos[i] += spacing * i;
}
return SkTextBlob::MakeFromPosTextH(glyphs, count * sizeof(SkGlyphID), xpos.get(), 0, font,
kGlyphID_SkTextEncoding);
SkTextEncoding::kGlyphID);
}
static sk_sp<SkTextBlob> make_pos(const SkFont& font, const SkGlyphID glyphs[], int count,
@ -172,7 +172,7 @@ static sk_sp<SkTextBlob> make_pos(const SkFont& font, const SkGlyphID glyphs[],
pos[i].fX += spacing * i;
}
return SkTextBlob::MakeFromPosText(glyphs, count * sizeof(SkGlyphID), pos.get(), font,
kGlyphID_SkTextEncoding);
SkTextEncoding::kGlyphID);
}
// widen the gaps with a margin (on each side of the gap), elimnating segments that go away
@ -241,9 +241,9 @@ DEF_SIMPLE_GM(textblob_intercepts, canvas, 940, 800) {
font.setTypeface(ToolUtils::create_portable_typeface());
font.setSize(100);
font.setEdging(SkFont::Edging::kAntiAlias);
const int count = font.countText(text, length, kUTF8_SkTextEncoding);
const int count = font.countText(text, length, SkTextEncoding::kUTF8);
SkAutoTArray<SkGlyphID> glyphs(count);
font.textToGlyphs(text, length, kUTF8_SkTextEncoding, glyphs.get(), count);
font.textToGlyphs(text, length, SkTextEncoding::kUTF8, glyphs.get(), count);
auto b0 = make_text(font, glyphs.get(), count);

View File

@ -54,13 +54,13 @@ static void drawKernText(SkCanvas* canvas, const void* text, size_t len,
SkScalar x, SkScalar y, const SkFont& font, const SkPaint& paint) {
SkTypeface* face = font.getTypefaceOrDefault();
if (!face) {
canvas->drawSimpleText(text, len, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, x, y, font, paint);
return;
}
SkAutoSTMalloc<128, uint16_t> glyphStorage(len);
uint16_t* glyphs = glyphStorage.get();
int glyphCount = font.textToGlyphs(text, len, kUTF8_SkTextEncoding, glyphs, len);
int glyphCount = font.textToGlyphs(text, len, SkTextEncoding::kUTF8, glyphs, len);
if (glyphCount < 1) {
return;
}
@ -68,7 +68,7 @@ static void drawKernText(SkCanvas* canvas, const void* text, size_t len,
SkAutoSTMalloc<128, int32_t> adjustmentStorage(glyphCount - 1);
int32_t* adjustments = adjustmentStorage.get();
if (!face->getKerningPairAdjustments(glyphs, glyphCount, adjustments)) {
canvas->drawSimpleText(text, len, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, x, y, font, paint);
return;
}
@ -137,7 +137,7 @@ protected:
SkPaint paint;
for (int i = 0; i < gStylesCount; i++) {
font.setTypeface(fFaces[i]);
canvas->drawSimpleText(text, textLen, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(text, textLen, SkTextEncoding::kUTF8, x, y, font, paint);
if (fApplyKerning) {
drawKernText(canvas, text, textLen, x + 240, y, font, paint);
}
@ -245,12 +245,12 @@ static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
canvas->rotate(2, x + subpixel.offset.x(),
y + subpixel.offset.y());
}
canvas->drawSimpleText(&character, 1, kUTF8_SkTextEncoding,
canvas->drawSimpleText(&character, 1, SkTextEncoding::kUTF8,
x + subpixel.offset.x(),
y + subpixel.offset.y(), font, paint);
SkScalar dx = SkScalarCeilToScalar(
font.measureText(&character, 1, kUTF8_SkTextEncoding)) + 5;
font.measureText(&character, 1, SkTextEncoding::kUTF8)) + 5;
x += dx;
xMax = SkTMax(x, xMax);
}
@ -295,10 +295,10 @@ static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
for (const StyleTests& style : styleTypes) {
paint.setStyle(style.style);
paint.setStrokeWidth(style.strokeWidth);
canvas->drawSimpleText(&character, 1, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(&character, 1, SkTextEncoding::kUTF8, x, y, font, paint);
SkScalar dx = SkScalarCeilToScalar(font.measureText(&character, 1,
kUTF8_SkTextEncoding)) + 5;
SkTextEncoding::kUTF8)) + 5;
x += dx;
}
}
@ -345,10 +345,10 @@ static void draw_typeface_rendering_gm(SkCanvas* canvas, sk_sp<SkTypeface> face,
}
for (const MaskTests& mask : maskTypes) {
paint.setMaskFilter(SkMaskFilter::MakeBlur(mask.style, mask.sigma));
canvas->drawSimpleText(&character, 1, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(&character, 1, SkTextEncoding::kUTF8, x, y, font, paint);
SkScalar dx = SkScalarCeilToScalar(font.measureText(&character, 1,
kUTF8_SkTextEncoding)) + 5;
SkTextEncoding::kUTF8)) + 5;
x += dx;
}
paint.setMaskFilter(nullptr);

View File

@ -94,7 +94,7 @@ protected:
fFont.setTypeface(fTypefaces[fTypefaceIndices[i]]);
fFont.setSize(fPtSizes[i]);
fFont.measureText(fStrings[i].c_str(), fStrings[i].size(), kUTF8_SkTextEncoding, &r);
fFont.measureText(fStrings[i].c_str(), fStrings[i].size(), SkTextEncoding::kUTF8, &r);
// safeRect is set of x,y positions where we can draw the string without hitting
// the GM's border.
SkRect safeRect = SkRect::MakeLTRB(-r.fLeft, -r.fTop, w - r.fRight, h - r.fBottom);
@ -125,7 +125,7 @@ protected:
canvas->save();
canvas->clipRect(fClipRects[i]);
canvas->translate(fPositions[i].fX, fPositions[i].fY);
canvas->drawSimpleText(fStrings[i].c_str(), fStrings[i].size(), kUTF8_SkTextEncoding,
canvas->drawSimpleText(fStrings[i].c_str(), fStrings[i].size(), SkTextEncoding::kUTF8,
0, 0, fFont, fPaint);
canvas->restore();
}

View File

@ -740,14 +740,14 @@ static void draw_col_label(SkCanvas* canvas, int x, int yuvColorSpace, bool opaq
SkString colLabel;
colLabel.printf("%s", kYUVColorSpaceNames[yuvColorSpace]);
font.measureText(colLabel.c_str(), colLabel.size(), kUTF8_SkTextEncoding, &textRect);
font.measureText(colLabel.c_str(), colLabel.size(), SkTextEncoding::kUTF8, &textRect);
int y = textRect.height();
SkTextUtils::DrawString(canvas, colLabel.c_str(), x, y, font, paint, SkTextUtils::kCenter_Align);
colLabel.printf("%s", opaque ? "Opaque" : "Transparent");
font.measureText(colLabel.c_str(), colLabel.size(), kUTF8_SkTextEncoding, &textRect);
font.measureText(colLabel.c_str(), colLabel.size(), SkTextEncoding::kUTF8, &textRect);
y += textRect.height();
SkTextUtils::DrawString(canvas, colLabel.c_str(), x, y, font, paint, SkTextUtils::kCenter_Align);
@ -765,7 +765,7 @@ static void draw_row_label(SkCanvas* canvas, int y, int yuvFormat) {
SkString rowLabel;
rowLabel.printf("%s", kYUVFormatNames[yuvFormat]);
font.measureText(rowLabel.c_str(), rowLabel.size(), kUTF8_SkTextEncoding, &textRect);
font.measureText(rowLabel.c_str(), rowLabel.size(), SkTextEncoding::kUTF8, &textRect);
y += kTileWidthHeight/2 + textRect.height()/2;
canvas->drawString(rowLabel, 0, y, font, paint);

View File

@ -1948,7 +1948,7 @@ public:
*/
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont& font,
const SkPaint& paint) {
this->drawSimpleText(str, strlen(str), kUTF8_SkTextEncoding, x, y, font, paint);
this->drawSimpleText(str, strlen(str), SkTextEncoding::kUTF8, x, y, font, paint);
}
/** Draws SkString, with origin at (x, y), using clip, SkMatrix, SkFont font,
@ -1977,7 +1977,7 @@ public:
*/
void drawString(const SkString& str, SkScalar x, SkScalar y, const SkFont& font,
const SkPaint& paint) {
this->drawSimpleText(str.c_str(), str.size(), kUTF8_SkTextEncoding, x, y, font, paint);
this->drawSimpleText(str.c_str(), str.size(), SkTextEncoding::kUTF8, x, y, font, paint);
}
/** Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
@ -1988,7 +1988,7 @@ public:
SkPaint font embedded bitmaps, SkPaint full hinting spacing, LCD text, SkPaint linear text,
and SkPaint subpixel text.
SkTextEncoding must be set to kGlyphID_SkTextEncoding.
SkTextEncoding must be set to SkTextEncoding::kGlyphID.
Elements of paint: anti-alias, SkBlendMode, color including alpha,
SkColorFilter, SkPaint dither, SkDrawLooper, SkMaskFilter, SkPathEffect, SkShader, and
@ -2011,7 +2011,7 @@ public:
SkPaint font embedded bitmaps, SkPaint full hinting spacing, LCD text, SkPaint linear text,
and SkPaint subpixel text.
SkTextEncoding must be set to kGlyphID_SkTextEncoding.
SkTextEncoding must be set to SkTextEncoding::kGlyphID.
Elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter,
SkImageFilter, and SkDrawLooper; apply to blob.

View File

@ -272,7 +272,7 @@ public:
If byteLength equals zero, returns zero.
If byteLength includes a partial character, the partial character is ignored.
If encoding is kUTF8_SkTextEncoding and text contains an invalid UTF-8 sequence,
If encoding is SkTextEncoding::kUTF8 and text contains an invalid UTF-8 sequence,
zero is returned.
When encoding is SkTextEncoding::kUTF8, SkTextEncoding::kUTF16, or
@ -286,8 +286,8 @@ public:
@param text character storage encoded with SkTextEncoding
@param byteLength length of character storage in bytes
@param encoding one of: kUTF8_SkTextEncoding, kUTF16_SkTextEncoding,
kUTF32_SkTextEncoding, kGlyphID_SkTextEncoding
@param encoding one of: SkTextEncoding::kUTF8, SkTextEncoding::kUTF16,
SkTextEncoding::kUTF32, SkTextEncoding::kGlyphID
@param glyphs storage for glyph indices; may be nullptr
@param maxGlyphCount storage capacity
@return number of glyphs represented by text of length byteLength
@ -308,14 +308,14 @@ public:
/** Returns number of glyphs represented by text.
If encoding is kUTF8_SkTextEncoding, kUTF16_SkTextEncoding, or
kUTF32_SkTextEncoding; then each Unicode codepoint is mapped to a
If encoding is SkTextEncoding::kUTF8, SkTextEncoding::kUTF16, or
SkTextEncoding::kUTF32; then each Unicode codepoint is mapped to a
single glyph.
@param text character storage encoded with SkTextEncoding
@param byteLength length of character storage in bytes
@param encoding one of: kUTF8_SkTextEncoding, kUTF16_SkTextEncoding,
kUTF32_SkTextEncoding, kGlyphID_SkTextEncoding
@param encoding one of: SkTextEncoding::kUTF8, SkTextEncoding::kUTF16,
SkTextEncoding::kUTF32, SkTextEncoding::kGlyphID
@return number of glyphs represented by text of length byteLength
*/
int countText(const void* text, size_t byteLength, SkTextEncoding encoding) const {
@ -328,8 +328,8 @@ public:
@param text character storage encoded with SkTextEncoding
@param byteLength length of character storage in bytes
@param encoding one of: kUTF8_SkTextEncoding, kUTF16_SkTextEncoding,
kUTF32_SkTextEncoding, kGlyphID_SkTextEncoding
@param encoding one of: SkTextEncoding::kUTF8, SkTextEncoding::kUTF16,
SkTextEncoding::kUTF32, SkTextEncoding::kGlyphID
@param bounds returns bounding box relative to (0, 0) if not nullptr
@return number of glyphs represented by text of length byteLength
*/
@ -345,8 +345,8 @@ public:
@param text character storage encoded with SkTextEncoding
@param byteLength length of character storage in bytes
@param encoding one of: kUTF8_SkTextEncoding, kUTF16_SkTextEncoding,
kUTF32_SkTextEncoding, kGlyphID_SkTextEncoding
@param encoding one of: SkTextEncoding::kUTF8, SkTextEncoding::kUTF16,
SkTextEncoding::kUTF32, SkTextEncoding::kGlyphID
@param bounds returns bounding box relative to (0, 0) if not nullptr
@param paint optional; may be nullptr
@return number of glyphs represented by text of length byteLength

View File

@ -77,7 +77,7 @@ public:
@return SkTextBlob constructed from one run
*/
static sk_sp<SkTextBlob> MakeFromText(const void* text, size_t byteLength, const SkFont& font,
SkTextEncoding encoding = kUTF8_SkTextEncoding);
SkTextEncoding encoding = SkTextEncoding::kUTF8);
/** Creates SkTextBlob with a single run. string meaning depends on SkTextEncoding;
by default, string is encoded as UTF-8.
@ -97,7 +97,7 @@ public:
@return SkTextBlob constructed from one run
*/
static sk_sp<SkTextBlob> MakeFromString(const char* string, const SkFont& font,
SkTextEncoding encoding = kUTF8_SkTextEncoding) {
SkTextEncoding encoding = SkTextEncoding::kUTF8) {
if (!string) {
return nullptr;
}
@ -118,7 +118,7 @@ public:
*/
static sk_sp<SkTextBlob> MakeFromPosTextH(const void* text, size_t byteLength,
const SkScalar xpos[], SkScalar constY, const SkFont& font,
SkTextEncoding encoding = kUTF8_SkTextEncoding);
SkTextEncoding encoding = SkTextEncoding::kUTF8);
/** Returns a textblob built from a single run of text with positions.
This is equivalent to using SkTextBlobBuilder and calling allocRunPos().
@ -133,11 +133,11 @@ public:
*/
static sk_sp<SkTextBlob> MakeFromPosText(const void* text, size_t byteLength,
const SkPoint pos[], const SkFont& font,
SkTextEncoding encoding = kUTF8_SkTextEncoding);
SkTextEncoding encoding = SkTextEncoding::kUTF8);
static sk_sp<SkTextBlob> MakeFromRSXform(const void* text, size_t byteLength,
const SkRSXform xform[], const SkFont& font,
SkTextEncoding encoding = kUTF8_SkTextEncoding);
SkTextEncoding encoding = SkTextEncoding::kUTF8);
/** Writes data to allow later reconstruction of SkTextBlob. memory points to storage
to receive the encoded data, and memory_size describes the size of storage.

View File

@ -28,7 +28,7 @@ public:
static void DrawString(SkCanvas* canvas, const char text[], SkScalar x, SkScalar y,
const SkFont& font, const SkPaint& paint, Align align = kLeft_Align) {
Draw(canvas, text, strlen(text), kUTF8_SkTextEncoding, x, y, font, paint, align);
Draw(canvas, text, strlen(text), SkTextEncoding::kUTF8, x, y, font, paint, align);
}
static void GetPath(const void* text, size_t length, SkTextEncoding, SkScalar x, SkScalar y,

View File

@ -356,7 +356,7 @@ private:
// Use the font manager's default font
SkFont font(nullptr, fFontSize);
SkPath path;
SkTextUtils::GetPath(fText.c_str(), fText.size(), kUTF8_SkTextEncoding, 0, 0, font, &path);
SkTextUtils::GetPath(fText.c_str(), fText.size(), SkTextEncoding::kUTF8, 0, 0, font, &path);
SkContourMeasureIter iter(path, false);
while (auto contour = iter.next()) {
fContours.push_back(contour);

View File

@ -57,7 +57,7 @@ SkRect Text::onRevalidate(InvalidationController*, const SkMatrix&) {
// 1) SkTextBlob has some trouble computing accurate bounds with alignment.
// 2) SkPaint::Align is slated for deprecation.
fBlob = SkTextBlob::MakeFromText(fText.c_str(), fText.size(), font, kUTF8_SkTextEncoding);
fBlob = SkTextBlob::MakeFromText(fText.c_str(), fText.size(), font, SkTextEncoding::kUTF8);
if (!fBlob) {
return SkRect::MakeEmpty();
}

View File

@ -125,7 +125,7 @@ unsigned skhb_nominal_glyphs(hb_font_t *hb_font, void *font_data,
unicodes = SkTAddOffset<const hb_codepoint_t>(unicodes, unicode_stride);
}
SkAutoSTMalloc<256, SkGlyphID> glyph(count);
font.textToGlyphs(unicode.get(), count * sizeof(SkUnichar), kUTF32_SkTextEncoding,
font.textToGlyphs(unicode.get(), count * sizeof(SkUnichar), SkTextEncoding::kUTF32,
glyph.get(), count);
// Copy the results back to the sparse array.

View File

@ -540,7 +540,7 @@ struct Button {
return;
}
canvas->drawRect(fBounds, paints.fStates[fState]);
SkTextUtils::Draw(canvas, &fLabel, 1, kUTF8_SkTextEncoding, fBounds.centerX(), fBounds.fBottom - 5,
SkTextUtils::Draw(canvas, &fLabel, 1, SkTextEncoding::kUTF8, fBounds.centerX(), fBounds.fBottom - 5,
paints.fLabelFont, SkPaint(), SkTextUtils::kCenter_Align);
}

View File

@ -38,10 +38,10 @@ protected:
kPauseKey, kResetKey);
const char* text = str.c_str();
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
fYOffset = bounds.height();
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, 5, fYOffset, font, SkPaint());
canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, 5, fYOffset, font, SkPaint());
fYOffset *= 2;
}

View File

@ -27,7 +27,7 @@ static void DrawTheText(SkCanvas* canvas, const char text[], size_t length, SkSc
const SkFont& font, const SkPaint& paint) {
SkFont f(font);
f.setSubpixel(true);
canvas->drawSimpleText(text, length, kUTF8_SkTextEncoding, x, y, f, paint);
canvas->drawSimpleText(text, length, SkTextEncoding::kUTF8, x, y, f, paint);
}
// This sample demonstrates the cache behavior of bitmap vs. distance field text

View File

@ -57,7 +57,7 @@ static sk_sp<SkImage> make_atlas(int atlasSize, int cellSize) {
paint.setColor(rand.nextU());
paint.setAlpha(0xFF);
int index = i % strlen(s);
SkTextUtils::Draw(canvas, &s[index], 1, kUTF8_SkTextEncoding,
SkTextUtils::Draw(canvas, &s[index], 1, SkTextEncoding::kUTF8,
x + half, y + half + half/2, font, paint,
SkTextUtils::kCenter_Align);
i += 1;

View File

@ -161,14 +161,14 @@ static void make_big_bitmap(SkBitmap* bm) {
SkFont font;
font.setSize(SkIntToScalar(BIG_H));
const int BIG_W = SkScalarRoundToInt(font.measureText(gText, strlen(gText), kUTF8_SkTextEncoding));
const int BIG_W = SkScalarRoundToInt(font.measureText(gText, strlen(gText), SkTextEncoding::kUTF8));
bm->allocN32Pixels(BIG_W, BIG_H);
bm->eraseColor(SK_ColorWHITE);
SkCanvas canvas(*bm);
canvas.drawSimpleText(gText, strlen(gText), kUTF8_SkTextEncoding, 0, font.getSize()*4/5, font, SkPaint());
canvas.drawSimpleText(gText, strlen(gText), SkTextEncoding::kUTF8, 0, font.getSize()*4/5, font, SkPaint());
}
class BitmapRectView2 : public Sample {

View File

@ -95,7 +95,7 @@ private:
ToolUtils::add_to_text_blob_w_len(&builder,
(const char*)glyphs,
kWordLength * 4,
kUTF32_SkTextEncoding,
SkTextEncoding::kUTF32,
font,
0,
0);
@ -224,7 +224,7 @@ private:
ToolUtils::add_to_text_blob_w_len(&builder,
(const char*)glyphs,
currentLineLength * 4,
kUTF32_SkTextEncoding,
SkTextEncoding::kUTF32,
font,
0,
y);

View File

@ -129,14 +129,14 @@ protected:
SkScalar txtX = SkIntToScalar(55);
paint.setColor(colorA);
const char* aTxt = invA ? "InverseA " : "A ";
canvas->drawSimpleText(aTxt, strlen(aTxt), kUTF8_SkTextEncoding, txtX, SkIntToScalar(220), font, paint);
txtX += font.measureText(aTxt, strlen(aTxt), kUTF8_SkTextEncoding);
canvas->drawSimpleText(aTxt, strlen(aTxt), SkTextEncoding::kUTF8, txtX, SkIntToScalar(220), font, paint);
txtX += font.measureText(aTxt, strlen(aTxt), SkTextEncoding::kUTF8);
paint.setColor(SK_ColorBLACK);
canvas->drawSimpleText(gOps[op].fName, strlen(gOps[op].fName), kUTF8_SkTextEncoding,
canvas->drawSimpleText(gOps[op].fName, strlen(gOps[op].fName), SkTextEncoding::kUTF8,
txtX, 220, font, paint);
txtX += font.measureText(gOps[op].fName, strlen(gOps[op].fName), kUTF8_SkTextEncoding);
txtX += font.measureText(gOps[op].fName, strlen(gOps[op].fName), SkTextEncoding::kUTF8);
paint.setColor(colorB);
canvas->drawSimpleText("B", 1, kUTF8_SkTextEncoding, txtX, 220, font, paint);
canvas->drawSimpleText("B", 1, SkTextEncoding::kUTF8, txtX, 220, font, paint);
canvas->translate(SkIntToScalar(250),0);
}

View File

@ -167,7 +167,7 @@ protected:
canvas->drawPath(path, p);
// draw time to make it easier to guess when the bad cubic was drawn
std::string timeStr = std::to_string((float) (curTime - start) / 1000.f);
canvas->drawSimpleText(timeStr.c_str(), timeStr.size(), kUTF8_SkTextEncoding, 20, 20, SkFont(), SkPaint());
canvas->drawSimpleText(timeStr.c_str(), timeStr.size(), SkTextEncoding::kUTF8, 20, 20, SkFont(), SkPaint());
SkDebugf("");
}

View File

@ -17,7 +17,7 @@ static void call_measure() {
SkRandom rand;
paint.setAntiAlias(true);
paint.setTextEncoding(kUTF16_SkTextEncoding);
paint.setTextEncoding(SkTextEncoding::kUTF16);
for (int j = 0; j < SK_ARRAY_COUNT(text); j++)
text[j] = (uint16_t)((rand.nextU() & 0xFF) + 32);
@ -36,7 +36,7 @@ static void call_draw(SkCanvas* canvas) {
SkRandom rand;
paint.setAntiAlias(true);
paint.setTextEncoding(kUTF16_SkTextEncoding);
paint.setTextEncoding(SkTextEncoding::kUTF16);
for (int j = 0; j < SK_ARRAY_COUNT(text); j++)
text[j] = (uint16_t)((rand.nextU() & 0xFF) + 32);

View File

@ -55,8 +55,8 @@ protected:
// d3 by default anchors text around the middle
SkRect bounds;
font.measureText(text, strlen(text), kUTF8_SkTextEncoding, &bounds);
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, -bounds.centerX(), -bounds.centerY(),
font.measureText(text, strlen(text), SkTextEncoding::kUTF8, &bounds);
canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, -bounds.centerX(), -bounds.centerY(),
font, paint);
}

View File

@ -46,9 +46,9 @@ protected:
textSize += delta;
font.setEdging(SkFont::Edging::kAntiAlias);
canvas->drawSimpleText(text, len, kUTF8_SkTextEncoding, x0, y, font, paint);
canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, x0, y, font, paint);
font.setEdging(SkFont::Edging::kSubpixelAntiAlias);
canvas->drawSimpleText(text, len, kUTF8_SkTextEncoding, x1, y, font, paint);
canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, x1, y, font, paint);
y += font.getSpacing();
}

View File

@ -509,7 +509,7 @@ protected:
paint.setStyle(SkPaint::kFill_Style);
SkFont font;
font.setSize(25.0f);
SkTextUtils::Draw(canvas, &button.fLabel, 1, kUTF8_SkTextEncoding,
SkTextUtils::Draw(canvas, &button.fLabel, 1, SkTextEncoding::kUTF8,
button.fBounds.centerX(), button.fBounds.fBottom - 5,
font, paint, SkTextUtils::kCenter_Align);
}
@ -682,7 +682,7 @@ protected:
path.reset();
SkFont font;
font.setSize(fTextSize);
SkTextUtils::GetPath(fText.c_str(), fText.size(), kUTF8_SkTextEncoding,
SkTextUtils::GetPath(fText.c_str(), fText.size(), SkTextEncoding::kUTF8,
0, fTextSize, font, &path);
setForText();
draw_stroke(canvas, path, width * fWidthScale / fTextSize, fTextSize, true);

View File

@ -61,14 +61,14 @@ static void drawFadingText(SkCanvas* canvas,
SkFontMetrics fm;
font.getMetrics(&fm);
bounds.set(x, y + fm.fTop, x + font.measureText(text, len, kUTF8_SkTextEncoding), y + fm.fBottom);
bounds.set(x, y + fm.fTop, x + font.measureText(text, len, SkTextEncoding::kUTF8), y + fm.fBottom);
// may need to outset bounds a little, to account for hinting and/or
// antialiasing
bounds.inset(-SkIntToScalar(2), -SkIntToScalar(2));
canvas->saveLayer(&bounds, nullptr);
canvas->drawSimpleText(text, len, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(text, len, SkTextEncoding::kUTF8, x, y, font, paint);
const SkPoint pts[] = {
{ bounds.fLeft, y },
@ -100,17 +100,18 @@ static void test_text(SkCanvas* canvas) {
SkScalar x = 20;
SkScalar y = 20;
canvas->drawSimpleText(str, len, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(str, len, SkTextEncoding::kUTF8, x, y, font, paint);
y += 20;
const SkPoint pts[] = { { x, y }, { x + font.measureText(str, len, kUTF8_SkTextEncoding), y } };
const SkPoint pts[] = { { x , y },
{ x + font.measureText(str, len, SkTextEncoding::kUTF8), y } };
const SkColor colors[] = { SK_ColorBLACK, SK_ColorBLACK, 0 };
const SkScalar pos[] = { 0, 0.9f, 1 };
paint.setShader(SkGradientShader::MakeLinear(pts, colors, pos,
SK_ARRAY_COUNT(colors),
SkTileMode::kClamp));
canvas->drawSimpleText(str, len, kUTF8_SkTextEncoding, x, y, font, paint);
canvas->drawSimpleText(str, len, SkTextEncoding::kUTF8, x, y, font, paint);
y += 20;
paint.setShader(nullptr);
@ -189,7 +190,7 @@ protected:
paint.setColor(hilite ? SK_ColorRED : 0x40FF0000);
SkFont font;
font.setSize(SkIntToScalar(20));
canvas->drawSimpleText(text, strlen(text), kUTF8_SkTextEncoding, loc.fX, loc.fY, font, paint);
canvas->drawSimpleText(text, strlen(text), SkTextEncoding::kUTF8, loc.fX, loc.fY, font, paint);
}
void drawPredicates(SkCanvas* canvas, const SkPoint pts[]) {
@ -316,7 +317,7 @@ protected:
canvas->translate(0, SkIntToScalar(200));
for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); op++) {
canvas->drawSimpleText(gOps[op].fName, strlen(gOps[op].fName), kUTF8_SkTextEncoding,
canvas->drawSimpleText(gOps[op].fName, strlen(gOps[op].fName), SkTextEncoding::kUTF8,
SkIntToScalar(75), SkIntToScalar(50), font, SkPaint());
this->drawRgnOped(canvas, gOps[op].fOp, gOps[op].fColor);

View File

@ -135,7 +135,7 @@ protected:
SkStrokeRec rec(SkStrokeRec::kFill_InitStyle);
SkPath path, dstPath;
SkTextUtils::GetPath(s.c_str(), s.size(), kUTF8_SkTextEncoding, x, y, font, &path);
SkTextUtils::GetPath(s.c_str(), s.size(), SkTextEncoding::kUTF8, x, y, font, &path);
pe->filterPath(&dstPath, path, &rec, nullptr);
SkPaint paint;

View File

@ -5225,7 +5225,7 @@ Draws <a href='#Text_Blob'>Text_Blob</a> <a href='#SkCanvas_drawTextBlob_blob'>b
and <a href='#Font_Subpixel'>Font_Subpixel</a>
.
<a href='#Paint_Text_Encoding'>Paint_Text_Encoding</a> must be set to <a href='undocumented#kGlyphID_SkTextEncoding'>kGlyphID_SkTextEncoding</a>.
<a href='#Paint_Text_Encoding'>Paint_Text_Encoding</a> must be set to <a href='undocumented#SkTextEncoding::kGlyphID'>SkTextEncoding::kGlyphID</a>.
Elements of <a href='#SkCanvas_drawTextBlob_paint'>paint</a>: <a href='#Paint_Anti_Alias'>Anti_Alias</a>, <a href='#Blend_Mode'>Blend_Mode</a>, <a href='SkColor_Reference#Color'>Color</a> including <a href='#Color_Alpha'>Color_Alpha</a>,
<a href='#Color_Filter'>Color_Filter</a>, <a href='#Paint_Dither'>Paint_Dither</a>, <a href='#Draw_Looper'>Draw_Looper</a>, <a href='#Mask_Filter'>Mask_Filter</a>, <a href='#Path_Effect'>Path_Effect</a>, <a href='undocumented#Shader'>Shader</a>, and
@ -5273,7 +5273,7 @@ Draws <a href='#Text_Blob'>Text_Blob</a> <a href='#SkCanvas_drawTextBlob_2_blob'
and <a href='#Font_Subpixel'>Font_Subpixel</a>
.
<a href='#Paint_Text_Encoding'>Paint_Text_Encoding</a> must be set to <a href='undocumented#kGlyphID_SkTextEncoding'>kGlyphID_SkTextEncoding</a>.
<a href='#Paint_Text_Encoding'>Paint_Text_Encoding</a> must be set to <a href='undocumented#SkTextEncoding::kGlyphID'>SkTextEncoding::kGlyphID</a>.
Elements of <a href='#SkCanvas_drawTextBlob_2_paint'>paint</a>: <a href='#Path_Effect'>Path_Effect</a>, <a href='#Mask_Filter'>Mask_Filter</a>, <a href='undocumented#Shader'>Shader</a>, <a href='#Color_Filter'>Color_Filter</a>,
<a href='#Image_Filter'>Image_Filter</a>, and <a href='#Draw_Looper'>Draw_Looper</a>; apply to <a href='#SkCanvas_drawTextBlob_2_blob'>blob</a>.

View File

@ -948,7 +948,7 @@ Does not check <a href='#SkFont_textToGlyphs_text'>text</a> for valid character
If <a href='#SkFont_textToGlyphs_byteLength'>byteLength</a> equals zero, returns zero.
If <a href='#SkFont_textToGlyphs_byteLength'>byteLength</a> includes a partial character, the partial character is ignored.
If <a href='#SkFont_textToGlyphs_encoding'>encoding</a> is <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a> and <a href='#SkFont_textToGlyphs_text'>text</a> contains an invalid UTF-8 sequence,
If <a href='#SkFont_textToGlyphs_encoding'>encoding</a> is <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a> and <a href='#SkFont_textToGlyphs_text'>text</a> contains an invalid UTF-8 sequence,
zero is returned.
If <a href='#SkFont_textToGlyphs_maxGlyphCount'>maxGlyphCount</a> is not sufficient to store all the <a href='#SkFont_textToGlyphs_glyphs'>glyphs</a>, no <a href='#SkFont_textToGlyphs_glyphs'>glyphs</a> are copied.
@ -963,11 +963,11 @@ The total <a href='undocumented#Glyph'>glyph</a> count is returned for subsequen
<td>length of character storage in bytes</td>
</tr>
<tr> <td><a name='SkFont_textToGlyphs_encoding'><code><strong>encoding</strong></code></a></td>
<td>one of: <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a>, <a href='undocumented#kUTF16_SkTextEncoding'>kUTF16_SkTextEncoding</a>,</td>
<td>one of: <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a>, <a href='undocumented#SkTextEncoding::kUTF16'>SkTextEncoding::kUTF16</a>,</td>
</tr>
</table>
<a href='undocumented#kUTF32_SkTextEncoding'>kUTF32_SkTextEncoding</a>, <a href='undocumented#kGlyphID_SkTextEncoding'>kGlyphID_SkTextEncoding</a>
<a href='undocumented#SkTextEncoding::kUTF32'>SkTextEncoding::kUTF32</a>, <a href='undocumented#SkTextEncoding::kGlyphID'>SkTextEncoding::kGlyphID</a>
### Parameters
@ -1039,11 +1039,11 @@ Returns number of <a href='undocumented#Glyph'>glyphs</a> represented by <a href
<td>length of character storage in bytes</td>
</tr>
<tr> <td><a name='SkFont_countText_encoding'><code><strong>encoding</strong></code></a></td>
<td>one of: <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a>, <a href='undocumented#kUTF16_SkTextEncoding'>kUTF16_SkTextEncoding</a>,</td>
<td>one of: <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a>, <a href='undocumented#SkTextEncoding::kUTF16'>SkTextEncoding::kUTF16</a>,</td>
</tr>
</table>
<a href='undocumented#kUTF32_SkTextEncoding'>kUTF32_SkTextEncoding</a>, <a href='undocumented#kGlyphID_SkTextEncoding'>kGlyphID_SkTextEncoding</a>
<a href='undocumented#SkTextEncoding::kUTF32'>SkTextEncoding::kUTF32</a>, <a href='undocumented#SkTextEncoding::kGlyphID'>SkTextEncoding::kGlyphID</a>
### Return Value
@ -1069,7 +1069,7 @@ Returns true if all <a href='#SkFont_containsText_text'>text</a> corresponds to
Returns false if any characters in <a href='#SkFont_containsText_text'>text</a> are not supported in
<a href='undocumented#SkTypeface'>SkTypeface</a>.
If <a href='undocumented#SkTextEncoding'>SkTextEncoding</a> is <a href='undocumented#kGlyphID_SkTextEncoding'>kGlyphID_SkTextEncoding</a>,
If <a href='undocumented#SkTextEncoding'>SkTextEncoding</a> is <a href='undocumented#SkTextEncoding::kGlyphID'>SkTextEncoding::kGlyphID</a>,
returns true if all <a href='undocumented#Glyph'>glyph</a> indices in <a href='#SkFont_containsText_text'>text</a> are non-zero;
does not check to see if <a href='#SkFont_containsText_text'>text</a> contains valid <a href='undocumented#Glyph'>glyph</a> indices for <a href='undocumented#SkTypeface'>SkTypeface</a>.
@ -1172,11 +1172,11 @@ Returns the bounding box of <a href='#SkFont_measureText_text'>text</a> if <a hr
<td>length of character storage in bytes</td>
</tr>
<tr> <td><a name='SkFont_measureText_encoding'><code><strong>encoding</strong></code></a></td>
<td>one of: <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a>, <a href='undocumented#kUTF16_SkTextEncoding'>kUTF16_SkTextEncoding</a>,</td>
<td>one of: <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a>, <a href='undocumented#SkTextEncoding::kUTF16'>SkTextEncoding::kUTF16</a>,</td>
</tr>
</table>
<a href='undocumented#kUTF32_SkTextEncoding'>kUTF32_SkTextEncoding</a>, <a href='undocumented#kGlyphID_SkTextEncoding'>kGlyphID_SkTextEncoding</a>
<a href='undocumented#SkTextEncoding::kUTF32'>SkTextEncoding::kUTF32</a>, <a href='undocumented#SkTextEncoding::kGlyphID'>SkTextEncoding::kGlyphID</a>
### Parameters

View File

@ -219,7 +219,7 @@ Constructs <a href='SkPaint_Reference#Paint'>Paint</a> with default values.
| <a href='#Path_Effect'>Path_Effect</a> | nullptr |
| <a href='undocumented#Shader'>Shader</a> | nullptr |
| <a href='#SkPaint_Style'>Style</a> | <a href='#SkPaint_kFill_Style'>kFill_Style</a> |
| <a href='#Text_Encoding'>Text_Encoding</a> | <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a> |
| <a href='#Text_Encoding'>Text_Encoding</a> | <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a> |
| <a href='undocumented#Typeface'>Typeface</a> | nullptr |
| <a href='#Paint_Stroke_Cap'>Stroke_Cap</a> | <a href='#SkPaint_kButt_Cap'>kButt_Cap</a> |
| <a href='#Paint_Stroke_Join'>Stroke_Join</a> | <a href='#SkPaint_kMiter_Join'>kMiter_Join</a> |
@ -3552,8 +3552,8 @@ the <a href='undocumented#Text'>text</a> encoding
#### Example Output
~~~~
kUTF8_SkTextEncoding == text encoding
kGlyphID_SkTextEncoding == text encoding
SkTextEncoding::kUTF8 == text encoding
SkTextEncoding::kGlyphID == text encoding
~~~~
</fiddle-embed></div>
@ -3680,7 +3680,7 @@ Does not check <a href='#SkPaint_textToGlyphs_text'>text</a> for valid character
If <a href='#SkPaint_textToGlyphs_byteLength'>byteLength</a> equals zero, returns zero.
If <a href='#SkPaint_textToGlyphs_byteLength'>byteLength</a> includes a partial character, the partial character is ignored.
If <a href='undocumented#SkTextEncoding'>SkTextEncoding</a> is <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a> and
If <a href='undocumented#SkTextEncoding'>SkTextEncoding</a> is <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a> and
<a href='#SkPaint_textToGlyphs_text'>text</a> contains an invalid UTF-8 sequence, zero is returned.
### Parameters
@ -3754,7 +3754,7 @@ Returns true if all <a href='#SkPaint_containsText_text'>text</a> corresponds to
Returns false if any characters in <a href='#SkPaint_containsText_text'>text</a> are not supported in
<a href='undocumented#SkTypeface'>SkTypeface</a>.
If <a href='undocumented#SkTextEncoding'>SkTextEncoding</a> is <a href='undocumented#kGlyphID_SkTextEncoding'>kGlyphID_SkTextEncoding</a>,
If <a href='undocumented#SkTextEncoding'>SkTextEncoding</a> is <a href='undocumented#SkTextEncoding::kGlyphID'>SkTextEncoding::kGlyphID</a>,
returns true if all <a href='undocumented#Glyph'>glyph</a> indices in <a href='#SkPaint_containsText_text'>text</a> are non-zero;
does not check to see if <a href='#SkPaint_containsText_text'>text</a> contains valid <a href='undocumented#Glyph'>glyph</a> indices for <a href='undocumented#SkTypeface'>SkTypeface</a>.
@ -3816,7 +3816,7 @@ void <a href='#SkPaint_glyphsToUnichars'>glyphsToUnichars</a>(const <a href='und
Converts <a href='#SkPaint_glyphsToUnichars_glyphs'>glyphs</a> into <a href='#SkPaint_glyphsToUnichars_text'>text</a> if possible.
<a href='undocumented#Glyph'>Glyph</a> values without direct Unicode equivalents are mapped to zero.
Uses the <a href='undocumented#SkTypeface'>SkTypeface</a>, but is unaffected
by <a href='undocumented#SkTextEncoding'>SkTextEncoding</a>; the <a href='#SkPaint_glyphsToUnichars_text'>text</a> values returned are equivalent to <a href='undocumented#kUTF32_SkTextEncoding'>kUTF32_SkTextEncoding</a>.
by <a href='undocumented#SkTextEncoding'>SkTextEncoding</a>; the <a href='#SkPaint_glyphsToUnichars_text'>text</a> values returned are equivalent to <a href='undocumented#SkTextEncoding::kUTF32'>SkTextEncoding::kUTF32</a>.
Only supported on platforms that use FreeType as the <a href='SkFont_Reference#Font_Engine'>font engine</a>.

View File

@ -14,9 +14,9 @@ class <a href='SkTextBlob_Reference#SkTextBlob'>SkTextBlob</a> final : public <a
int <a href='#SkTextBlob_getIntercepts'>getIntercepts</a>(const <a href='undocumented#SkScalar'>SkScalar</a> bounds[2], <a href='undocumented#SkScalar'>SkScalar</a> intervals[],
const <a href='SkPaint_Reference#SkPaint'>SkPaint</a>* <a href='SkPaint_Reference#Paint'>paint</a> = nullptr) const;
static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkTextBlob_Reference#SkTextBlob'>SkTextBlob</a>> <a href='#SkTextBlob_MakeFromText'>MakeFromText</a>(const void* <a href='undocumented#Text'>text</a>, size_t byteLength, const <a href='SkFont_Reference#SkFont'>SkFont</a>& <a href='SkFont_Reference#Font'>font</a>,
<a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding = <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a>);
<a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding = <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a>);
static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkTextBlob_Reference#SkTextBlob'>SkTextBlob</a>> <a href='#SkTextBlob_MakeFromString'>MakeFromString</a>(const char* <a href='undocumented#String'>string</a>, const <a href='SkFont_Reference#SkFont'>SkFont</a>& <a href='SkFont_Reference#Font'>font</a>,
<a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding = <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a>);
<a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding = <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a>);
size_t <a href='#SkTextBlob_serialize'>serialize</a>(const <a href='undocumented#SkSerialProcs'>SkSerialProcs</a>& procs, void* memory, size_t memory_size) const;
<a href='undocumented#sk_sp'>sk_sp</a><<a href='undocumented#SkData'>SkData</a>> <a href='#SkTextBlob_serialize'>serialize</a>(const <a href='undocumented#SkSerialProcs'>SkSerialProcs</a>& procs) const;
static <a href='undocumented#sk_sp'>sk_sp</a><<a href='SkTextBlob_Reference#SkTextBlob'>SkTextBlob</a>> <a href='#SkTextBlob_Deserialize'>Deserialize</a>(const void* <a href='undocumented#Data'>data</a>, size_t <a href='undocumented#Size'>size</a>,
@ -125,7 +125,7 @@ number of intersections; may be zero
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkTextBlob_Reference#SkTextBlob'>SkTextBlob</a>&gt; <a href='#SkTextBlob_MakeFromText'>MakeFromText</a>(const void* <a href='undocumented#Text'>text</a>, size_t byteLength, const <a href='SkFont_Reference#SkFont'>SkFont</a>& <a href='SkFont_Reference#Font'>font</a>,
<a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding = <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a>)
<a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding = <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a>)
</pre>
Creates <a href='#Text_Blob'>Text_Blob</a> with a single run. <a href='#SkTextBlob_MakeFromText_text'>text</a> meaning depends on <a href='#Text_Encoding'>Text_Encoding</a>;
@ -149,8 +149,8 @@ and <a href='#Font_Subpixel'>Font_Subpixel</a>
<td><a href='#SkTextBlob_MakeFromText_text'>text</a> <a href='undocumented#Size'>size</a>, <a href='undocumented#Typeface'>typeface</a>, <a href='#SkTextBlob_MakeFromText_text'>text scale</a>, and so on, used to draw</td>
</tr>
<tr> <td><a name='SkTextBlob_MakeFromText_encoding'><code><strong>encoding</strong></code></a></td>
<td>one of: <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a>, <a href='undocumented#kUTF16_SkTextEncoding'>kUTF16_SkTextEncoding</a>,
<a href='undocumented#kUTF32_SkTextEncoding'>kUTF32_SkTextEncoding</a>, <a href='undocumented#kGlyphID_SkTextEncoding'>kGlyphID_SkTextEncoding</a>
<td>one of: <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a>, <a href='undocumented#SkTextEncoding::kUTF16'>SkTextEncoding::kUTF16</a>,
<a href='undocumented#SkTextEncoding::kUTF32'>SkTextEncoding::kUTF32</a>, <a href='undocumented#SkTextEncoding::kGlyphID'>SkTextEncoding::kGlyphID</a>
</td>
</tr>
</table>
@ -173,7 +173,7 @@ and <a href='#Font_Subpixel'>Font_Subpixel</a>
<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
static <a href='undocumented#sk_sp'>sk_sp</a>&lt;<a href='SkTextBlob_Reference#SkTextBlob'>SkTextBlob</a>&gt; <a href='#SkTextBlob_MakeFromString'>MakeFromString</a>(const char* <a href='undocumented#String'>string</a>, const <a href='SkFont_Reference#SkFont'>SkFont</a>& <a href='SkFont_Reference#Font'>font</a>,
<a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding = <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a>)
<a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding = <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a>)
</pre>
Creates <a href='#Text_Blob'>Text_Blob</a> with a single run. <a href='#SkTextBlob_MakeFromString_string'>string</a> meaning depends on <a href='#Text_Encoding'>Text_Encoding</a>;
@ -194,8 +194,8 @@ and <a href='#Font_Subpixel'>Font_Subpixel</a>
<td><a href='undocumented#Text'>text</a> <a href='undocumented#Size'>size</a>, <a href='undocumented#Typeface'>typeface</a>, <a href='undocumented#Text'>text scale</a>, and so on, used to draw</td>
</tr>
<tr> <td><a name='SkTextBlob_MakeFromString_encoding'><code><strong>encoding</strong></code></a></td>
<td>one of: <a href='undocumented#kUTF8_SkTextEncoding'>kUTF8_SkTextEncoding</a>, <a href='undocumented#kUTF16_SkTextEncoding'>kUTF16_SkTextEncoding</a>,
<a href='undocumented#kUTF32_SkTextEncoding'>kUTF32_SkTextEncoding</a>, <a href='undocumented#kGlyphID_SkTextEncoding'>kGlyphID_SkTextEncoding</a>
<td>one of: <a href='undocumented#SkTextEncoding::kUTF8'>SkTextEncoding::kUTF8</a>, <a href='undocumented#SkTextEncoding::kUTF16'>SkTextEncoding::kUTF16</a>,
<a href='undocumented#SkTextEncoding::kUTF32'>SkTextEncoding::kUTF32</a>, <a href='undocumented#SkTextEncoding::kGlyphID'>SkTextEncoding::kGlyphID</a>
</td>
</tr>
</table>

View File

@ -1401,7 +1401,7 @@
"stdout": "[ 1.0000 0.0000 3.0000][ 0.0000 2.0000 4.0000][ 0.0000 0.0000 1.0000]\\n"
},
"SkPaint_containsText": {
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const uint16_t goodGlyph = 511;\n const uint16_t zeroGlyph = 0;\n const uint16_t badGlyph = 65535; // larger than glyph count in font\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n SkDebugf(\"0x%04x %c= has glyph\\n\", goodGlyph,\n paint.containsText(&goodGlyph, 2) ? '=' : '!');\n SkDebugf(\"0x%04x %c= has glyph\\n\", zeroGlyph,\n paint.containsText(&zeroGlyph, 2) ? '=' : '!');\n SkDebugf(\"0x%04x %c= has glyph\\n\", badGlyph,\n paint.containsText(&badGlyph, 2) ? '=' : '!');\n}",
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const uint16_t goodGlyph = 511;\n const uint16_t zeroGlyph = 0;\n const uint16_t badGlyph = 65535; // larger than glyph count in font\n paint.setTextEncoding(SkTextEncoding::kGlyphID);\n SkDebugf(\"0x%04x %c= has glyph\\n\", goodGlyph,\n paint.containsText(&goodGlyph, 2) ? '=' : '!');\n SkDebugf(\"0x%04x %c= has glyph\\n\", zeroGlyph,\n paint.containsText(&zeroGlyph, 2) ? '=' : '!');\n SkDebugf(\"0x%04x %c= has glyph\\n\", badGlyph,\n paint.containsText(&badGlyph, 2) ? '=' : '!');\n}",
"hash": "6a68cb3c8b81a5976c81ee004f559247",
"file": "SkPaint_Reference",
"name": "SkPaint::containsText",
@ -1576,11 +1576,11 @@
"stdout": "SkPaint::kFill_Style == paint.getStyle()\\n"
},
"SkPaint_getTextEncoding": {
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n SkDebugf(\"kUTF8_SkTextEncoding %c= text encoding\\n\",\n kUTF8_SkTextEncoding == paint.getTextEncoding() ? '=' : '!');\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n SkDebugf(\"kGlyphID_SkTextEncoding %c= text encoding\\n\",\n kGlyphID_SkTextEncoding == paint.getTextEncoding() ? '=' : '!');\n}",
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n SkDebugf(\"SkTextEncoding::kUTF8 %c= text encoding\\n\",\n SkTextEncoding::kUTF8 == paint.getTextEncoding() ? '=' : '!');\n paint.setTextEncoding(SkTextEncoding::kGlyphID);\n SkDebugf(\"SkTextEncoding::kGlyphID %c= text encoding\\n\",\n SkTextEncoding::kGlyphID == paint.getTextEncoding() ? '=' : '!');\n}",
"hash": "0d21e968e9a4c78c902ae3ef494941a0",
"file": "SkPaint_Reference",
"name": "SkPaint::getTextEncoding",
"stdout": "kUTF8_SkTextEncoding == text encoding\\nkGlyphID_SkTextEncoding == text encoding\\n"
"stdout": "SkTextEncoding::kUTF8 == text encoding\\nSkTextEncoding::kGlyphID == text encoding\\n"
},
"SkPaint_getTextScaleX": {
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n SkDebugf(\"1 %c= default text scale x\\n\", 1 == paint.getTextScaleX() ? '=' : '!');\n}",
@ -3564,7 +3564,7 @@
"stdout": "blob equals nullptr"
},
"SkTextBlobBuilder_make": {
"code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder builder;\n sk_sp<SkTextBlob> blob = builder.make();\n SkDebugf(\"blob \" \"%s\" \" nullptr\\n\", blob == nullptr ? \"equals\" : \"does not equal\");\n SkPaint paint;\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n SkFont font;\n paint.textToGlyphs(\"x\", 1, builder.allocRun(font, 1, 20, 20).glyphs);\n blob = builder.make();\n SkDebugf(\"blob \" \"%s\" \" nullptr\\n\", blob == nullptr ? \"equals\" : \"does not equal\");\n blob = builder.make();\n SkDebugf(\"blob \" \"%s\" \" nullptr\\n\", blob == nullptr ? \"equals\" : \"does not equal\");\n}",
"code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder builder;\n sk_sp<SkTextBlob> blob = builder.make();\n SkDebugf(\"blob \" \"%s\" \" nullptr\\n\", blob == nullptr ? \"equals\" : \"does not equal\");\n SkPaint paint;\n paint.setTextEncoding(SkTextEncoding::kGlyphID);\n SkFont font;\n paint.textToGlyphs(\"x\", 1, builder.allocRun(font, 1, 20, 20).glyphs);\n blob = builder.make();\n SkDebugf(\"blob \" \"%s\" \" nullptr\\n\", blob == nullptr ? \"equals\" : \"does not equal\");\n blob = builder.make();\n SkDebugf(\"blob \" \"%s\" \" nullptr\\n\", blob == nullptr ? \"equals\" : \"does not equal\");\n}",
"hash": "34c37c0212cc0aef670d96945d08fe24",
"file": "SkTextBlobBuilder_Reference",
"name": "SkTextBlobBuilder::make()",
@ -4245,7 +4245,7 @@
"name": "Stroke_Width"
},
"Paint_Text_Encoding": {
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const char hello8[] = \"Hello\" \"\\xE2\" \"\\x98\" \"\\xBA\";\n const uint16_t hello16[] = { 'H', 'e', 'l', 'l', 'o', 0x263A };\n const uint32_t hello32[] = { 'H', 'e', 'l', 'l', 'o', 0x263A };\n paint.setTextSize(24);\n canvas->drawText(hello8, sizeof(hello8) - 1, 10, 30, paint);\n paint.setTextEncoding(kUTF16_SkTextEncoding);\n canvas->drawText(hello16, sizeof(hello16), 10, 60, paint);\n paint.setTextEncoding(kUTF32_SkTextEncoding);\n canvas->drawText(hello32, sizeof(hello32), 10, 90, paint);\n uint16_t glyphs[SK_ARRAY_COUNT(hello32)];\n paint.textToGlyphs(hello32, sizeof(hello32), glyphs);\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n canvas->drawText(glyphs, sizeof(glyphs), 10, 120, paint);\n}\n",
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const char hello8[] = \"Hello\" \"\\xE2\" \"\\x98\" \"\\xBA\";\n const uint16_t hello16[] = { 'H', 'e', 'l', 'l', 'o', 0x263A };\n const uint32_t hello32[] = { 'H', 'e', 'l', 'l', 'o', 0x263A };\n paint.setTextSize(24);\n canvas->drawText(hello8, sizeof(hello8) - 1, 10, 30, paint);\n paint.setTextEncoding(SkTextEncoding::kUTF16);\n canvas->drawText(hello16, sizeof(hello16), 10, 60, paint);\n paint.setTextEncoding(SkTextEncoding::kUTF32);\n canvas->drawText(hello32, sizeof(hello32), 10, 90, paint);\n uint16_t glyphs[SK_ARRAY_COUNT(hello32)];\n paint.textToGlyphs(hello32, sizeof(hello32), glyphs);\n paint.setTextEncoding(SkTextEncoding::kGlyphID);\n canvas->drawText(glyphs, sizeof(glyphs), 10, 120, paint);\n}\n",
"width": 256,
"height": 128,
"hash": "767fa4e7b6300e16a419f9881f0f9d3d",
@ -5237,7 +5237,7 @@
"name": "SkCanvas::drawText"
},
"SkCanvas_drawTextBlob": {
"code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n SkFont font;\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 100 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n paint.setTextSize(1 == runLen ? 20 : 50);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n paint.reset();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n}\n",
"code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(SkTextEncoding::kGlyphID);\n SkFont font;\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 100 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n paint.setTextSize(1 == runLen ? 20 : 50);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n paint.reset();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n}\n",
"width": 256,
"height": 120,
"hash": "005502b502c1282cb8d306d6c8d998fb",
@ -7437,7 +7437,7 @@
"name": "SkPaint::getTextWidths"
},
"SkPaint_glyphsToUnichars": {
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const char hello[] = \"Hello!\";\n const int count = sizeof(hello) - 1;\n SkGlyphID glyphs[count];\n if (count != paint.textToGlyphs(hello, count, glyphs)) {\n return;\n }\n SkUnichar unichars[count];\n paint.glyphsToUnichars(glyphs, count, unichars);\n paint.setTextEncoding(kUTF32_SkTextEncoding);\n canvas->drawText(unichars, sizeof(unichars), 10, 30, paint);\n}\n",
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const char hello[] = \"Hello!\";\n const int count = sizeof(hello) - 1;\n SkGlyphID glyphs[count];\n if (count != paint.textToGlyphs(hello, count, glyphs)) {\n return;\n }\n SkUnichar unichars[count];\n paint.glyphsToUnichars(glyphs, count, unichars);\n paint.setTextEncoding(SkTextEncoding::kUTF32);\n canvas->drawText(unichars, sizeof(unichars), 10, 30, paint);\n}\n",
"width": 256,
"height": 64,
"hash": "79c550ec6c34054ab60fbcd1b81adc03",
@ -7541,7 +7541,7 @@
"name": "SkPaint::setTypeface"
},
"SkPaint_textToGlyphs": {
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const uint8_t utf8[] = { 0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0xC2, 0xA5, 0xC2, 0xA3 };\n std::vector<SkGlyphID> glyphs;\n int count = paint.textToGlyphs(utf8, sizeof(utf8), nullptr);\n glyphs.resize(count);\n (void) paint.textToGlyphs(utf8, sizeof(utf8), &glyphs.front());\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n paint.setTextSize(32);\n canvas->drawText(&glyphs.front(), glyphs.size() * sizeof(SkGlyphID), 10, 40, paint);\n}\n",
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const uint8_t utf8[] = { 0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0xC2, 0xA5, 0xC2, 0xA3 };\n std::vector<SkGlyphID> glyphs;\n int count = paint.textToGlyphs(utf8, sizeof(utf8), nullptr);\n glyphs.resize(count);\n (void) paint.textToGlyphs(utf8, sizeof(utf8), &glyphs.front());\n paint.setTextEncoding(SkTextEncoding::kGlyphID);\n paint.setTextSize(32);\n canvas->drawText(&glyphs.front(), glyphs.size() * sizeof(SkGlyphID), 10, 40, paint);\n}\n",
"width": 256,
"height": 64,
"hash": "d11136d8a74f63009da2a7f550710823",
@ -9333,7 +9333,7 @@
"name": "SkTextBlob::MakeFromText"
},
"SkTextBlob_bounds": {
"code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n SkFont font;\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 50 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n paint.setTextSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n paint.setStyle(SkPaint::kStroke_Style);\n canvas->drawRect(blob->bounds(), paint);\n}",
"code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(SkTextEncoding::kGlyphID);\n SkFont font;\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 50 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n paint.setTextSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n paint.setStyle(SkPaint::kStroke_Style);\n canvas->drawRect(blob->bounds(), paint);\n}",
"width": 256,
"height": 70,
"hash": "fb8b2502bbe52d2029aecdf569dd9fdb",
@ -9357,7 +9357,7 @@
"name": "SkTextBlob::serialize_2"
},
"SkTextBlob_uniqueID": {
"code": "void draw(SkCanvas* canvas) {\n for (int index = 0; index < 2; ++index) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n paint.setTextScaleX(0.5);\n SkFont font;\n font.setScaleX(0.5);\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 50 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n paint.setTextSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n paint.reset();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n std::string id = \"unique ID:\" + std::to_string(blob->uniqueID());\n canvas->drawString(id.c_str(), 30, blob->bounds().fBottom + 15, paint);\n canvas->translate(blob->bounds().fRight + 10, 0);\n }\n}",
"code": "void draw(SkCanvas* canvas) {\n for (int index = 0; index < 2; ++index) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(SkTextEncoding::kGlyphID);\n paint.setTextScaleX(0.5);\n SkFont font;\n font.setScaleX(0.5);\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 50 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n paint.setTextSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp<const SkTextBlob> blob = textBlobBuilder.make();\n paint.reset();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n std::string id = \"unique ID:\" + std::to_string(blob->uniqueID());\n canvas->drawString(id.c_str(), 30, blob->bounds().fBottom + 15, paint);\n canvas->translate(blob->bounds().fRight + 10, 0);\n }\n}",
"width": 256,
"height": 256,
"hash": "6e12cceca981ddabc0fc18c380543f34",

View File

@ -227,25 +227,25 @@ void <a href='#SkDrawable_draw'>draw</a>(<a href='SkCanvas_Reference#SkCanvas'>S
<th style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>Value</th>
<th style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>Description</th></tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='kUTF8_SkTextEncoding'><code>kUTF8_SkTextEncoding</code></a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkTextEncoding::kUTF8'><code>SkTextEncoding::kUTF8</code></a></td>
<td style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>0</td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
</td>
</tr>
<tr>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='kUTF16_SkTextEncoding'><code>kUTF16_SkTextEncoding</code></a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkTextEncoding::kUTF16'><code>SkTextEncoding::kUTF16</code></a></td>
<td style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>1</td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
</td>
</tr>
<tr style='background-color: #f0f0f0; '>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='kUTF32_SkTextEncoding'><code>kUTF32_SkTextEncoding</code></a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkTextEncoding::kUTF32'><code>SkTextEncoding::kUTF32</code></a></td>
<td style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>2</td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
</td>
</tr>
<tr>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='kGlyphID_SkTextEncoding'><code>kGlyphID_SkTextEncoding</code></a></td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '><a name='SkTextEncoding::kGlyphID'><code>SkTextEncoding::kGlyphID</code></a></td>
<td style='text-align: center; border: 2px solid #dddddd; padding: 8px; '>3</td>
<td style='text-align: left; border: 2px solid #dddddd; padding: 8px; '>
</td>

View File

@ -479,13 +479,13 @@ SkRect SkFontPriv::GetFontBounds(const SkFont& font) {
int SkFontPriv::CountTextElements(const void* text, size_t byteLength, SkTextEncoding encoding) {
switch (encoding) {
case kUTF8_SkTextEncoding:
case SkTextEncoding::kUTF8:
return SkUTF::CountUTF8(reinterpret_cast<const char*>(text), byteLength);
case kUTF16_SkTextEncoding:
case SkTextEncoding::kUTF16:
return SkUTF::CountUTF16(reinterpret_cast<const uint16_t*>(text), byteLength);
case kUTF32_SkTextEncoding:
case SkTextEncoding::kUTF32:
return byteLength >> 2;
case kGlyphID_SkTextEncoding:
case SkTextEncoding::kGlyphID:
return byteLength >> 1;
}
SkASSERT(false);

View File

@ -85,7 +85,7 @@ public:
class SkAutoToGlyphs {
public:
SkAutoToGlyphs(const SkFont& font, const void* text, size_t length, SkTextEncoding encoding) {
if (encoding == kGlyphID_SkTextEncoding || length == 0) {
if (encoding == SkTextEncoding::kGlyphID || length == 0) {
fGlyphs = reinterpret_cast<const uint16_t*>(text);
fCount = length >> 1;
} else {

View File

@ -162,7 +162,7 @@ SkSpan<const SkGlyphID> SkGlyphIDSet::uniquifyGlyphIDs(
// -- SkGlyphRunBuilder ----------------------------------------------------------------------------
void SkGlyphRunBuilder::drawTextUTF8(const SkPaint& paint, const SkFont& font, const void* bytes,
size_t byteLength, SkPoint origin) {
auto glyphIDs = textToGlyphIDs(font, bytes, byteLength, kUTF8_SkTextEncoding);
auto glyphIDs = textToGlyphIDs(font, bytes, byteLength, SkTextEncoding::kUTF8);
if (!glyphIDs.empty()) {
this->initialize(glyphIDs.size());
this->simplifyDrawText(font, glyphIDs, origin, fPositions);
@ -258,7 +258,7 @@ void SkGlyphRunBuilder::initialize(size_t totalRunSize) {
SkSpan<const SkGlyphID> SkGlyphRunBuilder::textToGlyphIDs(
const SkFont& font, const void* bytes, size_t byteLength, SkTextEncoding encoding) {
if (encoding != kGlyphID_SkTextEncoding) {
if (encoding != SkTextEncoding::kGlyphID) {
int count = font.countText(bytes, byteLength, encoding);
if (count > 0) {
fScratchGlyphIDs.resize(count);

View File

@ -262,7 +262,7 @@ SkRect SkTextBlobBuilder::TightRunBounds(const SkTextBlob::RunRecord& run) {
if (SkTextBlob::kDefault_Positioning == run.positioning()) {
font.measureText(run.glyphBuffer(), run.glyphCount() * sizeof(uint16_t),
kGlyphID_SkTextEncoding, &bounds);
SkTextEncoding::kGlyphID, &bounds);
return bounds.makeOffset(run.offset().x(), run.offset().y());
}

View File

@ -563,7 +563,7 @@ static int lcanvas_drawText(lua_State* L) {
size_t len;
const char* text = lua_tolstring(L, 2, &len);
get_ref<SkCanvas>(L, 1)->drawSimpleText(
text, len, kUTF8_SkTextEncoding,
text, len, SkTextEncoding::kUTF8,
lua2scalar(L, 3), lua2scalar(L, 4),
SkFont::LEGACY_ExtractFromPaint(*get_obj<SkPaint>(L, 5)),
*get_obj<SkPaint>(L, 5));
@ -977,7 +977,7 @@ static int lfont_measureText(lua_State* L) {
if (lua_isstring(L, 2)) {
size_t len;
const char* text = lua_tolstring(L, 2, &len);
SkLua(L).pushScalar(get_obj<SkFont>(L, 1)->measureText(text, len, kUTF8_SkTextEncoding));
SkLua(L).pushScalar(get_obj<SkFont>(L, 1)->measureText(text, len, SkTextEncoding::kUTF8));
return 1;
}
return 0;

View File

@ -50,17 +50,17 @@ private:
void AutoCallLua::pushEncodedText(SkTextEncoding enc, const void* text, size_t length) {
switch (enc) {
case kUTF8_SkTextEncoding:
case SkTextEncoding::kUTF8:
this->pushString((const char*)text, length, "text");
break;
case kUTF16_SkTextEncoding:
case SkTextEncoding::kUTF16:
this->pushString(SkStringFromUTF16((const uint16_t*)text, length), "text");
break;
case kGlyphID_SkTextEncoding:
case SkTextEncoding::kGlyphID:
this->pushArrayU16((const uint16_t*)text, SkToInt(length >> 1),
"glyphs");
break;
case kUTF32_SkTextEncoding:
case SkTextEncoding::kUTF32:
break;
}
}

View File

@ -1905,10 +1905,10 @@ HRESULT SkXPSDevice::AddGlyphs(IXpsOMObjectFactory* xpsFactory,
}
static int num_glyph_guess(SkTextEncoding encoding, const void* text, size_t byteLength) {
static_assert((int)SkTypeface::kUTF8_Encoding == (int)kUTF8_SkTextEncoding, "");
static_assert((int)SkTypeface::kUTF16_Encoding == (int)kUTF16_SkTextEncoding, "");
static_assert((int)SkTypeface::kUTF32_Encoding == (int)kUTF32_SkTextEncoding, "");
if (encoding == kGlyphID_SkTextEncoding) {
static_assert((int)SkTypeface::kUTF8_Encoding == (int)SkTextEncoding::kUTF8, "");
static_assert((int)SkTypeface::kUTF16_Encoding == (int)SkTextEncoding::kUTF16, "");
static_assert((int)SkTypeface::kUTF32_Encoding == (int)SkTextEncoding::kUTF32, "");
if (encoding == SkTextEncoding::kGlyphID) {
return SkToInt(byteLength / 2);
}
return SkUTFN_CountUnichars((SkTypeface::Encoding)encoding, text, byteLength);

View File

@ -229,7 +229,8 @@ static void test_advances(skiatest::Reporter* reporter) {
};
SkFont font;
char txt[] = "long.text.with.lots.of.dots.";
char const * const txt = "long.text.with.lots.of.dots.";
size_t textLen = strlen(txt);
for (size_t i = 0; i < SK_ARRAY_COUNT(faces); i++) {
font.setTypeface(SkTypeface::MakeFromName(faces[i], SkFontStyle()));
@ -247,10 +248,10 @@ static void test_advances(skiatest::Reporter* reporter) {
// For no hinting and light hinting this should take the
// optimized generateAdvance path.
SkScalar width1 = font.measureText(txt, strlen(txt), kUTF8_SkTextEncoding);
SkScalar width1 = font.measureText(txt, textLen, SkTextEncoding::kUTF8);
// Requesting the bounds forces a generateMetrics call.
SkScalar width2 = font.measureText(txt, strlen(txt), kUTF8_SkTextEncoding, &bounds);
SkScalar width2 = font.measureText(txt, textLen, SkTextEncoding::kUTF8, &bounds);
// SkDebugf("Font: %s, generateAdvance: %f, generateMetrics: %f\n",
// faces[i], SkScalarToFloat(width1), SkScalarToFloat(width2));

Some files were not shown because too many files have changed in this diff Show More