40 for (
int i = 0; i <
count; ++i) {
48 SkScalar scale = font.getSize() / font.getTypeface()->getUnitsPerEm();
51 for (
int i = 0; i <
count - 1; ++i) {
52 globalAdj += adjustments[i] *
scale;
53 pos[i + 1].
fX += globalAdj;
73 int32_t* adjustments = adjustmentStorage.
get();
81 auto rec = builder.allocRunPos(font, glyphCount);
84 applyKerning(rec.points(), adjustments, glyphCount, font);
116 name.append(
"_kerning");
128 const char*
text = fApplyKerning ?
"Type AWAY" :
"Hamburgefons";
129 const size_t textLen = strlen(
text);
132 SkScalar dy = font.getMetrics(
nullptr);
137 font.setSubpixel(
true);
139 font.setLinearMetrics(
true);
145 font.setTypeface(fFaces[i]);
167 }
constexpr aliasTypes[] {
168#ifndef SK_BUILD_FOR_IOS
196 constexpr SkScalar textSizes[] = { 9, 10, 11, 12, 13, 14, 15, 16 };
205 struct SubpixelType {
208 }
constexpr subpixelTypes[] = {
209 {
false, { 0.00, 0.00 } },
210 {
true , { 0.00, 0.00 } },
211 {
true , { 0.25, 0.00 } },
212 {
true , { 0.25, 0.25 } },
215 constexpr bool rotateABitTypes[] = {
false,
true };
222 font.setEmbeddedBitmaps(
true);
227 for (
const SubpixelType subpixel : subpixelTypes) {
229 font.setSubpixel(subpixel.requested);
231 for (
const AliasType& alias : aliasTypes) {
232 font.setEdging(alias.edging);
238 for (
const SkScalar& textSize : textSizes) {
240 font.setSize(textSize);
245 font.setHinting(hinting);
247 for (
const bool& rotateABit : rotateABitTypes) {
250 canvas->
rotate(2,
x + subpixel.offset.x(),
251 y + subpixel.offset.y());
254 x + subpixel.offset.x(),
255 y + subpixel.offset.y(), font,
paint);
260 xMax = std::max(
x, xMax);
270 constexpr struct StyleTests {
280 constexpr bool fakeBoldTypes[] = {
false,
true };
288 for (
const bool& fakeBold : fakeBoldTypes) {
293 font.setEmbolden(fakeBold);
294 for (
const AliasType& alias : aliasTypes) {
295 font.setEdging(alias.edging);
300 for (
const StyleTests& style : styleTypes) {
301 paint.setStyle(style.style);
302 paint.setStrokeWidth(style.strokeWidth);
315 constexpr struct MaskTests {
342 for (
const AliasType& alias : aliasTypes) {
347 font.setEdging(alias.edging);
352 for (
const MaskTests& mask : maskTypes) {
361 paint.setMaskFilter(
nullptr);
381#ifndef SK_BUILD_FOR_WIN
414 uint16_t
glyphs[1] = { font.unicharToGlyph(
'A') };
424 paint.setStyle(style);
427 font.setEmbolden(
true);
431 font.setEmbolden(
false);
449 for (
auto r : recs) {
450 draw(r.style, r.width);
static const int strokeWidth
@ kOuter_SkBlurStyle
nothing inside, fuzzy outside
@ kSolid_SkBlurStyle
solid inside, fuzzy outside
@ kInner_SkBlurStyle
fuzzy inside, nothing outside
@ kNormal_SkBlurStyle
fuzzy inside and outside
constexpr SkColor SK_ColorYELLOW
@ kNormal
glyph outlines modified to improve constrast
@ kNone
glyph outlines unchanged
@ kSlight
minimal modification to improve constrast
@ kFull
modifies glyph outlines for maximum constrast
@ kUTF8
uses bytes to represent UTF-8 or ASCII
@ kGlyphID
uses two byte words to represent glyph indices
#define SkScalarCeilToScalar(x)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
int saveLayer(const SkRect *bounds, const SkPaint *paint)
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint positions[], const uint32_t clusters[], int textByteCount, const char utf8text[], SkPoint origin, const SkFont &font, const SkPaint &paint)
void rotate(SkScalar degrees)
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
static constexpr SkFontStyle Italic()
static constexpr SkFontStyle BoldItalic()
static constexpr SkFontStyle Bold()
static constexpr SkFontStyle Normal()
@ kAntiAlias
may have transparent pixels on glyph edges
@ kAlias
no transparent pixels on glyph edges
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
@ kStroke_Style
set to stroke geometry
@ kFill_Style
set to fill geometry
@ kStrokeAndFill_Style
sets to stroke and fill geometry
bool getKerningPairAdjustments(const SkGlyphID glyphs[], int count, int32_t adjustments[]) const
void onOnceBeforeDraw() override
SkISize getISize() override
void onDraw(SkCanvas *canvas) override
SkString getName() const override
TypefaceStylesGM(bool applyKerning)
#define DEF_SIMPLE_GM_CAN_FAIL(NAME, CANVAS, ERR_MSG, W, H)
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
static constexpr SkISize Make(int32_t w, int32_t h)
void set(float x, float y)
static void draw_typeface_rendering_gm(SkCanvas *canvas, sk_sp< SkTypeface > face, SkGlyphID glyph)
static void applyKerning(SkPoint pos[], const int32_t adjustments[], int count, const SkFont &font)
static void getGlyphPositions(const SkFont &font, const uint16_t glyphs[], int count, SkScalar x, SkScalar y, SkPoint pos[])
constexpr int gStylesCount
static void drawKernText(SkCanvas *canvas, const void *text, size_t len, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
static constexpr SkFontStyle gStyles[]