Flutter Engine
The Flutter Engine
|
#include <SkFont.h>
Public Types | |
enum class | Edging { kAlias , kAntiAlias , kSubpixelAntiAlias } |
using | sk_is_trivially_relocatable = std::true_type |
Public Member Functions | |
SkFont () | |
SkFont (sk_sp< SkTypeface > typeface, SkScalar size) | |
SkFont (sk_sp< SkTypeface > typeface) | |
SkFont (sk_sp< SkTypeface > typeface, SkScalar size, SkScalar scaleX, SkScalar skewX) | |
bool | operator== (const SkFont &font) const |
bool | operator!= (const SkFont &font) const |
bool | isForceAutoHinting () const |
bool | isEmbeddedBitmaps () const |
bool | isSubpixel () const |
bool | isLinearMetrics () const |
bool | isEmbolden () const |
bool | isBaselineSnap () const |
void | setForceAutoHinting (bool forceAutoHinting) |
void | setEmbeddedBitmaps (bool embeddedBitmaps) |
void | setSubpixel (bool subpixel) |
void | setLinearMetrics (bool linearMetrics) |
void | setEmbolden (bool embolden) |
void | setBaselineSnap (bool baselineSnap) |
Edging | getEdging () const |
void | setEdging (Edging edging) |
void | setHinting (SkFontHinting hintingLevel) |
SkFontHinting | getHinting () const |
SkFont | makeWithSize (SkScalar size) const |
SkTypeface * | getTypeface () const |
SkScalar | getSize () const |
SkScalar | getScaleX () const |
SkScalar | getSkewX () const |
sk_sp< SkTypeface > | refTypeface () const |
void | setTypeface (sk_sp< SkTypeface > tf) |
void | setSize (SkScalar textSize) |
void | setScaleX (SkScalar scaleX) |
void | setSkewX (SkScalar skewX) |
int | textToGlyphs (const void *text, size_t byteLength, SkTextEncoding encoding, SkGlyphID glyphs[], int maxGlyphCount) const |
SkGlyphID | unicharToGlyph (SkUnichar uni) const |
void | unicharsToGlyphs (const SkUnichar uni[], int count, SkGlyphID glyphs[]) const |
int | countText (const void *text, size_t byteLength, SkTextEncoding encoding) const |
SkScalar | measureText (const void *text, size_t byteLength, SkTextEncoding encoding, SkRect *bounds=nullptr) const |
SkScalar | measureText (const void *text, size_t byteLength, SkTextEncoding encoding, SkRect *bounds, const SkPaint *paint) const |
void | getWidths (const SkGlyphID glyphs[], int count, SkScalar widths[], SkRect bounds[]) const |
void | getWidths (const SkGlyphID glyphs[], int count, SkScalar widths[], std::nullptr_t) const |
void | getWidths (const SkGlyphID glyphs[], int count, SkScalar widths[]) const |
void | getWidthsBounds (const SkGlyphID glyphs[], int count, SkScalar widths[], SkRect bounds[], const SkPaint *paint) const |
void | getBounds (const SkGlyphID glyphs[], int count, SkRect bounds[], const SkPaint *paint) const |
void | getPos (const SkGlyphID glyphs[], int count, SkPoint pos[], SkPoint origin={0, 0}) const |
void | getXPos (const SkGlyphID glyphs[], int count, SkScalar xpos[], SkScalar origin=0) const |
std::vector< SkScalar > | getIntercepts (const SkGlyphID glyphs[], int count, const SkPoint pos[], SkScalar top, SkScalar bottom, const SkPaint *=nullptr) const |
bool | getPath (SkGlyphID glyphID, SkPath *path) const |
void | getPaths (const SkGlyphID glyphIDs[], int count, void(*glyphPathProc)(const SkPath *pathOrNull, const SkMatrix &mx, void *ctx), void *ctx) const |
SkScalar | getMetrics (SkFontMetrics *metrics) const |
SkScalar | getSpacing () const |
void | dump () const |
Friends | |
class | SkFontPriv |
class | SkGlyphRunListPainterCPU |
class | SkStrikeSpec |
class | SkRemoteGlyphCacheTest |
SkFont controls options applied when drawing and measuring text.
using SkFont::sk_is_trivially_relocatable = std::true_type |
|
strong |
Whether edge pixels draw opaque or with partial transparency.
Enumerator | |
---|---|
kAlias | no transparent pixels on glyph edges |
kAntiAlias | may have transparent pixels on glyph edges |
kSubpixelAntiAlias | glyph positioned in pixel using transparency |
Definition at line 39 of file SkFont.h.
SkFont::SkFont | ( | ) |
Constructs SkFont with default values.
Definition at line 68 of file SkFont.cpp.
SkFont::SkFont | ( | sk_sp< SkTypeface > | typeface, |
SkScalar | size | ||
) |
Constructs SkFont with default values with SkTypeface and size in points.
typeface | font and style used to draw and measure text |
size | typographic height of text |
Definition at line 64 of file SkFont.cpp.
|
explicit |
Constructs SkFont with default values with SkTypeface.
typeface | font and style used to draw and measure text |
Definition at line 66 of file SkFont.cpp.
SkFont::SkFont | ( | sk_sp< SkTypeface > | typeface, |
SkScalar | size, | ||
SkScalar | scaleX, | ||
SkScalar | skewX | ||
) |
Constructs SkFont with default values with SkTypeface and size in points, horizontal scale, and horizontal skew. Horizontal scale emulates condensed and expanded fonts. Horizontal skew emulates oblique fonts.
typeface | font and style used to draw and measure text |
size | typographic height of text |
scaleX | text horizontal scale |
skewX | additional shear on x-axis relative to y-axis |
Definition at line 51 of file SkFont.cpp.
|
inline |
Returns number of glyphs represented by text.
If encoding is SkTextEncoding::kUTF8, SkTextEncoding::kUTF16, or SkTextEncoding::kUTF32; then each Unicode codepoint is mapped to a single glyph.
text | character storage encoded with SkTextEncoding |
byteLength | length of character storage in bytes |
Definition at line 323 of file SkFont.h.
void SkFont::dump | ( | ) | const |
Dumps fields of the font to SkDebugf. May change its output over time, so clients should not rely on this for anything specific. Used to aid in debugging.
Definition at line 80 of file SkFont.cpp.
|
inline |
Retrieves the bounds for each glyph in glyphs. bounds must be an array of count entries. If paint is not nullptr, its stroking, SkPathEffect, and SkMaskFilter fields are respected.
glyphs | array of glyph indices to be measured |
count | number of glyphs |
bounds | returns bounds for each glyph relative to (0, 0); may be nullptr |
paint | optional, specifies stroking, SkPathEffect, and SkMaskFilter |
Definition at line 412 of file SkFont.h.
|
inline |
|
inline |
std::vector< SkScalar > SkFont::getIntercepts | ( | const SkGlyphID | glyphs[], |
int | count, | ||
const SkPoint | pos[], | ||
SkScalar | top, | ||
SkScalar | bottom, | ||
const SkPaint * | paintPtr = nullptr |
||
) | const |
Returns intervals [start, end] describing lines parallel to the advance that intersect with the glyphs.
glyphs | the glyphs to intersect |
count | the number of glyphs and positions |
pos | the position of each glyph |
top | the top of the line intersecting |
bottom | the bottom of the line intersecting |
Definition at line 950 of file SkTextBlob.cpp.
SkScalar SkFont::getMetrics | ( | SkFontMetrics * | metrics | ) | const |
Returns SkFontMetrics associated with SkTypeface. The return value is the recommended spacing between lines: the sum of metrics descent, ascent, and leading. If metrics is not nullptr, SkFontMetrics is copied to metrics. Results are scaled by text size but does not take into account dimensions required by text scale, text skew, fake bold, style stroke, and SkPathEffect.
metrics | storage for SkFontMetrics; may be nullptr |
Definition at line 316 of file SkFont.cpp.
Modifies path to be the outline of the glyph. If the glyph has an outline, modifies path to be the glyph's outline and returns true. The glyph outline may be empty. Degenerate contours in the glyph outline will be skipped. If glyph is described by a bitmap, returns false and ignores path parameter.
glyphID | index of glyph |
path | pointer to existing SkPath |
Definition at line 300 of file SkFont.cpp.
void SkFont::getPaths | ( | const SkGlyphID | glyphIDs[], |
int | count, | ||
void(*)(const SkPath *pathOrNull, const SkMatrix &mx, void *ctx) | glyphPathProc, | ||
void * | ctx | ||
) | const |
Returns path corresponding to glyph array.
glyphIDs | array of glyph indices |
count | number of glyphs |
glyphPathProc | function returning one glyph description as path |
ctx | function context |
Definition at line 285 of file SkFont.cpp.
void SkFont::getPos | ( | const SkGlyphID | glyphs[], |
int | count, | ||
SkPoint | pos[], | ||
SkPoint | origin = {0, 0} |
||
) | const |
Retrieves the positions for each glyph, beginning at the specified origin. The caller must allocated at least count number of elements in the pos[] array.
glyphs | array of glyph indices to be positioned |
count | number of glyphs |
pos | returns glyphs positions |
origin | location of the first glyph. Defaults to {0, 0}. |
Definition at line 258 of file SkFont.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
Returns the recommended spacing between lines: the sum of metrics descent, ascent, and leading. Result is scaled by text size but does not take into account dimensions required by stroking and SkPathEffect. Returns the same result as getMetrics().
Definition at line 494 of file SkFont.h.
|
inline |
Does not alter SkTypeface SkRefCnt.
Retrieves the advance and bounds for each glyph in glyphs. Both widths and bounds may be nullptr. If widths is not nullptr, widths must be an array of count entries. if bounds is not nullptr, bounds must be an array of count entries.
glyphs | array of glyph indices to be measured |
count | number of glyphs |
widths | returns text advances for each glyph |
Definition at line 384 of file SkFont.h.
|
inline |
DEPRECATED Retrieves the advance and bounds for each glyph in glyphs. Both widths and bounds may be nullptr. If widths is not nullptr, widths must be an array of count entries. if bounds is not nullptr, bounds must be an array of count entries.
glyphs | array of glyph indices to be measured |
count | number of glyphs |
widths | returns text advances for each glyph; may be nullptr |
bounds | returns bounds for each glyph relative to (0, 0); may be nullptr |
|
inline |
Definition at line 371 of file SkFont.h.
void SkFont::getWidthsBounds | ( | const SkGlyphID | glyphs[], |
int | count, | ||
SkScalar | widths[], | ||
SkRect | bounds[], | ||
const SkPaint * | paint | ||
) | const |
Retrieves the advance and bounds for each glyph in glyphs. Both widths and bounds may be nullptr. If widths is not nullptr, widths must be an array of count entries. if bounds is not nullptr, bounds must be an array of count entries.
glyphs | array of glyph indices to be measured |
count | number of glyphs |
widths | returns text advances for each glyph; may be nullptr |
bounds | returns bounds for each glyph relative to (0, 0); may be nullptr |
paint | optional, specifies stroking, SkPathEffect and SkMaskFilter |
Definition at line 233 of file SkFont.cpp.
void SkFont::getXPos | ( | const SkGlyphID | glyphs[], |
int | count, | ||
SkScalar | xpos[], | ||
SkScalar | origin = 0 |
||
) | const |
Retrieves the x-positions for each glyph, beginning at the specified origin. The caller must allocated at least count number of elements in the xpos[] array.
glyphs | array of glyph indices to be positioned |
count | number of glyphs |
xpos | returns glyphs x-positions |
origin | x-position of the first glyph. Defaults to 0. |
Definition at line 270 of file SkFont.cpp.
|
inline |
Returns true if baselines will be snapped to pixel positions when the current transformation matrix is axis aligned.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Returns a font with the same attributes of this font, but with the specified size. Returns nullptr if size is less than zero, infinite, or NaN.
size | typographic height of text |
Definition at line 139 of file SkFont.cpp.
SkScalar SkFont::measureText | ( | const void * | text, |
size_t | byteLength, | ||
SkTextEncoding | encoding, | ||
SkRect * | bounds, | ||
const SkPaint * | paint | ||
) | const |
Returns the advance width of text. The advance is the normal distance to move before drawing additional text. Returns the bounding box of text if bounds is not nullptr. The paint stroke settings, mask filter, or path effect may modify the bounds.
text | character storage encoded with SkTextEncoding |
byteLength | length of character storage in bytes |
bounds | returns bounding box relative to (0, 0) if not nullptr |
paint | optional; may be nullptr |
Definition at line 187 of file SkFont.cpp.
|
inline |
Returns the advance width of text. The advance is the normal distance to move before drawing additional text. Returns the bounding box of text if bounds is not nullptr.
text | character storage encoded with SkTextEncoding |
byteLength | length of character storage in bytes |
bounds | returns bounding box relative to (0, 0) if not nullptr |
Definition at line 336 of file SkFont.h.
|
inline |
bool SkFont::operator== | ( | const SkFont & | font | ) | const |
Compares SkFont and font, and returns true if they are equivalent. May return false if SkTypeface has identical contents but different pointers.
font | font to compare |
Definition at line 70 of file SkFont.cpp.
|
inline |
Increases SkTypeface SkRefCnt by one.
void SkFont::setBaselineSnap | ( | bool | baselineSnap | ) |
Requests that baselines be snapped to pixels when the current transformation matrix is axis aligned.
baselineSnap | setting for baseline snapping to pixels |
Definition at line 118 of file SkFont.cpp.
void SkFont::setEdging | ( | Edging | edging | ) |
Requests, but does not require, that edge pixels draw opaque or with partial transparency.
Definition at line 121 of file SkFont.cpp.
void SkFont::setEmbeddedBitmaps | ( | bool | embeddedBitmaps | ) |
Requests, but does not require, to use bitmaps in fonts instead of outlines.
embeddedBitmaps | setting to use bitmaps in fonts |
Definition at line 106 of file SkFont.cpp.
void SkFont::setEmbolden | ( | bool | embolden | ) |
Increases stroke width when creating glyph bitmaps to approximate a bold typeface.
embolden | setting for bold approximation |
Definition at line 115 of file SkFont.cpp.
void SkFont::setForceAutoHinting | ( | bool | forceAutoHinting | ) |
Sets whether to always hint glyphs. If forceAutoHinting is set, instructs the font manager to always hint glyphs.
Only affects platforms that use FreeType as the font manager.
forceAutoHinting | setting to always hint glyphs |
Definition at line 103 of file SkFont.cpp.
void SkFont::setHinting | ( | SkFontHinting | hintingLevel | ) |
Sets level of glyph outline adjustment. Does not check for valid values of hintingLevel.
Definition at line 125 of file SkFont.cpp.
void SkFont::setLinearMetrics | ( | bool | linearMetrics | ) |
Requests, but does not require, linearly scalable font and glyph metrics.
For outline fonts 'true' means font and glyph metrics should ignore hinting and rounding. Note that some bitmap formats may not be able to scale linearly and will ignore this flag.
linearMetrics | setting for linearly scalable font and glyph metrics. |
Definition at line 112 of file SkFont.cpp.
void SkFont::setScaleX | ( | SkScalar | scaleX | ) |
Sets text scale on x-axis. Default value is 1.
scaleX | text horizontal scale |
Definition at line 132 of file SkFont.cpp.
void SkFont::setSize | ( | SkScalar | textSize | ) |
Sets text size in points. Has no effect if textSize is not greater than or equal to zero.
textSize | typographic height of text |
Definition at line 129 of file SkFont.cpp.
void SkFont::setSkewX | ( | SkScalar | skewX | ) |
Sets text skew on x-axis. Default value is zero.
skewX | additional shear on x-axis relative to y-axis |
Definition at line 135 of file SkFont.cpp.
void SkFont::setSubpixel | ( | bool | subpixel | ) |
Requests, but does not require, that glyphs respect sub-pixel positioning.
subpixel | setting for sub-pixel positioning |
Definition at line 109 of file SkFont.cpp.
void SkFont::setTypeface | ( | sk_sp< SkTypeface > | tf | ) |
Sets SkTypeface to typeface, decreasing SkRefCnt of the previous SkTypeface. Pass nullptr to clear SkTypeface and use an empty typeface (which draws nothing). Increments tf SkRefCnt by one.
tf | font and style used to draw text |
Definition at line 90 of file SkFont.cpp.
int SkFont::textToGlyphs | ( | const void * | text, |
size_t | byteLength, | ||
SkTextEncoding | encoding, | ||
SkGlyphID | glyphs[], | ||
int | maxGlyphCount | ||
) | const |
Converts text into glyph indices. Returns the number of glyph indices represented by text. SkTextEncoding specifies how text represents characters or glyphs. glyphs may be nullptr, to compute the glyph count.
Does not check text for valid character codes or valid glyph indices.
If byteLength equals zero, returns zero. If byteLength includes a partial character, the partial character is ignored.
If encoding is SkTextEncoding::kUTF8 and text contains an invalid UTF-8 sequence, zero is returned.
When encoding is SkTextEncoding::kUTF8, SkTextEncoding::kUTF16, or SkTextEncoding::kUTF32; then each Unicode codepoint is mapped to a single glyph. This function uses the default character-to-glyph mapping from the SkTypeface and maps characters not found in the SkTypeface to zero.
If maxGlyphCount is not sufficient to store all the glyphs, no glyphs are copied. The total glyph count is returned for subsequent buffer reallocation.
text | character storage encoded with SkTextEncoding |
byteLength | length of character storage in bytes |
glyphs | storage for glyph indices; may be nullptr |
maxGlyphCount | storage capacity |
Definition at line 181 of file SkFont.cpp.
Definition at line 177 of file SkFont.cpp.
Returns glyph index for Unicode character.
If the character is not supported by the SkTypeface, returns 0.
uni | Unicode character |
Definition at line 173 of file SkFont.cpp.
|
friend |
|
friend |
|
friend |
|
friend |