use font instead of paint for text
Bug: skia:
Change-Id: I508ecbd6c4dad41f67f5f2ce6da6c0065dacba6c
Reviewed-on: https://skia-review.googlesource.com/c/180365
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
diff --git a/samplecode/SampleComplexClip.cpp b/samplecode/SampleComplexClip.cpp
index fea5dd1..897b045 100644
--- a/samplecode/SampleComplexClip.cpp
+++ b/samplecode/SampleComplexClip.cpp
@@ -7,6 +7,7 @@
#include "Sample.h"
#include "SkCanvas.h"
+#include "SkFont.h"
#include "SkPath.h"
#include "SkClipOpPriv.h"
@@ -65,6 +66,9 @@
clipB.close();
SkColor colorB = SK_ColorRED;
+ SkFont font;
+ font.setSize(20);
+
SkPaint paint;
paint.setAntiAlias(true);
@@ -122,19 +126,17 @@
paint.setColor(colorB);
canvas->drawPath(clipB, paint);
- paint.setTextSize(SkIntToScalar(20));
-
SkScalar txtX = SkIntToScalar(55);
paint.setColor(colorA);
const char* aTxt = invA ? "InverseA " : "A ";
canvas->drawString(aTxt, txtX, SkIntToScalar(220), paint);
- txtX += paint.measureText(aTxt, strlen(aTxt));
+ txtX += font.measureText(aTxt, strlen(aTxt), kUTF8_SkTextEncoding);
paint.setColor(SK_ColorBLACK);
- canvas->drawString(gOps[op].fName,
- txtX, SkIntToScalar(220), paint);
- txtX += paint.measureText(gOps[op].fName, strlen(gOps[op].fName));
+ canvas->drawSimpleText(gOps[op].fName, strlen(gOps[op].fName), kUTF8_SkTextEncoding,
+ txtX, 220, font, paint);
+ txtX += font.measureText(gOps[op].fName, strlen(gOps[op].fName), kUTF8_SkTextEncoding);
paint.setColor(colorB);
- canvas->drawString("B", txtX, SkIntToScalar(220), paint);
+ canvas->drawSimpleText("B", 1, kUTF8_SkTextEncoding, txtX, 220, font, paint);
canvas->translate(SkIntToScalar(250),0);
}