42#define kDefault_Size SkPaintDefaults_TextSize
43#define kDefault_Flags SkFont::kBaselineSnap_PrivFlag
44#define kDefault_Edging SkFont::Edging::kAntiAlias
45#define kDefault_Hinting SkPaintDefaults_Hinting
48 return std::max<SkScalar>(0,
size);
52 : fTypeface(
std::move(face))
71 return fTypeface.
get() ==
b.fTypeface.get() &&
73 fScaleX ==
b.fScaleX &&
76 fEdging ==
b.fEdging &&
77 fHinting ==
b.fHinting;
86 SkDebugf(
"edging %u\n", (
unsigned)fEdging);
87 SkDebugf(
"hinting %u\n", (
unsigned)fHinting);
91 fTypeface = std::move(tf);
100 return cond ?
bits | mask :
bits & ~mask;
104 fFlags =
set_clear_mask(fFlags, predicate, kForceAutoHinting_PrivFlag);
107 fFlags =
set_clear_mask(fFlags, predicate, kEmbeddedBitmaps_PrivFlag);
113 fFlags =
set_clear_mask(fFlags, predicate, kLinearMetrics_PrivFlag);
119 fFlags =
set_clear_mask(fFlags, predicate, kBaselineSnap_PrivFlag);
141 font.setSize(newSize);
148 constexpr uint32_t flagsToIgnore = kEmbeddedBitmaps_PrivFlag |
149 kForceAutoHinting_PrivFlag;
151 fFlags = (fFlags & ~flagsToIgnore) | kSubpixel_PrivFlag;
160 paint->setPathEffect(
nullptr);
167bool SkFont::hasSomeAntiAliasing()
const {
191 const int glyphCount = atg.
count();
192 if (glyphCount == 0) {
208 for (
int i = 1;
i < glyphCount; ++
i) {
215 for (
auto glyph :
glyphs) {
216 width += glyph->advanceX();
220 if (strikeToSourceScale != 1) {
221 width *= strikeToSourceScale;
223 bounds->fLeft *= strikeToSourceScale;
224 bounds->fTop *= strikeToSourceScale;
225 bounds->fRight *= strikeToSourceScale;
226 bounds->fBottom *= strikeToSourceScale;
245 for (
auto glyph :
glyphs) {
252 for (
auto glyph :
glyphs) {
253 *cursor++ = glyph->advanceX() * strikeToSourceScale;
264 for (
auto glyph :
glyphs) {
266 sum += glyph->advanceVector() * strikeToSourceScale;
279 for (
auto glyph :
glyphs) {
281 loc += glyph->advanceX() * strikeToSourceScale;
286 void (*proc)(
const SkPath*,
const SkMatrix&,
void*),
void* ctx)
const {
295 for (
auto glyph :
glyphs) {
296 proc(glyph->path(), mx, ctx);
304 } pair = {
path,
false };
307 Pair* pair =
static_cast<Pair*
>(ctx);
310 pair->fWasSet =
true;
321 if (
nullptr == metrics) {
325 auto cache = strikeSpec.findOrCreateStrike();
326 *metrics =
cache->getFontMetrics();
328 if (strikeToSourceScale != 1) {
356 m.setScale(
font.getSize() *
font.getScaleX(),
font.getSize());
357 m.postSkew(
font.getSkewX(), 0);
368 if (!
matrix.hasPerspective()) {
376 return -
font.getSize();
388 return byteLength >> 2;
390 return byteLength >> 1;
402 auto typeface =
font.getTypeface();
403 const unsigned numGlyphsInTypeface = typeface->countGlyphs();
405 typeface->getGlyphToUnicodeMap(unichars.
get());
409 text[
i] = (
id < numGlyphsInTypeface) ? unichars[
id] : 0xFFFD;
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static bool SkIsFinite(T x, Pack... values)
@ kNone
glyph outlines unchanged
@ kUTF8
uses bytes to represent UTF-8 or ASCII
@ kUTF16
uses two byte words to represent most of Unicode
@ kUTF32
uses four byte words to represent all of Unicode
@ kGlyphID
uses two byte words to represent glyph indices
static SkScalar valid_size(SkScalar size)
static uint32_t set_clear_mask(uint32_t bits, bool cond, uint32_t mask)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
constexpr uint8_t SkToU8(S x)
const uint16_t * glyphs() const
static int CountTextElements(const void *text, size_t byteLength, SkTextEncoding)
static void ScaleFontMetrics(SkFontMetrics *, SkScalar)
static SkScalar ApproximateTransformedTextSize(const SkFont &font, const SkMatrix &matrix, const SkPoint &textLocation)
static constexpr int kCanonicalTextSizeForPaths
static void GlyphsToUnichars(const SkFont &, const uint16_t glyphs[], int count, SkUnichar[])
static SkRect GetFontBounds(const SkFont &)
void setSubpixel(bool subpixel)
void getXPos(const SkGlyphID glyphs[], int count, SkScalar xpos[], SkScalar origin=0) const
bool getPath(SkGlyphID glyphID, SkPath *path) const
void setScaleX(SkScalar scaleX)
bool operator==(const SkFont &font) const
void setLinearMetrics(bool linearMetrics)
SkTypeface * getTypeface() const
void setTypeface(sk_sp< SkTypeface > tf)
SkScalar measureText(const void *text, size_t byteLength, SkTextEncoding encoding, SkRect *bounds=nullptr) const
void setBaselineSnap(bool baselineSnap)
void getPos(const SkGlyphID glyphs[], int count, SkPoint pos[], SkPoint origin={0, 0}) const
void setEdging(Edging edging)
void setSize(SkScalar textSize)
void getPaths(const SkGlyphID glyphIDs[], int count, void(*glyphPathProc)(const SkPath *pathOrNull, const SkMatrix &mx, void *ctx), void *ctx) const
void setSkewX(SkScalar skewX)
void setForceAutoHinting(bool forceAutoHinting)
SkGlyphID unicharToGlyph(SkUnichar uni) const
SkScalar getMetrics(SkFontMetrics *metrics) const
int textToGlyphs(const void *text, size_t byteLength, SkTextEncoding encoding, SkGlyphID glyphs[], int maxGlyphCount) const
void unicharsToGlyphs(const SkUnichar uni[], int count, SkGlyphID glyphs[]) const
SkFont makeWithSize(SkScalar size) const
void setHinting(SkFontHinting hintingLevel)
@ kAntiAlias
may have transparent pixels on glyph edges
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
void setEmbolden(bool embolden)
void setEmbeddedBitmaps(bool embeddedBitmaps)
void getWidthsBounds(const SkGlyphID glyphs[], int count, SkScalar widths[], SkRect bounds[], const SkPaint *paint) const
static SkScalar DifferentialAreaScale(const SkMatrix &m, const SkPoint &p)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
void mapRectScaleTranslate(SkRect *dst, const SkRect &src) const
@ kFill_Style
set to fill geometry
void transform(const SkMatrix &matrix, SkPath *dst, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
static SkStrikeSpec MakeWithNoDevice(const SkFont &font, const SkPaint *paint=nullptr)
static std::tuple< SkStrikeSpec, SkScalar > MakeCanonicalized(const SkFont &font, const SkPaint *paint=nullptr)
int textToGlyphs(const void *text, size_t byteLength, SkTextEncoding encoding, SkGlyphID glyphs[], int maxGlyphCount) const
static sk_sp< SkTypeface > MakeEmpty()
SkGlyphID unicharToGlyph(SkUnichar unichar) const
void unicharsToGlyphs(const SkUnichar uni[], int count, SkGlyphID glyphs[]) const
unsigned useCenter Optional< SkMatrix > matrix
Optional< SkRect > bounds
SK_SPI int CountUTF16(const uint16_t *utf16, size_t byteLength)
SK_SPI int CountUTF8(const char *utf8, size_t byteLength)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
font
Font Metadata and Metrics.
SkScalar fTop
greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable ...
SkScalar fLeading
distance to add between lines, typically positive or zero
SkScalar fAvgCharWidth
average character width, zero if unknown
SkScalar fStrikeoutPosition
distance from baseline to bottom of stroke, typically negative
SkScalar fStrikeoutThickness
strikeout thickness
SkScalar fMaxCharWidth
maximum character width, zero if unknown
SkScalar fBottom
greatest extent below origin of any glyph bounding box, typically positive; deprecated with variable ...
SkScalar fAscent
distance to reserve above baseline, typically negative
SkScalar fXHeight
height of lower-case 'x', zero if unknown, typically negative
SkScalar fUnderlineThickness
underline thickness
SkScalar fDescent
distance to reserve below baseline, typically positive
SkScalar fCapHeight
height of an upper-case letter, zero if unknown, typically negative
SkScalar fXMin
greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with vari...
SkScalar fUnderlinePosition
distance from baseline to top of stroke, typically positive
SkScalar fXMax
greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with var...
void offset(float dx, float dy)