Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
mac_aa_explorer.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkFont.h"
#include "include/core/SkFontStyle.h"
#include "include/core/SkFontTypes.h"
#include "include/core/SkPaint.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "tools/fonts/FontToolUtils.h"
#include <string.h>
#include <initializer_list>

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (macaa_colors, canvas, 800, 500)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( macaa_colors  ,
canvas  ,
800  ,
500   
)

Definition at line 136 of file mac_aa_explorer.cpp.

136 {
137 const SkColor GRAY = 0xFF808080;
138 const SkColor colors[] = {
140 SK_ColorBLACK, GRAY,
142 SK_ColorWHITE, GRAY,
143 };
144 const SkScalar sizes[] = {10, 12, 15, 18, 24};
145
146 const SkScalar width = 200;
147 const SkScalar height = 500;
148 const char str[] = "Hamburgefons";
149 const size_t len = strlen(str);
150
152 if (!face) {
154 }
155 SkFont font(face, 12);
156
157 for (size_t i = 0; i < std::size(colors); i += 2) {
158 canvas->save();
159
161 paint.setColor(colors[i+1]);
162 canvas->drawRect({0, 0, width, height}, paint);
163 paint.setColor(colors[i]);
164
165 SkScalar y = 10;
166 SkScalar x = 10;
167 for (SkScalar ps : sizes) {
168 font.setSize(ps);
169 for (bool lcd : {false, true}) {
171 : SkFont::Edging::kAntiAlias);
173 font.setHinting(h);
174
175 y += font.getSpacing() + 2;
176 canvas->drawSimpleText(str, len, SkTextEncoding::kUTF8, x, y, font, paint);
177 }
178 }
179 y += 8;
180 }
181 canvas->restore();
182 canvas->translate(width, 0);
183 }
184}
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
@ kNormal
glyph outlines modified to improve constrast
@ kNone
glyph outlines unchanged
@ kUTF8
uses bytes to represent UTF-8 or ASCII
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
const Paint & paint
float SkScalar
Definition extension.cpp:12
double y
double x
PODArray< SkColor > colors
Definition SkRecords.h:276
sk_sp< SkTypeface > DefaultPortableTypeface()
sk_sp< SkTypeface > CreateTestTypeface(const char *name, SkFontStyle style)
@ kAntiAlias
Definition layer.h:52
font
Font Metadata and Metrics.
SkScalar h
int32_t height
int32_t width