1SkPaint Reference 2=== 3 4# <a name="Paint"></a> Paint 5 6## <a name="Overview"></a> Overview 7 8## <a name="Overview_Subtopic"></a> Overview Subtopic 9 10| name | description | 11| --- | --- | 12| <a href="#Class_or_Struct">Class or Struct</a> | embedded struct and class members | 13| <a href="#Constant">Constant</a> | enum and enum class, const values | 14| <a href="#Constructor">Constructor</a> | functions that construct <a href="#SkPaint">SkPaint</a> | 15| <a href="#Member_Function">Member Function</a> | static functions and member methods | 16| <a href="#Operator">Operator</a> | operator overloading methods | 17| <a href="#Related_Function">Related Function</a> | similar methods grouped together | 18 19# <a name="SkPaint"></a> Class SkPaint 20<a href="#Paint">Paint</a> controls options applied when drawing and measuring. <a href="#Paint">Paint</a> collects all 21options outside of the <a href="SkCanvas_Reference#Clip">Canvas Clip</a> and <a href="SkCanvas_Reference#Matrix">Canvas Matrix</a>. 22 23Various options apply to text, strokes and fills, and images. 24 25Some options may not be implemented on all platforms; in these cases, setting 26the option has no effect. Some options are conveniences that duplicate <a href="SkCanvas_Reference#Canvas">Canvas</a> 27functionality; for instance, text size is identical to matrix scale. 28 29<a href="#Paint">Paint</a> options are rarely exclusive; each option modifies a stage of the drawing 30pipeline and multiple pipeline stages may be affected by a single <a href="#Paint">Paint</a>. 31 32<a href="#Paint">Paint</a> collects effects and filters that describe single-pass and multiple-pass 33algorithms that alter the drawing geometry, color, and transparency. For instance, 34<a href="#Paint">Paint</a> does not directly implement dashing or blur, but contains the objects that do so. 35 36The objects contained by <a href="#Paint">Paint</a> are opaque, and cannot be edited outside of the <a href="#Paint">Paint</a> 37to affect it. The implementation is free to defer computations associated with the 38<a href="#Paint">Paint</a>, or ignore them altogether. For instance, some GPU implementations draw all 39<a href="SkPath_Reference#Path">Path</a> geometries with Anti-aliasing, regardless of how <a href="#SkPaint_kAntiAlias_Flag">SkPaint::kAntiAlias Flag</a> 40is set in <a href="#Paint">Paint</a>. 41 42<a href="#Paint">Paint</a> describes a single color, a single font, a single image quality, and so on. 43Multiple colors are drawn either by using multiple paints or with objects like 44<a href="undocumented#Shader">Shader</a> attached to <a href="#Paint">Paint</a>. 45 46## <a name="Related_Function"></a> Related Function 47 48| name | description | 49| --- | --- | 50| <a href="#Alpha_Methods">Alpha Methods</a> | get and set <a href="undocumented#Alpha">Alpha</a> | 51| Anti-alias | approximating coverage with transparency | 52| <a href="#Automatic_Hinting">Automatic Hinting</a> | always adjust glyph paths | 53| <a href="#Blend_Mode_Methods">Blend Mode Methods</a> | get and set <a href="undocumented#Blend_Mode">Blend Mode</a> | 54| <a href="#Color_Filter_Methods">Color Filter Methods</a> | get and set <a href="undocumented#Color_Filter">Color Filter</a> | 55| <a href="#Color_Methods">Color Methods</a> | get and set <a href="undocumented#Color">Color</a> | 56| <a href="#Device_Text">Device Text</a> | increase precision of glyph position | 57| <a href="#Dither">Dither</a> | distributing color error | 58| <a href="#Draw_Looper_Methods">Draw Looper Methods</a> | get and set <a href="undocumented#Draw_Looper">Draw Looper</a> | 59| <a href="#Fake_Bold">Fake Bold</a> | approximate font styles | 60| <a href="#Fast_Bounds">Fast Bounds</a> | approximate area required by <a href="#Paint">Paint</a> | 61| <a href="#Fill_Path">Fill Path</a> | make <a href="SkPath_Reference#Path">Path</a> from <a href="undocumented#Path_Effect">Path Effect</a>, stroking | 62| <a href="#Filter_Quality_Methods">Filter Quality Methods</a> | get and set <a href="undocumented#Filter_Quality">Filter Quality</a> | 63| <a href="#SkPaint_Flags">Flags</a> | attributes represented by single bits | 64| <a href="#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> | custom sized bitmap <a href="undocumented#Glyph">Glyphs</a> | 65| <a href="#Font_Metrics">Font Metrics</a> | common glyph dimensions | 66| <a href="#Full_Hinting_Spacing">Full Hinting Spacing</a> | glyph spacing affected by hinting | 67| <a href="#SkPaint_Hinting">Hinting</a> | glyph outline adjustment | 68| <a href="#Image_Filter_Methods">Image Filter Methods</a> | get and set <a href="undocumented#Image_Filter">Image Filter</a> | 69| <a href="#Initializers">Initializers</a> | constructors and initialization | 70| <a href="#LCD_Text">LCD Text</a> | text relying on the order of <a href="undocumented#RGB">Color RGB</a> stripes | 71| <a href="#Linear_Text">Linear Text</a> | selects text rendering as <a href="undocumented#Glyph">Glyph</a> or <a href="SkPath_Reference#Path">Path</a> | 72| <a href="#Management">Management</a> | paint copying, moving, comparing | 73| <a href="#Mask_Filter_Methods">Mask Filter Methods</a> | get and set <a href="undocumented#Mask_Filter">Mask Filter</a> | 74| <a href="#Measure_Text">Measure Text</a> | width, height, bounds of text | 75| <a href="#Miter_Limit">Miter Limit</a> | maximum length of stroked corners | 76| <a href="#Path_Effect_Methods">Path Effect Methods</a> | get and set <a href="undocumented#Path_Effect">Path Effect</a> | 77| <a href="#Shader_Methods">Shader Methods</a> | get and set <a href="undocumented#Shader">Shader</a> | 78| <a href="#Stroke_Cap">Stroke Cap</a> | decorations at ends of open strokes | 79| <a href="#Stroke_Join">Stroke Join</a> | decoration at corners of strokes | 80| <a href="#Stroke_Width">Stroke Width</a> | thickness perpendicular to geometry | 81| <a href="#SkPaint_Style">Style</a> | geometry filling, stroking | 82| <a href="#Style_Fill">Style Fill</a> | fill and stroke | 83| <a href="#Style_Hairline">Style Hairline</a> | lines and curves with minimal width | 84| <a href="#Style_Stroke">Style Stroke</a> | lines and curves with width | 85| <a href="#Subpixel_Text">Subpixel Text</a> | uses pixel transparency to represent fractional offset | 86| <a href="#Text_Align">Text Align</a> | text placement relative to position | 87| <a href="#Text_Encoding">Text Encoding</a> | text encoded as characters or <a href="undocumented#Glyph">Glyphs</a> | 88| <a href="#Text_Intercepts">Text Intercepts</a> | advanced underline, strike through | 89| <a href="#Text_Path">Text Path</a> | geometry of <a href="undocumented#Glyph">Glyphs</a> | 90| <a href="#Text_Scale_X">Text Scale X</a> | text horizontal scale | 91| <a href="#Text_Size">Text Size</a> | overall height in points | 92| <a href="#Text_Skew_X">Text Skew X</a> | text horizontal slant | 93| <a href="#Typeface_Methods">Typeface Methods</a> | get and set <a href="undocumented#Typeface">Typeface</a> | 94| <a href="#Utility">Utility</a> | rarely called management functions | 95| <a href="#Vertical_Text">Vertical Text</a> | orient text from top to bottom | 96 97## <a name="Constant"></a> Constant 98 99| name | description | 100| --- | --- | 101| <a href="#SkPaint_Align">Align</a> | glyph locations relative to text position | 102| <a href="#SkPaint_Cap">Cap</a> | start and end geometry on stroked shapes | 103| <a href="#SkPaint_Flags">Flags</a> | values described by bits and masks | 104| <a href="#SkPaint_Hinting">Hinting</a> | level of glyph outline adjustment | 105| <a href="#SkPaint_Join">Join</a> | corner geometry on stroked shapes | 106| <a href="#SkPaint_Style">Style</a> | stroke, fill, or both | 107| <a href="#SkPaint_TextEncoding">TextEncoding</a> | character or glyph encoded size | 108| _anonymous | number of <a href="#SkPaint_Style">Style</a> defines | 109| _anonymous_2 | number of <a href="#Text_Align">Text Align</a> values | 110 111## <a name="Class_or_Struct"></a> Class or Struct 112 113| name | description | 114| --- | --- | 115| <a href="#SkPaint_FontMetrics">FontMetrics</a> | values computed by <a href="undocumented#Font_Manager">Font Manager</a> using <a href="undocumented#Typeface">Typeface</a> | 116 117## <a name="Constructor"></a> Constructor 118 119| name | description | 120| --- | --- | 121| <a href="#SkPaint_empty_constructor">SkPaint()</a> | constructs with default values | 122| <a href="#SkPaint_move_SkPaint">SkPaint(SkPaint&& paint)</a> | moves paint without copying it | 123| <a href="#SkPaint_copy_const_SkPaint">SkPaint(const SkPaint& paint)</a> | makes a shallow copy | 124| <a href="#SkPaint_destructor">~SkPaint()</a> | decreases <a href="undocumented#Reference_Count">Reference Count</a> of owned objects | 125 126## <a name="Operator"></a> Operator 127 128| name | description | 129| --- | --- | 130| <a href="#SkPaint_notequal_operator">operator!=(const SkPaint& a, const SkPaint& b)</a> | compares paints for inequality | 131| <a href="#SkPaint_move_operator">operator=(SkPaint&& paint)</a> | moves paint without copying it | 132| <a href="#SkPaint_copy_operator">operator=(const SkPaint& paint)</a> | makes a shallow copy | 133| <a href="#SkPaint_equal_operator">operator==(const SkPaint& a, const SkPaint& b)</a> | compares paints for equality | 134 135## <a name="Member_Function"></a> Member Function 136 137| name | description | 138| --- | --- | 139| <a href="#SkPaint_breakText">breakText</a> | returns text that fits in a width | 140| <a href="#SkPaint_canComputeFastBounds">canComputeFastBounds</a> | returns true if settings allow for fast bounds computation | 141| <a href="#SkPaint_computeFastBounds">computeFastBounds</a> | returns fill bounds for quick reject tests | 142| <a href="#SkPaint_computeFastStrokeBounds">computeFastStrokeBounds</a> | returns stroke bounds for quick reject tests | 143| <a href="#SkPaint_containsText">containsText</a> | returns if all text corresponds to <a href="undocumented#Glyph">Glyphs</a> | 144| <a href="#SkPaint_countText">countText</a> | returns number of <a href="undocumented#Glyph">Glyphs</a> in text | 145| <a href="#SkPaint_doComputeFastBounds">doComputeFastBounds</a> | returns bounds for quick reject tests | 146| <a href="#SkPaint_flatten">flatten</a> | serializes into a buffer | 147| <a href="#SkPaint_getAlpha">getAlpha</a> | returns <a href="undocumented#Alpha">Color Alpha</a>, color opacity | 148| <a href="#SkPaint_getBlendMode">getBlendMode</a> | returns <a href="undocumented#Blend_Mode">Blend Mode</a>, how colors combine with <a href="undocumented#Device">Device</a> | 149| <a href="#SkPaint_getColor">getColor</a> | returns <a href="undocumented#Alpha">Color Alpha</a> and <a href="undocumented#RGB">Color RGB</a>, one drawing color | 150| <a href="#SkPaint_getColorFilter">getColorFilter</a> | returns <a href="undocumented#Color_Filter">Color Filter</a>, how colors are altered | 151| <a href="#SkPaint_getDrawLooper">getDrawLooper</a> | returns <a href="undocumented#Draw_Looper">Draw Looper</a>, multiple layers | 152| <a href="#SkPaint_getFillPath">getFillPath</a> | returns fill path equivalent to stroke | 153| <a href="#SkPaint_getFilterQuality">getFilterQuality</a> | returns <a href="undocumented#Filter_Quality">Filter Quality</a>, image filtering level | 154| <a href="#SkPaint_getFlags">getFlags</a> | returns <a href="#SkPaint_Flags">Flags</a> stored in a bit field | 155| <a href="#SkPaint_getFontBounds">getFontBounds</a> | returns union all glyph bounds | 156| <a href="#SkPaint_getFontMetrics">getFontMetrics</a> | returns <a href="undocumented#Typeface">Typeface</a> metrics scaled by text size | 157| <a href="#SkPaint_getFontSpacing">getFontSpacing</a> | returns recommended spacing between lines | 158| <a href="#SkPaint_getHash">getHash</a> | returns a shallow hash for equality checks | 159| <a href="#SkPaint_getHinting">getHinting</a> | returns <a href="#SkPaint_Hinting">Hinting</a>, glyph outline adjustment level | 160| <a href="#SkPaint_getImageFilter">getImageFilter</a> | returns <a href="undocumented#Image_Filter">Image Filter</a>, alter pixels; blur | 161| <a href="#SkPaint_getMaskFilter">getMaskFilter</a> | returns <a href="undocumented#Mask_Filter">Mask Filter</a>, alterations to <a href="undocumented#Mask_Alpha">Mask Alpha</a> | 162| <a href="#SkPaint_getPathEffect">getPathEffect</a> | returns <a href="undocumented#Path_Effect">Path Effect</a>, modifications to path geometry; dashing | 163| <a href="#SkPaint_getPosTextHIntercepts">getPosTextHIntercepts</a> | returns where lines intersect horizontally positioned text; underlines | 164| <a href="#SkPaint_getPosTextIntercepts">getPosTextIntercepts</a> | returns where lines intersect positioned text; underlines | 165| <a href="#SkPaint_getPosTextPath">getPosTextPath</a> | returns <a href="SkPath_Reference#Path">Path</a> equivalent to positioned text | 166| <a href="#SkPaint_getShader">getShader</a> | returns <a href="undocumented#Shader">Shader</a>, multiple drawing colors; gradients | 167| <a href="#SkPaint_getStrokeCap">getStrokeCap</a> | returns <a href="#SkPaint_Cap">Cap</a>, the area drawn at path ends | 168| <a href="#SkPaint_getStrokeJoin">getStrokeJoin</a> | returns <a href="#SkPaint_Join">Join</a>, geometry on path corners | 169| <a href="#SkPaint_getStrokeMiter">getStrokeMiter</a> | returns <a href="#Miter_Limit">Miter Limit</a>, angles with sharp corners | 170| <a href="#SkPaint_getStrokeWidth">getStrokeWidth</a> | returns thickness of the stroke | 171| <a href="#SkPaint_getStyle">getStyle</a> | returns <a href="#SkPaint_Style">Style</a>: stroke, fill, or both | 172| <a href="#SkPaint_getTextAlign">getTextAlign</a> | returns <a href="#SkPaint_Align">Align</a>: left, center, or right | 173| <a href="#SkPaint_getTextBlobIntercepts">getTextBlobIntercepts</a> | returns where lines intersect <a href="undocumented#Text_Blob">Text Blob</a>; underlines | 174| <a href="#SkPaint_getTextEncoding">getTextEncoding</a> | returns character or glyph encoded size | 175| <a href="#SkPaint_getTextIntercepts">getTextIntercepts</a> | returns where lines intersect text; underlines | 176| <a href="#SkPaint_getTextPath">getTextPath</a> | returns <a href="SkPath_Reference#Path">Path</a> equivalent to text | 177| <a href="#SkPaint_getTextScaleX">getTextScaleX</a> | returns the text horizontal scale; condensed text | 178| <a href="#SkPaint_getTextSize">getTextSize</a> | returns text size in points | 179| <a href="#SkPaint_getTextSkewX">getTextSkewX</a> | returns the text horizontal skew; oblique text | 180| <a href="#SkPaint_getTextWidths">getTextWidths</a> | returns advance and bounds for each glyph in text | 181| <a href="#SkPaint_getTypeface">getTypeface</a> | returns <a href="undocumented#Typeface">Typeface</a>, font description | 182| <a href="#SkPaint_glyphsToUnichars">glyphsToUnichars</a> | converts <a href="undocumented#Glyph">Glyphs</a> into text | 183| <a href="#SkPaint_isAntiAlias">isAntiAlias</a> | returns true if Anti-alias is set | 184| <a href="#SkPaint_isAutohinted">isAutohinted</a> | returns true if <a href="undocumented#Glyph">Glyphs</a> are always hinted | 185| <a href="#SkPaint_isDevKernText">isDevKernText</a> | returns true if <a href="#Full_Hinting_Spacing">Full Hinting Spacing</a> is set | 186| <a href="#SkPaint_isDither">isDither</a> | returns true if <a href="#Dither">Dither</a> is set | 187| <a href="#SkPaint_isEmbeddedBitmapText">isEmbeddedBitmapText</a> | returns true if <a href="#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> is set | 188| <a href="#SkPaint_isFakeBoldText">isFakeBoldText</a> | returns true if <a href="#Fake_Bold">Fake Bold</a> is set | 189| <a href="#SkPaint_isLCDRenderText">isLCDRenderText</a> | returns true if <a href="#LCD_Text">LCD Text</a> is set | 190| <a href="#SkPaint_isLinearText">isLinearText</a> | returns true if text is converted to <a href="SkPath_Reference#Path">Path</a> | 191| <a href="#SkPaint_isSrcOver">isSrcOver</a> | returns true if <a href="undocumented#Blend_Mode">Blend Mode</a> is <a href="undocumented#SkBlendMode_kSrcOver">SkBlendMode::kSrcOver</a> | 192| <a href="#SkPaint_isSubpixelText">isSubpixelText</a> | returns true if <a href="#Subpixel_Text">Subpixel Text</a> is set | 193| <a href="#SkPaint_isVerticalText">isVerticalText</a> | returns true if <a href="#Vertical_Text">Vertical Text</a> is set | 194| <a href="#SkPaint_measureText">measureText</a> | returns advance width and bounds of text | 195| <a href="#SkPaint_nothingToDraw">nothingToDraw</a> | returns true if <a href="#Paint">Paint</a> prevents all drawing | 196| <a href="#SkPaint_refColorFilter">refColorFilter</a> | references <a href="undocumented#Color_Filter">Color Filter</a>, how colors are altered | 197| <a href="#SkPaint_refDrawLooper">refDrawLooper</a> | references <a href="undocumented#Draw_Looper">Draw Looper</a>, multiple layers | 198| <a href="#SkPaint_refImageFilter">refImageFilter</a> | references <a href="undocumented#Image_Filter">Image Filter</a>, alter pixels; blur | 199| <a href="#SkPaint_refMaskFilter">refMaskFilter</a> | references <a href="undocumented#Mask_Filter">Mask Filter</a>, alterations to <a href="undocumented#Mask_Alpha">Mask Alpha</a> | 200| <a href="#SkPaint_refPathEffect">refPathEffect</a> | references <a href="undocumented#Path_Effect">Path Effect</a>, modifications to path geometry; dashing | 201| <a href="#SkPaint_refShader">refShader</a> | references <a href="undocumented#Shader">Shader</a>, multiple drawing colors; gradients | 202| <a href="#SkPaint_refTypeface">refTypeface</a> | references <a href="undocumented#Typeface">Typeface</a>, font description | 203| <a href="#SkPaint_reset">reset</a> | sets to default values | 204| <a href="#SkPaint_setARGB">setARGB</a> | sets color by component | 205| <a href="#SkPaint_setAlpha">setAlpha</a> | sets <a href="undocumented#Alpha">Color Alpha</a>, color opacity | 206| <a href="#SkPaint_setAntiAlias">setAntiAlias</a> | sets or clears Anti-alias | 207| <a href="#SkPaint_setAutohinted">setAutohinted</a> | sets <a href="undocumented#Glyph">Glyphs</a> to always be hinted | 208| <a href="#SkPaint_setBlendMode">setBlendMode</a> | sets <a href="undocumented#Blend_Mode">Blend Mode</a>, how colors combine with destination | 209| <a href="#SkPaint_setColor">setColor</a> | sets <a href="undocumented#Alpha">Color Alpha</a> and <a href="undocumented#RGB">Color RGB</a>, one drawing color | 210| <a href="#SkPaint_setColorFilter">setColorFilter</a> | sets <a href="undocumented#Color_Filter">Color Filter</a>, alters color | 211| <a href="#SkPaint_setDevKernText">setDevKernText</a> | sets or clears <a href="#Full_Hinting_Spacing">Full Hinting Spacing</a> | 212| <a href="#SkPaint_setDither">setDither</a> | sets or clears <a href="#Dither">Dither</a> | 213| <a href="#SkPaint_setDrawLooper">setDrawLooper</a> | sets <a href="undocumented#Draw_Looper">Draw Looper</a>, multiple layers | 214| <a href="#SkPaint_setEmbeddedBitmapText">setEmbeddedBitmapText</a> | sets or clears <a href="#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> | 215| <a href="#SkPaint_setFakeBoldText">setFakeBoldText</a> | sets or clears <a href="#Fake_Bold">Fake Bold</a> | 216| <a href="#SkPaint_setFilterQuality">setFilterQuality</a> | sets <a href="undocumented#Filter_Quality">Filter Quality</a>, the image filtering level | 217| <a href="#SkPaint_setFlags">setFlags</a> | sets multiple <a href="#SkPaint_Flags">Flags</a> in a bit field | 218| <a href="#SkPaint_setHinting">setHinting</a> | sets <a href="#SkPaint_Hinting">Hinting</a>, glyph outline adjustment level | 219| <a href="#SkPaint_setImageFilter">setImageFilter</a> | sets <a href="undocumented#Image_Filter">Image Filter</a>, alter pixels; blur | 220| <a href="#SkPaint_setLCDRenderText">setLCDRenderText</a> | sets or clears <a href="#LCD_Text">LCD Text</a> | 221| <a href="#SkPaint_setLinearText">setLinearText</a> | converts to <a href="SkPath_Reference#Path">Path</a> before draw or measure | 222| <a href="#SkPaint_setMaskFilter">setMaskFilter</a> | sets <a href="undocumented#Mask_Filter">Mask Filter</a>, alterations to <a href="undocumented#Mask_Alpha">Mask Alpha</a> | 223| <a href="#SkPaint_setPathEffect">setPathEffect</a> | sets <a href="undocumented#Path_Effect">Path Effect</a>, modifications to path geometry; dashing | 224| <a href="#SkPaint_setShader">setShader</a> | sets <a href="undocumented#Shader">Shader</a>, multiple drawing colors; gradients | 225| <a href="#SkPaint_setStrokeCap">setStrokeCap</a> | sets <a href="#SkPaint_Cap">Cap</a>, the area drawn at path ends | 226| <a href="#SkPaint_setStrokeJoin">setStrokeJoin</a> | sets <a href="#SkPaint_Join">Join</a>, geometry on path corners | 227| <a href="#SkPaint_setStrokeMiter">setStrokeMiter</a> | sets <a href="#Miter_Limit">Miter Limit</a>, angles with sharp corners | 228| <a href="#SkPaint_setStrokeWidth">setStrokeWidth</a> | sets thickness of the stroke | 229| <a href="#SkPaint_setStyle">setStyle</a> | sets <a href="#SkPaint_Style">Style</a>: stroke, fill, or both | 230| <a href="#SkPaint_setSubpixelText">setSubpixelText</a> | sets or clears <a href="#Subpixel_Text">Subpixel Text</a> | 231| <a href="#SkPaint_setTextAlign">setTextAlign</a> | sets <a href="#SkPaint_Align">Align</a>: left, center, or right | 232| <a href="#SkPaint_setTextEncoding">setTextEncoding</a> | sets character or glyph encoded size | 233| <a href="#SkPaint_setTextScaleX">setTextScaleX</a> | sets the text horizontal scale; condensed text | 234| <a href="#SkPaint_setTextSize">setTextSize</a> | sets text size in points | 235| <a href="#SkPaint_setTextSkewX">setTextSkewX</a> | sets the text horizontal skew; oblique text | 236| <a href="#SkPaint_setTypeface">setTypeface</a> | sets <a href="undocumented#Typeface">Typeface</a>, font description | 237| <a href="#SkPaint_setVerticalText">setVerticalText</a> | sets or clears <a href="#Vertical_Text">Vertical Text</a> | 238| <a href="#SkPaint_textToGlyphs">textToGlyphs</a> | converts text into glyph indices | 239| <a href="#SkPaint_toString">toString</a> | converts <a href="#Paint">Paint</a> to machine readable form | 240| <a href="#SkPaint_unflatten">unflatten</a> | populates from a serialized stream | 241 242## <a name="Initializers"></a> Initializers 243 244<a name="SkPaint_empty_constructor"></a> 245## SkPaint 246 247<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 248SkPaint() 249</pre> 250 251Constructs <a href="#Paint">Paint</a> with default values. 252 253| attribute | default value | 254| --- | --- | 255| Anti-alias | false | 256| <a href="undocumented#Blend_Mode">Blend Mode</a> | <a href="undocumented#SkBlendMode_kSrcOver">SkBlendMode::kSrcOver</a> | 257| <a href="undocumented#Color">Color</a> | <a href="undocumented#SK_ColorBLACK">SK ColorBLACK</a> | 258| <a href="undocumented#Alpha">Color Alpha</a> | 255 | 259| <a href="undocumented#Color_Filter">Color Filter</a> | nullptr | 260| <a href="#Dither">Dither</a> | false | 261| <a href="undocumented#Draw_Looper">Draw Looper</a> | nullptr | 262| <a href="#Fake_Bold">Fake Bold</a> | false | 263| <a href="undocumented#Filter_Quality">Filter Quality</a> | <a href="undocumented#kNone_SkFilterQuality">kNone_SkFilterQuality</a> | 264| <a href="#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> | false | 265| <a href="#Automatic_Hinting">Automatic Hinting</a> | false | 266| <a href="#Full_Hinting_Spacing">Full Hinting Spacing</a> | false | 267| <a href="#SkPaint_Hinting">Hinting</a> | <a href="#SkPaint_kNormal_Hinting">kNormal Hinting</a> | 268| <a href="undocumented#Image_Filter">Image Filter</a> | nullptr | 269| <a href="#LCD_Text">LCD Text</a> | false | 270| <a href="#Linear_Text">Linear Text</a> | false | 271| <a href="#Miter_Limit">Miter Limit</a> | 4 | 272| <a href="undocumented#Mask_Filter">Mask Filter</a> | nullptr | 273| <a href="undocumented#Path_Effect">Path Effect</a> | nullptr | 274| <a href="undocumented#Shader">Shader</a> | nullptr | 275| <a href="#SkPaint_Style">Style</a> | <a href="#SkPaint_kFill_Style">kFill Style</a> | 276| <a href="#Text_Align">Text Align</a> | <a href="#SkPaint_kLeft_Align">kLeft Align</a> | 277| <a href="#Text_Encoding">Text Encoding</a> | <a href="#SkPaint_kUTF8_TextEncoding">kUTF8 TextEncoding</a> | 278| <a href="#Text_Scale_X">Text Scale X</a> | 1 | 279| <a href="#Text_Size">Text Size</a> | 12 | 280| <a href="#Text_Skew_X">Text Skew X</a> | 0 | 281| <a href="undocumented#Typeface">Typeface</a> | nullptr | 282| <a href="#Stroke_Cap">Stroke Cap</a> | <a href="#SkPaint_kButt_Cap">kButt Cap</a> | 283| <a href="#Stroke_Join">Stroke Join</a> | <a href="#SkPaint_kMiter_Join">kMiter Join</a> | 284| <a href="#Stroke_Width">Stroke Width</a> | 0 | 285| <a href="#Subpixel_Text">Subpixel Text</a> | false | 286| <a href="#Vertical_Text">Vertical Text</a> | false | 287 288The flags, text size, hinting, and miter limit may be overridden at compile time by defining 289paint default values. The overrides may be included in "SkUserConfig.h" or predefined by the 290build system. 291 292### Return Value 293 294default initialized <a href="#Paint">Paint</a> 295 296### Example 297 298<div><fiddle-embed name="c4b2186d85c142a481298f7144295ffd"></fiddle-embed></div> 299 300--- 301 302<a name="SkPaint_copy_const_SkPaint"></a> 303## SkPaint 304 305<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 306SkPaint(const SkPaint& paint) 307</pre> 308 309Makes a shallow copy of <a href="#Paint">Paint</a>. <a href="undocumented#Typeface">Typeface</a>, <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, 310<a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Draw_Looper">Draw Looper</a>, and <a href="undocumented#Image_Filter">Image Filter</a> are shared 311between the original <a href="#SkPaint_copy_const_SkPaint_paint">paint</a> and the copy. Objects containing <a href="undocumented#Reference_Count">Reference Count</a> increment 312their references by one. 313 314The referenced objects <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, 315<a href="undocumented#Draw_Looper">Draw Looper</a>, and <a href="undocumented#Image_Filter">Image Filter</a> cannot be modified after they are created. 316This prevents objects with <a href="undocumented#Reference_Count">Reference Count</a> from being modified once <a href="#Paint">Paint</a> refers to them. 317 318### Parameters 319 320<table> <tr> <td><a name="SkPaint_copy_const_SkPaint_paint"> <code><strong>paint </strong></code> </a></td> <td> 321original to copy</td> 322 </tr> 323</table> 324 325### Return Value 326 327shallow copy of <a href="#SkPaint_copy_const_SkPaint_paint">paint</a> 328 329### Example 330 331<div><fiddle-embed name="b99971ad0ef243d617925289d963b62d"> 332 333#### Example Output 334 335~~~~ 336SK_ColorRED == paint1.getColor() 337SK_ColorBLUE == paint2.getColor() 338~~~~ 339 340</fiddle-embed></div> 341 342--- 343 344<a name="SkPaint_move_SkPaint"></a> 345## SkPaint 346 347<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 348SkPaint(SkPaint&& paint) 349</pre> 350 351Implements a move constructor to avoid increasing the reference counts 352of objects referenced by the <a href="#SkPaint_move_SkPaint_paint">paint</a>. 353 354After the call, <a href="#SkPaint_move_SkPaint_paint">paint</a> is undefined, and can be safely destructed. 355 356### Parameters 357 358<table> <tr> <td><a name="SkPaint_move_SkPaint_paint"> <code><strong>paint </strong></code> </a></td> <td> 359original to move</td> 360 </tr> 361</table> 362 363### Return Value 364 365content of <a href="#SkPaint_move_SkPaint_paint">paint</a> 366 367### Example 368 369<div><fiddle-embed name="8ed1488a503cd5282b86a51614aa90b1"> 370 371#### Example Output 372 373~~~~ 374path effect unique: true 375~~~~ 376 377</fiddle-embed></div> 378 379--- 380 381<a name="SkPaint_reset"></a> 382## reset 383 384<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 385void reset() 386</pre> 387 388Sets all <a href="#Paint">Paint</a> contents to their initial values. This is equivalent to replacing 389<a href="#Paint">Paint</a> with the result of <a href="#SkPaint_empty_constructor">SkPaint()</a>. 390 391### Example 392 393<div><fiddle-embed name="ef269937ade7e7353635121d9a64f9f7"> 394 395#### Example Output 396 397~~~~ 398paint1 == paint2 399~~~~ 400 401</fiddle-embed></div> 402 403--- 404 405<a name="SkPaint_destructor"></a> 406## ~SkPaint 407 408<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 409~SkPaint() 410</pre> 411 412Decreases <a href="#Paint">Paint</a> <a href="undocumented#Reference_Count">Reference Count</a> of owned objects: <a href="undocumented#Typeface">Typeface</a>, <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, 413<a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Draw_Looper">Draw Looper</a>, and <a href="undocumented#Image_Filter">Image Filter</a>. If the 414objects containing <a href="undocumented#Reference_Count">Reference Count</a> go to zero, they are deleted. 415 416--- 417 418## <a name="Management"></a> Management 419 420<a name="SkPaint_copy_operator"></a> 421## operator= 422 423<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 424SkPaint& operator=(const SkPaint& paint) 425</pre> 426 427Makes a shallow copy of <a href="#Paint">Paint</a>. <a href="undocumented#Typeface">Typeface</a>, <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, 428<a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, <a href="undocumented#Draw_Looper">Draw Looper</a>, and <a href="undocumented#Image_Filter">Image Filter</a> are shared 429between the original <a href="#SkPaint_copy_operator_paint">paint</a> and the copy. Objects containing <a href="undocumented#Reference_Count">Reference Count</a> in the 430prior destination are decreased by one, and the referenced objects are deleted if the 431resulting count is zero. Objects containing <a href="undocumented#Reference_Count">Reference Count</a> in the parameter <a href="#SkPaint_copy_operator_paint">paint</a> 432are increased by one. <a href="#SkPaint_copy_operator_paint">paint</a> is unmodified. 433 434### Parameters 435 436<table> <tr> <td><a name="SkPaint_copy_operator_paint"> <code><strong>paint </strong></code> </a></td> <td> 437original to copy</td> 438 </tr> 439</table> 440 441### Return Value 442 443content of <a href="#SkPaint_copy_operator_paint">paint</a> 444 445### Example 446 447<div><fiddle-embed name="b476a9088f80dece176ed577807d3992"> 448 449#### Example Output 450 451~~~~ 452SK_ColorRED == paint1.getColor() 453SK_ColorRED == paint2.getColor() 454~~~~ 455 456</fiddle-embed></div> 457 458--- 459 460<a name="SkPaint_move_operator"></a> 461## operator= 462 463<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 464SkPaint& operator=(SkPaint&& paint) 465</pre> 466 467Moves the <a href="#SkPaint_move_operator_paint">paint</a> to avoid increasing the reference counts 468of objects referenced by the <a href="#SkPaint_move_operator_paint">paint</a> parameter. Objects containing <a href="undocumented#Reference_Count">Reference Count</a> in the 469prior destination are decreased by one; those objects are deleted if the resulting count 470is zero. 471 472After the call, <a href="#SkPaint_move_operator_paint">paint</a> is undefined, and can be safely destructed. 473 474### Parameters 475 476<table> <tr> <td><a name="SkPaint_move_operator_paint"> <code><strong>paint </strong></code> </a></td> <td> 477original to move</td> 478 </tr> 479</table> 480 481### Return Value 482 483content of <a href="#SkPaint_move_operator_paint">paint</a> 484 485### Example 486 487<div><fiddle-embed name="9fb7459b097d713f5f1fe5675afe14f5"> 488 489#### Example Output 490 491~~~~ 492SK_ColorRED == paint2.getColor() 493~~~~ 494 495</fiddle-embed></div> 496 497--- 498 499<a name="SkPaint_equal_operator"></a> 500## operator== 501 502<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 503bool operator==(const SkPaint& a, const SkPaint& b) 504</pre> 505 506Compares <a href="#SkPaint_equal_operator_a">a</a> and <a href="#SkPaint_equal_operator_b">b</a>, and returns true if <a href="#SkPaint_equal_operator_a">a</a> and <a href="#SkPaint_equal_operator_b">b</a> are equivalent. May return false 507if <a href="undocumented#Typeface">Typeface</a>, <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, 508<a href="undocumented#Draw_Looper">Draw Looper</a>, or <a href="undocumented#Image_Filter">Image Filter</a> have identical contents but different pointers. 509 510### Parameters 511 512<table> <tr> <td><a name="SkPaint_equal_operator_a"> <code><strong>a </strong></code> </a></td> <td> 513<a href="#Paint">Paint</a> to compare</td> 514 </tr> <tr> <td><a name="SkPaint_equal_operator_b"> <code><strong>b </strong></code> </a></td> <td> 515<a href="#Paint">Paint</a> to compare</td> 516 </tr> 517</table> 518 519### Return Value 520 521true if <a href="#Paint">Paint</a> pair are equivalent 522 523### Example 524 525<div><fiddle-embed name="7481a948e34672720337a631830586dd"> 526 527#### Example Output 528 529~~~~ 530paint1 == paint2 531paint1 != paint2 532~~~~ 533 534</fiddle-embed></div> 535 536--- 537 538<a name="SkPaint_notequal_operator"></a> 539## operator!= 540 541<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 542bool operator!=(const SkPaint& a, const SkPaint& b) 543</pre> 544 545Compares <a href="#SkPaint_notequal_operator_a">a</a> and <a href="#SkPaint_notequal_operator_b">b</a>, and returns true if <a href="#SkPaint_notequal_operator_a">a</a> and <a href="#SkPaint_notequal_operator_b">b</a> are not equivalent. May return true 546if <a href="undocumented#Typeface">Typeface</a>, <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Shader">Shader</a>, <a href="undocumented#Mask_Filter">Mask Filter</a>, <a href="undocumented#Color_Filter">Color Filter</a>, 547<a href="undocumented#Draw_Looper">Draw Looper</a>, or <a href="undocumented#Image_Filter">Image Filter</a> have identical contents but different pointers. 548 549### Parameters 550 551<table> <tr> <td><a name="SkPaint_notequal_operator_a"> <code><strong>a </strong></code> </a></td> <td> 552<a href="#Paint">Paint</a> to compare</td> 553 </tr> <tr> <td><a name="SkPaint_notequal_operator_b"> <code><strong>b </strong></code> </a></td> <td> 554<a href="#Paint">Paint</a> to compare</td> 555 </tr> 556</table> 557 558### Return Value 559 560true if <a href="#Paint">Paint</a> pair are not equivalent 561 562### Example 563 564<div><fiddle-embed name="b6c8484b1187f555b435ad5369833be4"> 565 566#### Example Output 567 568~~~~ 569paint1 == paint2 570paint1 == paint2 571~~~~ 572 573</fiddle-embed></div> 574 575--- 576 577<a name="SkPaint_getHash"></a> 578## getHash 579 580<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 581uint32_t getHash() const 582</pre> 583 584Returns a hash generated from <a href="#Paint">Paint</a> values and pointers. 585Identical hashes guarantee that the paints are 586equivalent, but differing hashes do not guarantee that the paints have differing 587contents. 588 589If <a href="#SkPaint_equal_operator">operator==(const SkPaint& a, const SkPaint& b)</a> returns true for two paints, 590their hashes are also equal. 591 592The hash returned is platform and implementation specific. 593 594### Return Value 595 596a shallow hash 597 598### Example 599 600<div><fiddle-embed name="7f7e1b701361912b344f90ae6b530393"> 601 602#### Example Output 603 604~~~~ 605paint1 == paint2 606paint1.getHash() == paint2.getHash() 607~~~~ 608 609</fiddle-embed></div> 610 611--- 612 613<a name="SkPaint_flatten"></a> 614## flatten 615 616<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 617void flatten(SkWriteBuffer& buffer) const 618</pre> 619 620Serializes <a href="#Paint">Paint</a> into a <a href="#SkPaint_flatten_buffer">buffer</a>. A companion <a href="#SkPaint_unflatten">unflatten</a> call 621can reconstitute the paint at a later time. 622 623### Parameters 624 625<table> <tr> <td><a name="SkPaint_flatten_buffer"> <code><strong>buffer </strong></code> </a></td> <td> 626<a href="undocumented#Write_Buffer">Write Buffer</a> receiving the flattened <a href="#Paint">Paint</a> data</td> 627 </tr> 628</table> 629 630--- 631 632<a name="SkPaint_unflatten"></a> 633## unflatten 634 635<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 636bool unflatten(SkReadBuffer& buffer) 637</pre> 638 639Populates <a href="#Paint">Paint</a>, typically from a serialized stream, created by calling 640<a href="#SkPaint_flatten">flatten</a> at an earlier time. 641 642<a href="undocumented#SkReadBuffer">SkReadBuffer</a> class is not public, so <a href="#SkPaint_unflatten">unflatten</a> cannot be meaningfully called 643by the client. 644 645### Parameters 646 647<table> <tr> <td><a name="SkPaint_unflatten_buffer"> <code><strong>buffer </strong></code> </a></td> <td> 648serialized data describing <a href="#Paint">Paint</a> content</td> 649 </tr> 650</table> 651 652### Return Value 653 654false if the <a href="#SkPaint_unflatten_buffer">buffer</a> contains invalid data 655 656### See Also 657 658<a href="undocumented#SkReadBuffer">SkReadBuffer</a> 659 660--- 661 662## <a name="Hinting"></a> Hinting 663 664## <a name="SkPaint_Hinting"></a> Enum SkPaint::Hinting 665 666<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 667enum <a href="#Hinting">Hinting</a> { 668<a href="#SkPaint_kNo_Hinting">kNo Hinting</a> = 0, 669<a href="#SkPaint_kSlight_Hinting">kSlight Hinting</a> = 1, 670<a href="#SkPaint_kNormal_Hinting">kNormal Hinting</a> = 2, 671<a href="#SkPaint_kFull_Hinting">kFull Hinting</a> = 3, 672};</pre> 673 674<a href="#Hinting">Hinting</a> adjusts the glyph outlines so that the shape provides a uniform 675look at a given point size on font engines that support it. <a href="#Hinting">Hinting</a> may have a 676muted effect or no effect at all depending on the platform. 677 678The four levels roughly control corresponding features on platforms that use FreeType 679as the <a href="undocumented#Engine">Font Engine</a>. 680 681### Constants 682 683<table> 684 <tr> 685 <td><a name="SkPaint_kNo_Hinting"> <code><strong>SkPaint::kNo_Hinting </strong></code> </a></td><td>0</td><td>Leaves glyph outlines unchanged from their native representation. 686With FreeType, this is equivalent to the FT_LOAD_NO_HINTING 687bit-field constant supplied to FT_Load_Glyph, which indicates that the vector 688outline being loaded should not be fitted to the pixel grid but simply scaled 689to 26.6 fractional pixels.</td> 690 </tr> 691 <tr> 692 <td><a name="SkPaint_kSlight_Hinting"> <code><strong>SkPaint::kSlight_Hinting </strong></code> </a></td><td>1</td><td>Modifies glyph outlines minimally to improve constrast. 693With FreeType, this is equivalent in spirit to the 694FT_LOAD_TARGET_LIGHT value supplied to FT_Load_Glyph. It chooses a 695lighter hinting algorithm for non-monochrome modes. 696Generated <a href="undocumented#Glyph">Glyphs</a> may be fuzzy but better resemble their original shape.</td> 697 </tr> 698 <tr> 699 <td><a name="SkPaint_kNormal_Hinting"> <code><strong>SkPaint::kNormal_Hinting </strong></code> </a></td><td>2</td><td>Modifies glyph outlines to improve constrast. This is the default. 700With FreeType, this supplies FT_LOAD_TARGET_NORMAL to FT_Load_Glyph, 701choosing the default hinting algorithm, which is optimized for standard 702gray-level rendering.</td> 703 </tr> 704 <tr> 705 <td><a name="SkPaint_kFull_Hinting"> <code><strong>SkPaint::kFull_Hinting </strong></code> </a></td><td>3</td><td>Modifies glyph outlines for maxiumum constrast. With FreeType, this selects 706FT_LOAD_TARGET_LCD or FT_LOAD_TARGET_LCD_V if <a href="#SkPaint_kLCDRenderText_Flag">kLCDRenderText Flag</a> is set. 707FT_LOAD_TARGET_LCD is a variant of FT_LOAD_TARGET_NORMAL optimized for 708horizontally decimated LCD displays; FT_LOAD_TARGET_LCD_V is a 709variant of FT_LOAD_TARGET_NORMAL optimized for vertically decimated LCD displays.</td> 710 </tr> 711</table> 712 713On Windows with DirectWrite, <a href="#Hinting">Hinting</a> has no effect. 714 715<a href="#Hinting">Hinting</a> defaults to <a href="#SkPaint_kNormal_Hinting">kNormal Hinting</a>. 716Set <a href="undocumented#SkPaintDefaults_Hinting">SkPaintDefaults Hinting</a> at compile time to change the default setting. 717 718 719 720<a name="SkPaint_getHinting"></a> 721## getHinting 722 723<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 724Hinting getHinting() const 725</pre> 726 727Returns level of glyph outline adjustment. 728 729### Return Value 730 731one of: <a href="#SkPaint_kNo_Hinting">kNo Hinting</a>, <a href="#SkPaint_kSlight_Hinting">kSlight Hinting</a>, <a href="#SkPaint_kNormal_Hinting">kNormal Hinting</a>, <a href="#SkPaint_kFull_Hinting">kFull Hinting</a> 732 733### Example 734 735<div><fiddle-embed name="329e2e5a5919ac431e1c58878a5b99e0"> 736 737#### Example Output 738 739~~~~ 740SkPaint::kNormal_Hinting == paint.getHinting() 741~~~~ 742 743</fiddle-embed></div> 744 745--- 746 747<a name="SkPaint_setHinting"></a> 748## setHinting 749 750<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 751void setHinting(Hinting hintingLevel) 752</pre> 753 754Sets level of glyph outline adjustment. 755Does not check for valid values of <a href="#SkPaint_setHinting_hintingLevel">hintingLevel</a>. 756 757| <a href="#Hinting">Hinting</a> | value | effect on generated glyph outlines | 758| --- | --- | --- | 759| <a href="#SkPaint_kNo_Hinting">kNo Hinting</a> | 0 | leaves glyph outlines unchanged from their native representation | 760| <a href="#SkPaint_kSlight_Hinting">kSlight Hinting</a> | 1 | modifies glyph outlines minimally to improve contrast | 761| <a href="#SkPaint_kNormal_Hinting">kNormal Hinting</a> | 2 | modifies glyph outlines to improve contrast | 762| <a href="#SkPaint_kFull_Hinting">kFull Hinting</a> | 3 | modifies glyph outlines for maximum contrast | 763 764### Parameters 765 766<table> <tr> <td><a name="SkPaint_setHinting_hintingLevel"> <code><strong>hintingLevel </strong></code> </a></td> <td> 767one of: <a href="#SkPaint_kNo_Hinting">kNo Hinting</a>, <a href="#SkPaint_kSlight_Hinting">kSlight Hinting</a>, <a href="#SkPaint_kNormal_Hinting">kNormal Hinting</a>, <a href="#SkPaint_kFull_Hinting">kFull Hinting</a></td> 768 </tr> 769</table> 770 771### Example 772 773<div><fiddle-embed name="78153fbd3f1000cb33b97bbe831ed34e"> 774 775#### Example Output 776 777~~~~ 778paint1 == paint2 779~~~~ 780 781</fiddle-embed></div> 782 783--- 784 785## <a name="Flags"></a> Flags 786 787## <a name="SkPaint_Flags"></a> Enum SkPaint::Flags 788 789<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 790enum <a href="#Flags">Flags</a> { 791<a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a> = 0x01, 792<a href="#SkPaint_kDither_Flag">kDither Flag</a> = 0x04, 793<a href="#SkPaint_kFakeBoldText_Flag">kFakeBoldText Flag</a> = 0x20, 794<a href="#SkPaint_kLinearText_Flag">kLinearText Flag</a> = 0x40, 795<a href="#SkPaint_kSubpixelText_Flag">kSubpixelText Flag</a> = 0x80, 796<a href="#SkPaint_kDevKernText_Flag">kDevKernText Flag</a> = 0x100, 797<a href="#SkPaint_kLCDRenderText_Flag">kLCDRenderText Flag</a> = 0x200, 798<a href="#SkPaint_kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> = 0x400, 799<a href="#SkPaint_kAutoHinting_Flag">kAutoHinting Flag</a> = 0x800, 800<a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> = 0x1000, 801<a href="#SkPaint_kGenA8FromLCD_Flag">kGenA8FromLCD Flag</a> = 0x2000, 802 803<a href="#SkPaint_kAllFlags">kAllFlags</a> = 0xFFFF, 804}; 805</pre> 806 807The bit values stored in <a href="#Flags">Flags</a>. 808The default value for <a href="#Flags">Flags</a>, normally zero, can be changed at compile time 809with a custom definition of <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a>. 810All flags can be read and written explicitly; <a href="#Flags">Flags</a> allows manipulating 811multiple settings at once. 812 813### Constants 814 815<table> 816 <tr> 817 <td><a name="SkPaint_kAntiAlias_Flag"> <code><strong>SkPaint::kAntiAlias_Flag </strong></code> </a></td><td>0x0001 </td><td>mask for setting Anti-alias</td> 818 </tr> 819 <tr> 820 <td><a name="SkPaint_kDither_Flag"> <code><strong>SkPaint::kDither_Flag </strong></code> </a></td><td>0x0004</td><td>mask for setting <a href="#Dither">Dither</a></td> 821 </tr> 822 <tr> 823 <td><a name="SkPaint_kFakeBoldText_Flag"> <code><strong>SkPaint::kFakeBoldText_Flag </strong></code> </a></td><td>0x0020</td><td>mask for setting <a href="#Fake_Bold">Fake Bold</a></td> 824 </tr> 825 <tr> 826 <td><a name="SkPaint_kLinearText_Flag"> <code><strong>SkPaint::kLinearText_Flag </strong></code> </a></td><td>0x0040</td><td>mask for setting <a href="#Linear_Text">Linear Text</a></td> 827 </tr> 828 <tr> 829 <td><a name="SkPaint_kSubpixelText_Flag"> <code><strong>SkPaint::kSubpixelText_Flag </strong></code> </a></td><td>0x0080</td><td>mask for setting <a href="#Subpixel_Text">Subpixel Text</a></td> 830 </tr> 831 <tr> 832 <td><a name="SkPaint_kDevKernText_Flag"> <code><strong>SkPaint::kDevKernText_Flag </strong></code> </a></td><td>0x0100</td><td>mask for setting <a href="#Full_Hinting_Spacing">Full Hinting Spacing</a></td> 833 </tr> 834 <tr> 835 <td><a name="SkPaint_kLCDRenderText_Flag"> <code><strong>SkPaint::kLCDRenderText_Flag </strong></code> </a></td><td>0x0200</td><td>mask for setting <a href="#LCD_Text">LCD Text</a></td> 836 </tr> 837 <tr> 838 <td><a name="SkPaint_kEmbeddedBitmapText_Flag"> <code><strong>SkPaint::kEmbeddedBitmapText_Flag </strong></code> </a></td><td>0x0400</td><td>mask for setting <a href="#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a></td> 839 </tr> 840 <tr> 841 <td><a name="SkPaint_kAutoHinting_Flag"> <code><strong>SkPaint::kAutoHinting_Flag </strong></code> </a></td><td>0x0800</td><td>mask for setting <a href="#Automatic_Hinting">Automatic Hinting</a></td> 842 </tr> 843 <tr> 844 <td><a name="SkPaint_kVerticalText_Flag"> <code><strong>SkPaint::kVerticalText_Flag </strong></code> </a></td><td>0x1000</td><td>mask for setting <a href="#Vertical_Text">Vertical Text</a></td> 845 </tr> 846 <tr> 847 <td><a name="SkPaint_kGenA8FromLCD_Flag"> <code><strong>SkPaint::kGenA8FromLCD_Flag </strong></code> </a></td><td>0x2000</td><td>not intended for public use</td> 848 </tr> 849 <tr> 850 <td><a name="SkPaint_kAllFlags"> <code><strong>SkPaint::kAllFlags </strong></code> </a></td><td>0xFFFF</td><td>mask of all <a href="#Flags">Flags</a>, including private flags and flags reserved for future use</td> 851 </tr> 852<a href="#Flags">Flags</a> default to all flags clear, disabling the associated feature. 853 854</table> 855 856## <a name="SkPaint_ReserveFlags"></a> Enum SkPaint::ReserveFlags 857 858soonOnly valid for Android framework. 859 860<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 861enum <a href="#SkPaint_ReserveFlags">ReserveFlags</a> { 862<a href="#SkPaint_kUnderlineText_ReserveFlag">kUnderlineText ReserveFlag</a> = 0x08, 863<a href="#SkPaint_kStrikeThruText_ReserveFlag">kStrikeThruText ReserveFlag</a> = 0x10, 864};</pre> 865 866### Constants 867 868<table> 869 <tr> 870 <td><a name="SkPaint_kUnderlineText_ReserveFlag"> <code><strong>SkPaint::kUnderlineText_ReserveFlag </strong></code> </a></td><td>0x0008</td><td>soon</td> 871 </tr> 872 <tr> 873 <td><a name="SkPaint_kStrikeThruText_ReserveFlag"> <code><strong>SkPaint::kStrikeThruText_ReserveFlag </strong></code> </a></td><td>0x0010</td><td>soon</td> 874 </tr> 875 876</table> 877 878<a name="SkPaint_getFlags"></a> 879## getFlags 880 881<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 882uint32_t getFlags() const 883</pre> 884 885Returns paint settings described by <a href="#Flags">Flags</a>. Each setting uses one 886bit, and can be tested with <a href="#Flags">Flags</a> members. 887 888### Return Value 889 890zero, one, or more bits described by <a href="#Flags">Flags</a> 891 892### Example 893 894<div><fiddle-embed name="8a3f8c309533388b01aa66e1267f322d"> 895 896#### Example Output 897 898~~~~ 899(SkPaint::kAntiAlias_Flag & paint.getFlags()) != 0 900~~~~ 901 902</fiddle-embed></div> 903 904--- 905 906<a name="SkPaint_setFlags"></a> 907## setFlags 908 909<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 910void setFlags(uint32_t flags) 911</pre> 912 913Replaces <a href="#Flags">Flags</a> with <a href="#SkPaint_setFlags_flags">flags</a>, the union of the <a href="#Flags">Flags</a> members. 914All <a href="#Flags">Flags</a> members may be cleared, or one or more may be set. 915 916### Parameters 917 918<table> <tr> <td><a name="SkPaint_setFlags_flags"> <code><strong>flags </strong></code> </a></td> <td> 919union of <a href="#Flags">Flags</a> for <a href="#Paint">Paint</a></td> 920 </tr> 921</table> 922 923### Example 924 925<div><fiddle-embed name="54baed3f6bc4b9c31ba664e27767fdc7"> 926 927#### Example Output 928 929~~~~ 930paint.isAntiAlias() 931paint.isDither() 932~~~~ 933 934</fiddle-embed></div> 935 936--- 937 938## <a name="Anti-alias"></a> Anti-alias 939 940Anti-alias drawing approximates partial pixel coverage with transparency. 941If <a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a> is clear, pixel centers contained by the shape edge are drawn opaque. 942If <a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a> is set, pixels are drawn with <a href="undocumented#Alpha">Color Alpha</a> equal to their coverage. 943 944The rule for <a href="undocumented#Alias">Aliased</a> pixels is inconsistent across platforms. A shape edge 945passing through the pixel center may, but is not required to, draw the pixel. 946 947<a href="undocumented#Raster_Engine">Raster Engine</a> draws <a href="undocumented#Alias">Aliased</a> pixels whose centers are on or to the right of the start of an 948active <a href="SkPath_Reference#Path">Path</a> edge, and whose center is to the left of the end of the active <a href="SkPath_Reference#Path">Path</a> edge. 949 950A platform may only support Anti-aliased drawing. Some GPU-backed platforms use 951<a href="undocumented#Supersampling">Supersampling</a> to Anti-alias all drawing, and have no mechanism to selectively 952<a href="undocumented#Alias">Alias</a>. 953 954The amount of coverage computed for Anti-aliased pixels also varies across platforms. 955 956Anti-alias is disabled by default. 957Anti-alias can be enabled by default by setting <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a> to <a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a> 958at compile time. 959 960### Example 961 962<div><fiddle-embed name="a6575a49467ce8d28bb01cc7638fa04d"><div>A red line is drawn with transparency on the edges to make it look smoother. 963A blue line draws only where the pixel centers are contained. 964The lines are drawn into <a href="SkBitmap_Reference#Bitmap">Bitmap</a>, then drawn magnified to make the 965<a href="undocumented#Alias">Aliasing</a> easier to see.</div></fiddle-embed></div> 966 967<a name="SkPaint_isAntiAlias"></a> 968## isAntiAlias 969 970<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 971bool isAntiAlias() const 972</pre> 973 974If true, pixels on the active edges of <a href="SkPath_Reference#Path">Path</a> may be drawn with partial transparency. 975 976Equivalent to <a href="#SkPaint_getFlags">getFlags</a> masked with <a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a>. 977 978### Return Value 979 980<a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a> state 981 982### Example 983 984<div><fiddle-embed name="d7d5f4f7da7acd5104a652f490c6f7b8"> 985 986#### Example Output 987 988~~~~ 989paint.isAntiAlias() == !!(paint.getFlags() & SkPaint::kAntiAlias_Flag) 990paint.isAntiAlias() == !!(paint.getFlags() & SkPaint::kAntiAlias_Flag) 991~~~~ 992 993</fiddle-embed></div> 994 995--- 996 997<a name="SkPaint_setAntiAlias"></a> 998## setAntiAlias 999 1000<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1001void setAntiAlias(bool aa) 1002</pre> 1003 1004Requests, but does not require, that <a href="SkPath_Reference#Path">Path</a> edge pixels draw opaque or with 1005partial transparency. 1006 1007Sets <a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a> if <a href="#SkPaint_setAntiAlias_aa">aa</a> is true. 1008Clears <a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a> if <a href="#SkPaint_setAntiAlias_aa">aa</a> is false. 1009 1010### Parameters 1011 1012<table> <tr> <td><a name="SkPaint_setAntiAlias_aa"> <code><strong>aa </strong></code> </a></td> <td> 1013setting for <a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a></td> 1014 </tr> 1015</table> 1016 1017### Example 1018 1019<div><fiddle-embed name="c2ff148374d01cbef845b223e725905c"> 1020 1021#### Example Output 1022 1023~~~~ 1024paint1 == paint2 1025~~~~ 1026 1027</fiddle-embed></div> 1028 1029--- 1030 1031## <a name="Dither"></a> Dither 1032 1033<a href="#Dither">Dither</a> increases fidelity by adjusting the color of adjacent pixels. 1034This can help to smooth color transitions and reducing banding in gradients. 1035Dithering lessens visible banding from <a href="SkImageInfo_Reference#kRGB_565_SkColorType">kRGB_565_SkColorType</a> 1036and <a href="SkImageInfo_Reference#kRGBA_8888_SkColorType">kRGBA_8888_SkColorType</a> gradients, 1037and improves rendering into a <a href="SkImageInfo_Reference#kRGB_565_SkColorType">kRGB_565_SkColorType</a> <a href="SkSurface_Reference#Surface">Surface</a>. 1038 1039Dithering is always enabled for linear gradients drawing into 1040<a href="SkImageInfo_Reference#kRGB_565_SkColorType">kRGB_565_SkColorType</a> <a href="SkSurface_Reference#Surface">Surface</a> and <a href="SkImageInfo_Reference#kRGBA_8888_SkColorType">kRGBA_8888_SkColorType</a> <a href="SkSurface_Reference#Surface">Surface</a>. 1041<a href="#Dither">Dither</a> cannot be enabled for <a href="SkImageInfo_Reference#kAlpha_8_SkColorType">kAlpha_8_SkColorType</a> <a href="SkSurface_Reference#Surface">Surface</a> and 1042<a href="SkImageInfo_Reference#kRGBA_F16_SkColorType">kRGBA_F16_SkColorType</a> <a href="SkSurface_Reference#Surface">Surface</a>. 1043 1044<a href="#Dither">Dither</a> is disabled by default. 1045<a href="#Dither">Dither</a> can be enabled by default by setting <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a> to <a href="#SkPaint_kDither_Flag">kDither Flag</a> 1046at compile time. 1047 1048Some platform implementations may ignore dithering. Setto ignore <a href="#Dither">Dither</a> on <a href="undocumented#GPU_Surface">GPU Surface</a>. 1049 1050### Example 1051 1052<div><fiddle-embed name="8b26507690b71462f44642b911890bbf"><div>Dithering in the bottom half more closely approximates the requested color by 1053alternating nearby colors from pixel to pixel.</div></fiddle-embed></div> 1054 1055### Example 1056 1057<div><fiddle-embed name="76d4d4a7931a48495e4d5f54e073be53"><div>Dithering introduces subtle adjustments to color to smooth gradients. 1058Drawing the gradient repeatedly with <a href="undocumented#SkBlendMode_kPlus">SkBlendMode::kPlus</a> exaggerates the 1059dither, making it easier to see.</div></fiddle-embed></div> 1060 1061<a name="SkPaint_isDither"></a> 1062## isDither 1063 1064<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1065bool isDither() const 1066</pre> 1067 1068If true, color error may be distributed to smooth color transition. 1069Equivalent to <a href="#SkPaint_getFlags">getFlags</a> masked with <a href="#SkPaint_kDither_Flag">kDither Flag</a>. 1070 1071### Return Value 1072 1073<a href="#SkPaint_kDither_Flag">kDither Flag</a> state 1074 1075### Example 1076 1077<div><fiddle-embed name="f4ce93f6c5e7335436a985377fd980c0"> 1078 1079#### Example Output 1080 1081~~~~ 1082paint.isDither() == !!(paint.getFlags() & SkPaint::kDither_Flag) 1083paint.isDither() == !!(paint.getFlags() & SkPaint::kDither_Flag) 1084~~~~ 1085 1086</fiddle-embed></div> 1087 1088--- 1089 1090<a name="SkPaint_setDither"></a> 1091## setDither 1092 1093<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1094void setDither(bool dither) 1095</pre> 1096 1097Requests, but does not require, to distribute color error. 1098 1099Sets <a href="#SkPaint_kDither_Flag">kDither Flag</a> if <a href="#SkPaint_setDither_dither">dither</a> is true. 1100Clears <a href="#SkPaint_kDither_Flag">kDither Flag</a> if <a href="#SkPaint_setDither_dither">dither</a> is false. 1101 1102### Parameters 1103 1104<table> <tr> <td><a name="SkPaint_setDither_dither"> <code><strong>dither </strong></code> </a></td> <td> 1105setting for <a href="#SkPaint_kDither_Flag">kDither Flag</a></td> 1106 </tr> 1107</table> 1108 1109### Example 1110 1111<div><fiddle-embed name="69b7162e8324d9239dd02dd9ada2bdff"> 1112 1113#### Example Output 1114 1115~~~~ 1116paint1 == paint2 1117~~~~ 1118 1119</fiddle-embed></div> 1120 1121### See Also 1122 1123<a href="SkImageInfo_Reference#kRGB_565_SkColorType">kRGB_565_SkColorType</a> 1124 1125--- 1126 1127### See Also 1128 1129Gradient <a href="undocumented#RGB">Color RGB</a>-565 1130 1131## <a name="Device_Text"></a> Device Text 1132 1133<a href="#LCD_Text">LCD Text</a> and <a href="#Subpixel_Text">Subpixel Text</a> increase the precision of glyph position. 1134 1135When set, <a href="#SkPaint_Flags">Flags</a> <a href="#SkPaint_kLCDRenderText_Flag">kLCDRenderText Flag</a> takes advantage of the organization of <a href="undocumented#RGB">Color RGB</a> stripes that 1136create a color, and relies 1137on the small size of the stripe and visual perception to make the color fringing imperceptible. 1138<a href="#LCD_Text">LCD Text</a> can be enabled on devices that orient stripes horizontally or vertically, and that order 1139the color components as <a href="undocumented#RGB">Color RGB</a> or <a href="undocumented#RBG">Color RBG</a>. 1140 1141<a href="#SkPaint_Flags">Flags</a> <a href="#SkPaint_kSubpixelText_Flag">kSubpixelText Flag</a> uses the pixel transparency to represent a fractional offset. 1142As the opaqueness 1143of the color increases, the edge of the glyph appears to move towards the outside of the pixel. 1144 1145Either or both techniques can be enabled. 1146<a href="#SkPaint_kLCDRenderText_Flag">kLCDRenderText Flag</a> and <a href="#SkPaint_kSubpixelText_Flag">kSubpixelText Flag</a> are clear by default. 1147<a href="#LCD_Text">LCD Text</a> or <a href="#Subpixel_Text">Subpixel Text</a> can be enabled by default by setting <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a> to 1148<a href="#SkPaint_kLCDRenderText_Flag">kLCDRenderText Flag</a> or <a href="#SkPaint_kSubpixelText_Flag">kSubpixelText Flag</a> (or both) at compile time. 1149 1150### Example 1151 1152<div><fiddle-embed name="4606ae1be792d6bc46d496432f050ee9"><div>Four commas are drawn normally and with combinations of <a href="#LCD_Text">LCD Text</a> and <a href="#Subpixel_Text">Subpixel Text</a>. 1153When <a href="#Subpixel_Text">Subpixel Text</a> is disabled, the comma <a href="undocumented#Glyph">Glyphs</a> are identical, but not evenly spaced. 1154When <a href="#Subpixel_Text">Subpixel Text</a> is enabled, the comma <a href="undocumented#Glyph">Glyphs</a> are unique, but appear evenly spaced.</div></fiddle-embed></div> 1155 1156## <a name="Linear_Text"></a> Linear Text 1157 1158<a href="#Linear_Text">Linear Text</a> selects whether text is rendered as a <a href="undocumented#Glyph">Glyph</a> or as a <a href="SkPath_Reference#Path">Path</a>. 1159If <a href="#SkPaint_kLinearText_Flag">kLinearText Flag</a> is set, it has the same effect as setting <a href="#SkPaint_Hinting">Hinting</a> to <a href="#SkPaint_kNormal_Hinting">kNormal Hinting</a>. 1160If <a href="#SkPaint_kLinearText_Flag">kLinearText Flag</a> is clear, it is the same as setting <a href="#SkPaint_Hinting">Hinting</a> to <a href="#SkPaint_kNo_Hinting">kNo Hinting</a>. 1161 1162<a name="SkPaint_isLinearText"></a> 1163## isLinearText 1164 1165<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1166bool isLinearText() const 1167</pre> 1168 1169If true, text is converted to <a href="SkPath_Reference#Path">Path</a> before drawing and measuring. 1170 1171Equivalent to <a href="#SkPaint_getFlags">getFlags</a> masked with <a href="#SkPaint_kLinearText_Flag">kLinearText Flag</a>. 1172 1173### Return Value 1174 1175<a href="#SkPaint_kLinearText_Flag">kLinearText Flag</a> state 1176 1177### Example 1178 1179<div><fiddle-embed name="2890ad644f980637837e6fcb386fb462"></fiddle-embed></div> 1180 1181### See Also 1182 1183<a href="#SkPaint_setLinearText">setLinearText</a> <a href="#SkPaint_Hinting">Hinting</a> 1184 1185--- 1186 1187<a name="SkPaint_setLinearText"></a> 1188## setLinearText 1189 1190<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1191void setLinearText(bool linearText) 1192</pre> 1193 1194If true, text is converted to <a href="SkPath_Reference#Path">Path</a> before drawing and measuring. 1195By default, <a href="#SkPaint_kLinearText_Flag">kLinearText Flag</a> is clear. 1196 1197Sets <a href="#SkPaint_kLinearText_Flag">kLinearText Flag</a> if <a href="#SkPaint_setLinearText_linearText">linearText</a> is true. 1198Clears <a href="#SkPaint_kLinearText_Flag">kLinearText Flag</a> if <a href="#SkPaint_setLinearText_linearText">linearText</a> is false. 1199 1200### Parameters 1201 1202<table> <tr> <td><a name="SkPaint_setLinearText_linearText"> <code><strong>linearText </strong></code> </a></td> <td> 1203setting for <a href="#SkPaint_kLinearText_Flag">kLinearText Flag</a></td> 1204 </tr> 1205</table> 1206 1207### Example 1208 1209<div><fiddle-embed name="c93bb912f3bddfb4d96d3ad70ada552b"></fiddle-embed></div> 1210 1211### See Also 1212 1213<a href="#SkPaint_isLinearText">isLinearText</a> <a href="#SkPaint_Hinting">Hinting</a> 1214 1215--- 1216 1217## <a name="Subpixel_Text"></a> Subpixel Text 1218 1219<a href="#SkPaint_Flags">Flags</a> <a href="#SkPaint_kSubpixelText_Flag">kSubpixelText Flag</a> uses the pixel transparency to represent a fractional offset. 1220As the opaqueness 1221of the color increases, the edge of the glyph appears to move towards the outside of the pixel. 1222 1223<a name="SkPaint_isSubpixelText"></a> 1224## isSubpixelText 1225 1226<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1227bool isSubpixelText() const 1228</pre> 1229 1230If true, <a href="undocumented#Glyph">Glyphs</a> at different sub-pixel positions may differ on pixel edge coverage. 1231 1232Equivalent to <a href="#SkPaint_getFlags">getFlags</a> masked with <a href="#SkPaint_kSubpixelText_Flag">kSubpixelText Flag</a>. 1233 1234### Return Value 1235 1236<a href="#SkPaint_kSubpixelText_Flag">kSubpixelText Flag</a> state 1237 1238### Example 1239 1240<div><fiddle-embed name="abe9afc0932e2199324ae6cbb396e67c"> 1241 1242#### Example Output 1243 1244~~~~ 1245paint.isSubpixelText() == !!(paint.getFlags() & SkPaint::kSubpixelText_Flag) 1246paint.isSubpixelText() == !!(paint.getFlags() & SkPaint::kSubpixelText_Flag) 1247~~~~ 1248 1249</fiddle-embed></div> 1250 1251--- 1252 1253<a name="SkPaint_setSubpixelText"></a> 1254## setSubpixelText 1255 1256<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1257void setSubpixelText(bool subpixelText) 1258</pre> 1259 1260Requests, but does not require, that <a href="undocumented#Glyph">Glyphs</a> respect sub-pixel positioning. 1261 1262Sets <a href="#SkPaint_kSubpixelText_Flag">kSubpixelText Flag</a> if <a href="#SkPaint_setSubpixelText_subpixelText">subpixelText</a> is true. 1263Clears <a href="#SkPaint_kSubpixelText_Flag">kSubpixelText Flag</a> if <a href="#SkPaint_setSubpixelText_subpixelText">subpixelText</a> is false. 1264 1265### Parameters 1266 1267<table> <tr> <td><a name="SkPaint_setSubpixelText_subpixelText"> <code><strong>subpixelText </strong></code> </a></td> <td> 1268setting for <a href="#SkPaint_kSubpixelText_Flag">kSubpixelText Flag</a></td> 1269 </tr> 1270</table> 1271 1272### Example 1273 1274<div><fiddle-embed name="a77bbc1a4e3be9a8ab0f842f877c5ee4"> 1275 1276#### Example Output 1277 1278~~~~ 1279paint1 == paint2 1280~~~~ 1281 1282</fiddle-embed></div> 1283 1284--- 1285 1286## <a name="LCD_Text"></a> LCD Text 1287 1288When set, <a href="#SkPaint_Flags">Flags</a> <a href="#SkPaint_kLCDRenderText_Flag">kLCDRenderText Flag</a> takes advantage of the organization of <a href="undocumented#RGB">Color RGB</a> stripes that 1289create a color, and relies 1290on the small size of the stripe and visual perception to make the color fringing imperceptible. 1291<a href="#LCD_Text">LCD Text</a> can be enabled on devices that orient stripes horizontally or vertically, and that order 1292the color components as <a href="undocumented#RGB">Color RGB</a> or <a href="undocumented#RBG">Color RBG</a>. 1293 1294<a name="SkPaint_isLCDRenderText"></a> 1295## isLCDRenderText 1296 1297<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1298bool isLCDRenderText() const 1299</pre> 1300 1301If true, <a href="undocumented#Glyph">Glyphs</a> may use LCD striping to improve glyph edges. 1302 1303Returns true if <a href="#SkPaint_Flags">Flags</a> <a href="#SkPaint_kLCDRenderText_Flag">kLCDRenderText Flag</a> is set. 1304 1305### Return Value 1306 1307<a href="#SkPaint_kLCDRenderText_Flag">kLCDRenderText Flag</a> state 1308 1309### Example 1310 1311<div><fiddle-embed name="68e1fd95dd2fd06a333899d2bd2396b9"> 1312 1313#### Example Output 1314 1315~~~~ 1316paint.isLCDRenderText() == !!(paint.getFlags() & SkPaint::kLCDRenderText_Flag) 1317paint.isLCDRenderText() == !!(paint.getFlags() & SkPaint::kLCDRenderText_Flag) 1318~~~~ 1319 1320</fiddle-embed></div> 1321 1322--- 1323 1324<a name="SkPaint_setLCDRenderText"></a> 1325## setLCDRenderText 1326 1327<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1328void setLCDRenderText(bool lcdText) 1329</pre> 1330 1331Requests, but does not require, that <a href="undocumented#Glyph">Glyphs</a> use LCD striping for glyph edges. 1332 1333Sets <a href="#SkPaint_kLCDRenderText_Flag">kLCDRenderText Flag</a> if <a href="#SkPaint_setLCDRenderText_lcdText">lcdText</a> is true. 1334Clears <a href="#SkPaint_kLCDRenderText_Flag">kLCDRenderText Flag</a> if <a href="#SkPaint_setLCDRenderText_lcdText">lcdText</a> is false. 1335 1336### Parameters 1337 1338<table> <tr> <td><a name="SkPaint_setLCDRenderText_lcdText"> <code><strong>lcdText </strong></code> </a></td> <td> 1339setting for <a href="#SkPaint_kLCDRenderText_Flag">kLCDRenderText Flag</a></td> 1340 </tr> 1341</table> 1342 1343### Example 1344 1345<div><fiddle-embed name="50dedf8450159571a3edaf4f0050defe"> 1346 1347#### Example Output 1348 1349~~~~ 1350paint1 == paint2 1351~~~~ 1352 1353</fiddle-embed></div> 1354 1355--- 1356 1357## <a name="Font_Embedded_Bitmaps"></a> Font Embedded Bitmaps 1358 1359<a href="#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> allows selecting custom sized bitmap <a href="undocumented#Glyph">Glyphs</a>. 1360<a href="#SkPaint_Flags">Flags</a> <a href="#SkPaint_kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> when set chooses an embedded bitmap glyph over an outline contained 1361in a font if the platform supports this option. 1362 1363FreeType selects the bitmap glyph if available when <a href="#SkPaint_kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> is set, and selects 1364the outline glyph if <a href="#SkPaint_kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> is clear. 1365Windows may select the bitmap glyph but is not required to do so. 1366<a href="undocumented#OS_X">OS X</a> and iOS do not support this option. 1367 1368<a href="#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> is disabled by default. 1369<a href="#Font_Embedded_Bitmaps">Font Embedded Bitmaps</a> can be enabled by default by setting <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a> to 1370<a href="#SkPaint_kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> at compile time. 1371 1372### Example 1373 1374<pre style="padding: 1em 1em 1em 1em; font-size: 13px width: 62.5em; background-color: #f0f0f0"> 1375void draw(SkCanvas* canvas) {<div>The "hintgasp" TrueType font in the Skia resources/fonts directory 1376 includes an embedded bitmap Glyph at odd font sizes. This example works 1377 on platforms that use FreeType as their Font_Engine. 1378 Windows may, but is not required to, return a bitmap glyph if 1379 kEmbeddedBitmapText_Flag is set.</div>SkBitmap bitmap; 1380 bitmap.allocN32Pixels(30, 15); 1381 bitmap.eraseColor(0); 1382 SkCanvas offscreen(bitmap); 1383 SkPaint paint; 1384 paint.setAntiAlias(true); 1385 paint.setTextSize(13); 1386 paint.setTypeface(MakeResourceAsTypeface("fonts/hintgasp.ttf")); 1387 for (bool embedded : { false, true}) { 1388 paint.setEmbeddedBitmapText(embedded); 1389 offscreen.drawString("A", embedded ? 5 : 15, 15, paint); 1390 } 1391 canvas->drawBitmap(bitmap, 0, 0); 1392 canvas->scale(10, 10); 1393 canvas->drawBitmap(bitmap, -2, 1); 1394} 1395</pre> 1396 1397<a name="SkPaint_isEmbeddedBitmapText"></a> 1398## isEmbeddedBitmapText 1399 1400<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1401bool isEmbeddedBitmapText() const 1402</pre> 1403 1404If true, <a href="undocumented#Engine">Font Engine</a> may return <a href="undocumented#Glyph">Glyphs</a> from font bitmaps instead of from outlines. 1405 1406Equivalent to <a href="#SkPaint_getFlags">getFlags</a> masked with <a href="#SkPaint_kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a>. 1407 1408### Return Value 1409 1410<a href="#SkPaint_kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> state 1411 1412### Example 1413 1414<div><fiddle-embed name="eba10b27b790e87183ae451b3fc5c4b1"> 1415 1416#### Example Output 1417 1418~~~~ 1419paint.isEmbeddedBitmapText() == !!(paint.getFlags() & SkPaint::kEmbeddedBitmapText_Flag) 1420paint.isEmbeddedBitmapText() == !!(paint.getFlags() & SkPaint::kEmbeddedBitmapText_Flag) 1421~~~~ 1422 1423</fiddle-embed></div> 1424 1425--- 1426 1427<a name="SkPaint_setEmbeddedBitmapText"></a> 1428## setEmbeddedBitmapText 1429 1430<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1431void setEmbeddedBitmapText(bool useEmbeddedBitmapText) 1432</pre> 1433 1434Requests, but does not require, to use bitmaps in fonts instead of outlines. 1435 1436Sets <a href="#SkPaint_kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> if <a href="#SkPaint_setEmbeddedBitmapText_useEmbeddedBitmapText">useEmbeddedBitmapText</a> is true. 1437Clears <a href="#SkPaint_kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a> if <a href="#SkPaint_setEmbeddedBitmapText_useEmbeddedBitmapText">useEmbeddedBitmapText</a> is false. 1438 1439### Parameters 1440 1441<table> <tr> <td><a name="SkPaint_setEmbeddedBitmapText_useEmbeddedBitmapText"> <code><strong>useEmbeddedBitmapText </strong></code> </a></td> <td> 1442setting for <a href="#SkPaint_kEmbeddedBitmapText_Flag">kEmbeddedBitmapText Flag</a></td> 1443 </tr> 1444</table> 1445 1446### Example 1447 1448<div><fiddle-embed name="246dffdd93a484ba4ad7ecf71198a5d4"> 1449 1450#### Example Output 1451 1452~~~~ 1453paint1 == paint2 1454~~~~ 1455 1456</fiddle-embed></div> 1457 1458--- 1459 1460## <a name="Automatic_Hinting"></a> Automatic Hinting 1461 1462If <a href="#SkPaint_Hinting">Hinting</a> is set to <a href="#SkPaint_kNormal_Hinting">kNormal Hinting</a> or <a href="#SkPaint_kFull_Hinting">kFull Hinting</a>, <a href="#Automatic_Hinting">Automatic Hinting</a> 1463instructs the <a href="undocumented#Font_Manager">Font Manager</a> to always hint <a href="undocumented#Glyph">Glyphs</a>. 1464<a href="#Automatic_Hinting">Automatic Hinting</a> has no effect if <a href="#SkPaint_Hinting">Hinting</a> is set to <a href="#SkPaint_kNo_Hinting">kNo Hinting</a> or 1465<a href="#SkPaint_kSlight_Hinting">kSlight Hinting</a>. 1466 1467<a href="#Automatic_Hinting">Automatic Hinting</a> only affects platforms that use FreeType as the <a href="undocumented#Font_Manager">Font Manager</a>. 1468 1469<a name="SkPaint_isAutohinted"></a> 1470## isAutohinted 1471 1472<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1473bool isAutohinted() const 1474</pre> 1475 1476If true, and if <a href="#SkPaint_Hinting">Hinting</a> is set to <a href="#SkPaint_kNormal_Hinting">kNormal Hinting</a> or <a href="#SkPaint_kFull_Hinting">kFull Hinting</a>, and if 1477platform uses FreeType as the <a href="undocumented#Font_Manager">Font Manager</a>, instruct the <a href="undocumented#Font_Manager">Font Manager</a> to always hint 1478<a href="undocumented#Glyph">Glyphs</a>. 1479 1480Equivalent to <a href="#SkPaint_getFlags">getFlags</a> masked with <a href="#SkPaint_kAutoHinting_Flag">kAutoHinting Flag</a>. 1481 1482### Return Value 1483 1484<a href="#SkPaint_kAutoHinting_Flag">kAutoHinting Flag</a> state 1485 1486### Example 1487 1488<div><fiddle-embed name="aa4781afbe3b90e7ef56a287e5b9ce1e"> 1489 1490#### Example Output 1491 1492~~~~ 1493paint.isAutohinted() == !!(paint.getFlags() & SkPaint::kAutoHinting_Flag) 1494paint.isAutohinted() == !!(paint.getFlags() & SkPaint::kAutoHinting_Flag) 1495~~~~ 1496 1497</fiddle-embed></div> 1498 1499### See Also 1500 1501<a href="#SkPaint_setAutohinted">setAutohinted</a> <a href="#SkPaint_Hinting">Hinting</a> 1502 1503--- 1504 1505<a name="SkPaint_setAutohinted"></a> 1506## setAutohinted 1507 1508<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1509void setAutohinted(bool useAutohinter) 1510</pre> 1511 1512If <a href="#SkPaint_Hinting">Hinting</a> is set to <a href="#SkPaint_kNormal_Hinting">kNormal Hinting</a> or <a href="#SkPaint_kFull_Hinting">kFull Hinting</a> and <a href="#SkPaint_setAutohinted_useAutohinter">useAutohinter</a> is set, 1513instruct the <a href="undocumented#Font_Manager">Font Manager</a> to always hint <a href="undocumented#Glyph">Glyphs</a>. 1514<a href="#Automatic_Hinting">Automatic Hinting</a> has no effect if <a href="#SkPaint_Hinting">Hinting</a> is set to <a href="#SkPaint_kNo_Hinting">kNo Hinting</a> or 1515<a href="#SkPaint_kSlight_Hinting">kSlight Hinting</a>. 1516 1517Only affects platforms that use FreeType as the <a href="undocumented#Font_Manager">Font Manager</a>. 1518 1519Sets <a href="#SkPaint_kAutoHinting_Flag">kAutoHinting Flag</a> if <a href="#SkPaint_setAutohinted_useAutohinter">useAutohinter</a> is true. 1520Clears <a href="#SkPaint_kAutoHinting_Flag">kAutoHinting Flag</a> if <a href="#SkPaint_setAutohinted_useAutohinter">useAutohinter</a> is false. 1521 1522### Parameters 1523 1524<table> <tr> <td><a name="SkPaint_setAutohinted_useAutohinter"> <code><strong>useAutohinter </strong></code> </a></td> <td> 1525setting for <a href="#SkPaint_kAutoHinting_Flag">kAutoHinting Flag</a></td> 1526 </tr> 1527</table> 1528 1529### Example 1530 1531<div><fiddle-embed name="4e185306d7de9390fe8445eed0139309"></fiddle-embed></div> 1532 1533### See Also 1534 1535<a href="#SkPaint_isAutohinted">isAutohinted</a> <a href="#SkPaint_Hinting">Hinting</a> 1536 1537--- 1538 1539## <a name="Vertical_Text"></a> Vertical Text 1540 1541<a href="undocumented#Text">Text</a> may be drawn by positioning each glyph, or by positioning the first glyph and 1542using <a href="undocumented#Advance">Font Advance</a> to position subsequent <a href="undocumented#Glyph">Glyphs</a>. By default, each successive glyph 1543is positioned to the right of the preceding glyph. <a href="#Vertical_Text">Vertical Text</a> sets successive 1544<a href="undocumented#Glyph">Glyphs</a> to position below the preceding glyph. 1545 1546Skia can translate text character codes as a series of <a href="undocumented#Glyph">Glyphs</a>, but does not implement 1547font substitution, 1548textual substitution, line layout, or contextual spacing like Kerning pairs. Use 1549a text shaping engine like <a href="http://harfbuzz.org/">HarfBuzz</a> to translate text runs 1550into glyph series. 1551 1552<a href="#Vertical_Text">Vertical Text</a> is clear if text is drawn left to right or set if drawn from top to bottom. 1553 1554<a href="#SkPaint_Flags">Flags</a> <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> if clear draws text left to right. 1555<a href="#SkPaint_Flags">Flags</a> <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> if set draws text top to bottom. 1556 1557<a href="#Vertical_Text">Vertical Text</a> is clear by default. 1558<a href="#Vertical_Text">Vertical Text</a> can be set by default by setting <a href="undocumented#SkPaintDefaults_Flags">SkPaintDefaults Flags</a> to 1559<a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> at compile time. 1560 1561### Example 1562 1563<div><fiddle-embed name="8df5800819311b71373d9abb669b49b8"></fiddle-embed></div> 1564 1565<a name="SkPaint_isVerticalText"></a> 1566## isVerticalText 1567 1568<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1569bool isVerticalText() const 1570</pre> 1571 1572If true, <a href="undocumented#Glyph">Glyphs</a> are drawn top to bottom instead of left to right. 1573 1574Equivalent to <a href="#SkPaint_getFlags">getFlags</a> masked with <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a>. 1575 1576### Return Value 1577 1578<a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> state 1579 1580### Example 1581 1582<div><fiddle-embed name="4a269b16e644d473870ffa873396f139"> 1583 1584#### Example Output 1585 1586~~~~ 1587paint.isVerticalText() == !!(paint.getFlags() & SkPaint::kVerticalText_Flag) 1588paint.isVerticalText() == !!(paint.getFlags() & SkPaint::kVerticalText_Flag) 1589~~~~ 1590 1591</fiddle-embed></div> 1592 1593--- 1594 1595<a name="SkPaint_setVerticalText"></a> 1596## setVerticalText 1597 1598<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1599void setVerticalText(bool verticalText) 1600</pre> 1601 1602If true, text advance positions the next glyph below the previous glyph instead of to the 1603right of previous glyph. 1604 1605Sets <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> if vertical is true. 1606Clears <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> if vertical is false. 1607 1608### Parameters 1609 1610<table> <tr> <td><a name="SkPaint_setVerticalText_verticalText"> <code><strong>verticalText </strong></code> </a></td> <td> 1611setting for <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a></td> 1612 </tr> 1613</table> 1614 1615### Example 1616 1617<div><fiddle-embed name="6fbd7e9e1a346cb8d7f537786009c736"> 1618 1619#### Example Output 1620 1621~~~~ 1622paint1 == paint2 1623~~~~ 1624 1625</fiddle-embed></div> 1626 1627--- 1628 1629## <a name="Fake_Bold"></a> Fake Bold 1630 1631<a href="#Fake_Bold">Fake Bold</a> approximates the bold font style accompanying a normal font when a bold font face 1632is not available. Skia does not provide font substitution; it is up to the client to find the 1633bold font face using the platform <a href="undocumented#Font_Manager">Font Manager</a>. 1634 1635Use <a href="#Text_Skew_X">Text Skew X</a> to approximate an italic font style when the italic font face 1636is not available. 1637 1638A FreeType based port may define SK_USE_FREETYPE_EMBOLDEN at compile time to direct 1639the font engine to create the bold <a href="undocumented#Glyph">Glyphs</a>. Otherwise, the extra bold is computed 1640by increasing the stroke width and setting the <a href="#SkPaint_Style">Style</a> to <a href="#SkPaint_kStrokeAndFill_Style">kStrokeAndFill Style</a> as needed. 1641 1642<a href="#Fake_Bold">Fake Bold</a> is disabled by default. 1643 1644### Example 1645 1646<div><fiddle-embed name="e811f4829a2daaaeaad3795504a7e02a"></fiddle-embed></div> 1647 1648<a name="SkPaint_isFakeBoldText"></a> 1649## isFakeBoldText 1650 1651<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1652bool isFakeBoldText() const 1653</pre> 1654 1655If true, approximate bold by increasing the stroke width when creating glyph bitmaps 1656from outlines. 1657 1658Equivalent to <a href="#SkPaint_getFlags">getFlags</a> masked with <a href="#SkPaint_kFakeBoldText_Flag">kFakeBoldText Flag</a>. 1659 1660### Return Value 1661 1662<a href="#SkPaint_kFakeBoldText_Flag">kFakeBoldText Flag</a> state 1663 1664### Example 1665 1666<div><fiddle-embed name="f54d1f85b16073b80b9eef2e1a1d151d"> 1667 1668#### Example Output 1669 1670~~~~ 1671paint.isFakeBoldText() == !!(paint.getFlags() & SkPaint::kFakeBoldText_Flag) 1672paint.isFakeBoldText() == !!(paint.getFlags() & SkPaint::kFakeBoldText_Flag) 1673~~~~ 1674 1675</fiddle-embed></div> 1676 1677--- 1678 1679<a name="SkPaint_setFakeBoldText"></a> 1680## setFakeBoldText 1681 1682<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1683void setFakeBoldText(bool fakeBoldText) 1684</pre> 1685 1686Use increased stroke width when creating glyph bitmaps to approximate a bold typeface. 1687 1688Sets <a href="#SkPaint_kFakeBoldText_Flag">kFakeBoldText Flag</a> if <a href="#SkPaint_setFakeBoldText_fakeBoldText">fakeBoldText</a> is true. 1689Clears <a href="#SkPaint_kFakeBoldText_Flag">kFakeBoldText Flag</a> if <a href="#SkPaint_setFakeBoldText_fakeBoldText">fakeBoldText</a> is false. 1690 1691### Parameters 1692 1693<table> <tr> <td><a name="SkPaint_setFakeBoldText_fakeBoldText"> <code><strong>fakeBoldText </strong></code> </a></td> <td> 1694setting for <a href="#SkPaint_kFakeBoldText_Flag">kFakeBoldText Flag</a></td> 1695 </tr> 1696</table> 1697 1698### Example 1699 1700<div><fiddle-embed name="594d47858eb11028cb626515a520910a"> 1701 1702#### Example Output 1703 1704~~~~ 1705paint1 == paint2 1706~~~~ 1707 1708</fiddle-embed></div> 1709 1710--- 1711 1712## <a name="Full_Hinting_Spacing"></a> Full Hinting Spacing 1713 1714if <a href="#SkPaint_Hinting">Hinting</a> is set to <a href="#SkPaint_kFull_Hinting">kFull Hinting</a>, <a href="#Full_Hinting_Spacing">Full Hinting Spacing</a> adjusts the character 1715spacing by the difference of the hinted and Unhinted <a href="undocumented#Left_Side_Bearing">Left Side Bearing</a> and 1716<a href="undocumented#Right_Side_Bearing">Right Side Bearing</a>. <a href="#Full_Hinting_Spacing">Full Hinting Spacing</a> only applies to platforms that use 1717FreeType as their <a href="undocumented#Engine">Font Engine</a>. 1718 1719<a href="#Full_Hinting_Spacing">Full Hinting Spacing</a> is not related to text Kerning, where the space between 1720a specific pair of characters is adjusted using data in the font Kerning tables. 1721 1722<a name="SkPaint_isDevKernText"></a> 1723## isDevKernText 1724 1725<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1726bool isDevKernText() const 1727</pre> 1728 1729Returns if character spacing may be adjusted by the hinting difference. 1730 1731Equivalent to <a href="#SkPaint_getFlags">getFlags</a> masked with <a href="#SkPaint_kDevKernText_Flag">kDevKernText Flag</a>. 1732 1733### Return Value 1734 1735<a href="#SkPaint_kDevKernText_Flag">kDevKernText Flag</a> state 1736 1737### Example 1738 1739<div><fiddle-embed name="4f69a84b2505b12809c30b0cc09c5157"></fiddle-embed></div> 1740 1741--- 1742 1743<a name="SkPaint_setDevKernText"></a> 1744## setDevKernText 1745 1746<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1747void setDevKernText(bool devKernText) 1748</pre> 1749 1750Requests, but does not require, to use hinting to adjust glyph spacing. 1751 1752Sets <a href="#SkPaint_kDevKernText_Flag">kDevKernText Flag</a> if <a href="#SkPaint_setDevKernText_devKernText">devKernText</a> is true. 1753Clears <a href="#SkPaint_kDevKernText_Flag">kDevKernText Flag</a> if <a href="#SkPaint_setDevKernText_devKernText">devKernText</a> is false. 1754 1755### Parameters 1756 1757<table> <tr> <td><a name="SkPaint_setDevKernText_devKernText"> <code><strong>devKernText </strong></code> </a></td> <td> 1758setting for <a href="#SkPaint_setDevKernText_devKernText">devKernText</a></td> 1759 </tr> 1760</table> 1761 1762### Example 1763 1764<div><fiddle-embed name="2b718a059072908bf68942503f264797"> 1765 1766#### Example Output 1767 1768~~~~ 1769paint1 == paint2 1770~~~~ 1771 1772</fiddle-embed></div> 1773 1774--- 1775 1776## <a name="Filter_Quality_Methods"></a> Filter Quality Methods 1777 1778<a href="undocumented#Filter_Quality">Filter Quality</a> trades speed for image filtering when the image is scaled. 1779A lower <a href="undocumented#Filter_Quality">Filter Quality</a> draws faster, but has less fidelity. 1780A higher <a href="undocumented#Filter_Quality">Filter Quality</a> draws slower, but looks better. 1781If the image is drawn without scaling, the <a href="undocumented#Filter_Quality">Filter Quality</a> choice will not result 1782in a noticeable difference. 1783 1784<a href="undocumented#Filter_Quality">Filter Quality</a> is used in <a href="#Paint">Paint</a> passed as a parameter to 1785 1786<table> <tr> 1787 <td><a href="SkCanvas_Reference#SkCanvas_drawBitmap">SkCanvas::drawBitmap</a></td> </tr> <tr> 1788 <td><a href="SkCanvas_Reference#SkCanvas_drawBitmapRect">SkCanvas::drawBitmapRect</a></td> </tr> <tr> 1789 <td><a href="SkCanvas_Reference#SkCanvas_drawImage">SkCanvas::drawImage</a></td> </tr> <tr> 1790 <td><a href="SkCanvas_Reference#SkCanvas_drawImageRect">SkCanvas::drawImageRect</a></td> </tr> 1791</table> 1792 1793and when <a href="#Paint">Paint</a> has a <a href="undocumented#Shader">Shader</a> specialization that uses <a href="SkImage_Reference#Image">Image</a> or <a href="SkBitmap_Reference#Bitmap">Bitmap</a>. 1794 1795<a href="undocumented#Filter_Quality">Filter Quality</a> is <a href="undocumented#kNone_SkFilterQuality">kNone_SkFilterQuality</a> by default. 1796 1797### Example 1798 1799<div><fiddle-embed name="ee77f83f7291e07ae0d89f1380c7d67c"></fiddle-embed></div> 1800 1801<a name="SkPaint_getFilterQuality"></a> 1802## getFilterQuality 1803 1804<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1805SkFilterQuality getFilterQuality() const 1806</pre> 1807 1808Returns <a href="undocumented#Filter_Quality">Filter Quality</a>, the image filtering level. A lower setting 1809draws faster; a higher setting looks better when the image is scaled. 1810 1811### Return Value 1812 1813one of: <a href="undocumented#kNone_SkFilterQuality">kNone_SkFilterQuality</a>, <a href="undocumented#kLow_SkFilterQuality">kLow_SkFilterQuality</a>, 1814<a href="undocumented#kMedium_SkFilterQuality">kMedium_SkFilterQuality</a>, <a href="undocumented#kHigh_SkFilterQuality">kHigh_SkFilterQuality</a> 1815 1816### Example 1817 1818<div><fiddle-embed name="d4ca1f23809b6835c4ba46ea98a86900"> 1819 1820#### Example Output 1821 1822~~~~ 1823kNone_SkFilterQuality == paint.getFilterQuality() 1824~~~~ 1825 1826</fiddle-embed></div> 1827 1828--- 1829 1830<a name="SkPaint_setFilterQuality"></a> 1831## setFilterQuality 1832 1833<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1834void setFilterQuality(SkFilterQuality quality) 1835</pre> 1836 1837Sets <a href="undocumented#Filter_Quality">Filter Quality</a>, the image filtering level. A lower setting 1838draws faster; a higher setting looks better when the image is scaled. 1839Does not check to see if <a href="#SkPaint_setFilterQuality_quality">quality</a> is valid. 1840 1841### Parameters 1842 1843<table> <tr> <td><a name="SkPaint_setFilterQuality_quality"> <code><strong>quality </strong></code> </a></td> <td> 1844one of: <a href="undocumented#kNone_SkFilterQuality">kNone_SkFilterQuality</a>, <a href="undocumented#kLow_SkFilterQuality">kLow_SkFilterQuality</a>, 1845<a href="undocumented#kMedium_SkFilterQuality">kMedium_SkFilterQuality</a>, <a href="undocumented#kHigh_SkFilterQuality">kHigh_SkFilterQuality</a></td> 1846 </tr> 1847</table> 1848 1849### Example 1850 1851<div><fiddle-embed name="e4288fabf24ee60b645e8bb6ea0afadf"> 1852 1853#### Example Output 1854 1855~~~~ 1856kHigh_SkFilterQuality == paint.getFilterQuality() 1857~~~~ 1858 1859</fiddle-embed></div> 1860 1861### See Also 1862 1863<a href="undocumented#SkFilterQuality">SkFilterQuality</a> <a href="undocumented#Image_Scaling">Image Scaling</a> 1864 1865--- 1866 1867## <a name="Color_Methods"></a> Color Methods 1868 1869| name | description | 1870| --- | --- | 1871| <a href="#SkPaint_getColor">getColor</a> | returns <a href="undocumented#Alpha">Color Alpha</a> and <a href="undocumented#RGB">Color RGB</a>, one drawing color | 1872| <a href="#SkPaint_setColor">setColor</a> | sets <a href="undocumented#Alpha">Color Alpha</a> and <a href="undocumented#RGB">Color RGB</a>, one drawing color | 1873 1874<a href="undocumented#Color">Color</a> specifies the <a href="undocumented#RGB_Red">Color RGB Red</a>, <a href="undocumented#RGB_Blue">Color RGB Blue</a>, <a href="undocumented#RGB_Green">Color RGB Green</a>, and <a href="undocumented#Alpha">Color Alpha</a> 1875values used to draw a filled or stroked shape in a 32-bit value. Each component 1876occupies 8-bits, ranging from zero: no contribution; to 255: full intensity. 1877All values in any combination are valid. 1878 1879<a href="undocumented#Color">Color</a> is not <a href="undocumented#Premultiply">Premultiplied</a>; <a href="undocumented#Alpha">Color Alpha</a> sets the transparency independent of 1880<a href="undocumented#RGB">Color RGB</a>: <a href="undocumented#RGB_Red">Color RGB Red</a>, <a href="undocumented#RGB_Blue">Color RGB Blue</a>, and <a href="undocumented#RGB_Green">Color RGB Green</a>. 1881 1882The bit positions of <a href="undocumented#Alpha">Color Alpha</a> and <a href="undocumented#RGB">Color RGB</a> are independent of the bit 1883positions on the output device, which may have more or fewer bits, and may have 1884a different arrangement. 1885 1886| bit positions | <a href="undocumented#Alpha">Color Alpha</a> | <a href="undocumented#RGB_Red">Color RGB Red</a> | <a href="undocumented#RGB_Blue">Color RGB Blue</a> | <a href="undocumented#RGB_Green">Color RGB Green</a> | 1887| --- | --- | --- | --- | --- | 1888| | 31 - 24 | 23 - 16 | 15 - 8 | 7 - 0 | 1889 1890### Example 1891 1892<div><fiddle-embed name="214b559d75c65a7bef6ef4be1f860053"></fiddle-embed></div> 1893 1894<a name="SkPaint_getColor"></a> 1895## getColor 1896 1897<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1898SkColor getColor() const 1899</pre> 1900 1901Retrieves <a href="undocumented#Alpha">Alpha</a> and <a href="undocumented#RGB">Color RGB</a>, <a href="undocumented#Unpremultiply">Unpremultiplied</a>, packed into 32 bits. 1902Use helpers <a href="undocumented#SkColorGetA">SkColorGetA</a>, <a href="undocumented#SkColorGetR">SkColorGetR</a>, <a href="undocumented#SkColorGetG">SkColorGetG</a>, and <a href="undocumented#SkColorGetB">SkColorGetB</a> to extract 1903a color component. 1904 1905### Return Value 1906 1907<a href="undocumented#Unpremultiply">Unpremultiplied</a> <a href="undocumented#ARGB">Color ARGB</a> 1908 1909### Example 1910 1911<div><fiddle-embed name="72d41f890203109a41f589a7403acae9"> 1912 1913#### Example Output 1914 1915~~~~ 1916Yellow is 100% red, 100% green, and 0% blue. 1917~~~~ 1918 1919</fiddle-embed></div> 1920 1921### See Also 1922 1923<a href="undocumented#SkColor">SkColor</a> 1924 1925--- 1926 1927<a name="SkPaint_setColor"></a> 1928## setColor 1929 1930<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1931void setColor(SkColor color) 1932</pre> 1933 1934Sets <a href="undocumented#Alpha">Alpha</a> and <a href="undocumented#RGB">Color RGB</a> used when stroking and filling. The <a href="#SkPaint_setColor_color">color</a> is a 32-bit value, 1935<a href="undocumented#Unpremultiply">Unpremultiplied</a>, packing 8-bit components for <a href="undocumented#Alpha">Alpha</a>, <a href="undocumented#RGB_Red">Red</a>, <a href="undocumented#RGB_Blue">Blue</a>, and <a href="undocumented#RGB_Green">Green</a>. 1936 1937### Parameters 1938 1939<table> <tr> <td><a name="SkPaint_setColor_color"> <code><strong>color </strong></code> </a></td> <td> 1940<a href="undocumented#Unpremultiply">Unpremultiplied</a> <a href="undocumented#ARGB">Color ARGB</a></td> 1941 </tr> 1942</table> 1943 1944### Example 1945 1946<div><fiddle-embed name="6e70f18300bd676a3c056ceb6b62f8df"> 1947 1948#### Example Output 1949 1950~~~~ 1951green1 == green2 1952~~~~ 1953 1954</fiddle-embed></div> 1955 1956### See Also 1957 1958<a href="undocumented#SkColor">SkColor</a> <a href="#SkPaint_setARGB">setARGB</a> <a href="undocumented#SkColorSetARGB">SkColorSetARGB</a> 1959 1960--- 1961 1962## <a name="Alpha_Methods"></a> Alpha Methods 1963 1964<a href="undocumented#Alpha">Color Alpha</a> sets the transparency independent of <a href="undocumented#RGB">Color RGB</a>: <a href="undocumented#RGB_Red">Color RGB Red</a>, <a href="undocumented#RGB_Blue">Color RGB Blue</a>, and <a href="undocumented#RGB_Green">Color RGB Green</a>. 1965 1966<a name="SkPaint_getAlpha"></a> 1967## getAlpha 1968 1969<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1970uint8_t getAlpha() const 1971</pre> 1972 1973Retrieves <a href="undocumented#Alpha">Alpha</a> from the <a href="undocumented#Color">Color</a> used when stroking and filling. 1974 1975### Return Value 1976 1977<a href="undocumented#Alpha">Alpha</a> ranging from zero, fully transparent, to 255, fully opaque 1978 1979### Example 1980 1981<div><fiddle-embed name="9a85bb62fe3d877b18fb7f952c4fa7f7"> 1982 1983#### Example Output 1984 1985~~~~ 1986255 == paint.getAlpha() 1987~~~~ 1988 1989</fiddle-embed></div> 1990 1991--- 1992 1993<a name="SkPaint_setAlpha"></a> 1994## setAlpha 1995 1996<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1997void setAlpha(U8CPU a) 1998</pre> 1999 2000Replaces <a href="undocumented#Alpha">Alpha</a>, leaving <a href="undocumented#RGB">Color RGB</a> 2001unchanged. An out of range value triggers an assert in the debug 2002build. <a href="#SkPaint_setAlpha_a">a</a> is <a href="#SkPaint_setAlpha_a">a</a> value from zero to 255. 2003<a href="#SkPaint_setAlpha_a">a</a> set to zero makes <a href="undocumented#Color">Color</a> fully transparent; <a href="#SkPaint_setAlpha_a">a</a> set to 255 makes <a href="undocumented#Color">Color</a> 2004fully opaque. 2005 2006### Parameters 2007 2008<table> <tr> <td><a name="SkPaint_setAlpha_a"> <code><strong>a </strong></code> </a></td> <td> 2009<a href="undocumented#Alpha">Alpha</a> component of <a href="undocumented#Color">Color</a></td> 2010 </tr> 2011</table> 2012 2013### Example 2014 2015<div><fiddle-embed name="6ddc0360512dfb9947e75c17e6a8103d"> 2016 2017#### Example Output 2018 2019~~~~ 20200x44112233 == paint.getColor() 2021~~~~ 2022 2023</fiddle-embed></div> 2024 2025--- 2026 2027<a name="SkPaint_setARGB"></a> 2028## setARGB 2029 2030<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2031void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) 2032</pre> 2033 2034Sets <a href="undocumented#Color">Color</a> used when drawing solid fills. The color components range from 0 to 255. 2035The color is <a href="undocumented#Unpremultiply">Unpremultiplied</a>; <a href="undocumented#Alpha">Alpha</a> sets the transparency independent of <a href="undocumented#RGB">Color RGB</a>. 2036 2037### Parameters 2038 2039<table> <tr> <td><a name="SkPaint_setARGB_a"> <code><strong>a </strong></code> </a></td> <td> 2040amount of <a href="undocumented#Alpha">Color Alpha</a>, from fully transparent (0) to fully opaque (255)</td> 2041 </tr> <tr> <td><a name="SkPaint_setARGB_r"> <code><strong>r </strong></code> </a></td> <td> 2042amount of <a href="undocumented#RGB_Red">Color RGB Red</a>, from no red (0) to full red (255)</td> 2043 </tr> <tr> <td><a name="SkPaint_setARGB_g"> <code><strong>g </strong></code> </a></td> <td> 2044amount of <a href="undocumented#RGB_Green">Color RGB Green</a>, from no green (0) to full green (255)</td> 2045 </tr> <tr> <td><a name="SkPaint_setARGB_b"> <code><strong>b </strong></code> </a></td> <td> 2046amount of <a href="undocumented#RGB_Blue">Color RGB Blue</a>, from no blue (0) to full blue (255)</td> 2047 </tr> 2048</table> 2049 2050### Example 2051 2052<div><fiddle-embed name="cb62e4755789ed32f7120dc55984959d"> 2053 2054#### Example Output 2055 2056~~~~ 2057transRed1 == transRed2 2058~~~~ 2059 2060</fiddle-embed></div> 2061 2062### See Also 2063 2064<a href="#SkPaint_setColor">setColor</a> <a href="undocumented#SkColorSetARGB">SkColorSetARGB</a> 2065 2066--- 2067 2068## <a name="Style"></a> Style 2069 2070<a href="#Style">Style</a> specifies if the geometry is filled, stroked, or both filled and stroked. 2071Some shapes ignore <a href="#Style">Style</a> and are always drawn filled or stroked. 2072 2073Set <a href="#Style">Style</a> to <a href="#SkPaint_kFill_Style">kFill Style</a> to fill the shape. 2074The fill covers the area inside the geometry for most shapes. 2075 2076Set <a href="#Style">Style</a> to <a href="#SkPaint_kStroke_Style">kStroke Style</a> to stroke the shape. 2077 2078## <a name="Style_Fill"></a> Style Fill 2079 2080### See Also 2081 2082<a href="SkPath_Reference#Fill_Type">Path Fill Type</a> 2083 2084## <a name="Style_Stroke"></a> Style Stroke 2085 2086The stroke covers the area described by following the shape edge with a pen or brush of 2087<a href="#Stroke_Width">Stroke Width</a>. The area covered where the shape starts and stops is described by <a href="#Stroke_Cap">Stroke Cap</a>. 2088The area covered where the shape turns a corner is described by <a href="#Stroke_Join">Stroke Join</a>. 2089The stroke is centered on the shape; it extends equally on either side of the shape edge. 2090 2091As <a href="#Stroke_Width">Stroke Width</a> gets smaller, the drawn path frame is thinner. <a href="#Stroke_Width">Stroke Width</a> less than one 2092may have gaps, and if <a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a> is set, <a href="undocumented#Alpha">Color Alpha</a> will increase to visually decrease coverage. 2093 2094## <a name="Style_Hairline"></a> Style Hairline 2095 2096<a href="#Stroke_Width">Stroke Width</a> of zero has a special meaning and switches drawing to use <a href="#Style_Hairline">Hairline</a>. 2097<a href="#Style_Hairline">Hairline</a> draws the thinnest continuous frame. If <a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a> is clear, adjacent pixels 2098flow horizontally, vertically,or diagonally. 2099 2100<a href="SkPath_Reference#Path">Path</a> drawing with <a href="#Style_Hairline">Hairline</a> may hit the same pixel more than once. For instance, <a href="SkPath_Reference#Path">Path</a> containing 2101two lines in one <a href="SkPath_Reference#Contour">Path Contour</a> will draw the corner point once, but may both lines may draw the adjacent 2102pixel. If <a href="#SkPaint_kAntiAlias_Flag">kAntiAlias Flag</a> is set, transparency is applied twice, resulting in a darker pixel. Some 2103GPU-backed implementations apply transparency at a later drawing stage, avoiding double hit pixels 2104while stroking. 2105 2106## <a name="SkPaint_Style"></a> Enum SkPaint::Style 2107 2108<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2109enum <a href="#SkPaint_Style">Style</a> { 2110<a href="#SkPaint_kFill_Style">kFill Style</a>, 2111<a href="#SkPaint_kStroke_Style">kStroke Style</a>, 2112<a href="#SkPaint_kStrokeAndFill_Style">kStrokeAndFill Style</a>, 2113};</pre> 2114 2115Set <a href="#SkPaint_Style">Style</a> to fill, stroke, or both fill and stroke geometry. 2116The stroke and fill 2117share all paint attributes; for instance, they are drawn with the same color. 2118 2119Use <a href="#SkPaint_kStrokeAndFill_Style">kStrokeAndFill Style</a> to avoid hitting the same pixels twice with a stroke draw and 2120a fill draw. 2121 2122### Constants 2123 2124<table> 2125 <tr> 2126 <td><a name="SkPaint_kFill_Style"> <code><strong>SkPaint::kFill_Style </strong></code> </a></td><td>0</td><td>Set to fill geometry. 2127Applies to <a href="SkRect_Reference#Rect">Rect</a>, <a href="undocumented#Region">Region</a>, <a href="undocumented#Round_Rect">Round Rect</a>, <a href="undocumented#Circle">Circles</a>, <a href="undocumented#Oval">Ovals</a>, <a href="SkPath_Reference#Path">Path</a>, and <a href="undocumented#Text">Text</a>. 2128<a href="SkBitmap_Reference#Bitmap">Bitmap</a>, <a href="SkImage_Reference#Image">Image</a>, <a href="undocumented#Patch">Patches</a>, <a href="undocumented#Region">Region</a>, <a href="undocumented#Sprite">Sprites</a>, and <a href="undocumented#Vertices">Vertices</a> are painted as if 2129<a href="#SkPaint_kFill_Style">kFill Style</a> is set, and ignore the set <a href="#SkPaint_Style">Style</a>. 2130The <a href="SkPath_Reference#Fill_Type">Path Fill Type</a> specifies additional rules to fill the area outside the path edge, 2131and to create an unfilled hole inside the shape. 2132<a href="#SkPaint_Style">Style</a> is set to <a href="#SkPaint_kFill_Style">kFill Style</a> by default.</td> 2133 </tr> 2134 <tr> 2135 <td><a name="SkPaint_kStroke_Style"> <code><strong>SkPaint::kStroke_Style </strong></code> </a></td><td>1</td><td>Set to stroke geometry. 2136Applies to <a href="SkRect_Reference#Rect">Rect</a>, <a href="undocumented#Region">Region</a>, <a href="undocumented#Round_Rect">Round Rect</a>, <a href="undocumented#Arc">Arcs</a>, <a href="undocumented#Circle">Circles</a>, <a href="undocumented#Oval">Ovals</a>, <a href="SkPath_Reference#Path">Path</a>, and <a href="undocumented#Text">Text</a>. 2137<a href="undocumented#Arc">Arcs</a>, <a href="undocumented#Line">Lines</a>, and points, are always drawn as if <a href="#SkPaint_kStroke_Style">kStroke Style</a> is set, 2138and ignore the set <a href="#SkPaint_Style">Style</a>. 2139The stroke construction is unaffected by the <a href="SkPath_Reference#Fill_Type">Path Fill Type</a>.</td> 2140 </tr> 2141 <tr> 2142 <td><a name="SkPaint_kStrokeAndFill_Style"> <code><strong>SkPaint::kStrokeAndFill_Style </strong></code> </a></td><td>2</td><td>Set to stroke and fill geometry. 2143Applies to <a href="SkRect_Reference#Rect">Rect</a>, <a href="undocumented#Region">Region</a>, <a href="undocumented#Round_Rect">Round Rect</a>, <a href="undocumented#Circle">Circles</a>, <a href="undocumented#Oval">Ovals</a>, <a href="SkPath_Reference#Path">Path</a>, and <a href="undocumented#Text">Text</a>. 2144<a href="SkPath_Reference#Path">Path</a> is treated as if it is set to <a href="SkPath_Reference#SkPath_kWinding_FillType">SkPath::kWinding FillType</a>, 2145and the set <a href="SkPath_Reference#Fill_Type">Path Fill Type</a> is ignored.</td> 2146 </tr> 2147 2148</table> 2149 2150## <a name="SkPaint__anonymous"></a> Enum SkPaint::_anonymous 2151 2152<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2153enum { 2154<a href="#SkPaint_kStyleCount">kStyleCount</a> = <a href="#SkPaint_kStrokeAndFill_Style">kStrokeAndFill Style</a> + 1, 2155};</pre> 2156 2157### Constants 2158 2159<table> 2160 <tr> 2161 <td><a name="SkPaint_kStyleCount"> <code><strong>SkPaint::kStyleCount </strong></code> </a></td><td>3</td><td>The number of different <a href="#SkPaint_Style">Style</a> values defined. 2162May be used to verify that <a href="#SkPaint_Style">Style</a> is a legal value.</td> 2163 </tr> 2164 2165</table> 2166 2167<a name="SkPaint_getStyle"></a> 2168## getStyle 2169 2170<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2171Style getStyle() const 2172</pre> 2173 2174Whether the geometry is filled, stroked, or filled and stroked. 2175 2176### Return Value 2177 2178one of:<a href="#SkPaint_kFill_Style">kFill Style</a>, <a href="#SkPaint_kStroke_Style">kStroke Style</a>, <a href="#SkPaint_kStrokeAndFill_Style">kStrokeAndFill Style</a> 2179 2180### Example 2181 2182<div><fiddle-embed name="1c5e18c3c0102d2dac86a78ba8c8ce01"> 2183 2184#### Example Output 2185 2186~~~~ 2187SkPaint::kFill_Style == paint.getStyle() 2188~~~~ 2189 2190</fiddle-embed></div> 2191 2192### See Also 2193 2194<a href="#SkPaint_Style">Style</a> <a href="#SkPaint_setStyle">setStyle</a> 2195 2196--- 2197 2198<a name="SkPaint_setStyle"></a> 2199## setStyle 2200 2201<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2202void setStyle(Style style) 2203</pre> 2204 2205Sets whether the geometry is filled, stroked, or filled and stroked. 2206Has no effect if <a href="#SkPaint_setStyle_style">style</a> is not a legal <a href="#SkPaint_Style">Style</a> value. 2207 2208### Parameters 2209 2210<table> <tr> <td><a name="SkPaint_setStyle_style"> <code><strong>style </strong></code> </a></td> <td> 2211one of: <a href="#SkPaint_kFill_Style">kFill Style</a>, <a href="#SkPaint_kStroke_Style">kStroke Style</a>, <a href="#SkPaint_kStrokeAndFill_Style">kStrokeAndFill Style</a></td> 2212 </tr> 2213</table> 2214 2215### Example 2216 2217<div><fiddle-embed name="c7bb6248e4735b8d1a32d02fba40d344"></fiddle-embed></div> 2218 2219### See Also 2220 2221<a href="#SkPaint_Style">Style</a> <a href="#SkPaint_getStyle">getStyle</a> 2222 2223--- 2224 2225### See Also 2226 2227<a href="SkPath_Reference#Fill_Type">Path Fill Type</a> <a href="undocumented#Path_Effect">Path Effect</a> <a href="#Style_Fill">Style Fill</a> <a href="#Style_Stroke">Style Stroke</a> 2228 2229## <a name="Stroke_Width"></a> Stroke Width 2230 2231<a href="#Stroke_Width">Stroke Width</a> sets the width for stroking. The width is the thickness 2232of the stroke perpendicular to the path direction when the paint style is 2233set to <a href="#SkPaint_kStroke_Style">kStroke Style</a> or <a href="#SkPaint_kStrokeAndFill_Style">kStrokeAndFill Style</a>. 2234 2235When width is greater than zero, the stroke encompasses as many pixels partially 2236or fully as needed. When the width equals zero, the paint enables hairlines; 2237the stroke is always one pixel wide. 2238 2239The stroke dimensions are scaled by the canvas matrix, but <a href="#Style_Hairline">Hairline</a> stroke 2240remains one pixel wide regardless of scaling. 2241 2242The default width for the paint is zero. 2243 2244### Example 2245 2246<div><fiddle-embed name="01e3e08a3022a351628ff54e84887756" gpu="true"><div>The pixels hit to represent thin lines vary with the angle of the 2247line and the platform implementation.</div></fiddle-embed></div> 2248 2249<a name="SkPaint_getStrokeWidth"></a> 2250## getStrokeWidth 2251 2252<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2253SkScalar getStrokeWidth() const 2254</pre> 2255 2256Returns the thickness of the pen used by <a href="#Paint">Paint</a> to 2257outline the shape. 2258 2259### Return Value 2260 2261zero for <a href="#Style_Hairline">Hairline</a>, greater than zero for pen thickness 2262 2263### Example 2264 2265<div><fiddle-embed name="99aa73f64df8bbf06e656cd891a81b9e"> 2266 2267#### Example Output 2268 2269~~~~ 22700 == paint.getStrokeWidth() 2271~~~~ 2272 2273</fiddle-embed></div> 2274 2275--- 2276 2277<a name="SkPaint_setStrokeWidth"></a> 2278## setStrokeWidth 2279 2280<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2281void setStrokeWidth(SkScalar width) 2282</pre> 2283 2284Sets the thickness of the pen used by the paint to 2285outline the shape. 2286Has no effect if <a href="#SkPaint_setStrokeWidth_width">width</a> is less than zero. 2287 2288### Parameters 2289 2290<table> <tr> <td><a name="SkPaint_setStrokeWidth_width"> <code><strong>width </strong></code> </a></td> <td> 2291zero thickness for <a href="#Style_Hairline">Hairline</a>; greater than zero for pen thickness</td> 2292 </tr> 2293</table> 2294 2295### Example 2296 2297<div><fiddle-embed name="0c4446c0870b5c7b5a2efe77ff92afb8"> 2298 2299#### Example Output 2300 2301~~~~ 23025 == paint.getStrokeWidth() 2303~~~~ 2304 2305</fiddle-embed></div> 2306 2307--- 2308 2309## <a name="Miter_Limit"></a> Miter Limit 2310 2311<a href="#Miter_Limit">Miter Limit</a> specifies the maximum miter length, 2312relative to the stroke width. 2313 2314<a href="#Miter_Limit">Miter Limit</a> is used when the <a href="#Stroke_Join">Stroke Join</a> 2315is set to <a href="#SkPaint_kMiter_Join">kMiter Join</a>, and the <a href="#SkPaint_Style">Style</a> is either <a href="#SkPaint_kStroke_Style">kStroke Style</a> 2316or <a href="#SkPaint_kStrokeAndFill_Style">kStrokeAndFill Style</a>. 2317 2318If the miter at a corner exceeds this limit, <a href="#SkPaint_kMiter_Join">kMiter Join</a> 2319is replaced with <a href="#SkPaint_kBevel_Join">kBevel Join</a>. 2320 2321<a href="#Miter_Limit">Miter Limit</a> can be computed from the corner angle: 2322 2323miter limit = 1 / sin ( angle / 2 )<a href="#Miter_Limit">Miter Limit</a> default value is 4. 2324The default may be changed at compile time by setting <a href="undocumented#SkPaintDefaults_MiterLimit">SkPaintDefaults MiterLimit</a> 2325in "SkUserConfig.h" or as a define supplied by the build environment. 2326 2327Here are some miter limits and the angles that triggers them. 2328 2329| miter limit | angle in degrees | 2330| --- | --- | 2331| 10 | 11.48 | 2332| 9 | 12.76 | 2333| 8 | 14.36 | 2334| 7 | 16.43 | 2335| 6 | 19.19 | 2336| 5 | 23.07 | 2337| 4 | 28.96 | 2338| 3 | 38.94 | 2339| 2 | 60 | 2340| 1 | 180 | 2341 2342### Example 2343 2344<div><fiddle-embed name="5de2de0f00354e59074a9bb1a42d5a63"><div>This example draws a stroked corner and the miter length beneath. 2345When the miter limit is decreased slightly, the miter join is replaced 2346by a bevel join.</div></fiddle-embed></div> 2347 2348<a name="SkPaint_getStrokeMiter"></a> 2349## getStrokeMiter 2350 2351<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2352SkScalar getStrokeMiter() const 2353</pre> 2354 2355The limit at which a sharp corner is drawn beveled. 2356 2357### Return Value 2358 2359zero and greater <a href="#Miter_Limit">Miter Limit</a> 2360 2361### Example 2362 2363<div><fiddle-embed name="50da74a43b725f07a914df588c867d36"> 2364 2365#### Example Output 2366 2367~~~~ 2368default miter limit == 4 2369~~~~ 2370 2371</fiddle-embed></div> 2372 2373### See Also 2374 2375<a href="#Miter_Limit">Miter Limit</a> <a href="#SkPaint_setStrokeMiter">setStrokeMiter</a> <a href="#SkPaint_Join">Join</a> 2376 2377--- 2378 2379<a name="SkPaint_setStrokeMiter"></a> 2380## setStrokeMiter 2381 2382<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2383void setStrokeMiter(SkScalar miter) 2384</pre> 2385 2386The limit at which a sharp corner is drawn beveled. 2387Valid values are zero and greater. 2388Has no effect if <a href="#SkPaint_setStrokeMiter_miter">miter</a> is less than zero. 2389 2390### Parameters 2391 2392<table> <tr> <td><a name="SkPaint_setStrokeMiter_miter"> <code><strong>miter </strong></code> </a></td> <td> 2393zero and greater <a href="#Miter_Limit">Miter Limit</a></td> 2394 </tr> 2395</table> 2396 2397### Example 2398 2399<div><fiddle-embed name="700b284dbc97785c6a9c9636088713ad"> 2400 2401#### Example Output 2402 2403~~~~ 2404default miter limit == 8 2405~~~~ 2406 2407</fiddle-embed></div> 2408 2409### See Also 2410 2411<a href="#Miter_Limit">Miter Limit</a> <a href="#SkPaint_getStrokeMiter">getStrokeMiter</a> <a href="#SkPaint_Join">Join</a> 2412 2413--- 2414 2415## <a name="Stroke_Cap"></a> Stroke Cap 2416 2417## <a name="SkPaint_Cap"></a> Enum SkPaint::Cap 2418 2419<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2420enum <a href="#SkPaint_Cap">Cap</a> { 2421<a href="#SkPaint_kButt_Cap">kButt Cap</a>, 2422<a href="#SkPaint_kRound_Cap">kRound Cap</a>, 2423<a href="#SkPaint_kSquare_Cap">kSquare Cap</a>, 2424 2425<a href="#SkPaint_kLast_Cap">kLast Cap</a> = <a href="#SkPaint_kSquare_Cap">kSquare Cap</a>, 2426<a href="#SkPaint_kDefault_Cap">kDefault Cap</a> = <a href="#SkPaint_kButt_Cap">kButt Cap</a>, 2427}; 2428 2429static constexpr int <a href="#SkPaint_kCapCount">kCapCount</a> = <a href="#SkPaint_kLast_Cap">kLast Cap</a> + 1;</pre> 2430 2431<a href="#Stroke_Cap">Stroke Cap</a> draws at the beginning and end of an open <a href="SkPath_Reference#Contour">Path Contour</a>. 2432 2433### Constants 2434 2435<table> 2436 <tr> 2437 <td><a name="SkPaint_kButt_Cap"> <code><strong>SkPaint::kButt_Cap </strong></code> </a></td><td>0</td><td>Does not extend the stroke past the beginning or the end.</td> 2438 </tr> 2439 <tr> 2440 <td><a name="SkPaint_kRound_Cap"> <code><strong>SkPaint::kRound_Cap </strong></code> </a></td><td>1</td><td>Adds a circle with a diameter equal to <a href="#Stroke_Width">Stroke Width</a> at the beginning 2441and end.</td> 2442 </tr> 2443 <tr> 2444 <td><a name="SkPaint_kSquare_Cap"> <code><strong>SkPaint::kSquare_Cap </strong></code> </a></td><td>2</td><td>Adds a square with sides equal to <a href="#Stroke_Width">Stroke Width</a> at the beginning 2445and end. The square sides are parallel to the initial and final direction 2446of the stroke.</td> 2447 </tr> 2448 <tr> 2449 <td><a name="SkPaint_kLast_Cap"> <code><strong>SkPaint::kLast_Cap </strong></code> </a></td><td>2</td><td>Equivalent to the largest value for <a href="#Stroke_Cap">Stroke Cap</a>.</td> 2450 </tr> 2451 <tr> 2452 <td><a name="SkPaint_kDefault_Cap"> <code><strong>SkPaint::kDefault_Cap </strong></code> </a></td><td>0</td><td>Equivalent to <a href="#SkPaint_kButt_Cap">kButt Cap</a>. 2453<a href="#Stroke_Cap">Stroke Cap</a> is set to <a href="#SkPaint_kButt_Cap">kButt Cap</a> by default.</td> 2454 </tr> 2455 <tr> 2456 <td><a name="SkPaint_kCapCount"> <code><strong>SkPaint::kCapCount </strong></code> </a></td><td>3</td><td>The number of different <a href="#Stroke_Cap">Stroke Cap</a> values defined. 2457May be used to verify that <a href="#Stroke_Cap">Stroke Cap</a> is a legal value.</td> 2458 </tr> 2459 2460Stroke describes the area covered by a pen of <a href="#Stroke_Width">Stroke Width</a> as it 2461follows the <a href="SkPath_Reference#Contour">Path Contour</a>, moving parallel to the contour direction. 2462 2463If the <a href="SkPath_Reference#Contour">Path Contour</a> is not terminated by <a href="SkPath_Reference#SkPath_kClose_Verb">SkPath::kClose Verb</a>, the contour has a 2464visible beginning and end. 2465 2466<a href="SkPath_Reference#Contour">Path Contour</a> may start and end at the same point; defining <a href="SkPath_Reference#Contour_Zero_Length">Zero Length Contour</a>. 2467 2468<a href="#SkPaint_kButt_Cap">kButt Cap</a> and <a href="SkPath_Reference#Contour_Zero_Length">Zero Length Contour</a> is not drawn. 2469<a href="#SkPaint_kRound_Cap">kRound Cap</a> and <a href="SkPath_Reference#Contour_Zero_Length">Zero Length Contour</a> draws a circle of diameter <a href="#Stroke_Width">Stroke Width</a> 2470at the contour point. 2471<a href="#SkPaint_kSquare_Cap">kSquare Cap</a> and <a href="SkPath_Reference#Contour_Zero_Length">Zero Length Contour</a> draws an upright square with a side of 2472<a href="#Stroke_Width">Stroke Width</a> at the contour point. 2473 2474<a href="#Stroke_Cap">Stroke Cap</a> is <a href="#SkPaint_kButt_Cap">kButt Cap</a> by default. 2475 2476</table> 2477 2478### Example 2479 2480<div><fiddle-embed name="2bffb6384cc20077e632e7d01da045ca"></fiddle-embed></div> 2481 2482<a name="SkPaint_getStrokeCap"></a> 2483## getStrokeCap 2484 2485<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2486Cap getStrokeCap() const 2487</pre> 2488 2489The geometry drawn at the beginning and end of strokes. 2490 2491### Return Value 2492 2493one of: <a href="#SkPaint_kButt_Cap">kButt Cap</a>, <a href="#SkPaint_kRound_Cap">kRound Cap</a>, <a href="#SkPaint_kSquare_Cap">kSquare Cap</a> 2494 2495### Example 2496 2497<div><fiddle-embed name="aabf9baee8e026fae36fca30e955512b"> 2498 2499#### Example Output 2500 2501~~~~ 2502kButt_Cap == default stroke cap 2503~~~~ 2504 2505</fiddle-embed></div> 2506 2507### See Also 2508 2509<a href="#Stroke_Cap">Stroke Cap</a> <a href="#SkPaint_setStrokeCap">setStrokeCap</a> 2510 2511--- 2512 2513<a name="SkPaint_setStrokeCap"></a> 2514## setStrokeCap 2515 2516<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2517void setStrokeCap(Cap cap) 2518</pre> 2519 2520The geometry drawn at the beginning and end of strokes. 2521 2522### Parameters 2523 2524<table> <tr> <td><a name="SkPaint_setStrokeCap_cap"> <code><strong>cap </strong></code> </a></td> <td> 2525one of: <a href="#SkPaint_kButt_Cap">kButt Cap</a>, <a href="#SkPaint_kRound_Cap">kRound Cap</a>, <a href="#SkPaint_kSquare_Cap">kSquare Cap</a>; 2526has no effect if <a href="#SkPaint_setStrokeCap_cap">cap</a> is not valid</td> 2527 </tr> 2528</table> 2529 2530### Example 2531 2532<div><fiddle-embed name="de83fbd848a4625345b4b87a6e55d98a"> 2533 2534#### Example Output 2535 2536~~~~ 2537kRound_Cap == paint.getStrokeCap() 2538~~~~ 2539 2540</fiddle-embed></div> 2541 2542### See Also 2543 2544<a href="#Stroke_Cap">Stroke Cap</a> <a href="#SkPaint_getStrokeCap">getStrokeCap</a> 2545 2546--- 2547 2548## <a name="Stroke_Join"></a> Stroke Join 2549 2550<a href="#Stroke_Join">Stroke Join</a> draws at the sharp corners of an open or closed <a href="SkPath_Reference#Contour">Path Contour</a>. 2551 2552Stroke describes the area covered by a pen of <a href="#Stroke_Width">Stroke Width</a> as it 2553follows the <a href="SkPath_Reference#Contour">Path Contour</a>, moving parallel to the contour direction. 2554 2555If the contour direction changes abruptly, because the tangent direction leading 2556to the end of a curve within the contour does not match the tangent direction of 2557the following curve, the pair of curves meet at <a href="#Stroke_Join">Stroke Join</a>. 2558 2559### Example 2560 2561<div><fiddle-embed name="917c44b504d3f9308571fd3835d90a0d"></fiddle-embed></div> 2562 2563## <a name="SkPaint_Join"></a> Enum SkPaint::Join 2564 2565<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2566enum <a href="#SkPaint_Join">Join</a> { 2567<a href="#SkPaint_kMiter_Join">kMiter Join</a>, 2568<a href="#SkPaint_kRound_Join">kRound Join</a>, 2569<a href="#SkPaint_kBevel_Join">kBevel Join</a>, 2570 2571<a href="#SkPaint_kLast_Join">kLast Join</a> = <a href="#SkPaint_kBevel_Join">kBevel Join</a>, 2572<a href="#SkPaint_kDefault_Join">kDefault Join</a> = <a href="#SkPaint_kMiter_Join">kMiter Join</a>, 2573}; 2574 2575static constexpr int <a href="#SkPaint_kJoinCount">kJoinCount</a> = <a href="#SkPaint_kLast_Join">kLast Join</a> + 1;</pre> 2576 2577<a href="#SkPaint_Join">Join</a> specifies how corners are drawn when a shape is stroked. <a href="#SkPaint_Join">Join</a> 2578affects the four corners of a stroked rectangle, and the connected segments in a 2579stroked path. 2580 2581Choose miter join to draw sharp corners. Choose round join to draw a circle with a 2582radius equal to the stroke width on top of the corner. Choose bevel join to minimally 2583connect the thick strokes. 2584 2585The fill path constructed to describe the stroked path respects the join setting but may 2586not contain the actual join. For instance, a fill path constructed with round joins does 2587not necessarily include circles at each connected segment. 2588 2589### Constants 2590 2591<table> 2592 <tr> 2593 <td><a name="SkPaint_kMiter_Join"> <code><strong>SkPaint::kMiter_Join </strong></code> </a></td><td>0</td><td>Extends the outside corner to the extent allowed by <a href="#Miter_Limit">Miter Limit</a>. 2594If the extension exceeds <a href="#Miter_Limit">Miter Limit</a>, <a href="#SkPaint_kBevel_Join">kBevel Join</a> is used instead.</td> 2595 </tr> 2596 <tr> 2597 <td><a name="SkPaint_kRound_Join"> <code><strong>SkPaint::kRound_Join </strong></code> </a></td><td>1</td><td>Adds a circle with a diameter of <a href="#Stroke_Width">Stroke Width</a> at the sharp corner.</td> 2598 </tr> 2599 <tr> 2600 <td><a name="SkPaint_kBevel_Join"> <code><strong>SkPaint::kBevel_Join </strong></code> </a></td><td>2</td><td>Connects the outside edges of the sharp corner.</td> 2601 </tr> 2602 <tr> 2603 <td><a name="SkPaint_kLast_Join"> <code><strong>SkPaint::kLast_Join </strong></code> </a></td><td>2</td><td>Equivalent to the largest value for <a href="#Stroke_Join">Stroke Join</a>.</td> 2604 </tr> 2605 <tr> 2606 <td><a name="SkPaint_kDefault_Join"> <code><strong>SkPaint::kDefault_Join </strong></code> </a></td><td>1</td><td>Equivalent to <a href="#SkPaint_kMiter_Join">kMiter Join</a>. 2607<a href="#Stroke_Join">Stroke Join</a> is set to <a href="#SkPaint_kMiter_Join">kMiter Join</a> by default.</td> 2608 </tr> 2609 <tr> 2610 <td><a name="SkPaint_kJoinCount"> <code><strong>SkPaint::kJoinCount </strong></code> </a></td><td>3</td><td>The number of different <a href="#Stroke_Join">Stroke Join</a> values defined. 2611May be used to verify that <a href="#Stroke_Join">Stroke Join</a> is a legal value.</td> 2612 </tr> 2613</table> 2614 2615### Example 2616 2617<div><fiddle-embed name="3b1aebacc21c1836a52876b9b0b3905e"></fiddle-embed></div> 2618 2619### See Also 2620 2621<a href="#SkPaint_setStrokeJoin">setStrokeJoin</a> <a href="#SkPaint_getStrokeJoin">getStrokeJoin</a> <a href="#SkPaint_setStrokeMiter">setStrokeMiter</a> <a href="#SkPaint_getStrokeMiter">getStrokeMiter</a> 2622 2623 2624 2625<a name="SkPaint_getStrokeJoin"></a> 2626## getStrokeJoin 2627 2628<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2629Join getStrokeJoin() const 2630</pre> 2631 2632The geometry drawn at the corners of strokes. 2633 2634### Return Value 2635 2636one of: <a href="#SkPaint_kMiter_Join">kMiter Join</a>, <a href="#SkPaint_kRound_Join">kRound Join</a>, <a href="#SkPaint_kBevel_Join">kBevel Join</a> 2637 2638### Example 2639 2640<div><fiddle-embed name="31bf751d0a8ddf176b871810820d8199"> 2641 2642#### Example Output 2643 2644~~~~ 2645kMiter_Join == default stroke join 2646~~~~ 2647 2648</fiddle-embed></div> 2649 2650### See Also 2651 2652<a href="#Stroke_Join">Stroke Join</a> <a href="#SkPaint_setStrokeJoin">setStrokeJoin</a> 2653 2654--- 2655 2656<a name="SkPaint_setStrokeJoin"></a> 2657## setStrokeJoin 2658 2659<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2660void setStrokeJoin(Join join) 2661</pre> 2662 2663The geometry drawn at the corners of strokes. 2664 2665### Parameters 2666 2667<table> <tr> <td><a name="SkPaint_setStrokeJoin_join"> <code><strong>join </strong></code> </a></td> <td> 2668one of: <a href="#SkPaint_kMiter_Join">kMiter Join</a>, <a href="#SkPaint_kRound_Join">kRound Join</a>, <a href="#SkPaint_kBevel_Join">kBevel Join</a>; 2669otherwise, has no effect</td> 2670 </tr> 2671</table> 2672 2673### Example 2674 2675<div><fiddle-embed name="48d963ad4286eddf680f9c511eb6da91"> 2676 2677#### Example Output 2678 2679~~~~ 2680kMiter_Join == paint.getStrokeJoin() 2681~~~~ 2682 2683</fiddle-embed></div> 2684 2685### See Also 2686 2687<a href="#Stroke_Join">Stroke Join</a> <a href="#SkPaint_getStrokeJoin">getStrokeJoin</a> 2688 2689--- 2690 2691### See Also 2692 2693<a href="#Miter_Limit">Miter Limit</a> 2694 2695## <a name="Fill_Path"></a> Fill Path 2696 2697<a href="#Fill_Path">Fill Path</a> creates a <a href="SkPath_Reference#Path">Path</a> by applying the <a href="undocumented#Path_Effect">Path Effect</a>, followed by the <a href="#Style_Stroke">Style Stroke</a>. 2698 2699If <a href="#Paint">Paint</a> contains <a href="undocumented#Path_Effect">Path Effect</a>, <a href="undocumented#Path_Effect">Path Effect</a> operates on the source <a href="SkPath_Reference#Path">Path</a>; the result 2700replaces the destination <a href="SkPath_Reference#Path">Path</a>. Otherwise, the source <a href="SkPath_Reference#Path">Path</a> is replaces the 2701destination <a href="SkPath_Reference#Path">Path</a>. 2702 2703Fill <a href="SkPath_Reference#Path">Path</a> can request the <a href="undocumented#Path_Effect">Path Effect</a> to restrict to a culling rectangle, but 2704the <a href="undocumented#Path_Effect">Path Effect</a> is not required to do so. 2705 2706If <a href="#SkPaint_Style">Style</a> is <a href="#SkPaint_kStroke_Style">kStroke Style</a> or <a href="#SkPaint_kStrokeAndFill_Style">kStrokeAndFill Style</a>, 2707and <a href="#Stroke_Width">Stroke Width</a> is greater than zero, the <a href="#Stroke_Width">Stroke Width</a>, <a href="#Stroke_Cap">Stroke Cap</a>, <a href="#Stroke_Join">Stroke Join</a>, 2708and <a href="#Miter_Limit">Miter Limit</a> operate on the destination <a href="SkPath_Reference#Path">Path</a>, replacing it. 2709 2710Fill <a href="SkPath_Reference#Path">Path</a> can specify the precision used by <a href="#Stroke_Width">Stroke Width</a> to approximate the stroke geometry. 2711 2712If the <a href="#SkPaint_Style">Style</a> is <a href="#SkPaint_kStroke_Style">kStroke Style</a> and the <a href="#Stroke_Width">Stroke Width</a> is zero, <a href="#SkPaint_getFillPath">getFillPath</a> 2713returns false since <a href="#Style_Hairline">Hairline</a> has no filled equivalent. 2714 2715<a name="SkPaint_getFillPath"></a> 2716## getFillPath 2717 2718<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2719bool getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect, SkScalar resScale = 1) const 2720</pre> 2721 2722The filled equivalent of the stroked path. 2723 2724### Parameters 2725 2726<table> <tr> <td><a name="SkPaint_getFillPath_src"> <code><strong>src </strong></code> </a></td> <td> 2727<a href="SkPath_Reference#Path">Path</a> read to create a filled version</td> 2728 </tr> <tr> <td><a name="SkPaint_getFillPath_dst"> <code><strong>dst </strong></code> </a></td> <td> 2729resulting <a href="SkPath_Reference#Path">Path</a>; may be the same as <a href="#SkPaint_getFillPath_src">src</a>, but may not be nullptr</td> 2730 </tr> <tr> <td><a name="SkPaint_getFillPath_cullRect"> <code><strong>cullRect </strong></code> </a></td> <td> 2731optional limit passed to <a href="undocumented#Path_Effect">Path Effect</a></td> 2732 </tr> <tr> <td><a name="SkPaint_getFillPath_resScale"> <code><strong>resScale </strong></code> </a></td> <td> 2733if > 1, increase precision, else if (0 < res < 1) reduce precision 2734to favor speed and size</td> 2735 </tr> 2736</table> 2737 2738### Return Value 2739 2740true if the path represents <a href="#Style_Fill">Style Fill</a>, or false if it represents <a href="#Style_Hairline">Hairline</a> 2741 2742### Example 2743 2744<div><fiddle-embed name="cedd6233848198e1fca4d1e14816baaf"><div>A very small <a href="SkPath_Reference#Quad">Quad</a> stroke is turned into a filled path with increasing levels of precision. 2745At the lowest precision, the <a href="SkPath_Reference#Quad">Quad</a> stroke is approximated by a rectangle. 2746At the highest precision, the filled path has high fidelity compared to the original stroke.</div></fiddle-embed></div> 2747 2748--- 2749 2750<a name="SkPaint_getFillPath_2"></a> 2751 2752<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2753bool getFillPath(const SkPath& src, SkPath* dst) const 2754</pre> 2755 2756The filled equivalent of the stroked path. 2757 2758Replaces <a href="#SkPaint_getFillPath_2_dst">dst</a> with the <a href="#SkPaint_getFillPath_2_src">src</a> path modified by <a href="undocumented#Path_Effect">Path Effect</a> and <a href="#Style_Stroke">Style Stroke</a>. 2759<a href="undocumented#Path_Effect">Path Effect</a>, if any, is not culled. <a href="#Stroke_Width">Stroke Width</a> is created with default precision. 2760 2761### Parameters 2762 2763<table> <tr> <td><a name="SkPaint_getFillPath_2_src"> <code><strong>src </strong></code> </a></td> <td> 2764<a href="SkPath_Reference#Path">Path</a> read to create a filled version</td> 2765 </tr> <tr> <td><a name="SkPaint_getFillPath_2_dst"> <code><strong>dst </strong></code> </a></td> <td> 2766resulting <a href="SkPath_Reference#Path">Path</a> <a href="#SkPaint_getFillPath_2_dst">dst</a> may be the same as <a href="#SkPaint_getFillPath_2_src">src</a>, but may not be nullptr</td> 2767 </tr> 2768</table> 2769 2770### Return Value 2771 2772true if the path represents <a href="#Style_Fill">Style Fill</a>, or false if it represents <a href="#Style_Hairline">Hairline</a> 2773 2774### Example 2775 2776<div><fiddle-embed name="e6d8ca0cc17e0b475bd54dd995825468"></fiddle-embed></div> 2777 2778--- 2779 2780### See Also 2781 2782<a href="#Style_Stroke">Style Stroke</a> <a href="#Stroke_Width">Stroke Width</a> <a href="undocumented#Path_Effect">Path Effect</a> 2783 2784## <a name="Shader_Methods"></a> Shader Methods 2785 2786<a href="undocumented#Shader">Shader</a> defines the colors used when drawing a shape. 2787<a href="undocumented#Shader">Shader</a> may be an image, a gradient, or a computed fill. 2788If <a href="#Paint">Paint</a> has no <a href="undocumented#Shader">Shader</a>, then <a href="undocumented#Color">Color</a> fills the shape. 2789 2790<a href="undocumented#Shader">Shader</a> is modulated by <a href="undocumented#Alpha">Color Alpha</a> component of <a href="undocumented#Color">Color</a>. 2791If <a href="undocumented#Shader">Shader</a> object defines only <a href="undocumented#Alpha">Color Alpha</a>, then <a href="undocumented#Color">Color</a> modulated by <a href="undocumented#Alpha">Color Alpha</a> describes 2792the fill. 2793 2794The drawn transparency can be modified without altering <a href="undocumented#Shader">Shader</a>, by changing <a href="undocumented#Alpha">Color Alpha</a>. 2795 2796### Example 2797 2798<div><fiddle-embed name="c015dc2010c15e1c00b4f7330232b0f7"></fiddle-embed></div> 2799 2800If <a href="undocumented#Shader">Shader</a> generates only <a href="undocumented#Alpha">Color Alpha</a> then all components of <a href="undocumented#Color">Color</a> modulate the output. 2801 2802### Example 2803 2804<div><fiddle-embed name="9673be7720ba3adcdae42ddc1565b588"></fiddle-embed></div> 2805 2806<a name="SkPaint_getShader"></a> 2807## getShader 2808 2809<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2810SkShader* getShader() const 2811</pre> 2812 2813Optional colors used when filling a path, such as a gradient. 2814 2815Does not alter <a href="undocumented#Shader">Shader</a> <a href="undocumented#Reference_Count">Reference Count</a>. 2816 2817### Return Value 2818 2819<a href="undocumented#Shader">Shader</a> if previously set, nullptr otherwise 2820 2821### Example 2822 2823<div><fiddle-embed name="09f15b9fd88882850da2d235eb86292f"> 2824 2825#### Example Output 2826 2827~~~~ 2828nullptr == shader 2829nullptr != shader 2830~~~~ 2831 2832</fiddle-embed></div> 2833 2834--- 2835 2836<a name="SkPaint_refShader"></a> 2837## refShader 2838 2839<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2840sk_sp<SkShader> refShader() const 2841</pre> 2842 2843Optional colors used when filling a path, such as a gradient. 2844 2845Increases <a href="undocumented#Shader">Shader</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 2846 2847### Return Value 2848 2849<a href="undocumented#Shader">Shader</a> if previously set, nullptr otherwise 2850 2851### Example 2852 2853<div><fiddle-embed name="53da0295972a418cbc9607bbb17feaa8"> 2854 2855#### Example Output 2856 2857~~~~ 2858shader unique: true 2859shader unique: false 2860~~~~ 2861 2862</fiddle-embed></div> 2863 2864--- 2865 2866<a name="SkPaint_setShader"></a> 2867## setShader 2868 2869<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2870void setShader(sk_sp<SkShader> shader) 2871</pre> 2872 2873Optional colors used when filling a path, such as a gradient. 2874 2875Sets <a href="undocumented#Shader">Shader</a> to <a href="#SkPaint_setShader_shader">shader</a>, decreasing <a href="undocumented#Reference_Count">Reference Count</a> of the previous <a href="undocumented#Shader">Shader</a>. 2876Increments <a href="#SkPaint_setShader_shader">shader</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 2877 2878### Parameters 2879 2880<table> <tr> <td><a name="SkPaint_setShader_shader"> <code><strong>shader </strong></code> </a></td> <td> 2881how geometry is filled with color; if nullptr, <a href="undocumented#Color">Color</a> is used instead</td> 2882 </tr> 2883</table> 2884 2885### Example 2886 2887<div><fiddle-embed name="77e64d5bae9b1ba037fd99252bb4aa58"></fiddle-embed></div> 2888 2889--- 2890 2891## <a name="Color_Filter_Methods"></a> Color Filter Methods 2892 2893<a href="undocumented#Color_Filter">Color Filter</a> alters the color used when drawing a shape. 2894<a href="undocumented#Color_Filter">Color Filter</a> may apply <a href="undocumented#Blend_Mode">Blend Mode</a>, transform the color through a matrix, or composite multiple filters. 2895If <a href="#Paint">Paint</a> has no <a href="undocumented#Color_Filter">Color Filter</a>, the color is unaltered. 2896 2897The drawn transparency can be modified without altering <a href="undocumented#Color_Filter">Color Filter</a>, by changing <a href="undocumented#Alpha">Color Alpha</a>. 2898 2899### Example 2900 2901<div><fiddle-embed name="5abde56ca2f89a18b8e231abd1b57c56"></fiddle-embed></div> 2902 2903<a name="SkPaint_getColorFilter"></a> 2904## getColorFilter 2905 2906<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2907SkColorFilter* getColorFilter() const 2908</pre> 2909 2910Returns <a href="undocumented#Color_Filter">Color Filter</a> if set, or nullptr. 2911Does not alter <a href="undocumented#Color_Filter">Color Filter</a> <a href="undocumented#Reference_Count">Reference Count</a>. 2912 2913### Return Value 2914 2915<a href="undocumented#Color_Filter">Color Filter</a> if previously set, nullptr otherwise 2916 2917### Example 2918 2919<div><fiddle-embed name="093bdc627d6b59002670fd290931f6c9"> 2920 2921#### Example Output 2922 2923~~~~ 2924nullptr == color filter 2925nullptr != color filter 2926~~~~ 2927 2928</fiddle-embed></div> 2929 2930--- 2931 2932<a name="SkPaint_refColorFilter"></a> 2933## refColorFilter 2934 2935<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2936sk_sp<SkColorFilter> refColorFilter() const 2937</pre> 2938 2939Returns <a href="undocumented#Color_Filter">Color Filter</a> if set, or nullptr. 2940Increases <a href="undocumented#Color_Filter">Color Filter</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 2941 2942### Return Value 2943 2944<a href="undocumented#Color_Filter">Color Filter</a> if set, or nullptr 2945 2946### Example 2947 2948<div><fiddle-embed name="b588c95fa4c86ddbc4b0546762f08297"> 2949 2950#### Example Output 2951 2952~~~~ 2953color filter unique: true 2954color filter unique: false 2955~~~~ 2956 2957</fiddle-embed></div> 2958 2959--- 2960 2961<a name="SkPaint_setColorFilter"></a> 2962## setColorFilter 2963 2964<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2965void setColorFilter(sk_sp<SkColorFilter> colorFilter) 2966</pre> 2967 2968Sets <a href="undocumented#Color_Filter">Color Filter</a> to filter, decreasing <a href="undocumented#Reference_Count">Reference Count</a> of the previous 2969<a href="undocumented#Color_Filter">Color Filter</a>. Pass nullptr to clear <a href="undocumented#Color_Filter">Color Filter</a>. 2970 2971Increments filter <a href="undocumented#Reference_Count">Reference Count</a> by one. 2972 2973### Parameters 2974 2975<table> <tr> <td><a name="SkPaint_setColorFilter_colorFilter"> <code><strong>colorFilter </strong></code> </a></td> <td> 2976<a href="undocumented#Color_Filter">Color Filter</a> to apply to subsequent draw</td> 2977 </tr> 2978</table> 2979 2980### Example 2981 2982<div><fiddle-embed name="c7b786dc9b3501cd0eaba47494b6fa31"></fiddle-embed></div> 2983 2984--- 2985 2986## <a name="Blend_Mode_Methods"></a> Blend Mode Methods 2987 2988<a href="undocumented#Blend_Mode">Blend Mode</a> describes how <a href="undocumented#Color">Color</a> combines with the destination color. 2989The default setting, <a href="undocumented#SkBlendMode_kSrcOver">SkBlendMode::kSrcOver</a>, draws the source color 2990over the destination color. 2991 2992### Example 2993 2994<div><fiddle-embed name="73092d4d06faecea3c204d852a4dd8a8"></fiddle-embed></div> 2995 2996### See Also 2997 2998<a href="undocumented#Blend_Mode">Blend Mode</a> 2999 3000<a name="SkPaint_getBlendMode"></a> 3001## getBlendMode 3002 3003<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3004SkBlendMode getBlendMode() const 3005</pre> 3006 3007Returns <a href="undocumented#Blend_Mode">Blend Mode</a>. 3008By default, returns <a href="undocumented#SkBlendMode_kSrcOver">SkBlendMode::kSrcOver</a>. 3009 3010### Return Value 3011 3012mode used to combine source color with destination color 3013 3014### Example 3015 3016<div><fiddle-embed name="4ec1864b8203d52c0810e8605092f45c"> 3017 3018#### Example Output 3019 3020~~~~ 3021kSrcOver == getBlendMode 3022kSrcOver != getBlendMode 3023~~~~ 3024 3025</fiddle-embed></div> 3026 3027--- 3028 3029<a name="SkPaint_isSrcOver"></a> 3030## isSrcOver 3031 3032<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3033bool isSrcOver() const 3034</pre> 3035 3036Returns true if <a href="undocumented#Blend_Mode">Blend Mode</a> is <a href="undocumented#SkBlendMode_kSrcOver">SkBlendMode::kSrcOver</a>, the default. 3037 3038### Return Value 3039 3040true if <a href="undocumented#Blend_Mode">Blend Mode</a> is <a href="undocumented#SkBlendMode_kSrcOver">SkBlendMode::kSrcOver</a> 3041 3042### Example 3043 3044<div><fiddle-embed name="257c9473db7a2b3a0fb2b9e2431e59a6"> 3045 3046#### Example Output 3047 3048~~~~ 3049isSrcOver == true 3050isSrcOver != true 3051~~~~ 3052 3053</fiddle-embed></div> 3054 3055--- 3056 3057<a name="SkPaint_setBlendMode"></a> 3058## setBlendMode 3059 3060<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3061void setBlendMode(SkBlendMode mode) 3062</pre> 3063 3064Sets <a href="undocumented#Blend_Mode">Blend Mode</a> to <a href="#SkPaint_setBlendMode_mode">mode</a>. 3065Does not check for valid input. 3066 3067### Parameters 3068 3069<table> <tr> <td><a name="SkPaint_setBlendMode_mode"> <code><strong>mode </strong></code> </a></td> <td> 3070<a href="undocumented#SkBlendMode">SkBlendMode</a> used to combine source color and destination</td> 3071 </tr> 3072</table> 3073 3074### Example 3075 3076<div><fiddle-embed name="257c9473db7a2b3a0fb2b9e2431e59a6"> 3077 3078#### Example Output 3079 3080~~~~ 3081isSrcOver == true 3082isSrcOver != true 3083~~~~ 3084 3085</fiddle-embed></div> 3086 3087--- 3088 3089## <a name="Path_Effect_Methods"></a> Path Effect Methods 3090 3091<a href="undocumented#Path_Effect">Path Effect</a> modifies the path geometry before drawing it. 3092<a href="undocumented#Path_Effect">Path Effect</a> may implement dashing, custom fill effects and custom stroke effects. 3093If <a href="#Paint">Paint</a> has no <a href="undocumented#Path_Effect">Path Effect</a>, the path geometry is unaltered when filled or stroked. 3094 3095### Example 3096 3097<div><fiddle-embed name="8cf5684b187d60f09e11c4a48993ea39"></fiddle-embed></div> 3098 3099### See Also 3100 3101<a href="undocumented#Path_Effect">Path Effect</a> 3102 3103<a name="SkPaint_getPathEffect"></a> 3104## getPathEffect 3105 3106<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3107SkPathEffect* getPathEffect() const 3108</pre> 3109 3110Returns <a href="undocumented#Path_Effect">Path Effect</a> if set, or nullptr. 3111Does not alter <a href="undocumented#Path_Effect">Path Effect</a> <a href="undocumented#Reference_Count">Reference Count</a>. 3112 3113### Return Value 3114 3115<a href="undocumented#Path_Effect">Path Effect</a> if previously set, nullptr otherwise 3116 3117### Example 3118 3119<div><fiddle-embed name="211a1b14bfa6c4332082c8eab4fbc5fd"> 3120 3121#### Example Output 3122 3123~~~~ 3124nullptr == path effect 3125nullptr != path effect 3126~~~~ 3127 3128</fiddle-embed></div> 3129 3130--- 3131 3132<a name="SkPaint_refPathEffect"></a> 3133## refPathEffect 3134 3135<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3136sk_sp<SkPathEffect> refPathEffect() const 3137</pre> 3138 3139Returns <a href="undocumented#Path_Effect">Path Effect</a> if set, or nullptr. 3140Increases <a href="undocumented#Path_Effect">Path Effect</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 3141 3142### Return Value 3143 3144<a href="undocumented#Path_Effect">Path Effect</a> if previously set, nullptr otherwise 3145 3146### Example 3147 3148<div><fiddle-embed name="f56039b94c702c2704c8c5100e623aca"> 3149 3150#### Example Output 3151 3152~~~~ 3153path effect unique: true 3154path effect unique: false 3155~~~~ 3156 3157</fiddle-embed></div> 3158 3159--- 3160 3161<a name="SkPaint_setPathEffect"></a> 3162## setPathEffect 3163 3164<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3165void setPathEffect(sk_sp<SkPathEffect> pathEffect) 3166</pre> 3167 3168Sets <a href="undocumented#Path_Effect">Path Effect</a> to <a href="#SkPaint_setPathEffect_pathEffect">pathEffect</a>, decreasing <a href="undocumented#Reference_Count">Reference Count</a> of the previous 3169<a href="undocumented#Path_Effect">Path Effect</a>. Pass nullptr to leave the path geometry unaltered. 3170 3171Increments <a href="#SkPaint_setPathEffect_pathEffect">pathEffect</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 3172 3173### Parameters 3174 3175<table> <tr> <td><a name="SkPaint_setPathEffect_pathEffect"> <code><strong>pathEffect </strong></code> </a></td> <td> 3176replace <a href="SkPath_Reference#Path">Path</a> with a modification when drawn</td> 3177 </tr> 3178</table> 3179 3180### Example 3181 3182<div><fiddle-embed name="52dd55074ca0b7d520d04e750ca2a0d7"></fiddle-embed></div> 3183 3184--- 3185 3186## <a name="Mask_Filter_Methods"></a> Mask Filter Methods 3187 3188<a href="undocumented#Mask_Filter">Mask Filter</a> uses coverage of the shape drawn to create <a href="undocumented#Mask_Alpha">Mask Alpha</a>. 3189<a href="undocumented#Mask_Filter">Mask Filter</a> takes a Mask, and returns a Mask. 3190 3191<a href="undocumented#Mask_Filter">Mask Filter</a> may change the geometry and transparency of the shape, such as 3192creating a blur effect. Set <a href="undocumented#Mask_Filter">Mask Filter</a> to nullptr to prevent <a href="undocumented#Mask_Filter">Mask Filter</a> from 3193modifying the draw. 3194 3195### Example 3196 3197<div><fiddle-embed name="320b04ea1e1291d49f1e61994a0410fe"></fiddle-embed></div> 3198 3199<a name="SkPaint_getMaskFilter"></a> 3200## getMaskFilter 3201 3202<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3203SkMaskFilter* getMaskFilter() const 3204</pre> 3205 3206Returns <a href="undocumented#Mask_Filter">Mask Filter</a> if set, or nullptr. 3207Does not alter <a href="undocumented#Mask_Filter">Mask Filter</a> <a href="undocumented#Reference_Count">Reference Count</a>. 3208 3209### Return Value 3210 3211<a href="undocumented#Mask_Filter">Mask Filter</a> if previously set, nullptr otherwise 3212 3213### Example 3214 3215<div><fiddle-embed name="8cd53ece8fc83e4560599ace094b0f16"> 3216 3217#### Example Output 3218 3219~~~~ 3220nullptr == mask filter 3221nullptr != mask filter 3222~~~~ 3223 3224</fiddle-embed></div> 3225 3226--- 3227 3228<a name="SkPaint_refMaskFilter"></a> 3229## refMaskFilter 3230 3231<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3232sk_sp<SkMaskFilter> refMaskFilter() const 3233</pre> 3234 3235Returns <a href="undocumented#Mask_Filter">Mask Filter</a> if set, or nullptr. 3236 3237Increases <a href="undocumented#Mask_Filter">Mask Filter</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 3238 3239### Return Value 3240 3241<a href="undocumented#Mask_Filter">Mask Filter</a> if previously set, nullptr otherwise 3242 3243### Example 3244 3245<div><fiddle-embed name="35a397dce5d44658ee4e9e9dfb9fee22"> 3246 3247#### Example Output 3248 3249~~~~ 3250mask filter unique: true 3251mask filter unique: false 3252~~~~ 3253 3254</fiddle-embed></div> 3255 3256--- 3257 3258<a name="SkPaint_setMaskFilter"></a> 3259## setMaskFilter 3260 3261<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3262void setMaskFilter(sk_sp<SkMaskFilter> maskFilter) 3263</pre> 3264 3265Sets <a href="undocumented#Mask_Filter">Mask Filter</a> to <a href="#SkPaint_setMaskFilter_maskFilter">maskFilter</a>, decreasing <a href="undocumented#Reference_Count">Reference Count</a> of the previous 3266<a href="undocumented#Mask_Filter">Mask Filter</a>. Pass nullptr to clear <a href="undocumented#Mask_Filter">Mask Filter</a> and leave <a href="undocumented#Mask_Filter">Mask Filter</a> effect on 3267<a href="undocumented#Mask_Alpha">Mask Alpha</a> unaltered. 3268 3269Increments <a href="#SkPaint_setMaskFilter_maskFilter">maskFilter</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 3270 3271### Parameters 3272 3273<table> <tr> <td><a name="SkPaint_setMaskFilter_maskFilter"> <code><strong>maskFilter </strong></code> </a></td> <td> 3274modifies clipping mask generated from drawn geometry</td> 3275 </tr> 3276</table> 3277 3278### Example 3279 3280<div><fiddle-embed name="62c5a826692f85c3de3bab65e9e97aa9"></fiddle-embed></div> 3281 3282--- 3283 3284## <a name="Typeface_Methods"></a> Typeface Methods 3285 3286<a href="undocumented#Typeface">Typeface</a> identifies the font used when drawing and measuring text. 3287<a href="undocumented#Typeface">Typeface</a> may be specified by name, from a file, or from a data stream. 3288The default <a href="undocumented#Typeface">Typeface</a> defers to the platform-specific default font 3289implementation. 3290 3291### Example 3292 3293<div><fiddle-embed name="1a7a5062725139760962582f599f1b97"></fiddle-embed></div> 3294 3295<a name="SkPaint_getTypeface"></a> 3296## getTypeface 3297 3298<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3299SkTypeface* getTypeface() const 3300</pre> 3301 3302Returns <a href="undocumented#Typeface">Typeface</a> if set, or nullptr. 3303Increments <a href="undocumented#Typeface">Typeface</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 3304 3305### Return Value 3306 3307<a href="undocumented#Typeface">Typeface</a> if previously set, nullptr otherwise 3308 3309### Example 3310 3311<div><fiddle-embed name="5ce718e5a184baaac80e7098d7dad67b"> 3312 3313#### Example Output 3314 3315~~~~ 3316nullptr == typeface 3317nullptr != typeface 3318~~~~ 3319 3320</fiddle-embed></div> 3321 3322--- 3323 3324<a name="SkPaint_refTypeface"></a> 3325## refTypeface 3326 3327<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3328sk_sp<SkTypeface> refTypeface() const 3329</pre> 3330 3331Increases <a href="undocumented#Typeface">Typeface</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 3332 3333### Return Value 3334 3335<a href="undocumented#Typeface">Typeface</a> if previously set, nullptr otherwise 3336 3337### Example 3338 3339<div><fiddle-embed name="4bf8ed109c4b46d8a05c8b7763c1982c"> 3340 3341#### Example Output 3342 3343~~~~ 3344typeface1 != typeface2 3345typeface1 == typeface2 3346~~~~ 3347 3348</fiddle-embed></div> 3349 3350--- 3351 3352<a name="SkPaint_setTypeface"></a> 3353## setTypeface 3354 3355<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3356void setTypeface(sk_sp<SkTypeface> typeface) 3357</pre> 3358 3359Sets <a href="undocumented#Typeface">Typeface</a> to <a href="#SkPaint_setTypeface_typeface">typeface</a>, decreasing <a href="undocumented#Reference_Count">Reference Count</a> of the previous <a href="undocumented#Typeface">Typeface</a>. 3360Pass nullptr to clear <a href="undocumented#Typeface">Typeface</a> and use the default <a href="#SkPaint_setTypeface_typeface">typeface</a>. Increments 3361<a href="#SkPaint_setTypeface_typeface">typeface</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 3362 3363### Parameters 3364 3365<table> <tr> <td><a name="SkPaint_setTypeface_typeface"> <code><strong>typeface </strong></code> </a></td> <td> 3366font and style used to draw text</td> 3367 </tr> 3368</table> 3369 3370### Example 3371 3372<div><fiddle-embed name="0e6fbb7773cd925b274552f4cd1abef2"></fiddle-embed></div> 3373 3374--- 3375 3376## <a name="Image_Filter_Methods"></a> Image Filter Methods 3377 3378<a href="undocumented#Image_Filter">Image Filter</a> operates on the pixel representation of the shape, as modified by <a href="#Paint">Paint</a> 3379with <a href="undocumented#Blend_Mode">Blend Mode</a> set to <a href="undocumented#SkBlendMode_kSrcOver">SkBlendMode::kSrcOver</a>. <a href="undocumented#Image_Filter">Image Filter</a> creates a new bitmap, 3380which is drawn to the device using the set <a href="undocumented#Blend_Mode">Blend Mode</a>. 3381 3382<a href="undocumented#Image_Filter">Image Filter</a> is higher level than <a href="undocumented#Mask_Filter">Mask Filter</a>; for instance, an <a href="undocumented#Image_Filter">Image Filter</a> 3383can operate on all channels of <a href="undocumented#Color">Color</a>, while <a href="undocumented#Mask_Filter">Mask Filter</a> generates <a href="undocumented#Alpha">Alpha</a> only. 3384<a href="undocumented#Image_Filter">Image Filter</a> operates independently of and can be used in combination with 3385<a href="undocumented#Mask_Filter">Mask Filter</a>. 3386 3387### Example 3388 3389<div><fiddle-embed name="0b2eec148d6397d6231e1fa0b3d1496d"></fiddle-embed></div> 3390 3391<a name="SkPaint_getImageFilter"></a> 3392## getImageFilter 3393 3394<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3395SkImageFilter* getImageFilter() const 3396</pre> 3397 3398Returns <a href="undocumented#Image_Filter">Image Filter</a> if set, or nullptr. 3399Does not alter <a href="undocumented#Image_Filter">Image Filter</a> <a href="undocumented#Reference_Count">Reference Count</a>. 3400 3401### Return Value 3402 3403<a href="undocumented#Image_Filter">Image Filter</a> if previously set, nullptr otherwise 3404 3405### Example 3406 3407<div><fiddle-embed name="7b8118ff57fcb84e6bc82380d155b62e"> 3408 3409#### Example Output 3410 3411~~~~ 3412nullptr == image filter 3413nullptr != image filter 3414~~~~ 3415 3416</fiddle-embed></div> 3417 3418--- 3419 3420<a name="SkPaint_refImageFilter"></a> 3421## refImageFilter 3422 3423<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3424sk_sp<SkImageFilter> refImageFilter() const 3425</pre> 3426 3427Returns <a href="undocumented#Image_Filter">Image Filter</a> if set, or nullptr. 3428Increases <a href="undocumented#Image_Filter">Image Filter</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 3429 3430### Return Value 3431 3432<a href="undocumented#Image_Filter">Image Filter</a> if previously set, nullptr otherwise 3433 3434### Example 3435 3436<div><fiddle-embed name="13f09088b569251547107d14ae989dc1"> 3437 3438#### Example Output 3439 3440~~~~ 3441image filter unique: true 3442image filter unique: false 3443~~~~ 3444 3445</fiddle-embed></div> 3446 3447--- 3448 3449<a name="SkPaint_setImageFilter"></a> 3450## setImageFilter 3451 3452<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3453void setImageFilter(sk_sp<SkImageFilter> imageFilter) 3454</pre> 3455 3456Sets <a href="undocumented#Image_Filter">Image Filter</a> to <a href="#SkPaint_setImageFilter_imageFilter">imageFilter</a>, decreasing <a href="undocumented#Reference_Count">Reference Count</a> of the previous 3457<a href="undocumented#Image_Filter">Image Filter</a>. Pass nullptr to clear <a href="undocumented#Image_Filter">Image Filter</a>, and remove <a href="undocumented#Image_Filter">Image Filter</a> effect 3458on drawing. 3459 3460Increments <a href="#SkPaint_setImageFilter_imageFilter">imageFilter</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 3461 3462### Parameters 3463 3464<table> <tr> <td><a name="SkPaint_setImageFilter_imageFilter"> <code><strong>imageFilter </strong></code> </a></td> <td> 3465how <a href="SkImage_Reference#Image">Image</a> is sampled when transformed</td> 3466 </tr> 3467</table> 3468 3469### Example 3470 3471<div><fiddle-embed name="6679d6e4ec632715ee03e68391bd7f9a"></fiddle-embed></div> 3472 3473--- 3474 3475## <a name="Draw_Looper_Methods"></a> Draw Looper Methods 3476 3477<a href="undocumented#Draw_Looper">Draw Looper</a> sets a modifier that communicates state from one <a href="undocumented#Draw_Layer">Draw Layer</a> 3478to another to construct the draw. 3479 3480<a href="undocumented#Draw_Looper">Draw Looper</a> draws one or more times, modifying the canvas and paint each time. 3481<a href="undocumented#Draw_Looper">Draw Looper</a> may be used to draw multiple colors or create a colored shadow. 3482Set <a href="undocumented#Draw_Looper">Draw Looper</a> to nullptr to prevent <a href="undocumented#Draw_Looper">Draw Looper</a> from modifying the draw. 3483 3484### Example 3485 3486<div><fiddle-embed name="84ec12a36e50df5ac565cc7a75ffbe9f"></fiddle-embed></div> 3487 3488<a name="SkPaint_getDrawLooper"></a> 3489## getDrawLooper 3490 3491<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3492SkDrawLooper* getDrawLooper() const 3493</pre> 3494 3495Returns <a href="undocumented#Draw_Looper">Draw Looper</a> if set, or nullptr. 3496Does not alter <a href="undocumented#Draw_Looper">Draw Looper</a> <a href="undocumented#Reference_Count">Reference Count</a>. 3497 3498### Return Value 3499 3500<a href="undocumented#Draw_Looper">Draw Looper</a> if previously set, nullptr otherwise 3501 3502### Example 3503 3504<div><fiddle-embed name="af4c5acc7a91e7f23c2af48018903ad4"> 3505 3506#### Example Output 3507 3508~~~~ 3509nullptr == draw looper 3510nullptr != draw looper 3511~~~~ 3512 3513</fiddle-embed></div> 3514 3515--- 3516 3517<a name="SkPaint_refDrawLooper"></a> 3518## refDrawLooper 3519 3520<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3521sk_sp<SkDrawLooper> refDrawLooper() const 3522</pre> 3523 3524Returns <a href="undocumented#Draw_Looper">Draw Looper</a> if set, or nullptr. 3525Increases <a href="undocumented#Draw_Looper">Draw Looper</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 3526 3527### Return Value 3528 3529<a href="undocumented#Draw_Looper">Draw Looper</a> if previously set, nullptr otherwise 3530 3531### Example 3532 3533<div><fiddle-embed name="2a3782c33f04ed17a725d0e449c6f7c3"> 3534 3535#### Example Output 3536 3537~~~~ 3538draw looper unique: true 3539draw looper unique: false 3540~~~~ 3541 3542</fiddle-embed></div> 3543 3544--- 3545 3546<a name="SkPaint_getLooper"></a> 3547## getLooper 3548 3549<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3550SkDrawLooper* getLooper() const 3551</pre> 3552 3553--- 3554 3555<a name="SkPaint_setDrawLooper"></a> 3556## setDrawLooper 3557 3558<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3559void setDrawLooper(sk_sp<SkDrawLooper> drawLooper) 3560</pre> 3561 3562Sets <a href="undocumented#Draw_Looper">Draw Looper</a> to <a href="#SkPaint_setDrawLooper_drawLooper">drawLooper</a>, decreasing <a href="undocumented#Reference_Count">Reference Count</a> of the previous 3563<a href="#SkPaint_setDrawLooper_drawLooper">drawLooper</a>. Pass nullptr to clear <a href="undocumented#Draw_Looper">Draw Looper</a> and leave <a href="undocumented#Draw_Looper">Draw Looper</a> effect on 3564drawing unaltered. 3565 3566Increments <a href="#SkPaint_setDrawLooper_drawLooper">drawLooper</a> <a href="undocumented#Reference_Count">Reference Count</a> by one. 3567 3568### Parameters 3569 3570<table> <tr> <td><a name="SkPaint_setDrawLooper_drawLooper"> <code><strong>drawLooper </strong></code> </a></td> <td> 3571iterates through drawing one or more time, altering <a href="#Paint">Paint</a></td> 3572 </tr> 3573</table> 3574 3575### Example 3576 3577<div><fiddle-embed name="bf10f838b330f0a3a3266d42ea68a638"></fiddle-embed></div> 3578 3579--- 3580 3581<a name="SkPaint_setLooper"></a> 3582## setLooper 3583 3584<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3585void setLooper(sk_sp<SkDrawLooper> drawLooper) 3586</pre> 3587 3588--- 3589 3590## <a name="Text_Align"></a> Text Align 3591 3592## <a name="SkPaint_Align"></a> Enum SkPaint::Align 3593 3594<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3595enum <a href="#SkPaint_Align">Align</a> { 3596<a href="#SkPaint_kLeft_Align">kLeft Align</a>, 3597<a href="#SkPaint_kCenter_Align">kCenter Align</a>, 3598<a href="#SkPaint_kRight_Align">kRight Align</a>, 3599};</pre> 3600 3601<a href="#SkPaint_Align">Align</a> adjusts the text relative to the text position. 3602<a href="#SkPaint_Align">Align</a> affects <a href="undocumented#Glyph">Glyphs</a> drawn with: <a href="SkCanvas_Reference#SkCanvas_drawText">SkCanvas::drawText</a>, <a href="SkCanvas_Reference#SkCanvas_drawPosText">SkCanvas::drawPosText</a>, 3603<a href="SkCanvas_Reference#SkCanvas_drawPosTextH">SkCanvas::drawPosTextH</a>, <a href="SkCanvas_Reference#SkCanvas_drawTextOnPath">SkCanvas::drawTextOnPath</a>, 3604<a href="SkCanvas_Reference#SkCanvas_drawTextOnPathHV">SkCanvas::drawTextOnPathHV</a>, <a href="SkCanvas_Reference#SkCanvas_drawTextRSXform">SkCanvas::drawTextRSXform</a>, <a href="SkCanvas_Reference#SkCanvas_drawTextBlob">SkCanvas::drawTextBlob</a>, 3605and <a href="SkCanvas_Reference#SkCanvas_drawString">SkCanvas::drawString</a>; 3606as well as calls that place text <a href="undocumented#Glyph">Glyphs</a> like <a href="#SkPaint_getTextWidths">getTextWidths</a> and <a href="#SkPaint_getTextPath">getTextPath</a>. 3607 3608The text position is set by the font for both horizontal and vertical text. 3609Typically, for horizontal text, the position is to the left side of the glyph on the 3610base line; and for vertical text, the position is the horizontal center of the glyph 3611at the caps height. 3612 3613<a href="#SkPaint_Align">Align</a> adjusts the glyph position to center it or move it to abut the position 3614using the metrics returned by the font. 3615 3616<a href="#SkPaint_Align">Align</a> defaults to <a href="#SkPaint_kLeft_Align">kLeft Align</a>. 3617 3618### Constants 3619 3620<table> 3621 <tr> 3622 <td><a name="SkPaint_kLeft_Align"> <code><strong>SkPaint::kLeft_Align </strong></code> </a></td><td>0</td><td>Leaves the glyph at the position computed by the font offset by the text position.</td> 3623 </tr> 3624 <tr> 3625 <td><a name="SkPaint_kCenter_Align"> <code><strong>SkPaint::kCenter_Align </strong></code> </a></td><td>1</td><td>Moves the glyph half its width if <a href="#SkPaint_Flags">Flags</a> has <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> clear, and 3626half its height if <a href="#SkPaint_Flags">Flags</a> has <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> set.</td> 3627 </tr> 3628 <tr> 3629 <td><a name="SkPaint_kRight_Align"> <code><strong>SkPaint::kRight_Align </strong></code> </a></td><td>2</td><td>Moves the glyph by its width if <a href="#SkPaint_Flags">Flags</a> has <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> clear, 3630and by its height if <a href="#SkPaint_Flags">Flags</a> has <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> set.</td> 3631 </tr> 3632 3633</table> 3634 3635## <a name="SkPaint__anonymous_2"></a> Enum SkPaint::_anonymous_2 3636 3637<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3638enum { 3639<a href="#SkPaint_kAlignCount">kAlignCount</a> = 3, 3640};</pre> 3641 3642### Constants 3643 3644<table> 3645 <tr> 3646 <td><a name="SkPaint_kAlignCount"> <code><strong>SkPaint::kAlignCount </strong></code> </a></td><td>3</td><td>The number of different <a href="#Text_Align">Text Align</a> values defined.</td> 3647 </tr> 3648 3649</table> 3650 3651### Example 3652 3653<div><fiddle-embed name="702617fd9ebc3f12e30081b5db93e8a8"><div>Each position separately moves the glyph in drawPosText.</div></fiddle-embed></div> 3654 3655### Example 3656 3657<div><fiddle-embed name="f1cbbbafe6b3c52b81309cccbf96a308"><div><a href="#Vertical_Text">Vertical Text</a> treats <a href="#SkPaint_kLeft_Align">kLeft Align</a> as top align, and <a href="#SkPaint_kRight_Align">kRight Align</a> as bottom align.</div></fiddle-embed></div> 3658 3659<a name="SkPaint_getTextAlign"></a> 3660## getTextAlign 3661 3662<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3663Align getTextAlign() const 3664</pre> 3665 3666Returns <a href="#Text_Align">Text Align</a>. 3667Returns <a href="#SkPaint_kLeft_Align">kLeft Align</a> if <a href="#Text_Align">Text Align</a> has not been set. 3668 3669### Return Value 3670 3671text placement relative to position 3672 3673### Example 3674 3675<div><fiddle-embed name="2df932f526e810f74c89d30ec3f4c947"> 3676 3677#### Example Output 3678 3679~~~~ 3680kLeft_Align == default 3681~~~~ 3682 3683</fiddle-embed></div> 3684 3685--- 3686 3687<a name="SkPaint_setTextAlign"></a> 3688## setTextAlign 3689 3690<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3691void setTextAlign(Align align) 3692</pre> 3693 3694Sets <a href="#Text_Align">Text Align</a> to <a href="#SkPaint_setTextAlign_align">align</a>. 3695Has no effect if <a href="#SkPaint_setTextAlign_align">align</a> is an invalid value. 3696 3697### Parameters 3698 3699<table> <tr> <td><a name="SkPaint_setTextAlign_align"> <code><strong>align </strong></code> </a></td> <td> 3700text placement relative to position</td> 3701 </tr> 3702</table> 3703 3704### Example 3705 3706<div><fiddle-embed name="d37540afd918506ac2594665ca63979b"><div><a href="undocumented#Text">Text</a> is left-aligned by default, and then set to center. Setting the 3707alignment out of range has no effect.</div></fiddle-embed></div> 3708 3709--- 3710 3711## <a name="Text_Size"></a> Text Size 3712 3713<a href="#Text_Size">Text Size</a> adjusts the overall text size in points. 3714<a href="#Text_Size">Text Size</a> can be set to any positive value or zero. 3715<a href="#Text_Size">Text Size</a> defaults to 12. 3716Set <a href="undocumented#SkPaintDefaults_TextSize">SkPaintDefaults TextSize</a> at compile time to change the default setting. 3717 3718### Example 3719 3720<div><fiddle-embed name="91c9a3e498bb9412e4522a95d076ed5f"></fiddle-embed></div> 3721 3722<a name="SkPaint_getTextSize"></a> 3723## getTextSize 3724 3725<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3726SkScalar getTextSize() const 3727</pre> 3728 3729Returns <a href="#Text_Size">Text Size</a> in points. 3730 3731### Return Value 3732 3733typographic height of text 3734 3735### Example 3736 3737<div><fiddle-embed name="983e2a71ba72d4ba8c945420040b8f1c"></fiddle-embed></div> 3738 3739--- 3740 3741<a name="SkPaint_setTextSize"></a> 3742## setTextSize 3743 3744<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3745void setTextSize(SkScalar textSize) 3746</pre> 3747 3748Sets <a href="#Text_Size">Text Size</a> in points. 3749Has no effect if <a href="#SkPaint_setTextSize_textSize">textSize</a> is not greater than or equal to zero. 3750 3751### Parameters 3752 3753<table> <tr> <td><a name="SkPaint_setTextSize_textSize"> <code><strong>textSize </strong></code> </a></td> <td> 3754typographic height of text</td> 3755 </tr> 3756</table> 3757 3758### Example 3759 3760<div><fiddle-embed name="6510c9e2f57b83c47e67829e7a68d493"></fiddle-embed></div> 3761 3762--- 3763 3764## <a name="Text_Scale_X"></a> Text Scale X 3765 3766<a href="#Text_Scale_X">Text Scale X</a> adjusts the text horizontal scale. 3767<a href="undocumented#Text">Text</a> scaling approximates condensed and expanded type faces when the actual face 3768is not available. 3769<a href="#Text_Scale_X">Text Scale X</a> can be set to any value. 3770<a href="#Text_Scale_X">Text Scale X</a> defaults to 1. 3771 3772### Example 3773 3774<div><fiddle-embed name="d13d787c1e36f515319fc998411c1d91"></fiddle-embed></div> 3775 3776<a name="SkPaint_getTextScaleX"></a> 3777## getTextScaleX 3778 3779<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3780SkScalar getTextScaleX() const 3781</pre> 3782 3783Returns <a href="#Text_Scale_X">Text Scale X</a>. 3784Default value is 1. 3785 3786### Return Value 3787 3788text horizontal scale 3789 3790### Example 3791 3792<div><fiddle-embed name="5dc8e58f6910cb8e4de9ed60f888188b"></fiddle-embed></div> 3793 3794--- 3795 3796<a name="SkPaint_setTextScaleX"></a> 3797## setTextScaleX 3798 3799<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3800void setTextScaleX(SkScalar scaleX) 3801</pre> 3802 3803Sets <a href="#Text_Scale_X">Text Scale X</a>. 3804Default value is 1. 3805 3806### Parameters 3807 3808<table> <tr> <td><a name="SkPaint_setTextScaleX_scaleX"> <code><strong>scaleX </strong></code> </a></td> <td> 3809text horizontal scale</td> 3810 </tr> 3811</table> 3812 3813### Example 3814 3815<div><fiddle-embed name="a75bbdb8bb866b125c4c1dd5e967d470"></fiddle-embed></div> 3816 3817--- 3818 3819## <a name="Text_Skew_X"></a> Text Skew X 3820 3821<a href="#Text_Skew_X">Text Skew X</a> adjusts the text horizontal slant. 3822<a href="undocumented#Text">Text</a> skewing approximates italic and oblique type faces when the actual face 3823is not available. 3824<a href="#Text_Skew_X">Text Skew X</a> can be set to any value. 3825<a href="#Text_Skew_X">Text Skew X</a> defaults to 0. 3826 3827### Example 3828 3829<div><fiddle-embed name="aff208b0aab265f273045b27e683c17c"></fiddle-embed></div> 3830 3831<a name="SkPaint_getTextSkewX"></a> 3832## getTextSkewX 3833 3834<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3835SkScalar getTextSkewX() const 3836</pre> 3837 3838Returns <a href="#Text_Skew_X">Text Skew X</a>. 3839Default value is zero. 3840 3841### Return Value 3842 3843additional shear in x-axis relative to y-axis 3844 3845### Example 3846 3847<div><fiddle-embed name="11c10f466dae0d1639dbb9f6a0040218"></fiddle-embed></div> 3848 3849--- 3850 3851<a name="SkPaint_setTextSkewX"></a> 3852## setTextSkewX 3853 3854<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3855void setTextSkewX(SkScalar skewX) 3856</pre> 3857 3858Sets <a href="#Text_Skew_X">Text Skew X</a>. 3859Default value is zero. 3860 3861### Parameters 3862 3863<table> <tr> <td><a name="SkPaint_setTextSkewX_skewX"> <code><strong>skewX </strong></code> </a></td> <td> 3864additional shear in x-axis relative to y-axis</td> 3865 </tr> 3866</table> 3867 3868### Example 3869 3870<div><fiddle-embed name="6bd705a6e0c5f8ee24f302fe531bfabc"></fiddle-embed></div> 3871 3872--- 3873 3874## <a name="Text_Encoding"></a> Text Encoding 3875 3876## <a name="SkPaint_TextEncoding"></a> Enum SkPaint::TextEncoding 3877 3878<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3879enum <a href="#SkPaint_TextEncoding">TextEncoding</a> { 3880<a href="#SkPaint_kUTF8_TextEncoding">kUTF8 TextEncoding</a>, 3881<a href="#SkPaint_kUTF16_TextEncoding">kUTF16 TextEncoding</a>, 3882<a href="#SkPaint_kUTF32_TextEncoding">kUTF32 TextEncoding</a>, 3883<a href="#SkPaint_kGlyphID_TextEncoding">kGlyphID TextEncoding</a>, 3884};</pre> 3885 3886<a href="#SkPaint_TextEncoding">TextEncoding</a> determines whether text specifies character codes and their encoded 3887size, or glyph indices. Characters are encoded as specified by the <a href="http://unicode.org/standard/standard.html">Unicode standard</a> . 3888 3889Character codes encoded size are specified by UTF-8, UTF-16, or UTF-32. 3890All character code formats are able to represent all of Unicode, differing only 3891in the total storage required. 3892 3893<a href="https://tools.ietf.org/html/rfc3629">UTF-8 (RFC 3629)</a> encodes each character as one or more 8-bit bytes. 3894 3895<a href="https://tools.ietf.org/html/rfc2781">UTF-16 (RFC 2781)</a> encodes each character as one or two 16-bit words. 3896 3897<a href="http://www.unicode.org/versions/Unicode5.0.0/ch03.pdf">UTF-32</a> encodes each character as one 32-bit word. 3898 3899<a href="undocumented#Font_Manager">Font Manager</a> uses font data to convert character code points into glyph indices. 3900A glyph index is a 16-bit word. 3901 3902<a href="#SkPaint_TextEncoding">TextEncoding</a> is set to <a href="#SkPaint_kUTF8_TextEncoding">kUTF8 TextEncoding</a> by default. 3903 3904### Constants 3905 3906<table> 3907 <tr> 3908 <td><a name="SkPaint_kUTF8_TextEncoding"> <code><strong>SkPaint::kUTF8_TextEncoding </strong></code> </a></td><td>0</td><td>Uses bytes to represent UTF-8 or ASCII.</td> 3909 </tr> 3910 <tr> 3911 <td><a name="SkPaint_kUTF16_TextEncoding"> <code><strong>SkPaint::kUTF16_TextEncoding </strong></code> </a></td><td>1</td><td>Uses two byte words to represent most of Unicode.</td> 3912 </tr> 3913 <tr> 3914 <td><a name="SkPaint_kUTF32_TextEncoding"> <code><strong>SkPaint::kUTF32_TextEncoding </strong></code> </a></td><td>2</td><td>Uses four byte words to represent all of Unicode.</td> 3915 </tr> 3916 <tr> 3917 <td><a name="SkPaint_kGlyphID_TextEncoding"> <code><strong>SkPaint::kGlyphID_TextEncoding </strong></code> </a></td><td>3</td><td>Uses two byte words to represent glyph indices.</td> 3918 </tr> 3919 3920</table> 3921 3922### Example 3923 3924<div><fiddle-embed name="b29294e7f29d160a1b46abf2dcec9d2a"><div>First line is encoded in UTF-8. 3925Second line is encoded in UTF-16. 3926Third line is encoded in UTF-32. 3927Fourth line has 16 bit glyph indices.</div></fiddle-embed></div> 3928 3929<a name="SkPaint_getTextEncoding"></a> 3930## getTextEncoding 3931 3932<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3933TextEncoding getTextEncoding() const 3934</pre> 3935 3936Returns <a href="#Text_Encoding">Text Encoding</a>. 3937<a href="#Text_Encoding">Text Encoding</a> determines how character code points are mapped to font glyph indices. 3938 3939### Return Value 3940 3941one of: <a href="#SkPaint_kUTF8_TextEncoding">kUTF8 TextEncoding</a>, <a href="#SkPaint_kUTF16_TextEncoding">kUTF16 TextEncoding</a>, <a href="#SkPaint_kUTF32_TextEncoding">kUTF32 TextEncoding</a>, or 3942<a href="#SkPaint_kGlyphID_TextEncoding">kGlyphID TextEncoding</a> 3943 3944### Example 3945 3946<div><fiddle-embed name="70ad28bbf7668b38474d7f225e3540bc"> 3947 3948#### Example Output 3949 3950~~~~ 3951kUTF8_TextEncoding == text encoding 3952kGlyphID_TextEncoding == text encoding 3953~~~~ 3954 3955</fiddle-embed></div> 3956 3957--- 3958 3959<a name="SkPaint_setTextEncoding"></a> 3960## setTextEncoding 3961 3962<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3963void setTextEncoding(TextEncoding encoding) 3964</pre> 3965 3966Sets <a href="#Text_Encoding">Text Encoding</a> to <a href="#SkPaint_setTextEncoding_encoding">encoding</a>. 3967<a href="#Text_Encoding">Text Encoding</a> determines how character code points are mapped to font glyph indices. 3968Invalid values for <a href="#SkPaint_setTextEncoding_encoding">encoding</a> are ignored. 3969 3970### Parameters 3971 3972<table> <tr> <td><a name="SkPaint_setTextEncoding_encoding"> <code><strong>encoding </strong></code> </a></td> <td> 3973one of: <a href="#SkPaint_kUTF8_TextEncoding">kUTF8 TextEncoding</a>, <a href="#SkPaint_kUTF16_TextEncoding">kUTF16 TextEncoding</a>, <a href="#SkPaint_kUTF32_TextEncoding">kUTF32 TextEncoding</a>, or 3974<a href="#SkPaint_kGlyphID_TextEncoding">kGlyphID TextEncoding</a></td> 3975 </tr> 3976# 3977 3978</table> 3979 3980### Example 3981 3982<div><fiddle-embed name="329b92fbc35151dee9aa0c0e70107665"> 3983 3984#### Example Output 3985 3986~~~~ 39874 != text encoding 3988~~~~ 3989 3990</fiddle-embed></div> 3991 3992--- 3993 3994## <a name="Font_Metrics"></a> Font Metrics 3995 3996<a href="#Font_Metrics">Font Metrics</a> describe dimensions common to the <a href="undocumented#Glyph">Glyphs</a> in <a href="undocumented#Typeface">Typeface</a>. 3997The dimensions are computed by <a href="undocumented#Font_Manager">Font Manager</a> from font data and do not take 3998<a href="#Paint">Paint</a> settings other than <a href="#Text_Size">Text Size</a> into account. 3999 4000<a href="undocumented#Font">Font</a> dimensions specify the anchor to the left of the glyph at baseline as the origin. 4001X-axis values to the left of the glyph are negative, and to the right of the left glyph edge 4002are positive. 4003Y-axis values above the baseline are negative, and below the baseline are positive. 4004 4005### Example 4006 4007<div><fiddle-embed name="2bfa3783719fcd769af177a1b244e171"></fiddle-embed></div> 4008 4009# <a name="SkPaint_FontMetrics"></a> Struct SkPaint::FontMetrics 4010 4011<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4012struct <a href="#SkPaint_FontMetrics">FontMetrics</a> { 4013enum <a href="#SkPaint_FontMetrics_FontMetricsFlags">FontMetricsFlags</a> { 4014<a href="#SkPaint_FontMetrics_kUnderlineThicknessIsValid_Flag">kUnderlineThicknessIsValid Flag</a> = 1 << 0, 4015<a href="#SkPaint_FontMetrics_kUnderlinePositionIsValid_Flag">kUnderlinePositionIsValid Flag</a> = 1 << 1, 4016<a href="#SkPaint_FontMetrics_kStrikeoutThicknessIsValid_Flag">kStrikeoutThicknessIsValid Flag</a> = 1 << 2, 4017<a href="#SkPaint_FontMetrics_kStrikeoutPositionIsValid_Flag">kStrikeoutPositionIsValid Flag</a> = 1 << 3, 4018}; 4019 4020uint32_t <a href="#SkPaint_FontMetrics_fFlags">fFlags</a>; 4021<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fTop">fTop</a>; 4022<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fAscent">fAscent</a>; 4023<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fDescent">fDescent</a>; 4024<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fBottom">fBottom</a>; 4025<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fLeading">fLeading</a>; 4026<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fAvgCharWidth">fAvgCharWidth</a>; 4027<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fMaxCharWidth">fMaxCharWidth</a>; 4028<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fXMin">fXMin</a>; 4029<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fXMax">fXMax</a>; 4030<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fXHeight">fXHeight</a>; 4031<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fCapHeight">fCapHeight</a>; 4032<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fUnderlineThickness">fUnderlineThickness</a>; 4033<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fUnderlinePosition">fUnderlinePosition</a>; 4034<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fStrikeoutThickness">fStrikeoutThickness</a>; 4035<a href="undocumented#SkScalar">SkScalar</a> <a href="#SkPaint_FontMetrics_fStrikeoutPosition">fStrikeoutPosition</a>; 4036 4037bool <a href="#SkPaint_FontMetrics_hasUnderlineThickness">hasUnderlineThickness(SkScalar* thickness)</a> const; 4038bool <a href="#SkPaint_FontMetrics_hasUnderlinePosition">hasUnderlinePosition(SkScalar* position)</a> const; 4039bool <a href="#SkPaint_FontMetrics_hasStrikeoutThickness">hasStrikeoutThickness(SkScalar* thickness)</a> const; 4040bool <a href="#SkPaint_FontMetrics_hasStrikeoutPosition">hasStrikeoutPosition(SkScalar* position)</a> const; 4041};</pre> 4042 4043<a href="#SkPaint_FontMetrics">FontMetrics</a> is filled out by <a href="#SkPaint_getFontMetrics">getFontMetrics</a>. <a href="#SkPaint_FontMetrics">FontMetrics</a> contents reflect the values 4044computed by <a href="undocumented#Font_Manager">Font Manager</a> using <a href="undocumented#Typeface">Typeface</a>. Values are set to zero if they are 4045not available. 4046 4047All vertical values relative to the baseline are given y-down. As such, zero is on the 4048baseline, negative values are above the baseline, and positive values are below the 4049baseline. 4050 4051<a href="#SkPaint_FontMetrics_fUnderlineThickness">fUnderlineThickness</a> and <a href="#SkPaint_FontMetrics_fUnderlinePosition">fUnderlinePosition</a> have a bit set in <a href="#SkPaint_FontMetrics_fFlags">fFlags</a> if their values 4052are valid, since their value may be zero. 4053 4054<a href="#SkPaint_FontMetrics_fStrikeoutThickness">fStrikeoutThickness</a> and <a href="#SkPaint_FontMetrics_fStrikeoutPosition">fStrikeoutPosition</a> have a bit set in <a href="#SkPaint_FontMetrics_fFlags">fFlags</a> if their values 4055are valid, since their value may be zero. 4056 4057## <a name="SkPaint_FontMetrics_FontMetricsFlags"></a> Enum SkPaint::FontMetrics::FontMetricsFlags 4058 4059<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4060enum <a href="#SkPaint_FontMetrics_FontMetricsFlags">FontMetricsFlags</a> { 4061<a href="#SkPaint_FontMetrics_kUnderlineThicknessIsValid_Flag">kUnderlineThicknessIsValid Flag</a> = 1 << 0, 4062<a href="#SkPaint_FontMetrics_kUnderlinePositionIsValid_Flag">kUnderlinePositionIsValid Flag</a> = 1 << 1, 4063<a href="#SkPaint_FontMetrics_kStrikeoutThicknessIsValid_Flag">kStrikeoutThicknessIsValid Flag</a> = 1 << 2, 4064<a href="#SkPaint_FontMetrics_kStrikeoutPositionIsValid_Flag">kStrikeoutPositionIsValid Flag</a> = 1 << 3, 4065};</pre> 4066 4067<a href="#SkPaint_FontMetrics_FontMetricsFlags">FontMetricsFlags</a> are set in <a href="#SkPaint_FontMetrics_fFlags">fFlags</a> when underline and strikeout metrics are valid; 4068the underline or strikeout metric may be valid and zero. 4069Fonts with embedded bitmaps may not have valid underline or strikeout metrics. 4070 4071### Constants 4072 4073<table> 4074 <tr> 4075 <td><a name="SkPaint_FontMetrics_kUnderlineThicknessIsValid_Flag"> <code><strong>SkPaint::FontMetrics::kUnderlineThicknessIsValid_Flag </strong></code> </a></td><td>0x0001</td><td>Set if <a href="#SkPaint_FontMetrics_fUnderlineThickness">fUnderlineThickness</a> is valid.</td> 4076 </tr> 4077 <tr> 4078 <td><a name="SkPaint_FontMetrics_kUnderlinePositionIsValid_Flag"> <code><strong>SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag </strong></code> </a></td><td>0x0002</td><td>Set if <a href="#SkPaint_FontMetrics_fUnderlinePosition">fUnderlinePosition</a> is valid.</td> 4079 </tr> 4080 <tr> 4081 <td><a name="SkPaint_FontMetrics_kStrikeoutThicknessIsValid_Flag"> <code><strong>SkPaint::FontMetrics::kStrikeoutThicknessIsValid_Flag </strong></code> </a></td><td>0x0004</td><td>Set if <a href="#SkPaint_FontMetrics_fStrikeoutThickness">fStrikeoutThickness</a> is valid.</td> 4082 </tr> 4083 <tr> 4084 <td><a name="SkPaint_FontMetrics_kStrikeoutPositionIsValid_Flag"> <code><strong>SkPaint::FontMetrics::kStrikeoutPositionIsValid_Flag </strong></code> </a></td><td>0x0008</td><td>Set if <a href="#SkPaint_FontMetrics_fStrikeoutPosition">fStrikeoutPosition</a> is valid.</td> 4085 </tr> 4086 4087</table> 4088 4089<a name="SkPaint_FontMetrics_fFlags"> <code><strong>uint32_t fFlags</strong></code> </a> 4090 4091<a href="#SkPaint_FontMetrics_fFlags">fFlags</a> is set when underline metrics are valid. 4092 4093<a name="SkPaint_FontMetrics_fTop"> <code><strong>SkScalar fTop</strong></code> </a> 4094 4095Greatest extent above the baseline for any glyph. 4096Typically less than zero. 4097 4098<a name="SkPaint_FontMetrics_fAscent"> <code><strong>SkScalar fAscent</strong></code> </a> 4099 4100Recommended distance above the baseline to reserve for a line of text. 4101Typically less than zero. 4102 4103<a name="SkPaint_FontMetrics_fDescent"> <code><strong>SkScalar fDescent</strong></code> </a> 4104 4105Recommended distance below the baseline to reserve for a line of text. 4106Typically greater than zero. 4107 4108<a name="SkPaint_FontMetrics_fBottom"> <code><strong>SkScalar fBottom</strong></code> </a> 4109 4110Greatest extent below the baseline for any glyph. 4111Typically greater than zero. 4112 4113<a name="SkPaint_FontMetrics_fLeading"> <code><strong>SkScalar fLeading</strong></code> </a> 4114 4115Recommended distance to add between lines of text. 4116Typically greater than or equal to zero. 4117 4118<a name="SkPaint_FontMetrics_fAvgCharWidth"> <code><strong>SkScalar fAvgCharWidth</strong></code> </a> 4119 4120Average character width, if it is available. 4121Zero if no average width is stored in the font. 4122 4123<a name="SkPaint_FontMetrics_fMaxCharWidth"> <code><strong>SkScalar fMaxCharWidth</strong></code> </a> 4124 4125Maximum character width. 4126 4127<a name="SkPaint_FontMetrics_fXMin"> <code><strong>SkScalar fXMin</strong></code> </a> 4128 4129Minimum bounding box x value for all <a href="undocumented#Glyph">Glyphs</a>. 4130Typically less than zero. 4131 4132<a name="SkPaint_FontMetrics_fXMax"> <code><strong>SkScalar fXMax</strong></code> </a> 4133 4134Maximum bounding box x value for all <a href="undocumented#Glyph">Glyphs</a>. 4135Typically greater than zero. 4136 4137<a name="SkPaint_FontMetrics_fXHeight"> <code><strong>SkScalar fXHeight</strong></code> </a> 4138 4139Height of a lower-case 'x'. 4140May be zero if no lower-case height is stored in the font. 4141 4142<a name="SkPaint_FontMetrics_fCapHeight"> <code><strong>SkScalar fCapHeight</strong></code> </a> 4143 4144Height of an upper-case letter. 4145May be zero if no upper-case height is stored in the font. 4146 4147<a name="SkPaint_FontMetrics_fUnderlineThickness"> <code><strong>SkScalar fUnderlineThickness</strong></code> </a> 4148 4149Underline thickness. 4150 4151If the metric is valid, the <a href="#SkPaint_FontMetrics_kUnderlineThicknessIsValid_Flag">kUnderlineThicknessIsValid Flag</a> is set in <a href="#SkPaint_FontMetrics_fFlags">fFlags</a>. 4152If <a href="#SkPaint_FontMetrics_kUnderlineThicknessIsValid_Flag">kUnderlineThicknessIsValid Flag</a> is clear, <a href="#SkPaint_FontMetrics_fUnderlineThickness">fUnderlineThickness</a> is zero. 4153 4154<a name="SkPaint_FontMetrics_fUnderlinePosition"> <code><strong>SkScalar fUnderlinePosition</strong></code> </a> 4155 4156Position of the top of the underline stroke relative to the baseline. 4157Typically positive when valid. 4158 4159If the metric is valid, the <a href="#SkPaint_FontMetrics_kUnderlinePositionIsValid_Flag">kUnderlinePositionIsValid Flag</a> is set in <a href="#SkPaint_FontMetrics_fFlags">fFlags</a>. 4160If <a href="#SkPaint_FontMetrics_kUnderlinePositionIsValid_Flag">kUnderlinePositionIsValid Flag</a> is clear, <a href="#SkPaint_FontMetrics_fUnderlinePosition">fUnderlinePosition</a> is zero. 4161 4162<a name="SkPaint_FontMetrics_fStrikeoutThickness"> <code><strong>SkScalar fStrikeoutThickness</strong></code> </a> 4163 4164Strikeout thickness. 4165 4166If the metric is valid, the <a href="#SkPaint_FontMetrics_kStrikeoutThicknessIsValid_Flag">kStrikeoutThicknessIsValid Flag</a> is set in <a href="#SkPaint_FontMetrics_fFlags">fFlags</a>. 4167If <a href="#SkPaint_FontMetrics_kStrikeoutThicknessIsValid_Flag">kStrikeoutThicknessIsValid Flag</a> is clear, <a href="#SkPaint_FontMetrics_fStrikeoutThickness">fStrikeoutThickness</a> is zero. 4168 4169<a name="SkPaint_FontMetrics_fStrikeoutPosition"> <code><strong>SkScalar fStrikeoutPosition</strong></code> </a> 4170 4171Position of the bottom of the strikeout stroke relative to the baseline. 4172Typically negative when valid. 4173 4174If the metric is valid, the <a href="#SkPaint_FontMetrics_kStrikeoutPositionIsValid_Flag">kStrikeoutPositionIsValid Flag</a> is set in <a href="#SkPaint_FontMetrics_fFlags">fFlags</a>. 4175If <a href="#SkPaint_FontMetrics_kStrikeoutPositionIsValid_Flag">kStrikeoutPositionIsValid Flag</a> is clear, <a href="#SkPaint_FontMetrics_fStrikeoutPosition">fStrikeoutPosition</a> is zero. 4176 4177<a name="SkPaint_FontMetrics_hasUnderlineThickness"></a> 4178## hasUnderlineThickness 4179 4180<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4181bool hasUnderlineThickness(SkScalar* thickness) const 4182</pre> 4183 4184If <a href="#Font_Metrics">Font Metrics</a> has a valid underline <a href="#SkPaint_FontMetrics_hasUnderlineThickness_thickness">thickness</a>, return true, and set 4185<a href="#SkPaint_FontMetrics_hasUnderlineThickness_thickness">thickness</a> to that value. If the underline <a href="#SkPaint_FontMetrics_hasUnderlineThickness_thickness">thickness</a> is not valid, 4186return false, and ignore <a href="#SkPaint_FontMetrics_hasUnderlineThickness_thickness">thickness</a>. 4187 4188### Parameters 4189 4190<table> <tr> <td><a name="SkPaint_FontMetrics_hasUnderlineThickness_thickness"> <code><strong>thickness </strong></code> </a></td> <td> 4191storage for underline width</td> 4192 </tr> 4193</table> 4194 4195### Return Value 4196 4197true if font specifies underline width 4198 4199--- 4200 4201<a name="SkPaint_FontMetrics_hasUnderlinePosition"></a> 4202## hasUnderlinePosition 4203 4204<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4205bool hasUnderlinePosition(SkScalar* position) const 4206</pre> 4207 4208If <a href="#Font_Metrics">Font Metrics</a> has a valid underline <a href="#SkPaint_FontMetrics_hasUnderlinePosition_position">position</a>, return true, and set 4209<a href="#SkPaint_FontMetrics_hasUnderlinePosition_position">position</a> to that value. If the underline <a href="#SkPaint_FontMetrics_hasUnderlinePosition_position">position</a> is not valid, 4210return false, and ignore <a href="#SkPaint_FontMetrics_hasUnderlinePosition_position">position</a>. 4211 4212### Parameters 4213 4214<table> <tr> <td><a name="SkPaint_FontMetrics_hasUnderlinePosition_position"> <code><strong>position </strong></code> </a></td> <td> 4215storage for underline <a href="#SkPaint_FontMetrics_hasUnderlinePosition_position">position</a></td> 4216 </tr> 4217</table> 4218 4219### Return Value 4220 4221true if font specifies underline <a href="#SkPaint_FontMetrics_hasUnderlinePosition_position">position</a> 4222 4223--- 4224 4225<a name="SkPaint_FontMetrics_hasStrikeoutThickness"></a> 4226## hasStrikeoutThickness 4227 4228<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4229bool hasStrikeoutThickness(SkScalar* thickness) const 4230</pre> 4231 4232If <a href="#Font_Metrics">Font Metrics</a> has a valid strikeout <a href="#SkPaint_FontMetrics_hasStrikeoutThickness_thickness">thickness</a>, return true, and set 4233<a href="#SkPaint_FontMetrics_hasStrikeoutThickness_thickness">thickness</a> to that value. If the underline <a href="#SkPaint_FontMetrics_hasStrikeoutThickness_thickness">thickness</a> is not valid, 4234return false, and ignore <a href="#SkPaint_FontMetrics_hasStrikeoutThickness_thickness">thickness</a>. 4235 4236### Parameters 4237 4238<table> <tr> <td><a name="SkPaint_FontMetrics_hasStrikeoutThickness_thickness"> <code><strong>thickness </strong></code> </a></td> <td> 4239storage for strikeout width</td> 4240 </tr> 4241</table> 4242 4243### Return Value 4244 4245true if font specifies strikeout width 4246 4247--- 4248 4249<a name="SkPaint_FontMetrics_hasStrikeoutPosition"></a> 4250## hasStrikeoutPosition 4251 4252<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4253bool hasStrikeoutPosition(SkScalar* position) const 4254</pre> 4255 4256If <a href="#Font_Metrics">Font Metrics</a> has a valid strikeout <a href="#SkPaint_FontMetrics_hasStrikeoutPosition_position">position</a>, return true, and set 4257<a href="#SkPaint_FontMetrics_hasStrikeoutPosition_position">position</a> to that value. If the underline <a href="#SkPaint_FontMetrics_hasStrikeoutPosition_position">position</a> is not valid, 4258return false, and ignore <a href="#SkPaint_FontMetrics_hasStrikeoutPosition_position">position</a>. 4259 4260### Parameters 4261 4262<table> <tr> <td><a name="SkPaint_FontMetrics_hasStrikeoutPosition_position"> <code><strong>position </strong></code> </a></td> <td> 4263storage for strikeout <a href="#SkPaint_FontMetrics_hasStrikeoutPosition_position">position</a></td> 4264 </tr> 4265</table> 4266 4267### Return Value 4268 4269true if font specifies strikeout <a href="#SkPaint_FontMetrics_hasStrikeoutPosition_position">position</a> 4270 4271--- 4272 4273<a name="SkPaint_getFontMetrics"></a> 4274## getFontMetrics 4275 4276<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4277SkScalar getFontMetrics(FontMetrics* metrics, SkScalar scale = 0) const 4278</pre> 4279 4280Returns <a href="#Font_Metrics">Font Metrics</a> associated with <a href="undocumented#Typeface">Typeface</a>. 4281The return value is the recommended spacing between lines: the sum of <a href="#SkPaint_getFontMetrics_metrics">metrics</a> 4282descent, ascent, and leading. 4283If <a href="#SkPaint_getFontMetrics_metrics">metrics</a> is not nullptr, <a href="#Font_Metrics">Font Metrics</a> is copied to <a href="#SkPaint_getFontMetrics_metrics">metrics</a>. 4284Results are scaled by <a href="#Text_Size">Text Size</a> but does not take into account 4285dimensions required by <a href="#Text_Scale_X">Text Scale X</a>, <a href="#Text_Skew_X">Text Skew X</a>, <a href="#Fake_Bold">Fake Bold</a>, 4286<a href="#Style_Stroke">Style Stroke</a>, and <a href="undocumented#Path_Effect">Path Effect</a>. 4287Results can be additionally scaled by <a href="#SkPaint_getFontMetrics_scale">scale</a>; a <a href="#SkPaint_getFontMetrics_scale">scale</a> of zero 4288is ignored. 4289 4290### Parameters 4291 4292<table> <tr> <td><a name="SkPaint_getFontMetrics_metrics"> <code><strong>metrics </strong></code> </a></td> <td> 4293storage for <a href="#Font_Metrics">Font Metrics</a> from <a href="undocumented#Typeface">Typeface</a>; may be nullptr</td> 4294 </tr> <tr> <td><a name="SkPaint_getFontMetrics_scale"> <code><strong>scale </strong></code> </a></td> <td> 4295additional multiplier for returned values</td> 4296 </tr> 4297</table> 4298 4299### Return Value 4300 4301recommended spacing between lines 4302 4303### Example 4304 4305<div><fiddle-embed name="b899d84caba6607340322d317992d070"></fiddle-embed></div> 4306 4307### See Also 4308 4309<a href="#Text_Size">Text Size</a> <a href="undocumented#Typeface">Typeface</a> <a href="#Typeface_Methods">Typeface Methods</a> 4310 4311--- 4312 4313<a name="SkPaint_getFontSpacing"></a> 4314## getFontSpacing 4315 4316<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4317SkScalar getFontSpacing() const 4318</pre> 4319 4320Returns the recommended spacing between lines: the sum of metrics 4321descent, ascent, and leading. 4322Result is scaled by <a href="#Text_Size">Text Size</a> but does not take into account 4323dimensions required by stroking and <a href="undocumented#Path_Effect">Path Effect</a>. 4324Returns the same result as <a href="#SkPaint_getFontMetrics">getFontMetrics</a>. 4325 4326### Return Value 4327 4328recommended spacing between lines 4329 4330### Example 4331 4332<div><fiddle-embed name="424741e26e1b174e43087d67422ce14f"> 4333 4334#### Example Output 4335 4336~~~~ 4337textSize: 12 fontSpacing: 13.9688 4338textSize: 18 fontSpacing: 20.9531 4339textSize: 24 fontSpacing: 27.9375 4340textSize: 32 fontSpacing: 37.25 4341~~~~ 4342 4343</fiddle-embed></div> 4344 4345--- 4346 4347<a name="SkPaint_getFontBounds"></a> 4348## getFontBounds 4349 4350<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4351SkRect getFontBounds() const 4352</pre> 4353 4354Returns the union of bounds of all <a href="undocumented#Glyph">Glyphs</a>. 4355Returned dimensions are computed by <a href="undocumented#Font_Manager">Font Manager</a> from font data, 4356ignoring <a href="#SkPaint_Hinting">Hinting</a>. Includes <a href="#Text_Size">Text Size</a>, <a href="#Text_Scale_X">Text Scale X</a>, 4357and <a href="#Text_Skew_X">Text Skew X</a>, but not <a href="#Fake_Bold">Fake Bold</a> or <a href="undocumented#Path_Effect">Path Effect</a>. 4358 4359If <a href="#Text_Size">Text Size</a> is large, <a href="#Text_Scale_X">Text Scale X</a> is one, and <a href="#Text_Skew_X">Text Skew X</a> is zero, 4360returns the same bounds as <a href="#Font_Metrics">Font Metrics</a> { <a href="#SkPaint_FontMetrics_fXMin">FontMetrics::fXMin</a>, 4361<a href="#SkPaint_FontMetrics_fTop">FontMetrics::fTop</a>, <a href="#SkPaint_FontMetrics_fXMax">FontMetrics::fXMax</a>, <a href="#SkPaint_FontMetrics_fBottom">FontMetrics::fBottom</a> }. 4362 4363### Return Value 4364 4365union of bounds of all <a href="undocumented#Glyph">Glyphs</a> 4366 4367### Example 4368 4369<div><fiddle-embed name="facaddeec7943bc491988e345e27e65f"> 4370 4371#### Example Output 4372 4373~~~~ 4374metrics bounds = { -12.2461, -14.7891, 21.5215, 5.55469 } 4375font bounds = { -12.2461, -14.7891, 21.5215, 5.55469 } 4376~~~~ 4377 4378</fiddle-embed></div> 4379 4380--- 4381 4382<a name="SkPaint_textToGlyphs"></a> 4383## textToGlyphs 4384 4385<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4386int textToGlyphs(const void* text, size_t byteLength, SkGlyphID glyphs[]) const 4387</pre> 4388 4389Converts <a href="#SkPaint_textToGlyphs_text">text</a> into glyph indices. 4390Returns the number of glyph indices represented by <a href="#SkPaint_textToGlyphs_text">text</a>. 4391<a href="#Text_Encoding">Text Encoding</a> specifies how <a href="#SkPaint_textToGlyphs_text">text</a> represents characters or <a href="#SkPaint_textToGlyphs_glyphs">glyphs</a>. 4392<a href="#SkPaint_textToGlyphs_glyphs">glyphs</a> may be nullptr, to compute the glyph count. 4393 4394Does not check <a href="#SkPaint_textToGlyphs_text">text</a> for valid character codes or valid glyph indices. 4395 4396If <a href="#SkPaint_textToGlyphs_byteLength">byteLength</a> equals zero, returns zero. 4397If <a href="#SkPaint_textToGlyphs_byteLength">byteLength</a> includes a partial character, the partial character is ignored. 4398 4399If <a href="#Text_Encoding">Text Encoding</a> is <a href="#SkPaint_kUTF8_TextEncoding">kUTF8 TextEncoding</a> and 4400<a href="#SkPaint_textToGlyphs_text">text</a> contains an invalid UTF-8 sequence, zero is returned. 4401 4402### Parameters 4403 4404<table> <tr> <td><a name="SkPaint_textToGlyphs_text"> <code><strong>text </strong></code> </a></td> <td> 4405character storage encoded with <a href="#Text_Encoding">Text Encoding</a></td> 4406 </tr> <tr> <td><a name="SkPaint_textToGlyphs_byteLength"> <code><strong>byteLength </strong></code> </a></td> <td> 4407length of character storage in bytes</td> 4408 </tr> <tr> <td><a name="SkPaint_textToGlyphs_glyphs"> <code><strong>glyphs </strong></code> </a></td> <td> 4409storage for glyph indices; may be nullptr</td> 4410 </tr> 4411</table> 4412 4413### Return Value 4414 4415number of <a href="#SkPaint_textToGlyphs_glyphs">glyphs</a> represented by <a href="#SkPaint_textToGlyphs_text">text</a> of length <a href="#SkPaint_textToGlyphs_byteLength">byteLength</a> 4416 4417### Example 4418 4419<div><fiddle-embed name="343e9471a7f7b5f09abdc3b44983433b"></fiddle-embed></div> 4420 4421--- 4422 4423<a name="SkPaint_countText"></a> 4424## countText 4425 4426<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4427int countText(const void* text, size_t byteLength) const 4428</pre> 4429 4430Returns the number of <a href="undocumented#Glyph">Glyphs</a> in <a href="#SkPaint_countText_text">text</a>. 4431Uses <a href="#Text_Encoding">Text Encoding</a> to count the <a href="undocumented#Glyph">Glyphs</a>. 4432Returns the same result as <a href="#SkPaint_textToGlyphs">textToGlyphs</a>. 4433 4434### Parameters 4435 4436<table> <tr> <td><a name="SkPaint_countText_text"> <code><strong>text </strong></code> </a></td> <td> 4437character storage encoded with <a href="#Text_Encoding">Text Encoding</a></td> 4438 </tr> <tr> <td><a name="SkPaint_countText_byteLength"> <code><strong>byteLength </strong></code> </a></td> <td> 4439length of character storage in bytes</td> 4440 </tr> 4441</table> 4442 4443### Return Value 4444 4445number of <a href="undocumented#Glyph">Glyphs</a> represented by <a href="#SkPaint_countText_text">text</a> of length <a href="#SkPaint_countText_byteLength">byteLength</a> 4446 4447### Example 4448 4449<div><fiddle-embed name="85436c71aab5410767fc688ab0573e09"> 4450 4451#### Example Output 4452 4453~~~~ 4454count = 5 4455~~~~ 4456 4457</fiddle-embed></div> 4458 4459--- 4460 4461<a name="SkPaint_containsText"></a> 4462## containsText 4463 4464<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4465bool containsText(const void* text, size_t byteLength) const 4466</pre> 4467 4468Returns true if all <a href="#SkPaint_containsText_text">text</a> corresponds to a non-zero glyph index. 4469Returns false if any characters in <a href="#SkPaint_containsText_text">text</a> are not supported in 4470<a href="undocumented#Typeface">Typeface</a>. 4471 4472If <a href="#Text_Encoding">Text Encoding</a> is <a href="#SkPaint_kGlyphID_TextEncoding">kGlyphID TextEncoding</a>, 4473returns true if all glyph indices in <a href="#SkPaint_containsText_text">text</a> are non-zero; 4474does not check to see if <a href="#SkPaint_containsText_text">text</a> contains valid glyph indices for <a href="undocumented#Typeface">Typeface</a>. 4475 4476Returns true if <a href="#SkPaint_containsText_byteLength">byteLength</a> is zero. 4477 4478### Parameters 4479 4480<table> <tr> <td><a name="SkPaint_containsText_text"> <code><strong>text </strong></code> </a></td> <td> 4481array of characters or <a href="undocumented#Glyph">Glyphs</a></td> 4482 </tr> <tr> <td><a name="SkPaint_containsText_byteLength"> <code><strong>byteLength </strong></code> </a></td> <td> 4483number of bytes in <a href="#SkPaint_containsText_text">text</a> array</td> 4484 </tr> 4485</table> 4486 4487### Return Value 4488 4489true if all <a href="#SkPaint_containsText_text">text</a> corresponds to a non-zero glyph index 4490 4491### Example 4492 4493<div><fiddle-embed name="9202369019552f09cd4bec7f3046fee4"><div><a href="#SkPaint_containsText">containsText</a> succeeds for degree symbol, but cannot find a glyph index 4494corresponding to the Unicode surrogate code point.</div> 4495 4496#### Example Output 4497 4498~~~~ 44990x00b0 == has char 45000xd800 != has char 4501~~~~ 4502 4503</fiddle-embed></div> 4504 4505### Example 4506 4507<div><fiddle-embed name="904227febfd1c2e264955da0ef66da73"><div><a href="#SkPaint_containsText">containsText</a> returns true that glyph index is greater than zero, not 4508that it corresponds to an entry in <a href="undocumented#Typeface">Typeface</a>.</div> 4509 4510#### Example Output 4511 4512~~~~ 45130x01ff == has glyph 45140x0000 != has glyph 45150xffff == has glyph 4516~~~~ 4517 4518</fiddle-embed></div> 4519 4520### See Also 4521 4522<a href="#SkPaint_setTextEncoding">setTextEncoding</a> <a href="undocumented#Typeface">Typeface</a> 4523 4524--- 4525 4526<a name="SkPaint_glyphsToUnichars"></a> 4527## glyphsToUnichars 4528 4529<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4530void glyphsToUnichars(const SkGlyphID glyphs[], int count, SkUnichar text[]) const 4531</pre> 4532 4533Converts <a href="#SkPaint_glyphsToUnichars_glyphs">glyphs</a> into <a href="#SkPaint_glyphsToUnichars_text">text</a> if possible. 4534<a href="undocumented#Glyph">Glyph</a> values without direct Unicode equivalents are mapped to zero. 4535Uses the <a href="undocumented#Typeface">Typeface</a>, but is unaffected 4536by <a href="#Text_Encoding">Text Encoding</a>; the <a href="#SkPaint_glyphsToUnichars_text">text</a> values returned are equivalent to <a href="#SkPaint_kUTF32_TextEncoding">kUTF32 TextEncoding</a>. 4537 4538Only supported on platforms that use FreeType as the <a href="undocumented#Engine">Font Engine</a>. 4539 4540### Parameters 4541 4542<table> <tr> <td><a name="SkPaint_glyphsToUnichars_glyphs"> <code><strong>glyphs </strong></code> </a></td> <td> 4543array of indices into font</td> 4544 </tr> <tr> <td><a name="SkPaint_glyphsToUnichars_count"> <code><strong>count </strong></code> </a></td> <td> 4545length of glyph array</td> 4546 </tr> <tr> <td><a name="SkPaint_glyphsToUnichars_text"> <code><strong>text </strong></code> </a></td> <td> 4547storage for character codes, one per glyph</td> 4548 </tr> 4549</table> 4550 4551### Example 4552 4553<div><fiddle-embed name="c12686b0b3e0a87d0a248bbfc57e9492"><div>Convert UTF-8 <a href="#SkPaint_glyphsToUnichars_text">text</a> to <a href="#SkPaint_glyphsToUnichars_glyphs">glyphs</a>; then convert <a href="#SkPaint_glyphsToUnichars_glyphs">glyphs</a> to Unichar code points.</div></fiddle-embed></div> 4554 4555--- 4556 4557## <a name="Measure_Text"></a> Measure Text 4558 4559<a name="SkPaint_measureText"></a> 4560## measureText 4561 4562<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4563SkScalar measureText(const void* text, size_t length, SkRect* bounds) const 4564</pre> 4565 4566Returns the advance width of <a href="#SkPaint_measureText_text">text</a> if <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> is clear, 4567and the height of <a href="#SkPaint_measureText_text">text</a> if <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> is set. 4568The advance is the normal distance to move before drawing additional <a href="#SkPaint_measureText_text">text</a>. 4569Uses <a href="#Text_Encoding">Text Encoding</a> to decode <a href="#SkPaint_measureText_text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the font metrics, 4570and <a href="#Text_Size">Text Size</a>, <a href="#Text_Scale_X">Text Scale X</a>, <a href="#Text_Skew_X">Text Skew X</a>, <a href="#Stroke_Width">Stroke Width</a>, and 4571<a href="undocumented#Path_Effect">Path Effect</a> to scale the metrics and <a href="#SkPaint_measureText_bounds">bounds</a>. 4572Returns the bounding box of <a href="#SkPaint_measureText_text">text</a> if <a href="#SkPaint_measureText_bounds">bounds</a> is not nullptr. 4573The bounding box is computed as if the <a href="#SkPaint_measureText_text">text</a> was drawn at the origin. 4574 4575### Parameters 4576 4577<table> <tr> <td><a name="SkPaint_measureText_text"> <code><strong>text </strong></code> </a></td> <td> 4578character codes or glyph indices to be measured</td> 4579 </tr> <tr> <td><a name="SkPaint_measureText_length"> <code><strong>length </strong></code> </a></td> <td> 4580number of bytes of <a href="#SkPaint_measureText_text">text</a> to measure</td> 4581 </tr> <tr> <td><a name="SkPaint_measureText_bounds"> <code><strong>bounds </strong></code> </a></td> <td> 4582returns bounding box relative to (0, 0) if not nullptr</td> 4583 </tr> 4584</table> 4585 4586### Return Value 4587 4588advance width or height 4589 4590### Example 4591 4592<div><fiddle-embed name="06084f609184470135a9cd9ebc5af149"></fiddle-embed></div> 4593 4594--- 4595 4596<a name="SkPaint_measureText_2"></a> 4597 4598<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4599SkScalar measureText(const void* text, size_t length) const 4600</pre> 4601 4602Returns the advance width of <a href="#SkPaint_measureText_2_text">text</a> if <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> is clear, 4603and the height of <a href="#SkPaint_measureText_2_text">text</a> if <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> is set. 4604The advance is the normal distance to move before drawing additional <a href="#SkPaint_measureText_2_text">text</a>. 4605Uses <a href="#Text_Encoding">Text Encoding</a> to decode <a href="#SkPaint_measureText_2_text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the font metrics, 4606and <a href="#Text_Size">Text Size</a> to scale the metrics. 4607Does not scale the advance or bounds by <a href="#Fake_Bold">Fake Bold</a> or <a href="undocumented#Path_Effect">Path Effect</a>. 4608 4609### Parameters 4610 4611<table> <tr> <td><a name="SkPaint_measureText_2_text"> <code><strong>text </strong></code> </a></td> <td> 4612character codes or glyph indices to be measured</td> 4613 </tr> <tr> <td><a name="SkPaint_measureText_2_length"> <code><strong>length </strong></code> </a></td> <td> 4614number of bytes of <a href="#SkPaint_measureText_2_text">text</a> to measure</td> 4615 </tr> 4616</table> 4617 4618### Return Value 4619 4620advance width or height 4621 4622### Example 4623 4624<div><fiddle-embed name="f1139a5ddd17fd47c2f45f6e642cac76"> 4625 4626#### Example Output 4627 4628~~~~ 4629default width = 5 4630double width = 10 4631~~~~ 4632 4633</fiddle-embed></div> 4634 4635--- 4636 4637<a name="SkPaint_breakText"></a> 4638## breakText 4639 4640<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4641size_t breakText(const void* text, size_t length, SkScalar maxWidth, 4642 SkScalar* measuredWidth = nullptr) const 4643</pre> 4644 4645Returns the bytes of <a href="#SkPaint_breakText_text">text</a> that fit within <a href="#SkPaint_breakText_maxWidth">maxWidth</a>. 4646If <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> is clear, the <a href="#SkPaint_breakText_text">text</a> fragment fits if its advance width is less than or 4647equal to <a href="#SkPaint_breakText_maxWidth">maxWidth</a>. 4648If <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> is set, the <a href="#SkPaint_breakText_text">text</a> fragment fits if its advance height is less than or 4649equal to <a href="#SkPaint_breakText_maxWidth">maxWidth</a>. 4650Measures only while the advance is less than or equal to <a href="#SkPaint_breakText_maxWidth">maxWidth</a>. 4651Returns the advance or the <a href="#SkPaint_breakText_text">text</a> fragment in <a href="#SkPaint_breakText_measuredWidth">measuredWidth</a> if it not nullptr. 4652Uses <a href="#Text_Encoding">Text Encoding</a> to decode <a href="#SkPaint_breakText_text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the font metrics, 4653and <a href="#Text_Size">Text Size</a> to scale the metrics. 4654Does not scale the advance or bounds by <a href="#Fake_Bold">Fake Bold</a> or <a href="undocumented#Path_Effect">Path Effect</a>. 4655 4656### Parameters 4657 4658<table> <tr> <td><a name="SkPaint_breakText_text"> <code><strong>text </strong></code> </a></td> <td> 4659character codes or glyph indices to be measured</td> 4660 </tr> <tr> <td><a name="SkPaint_breakText_length"> <code><strong>length </strong></code> </a></td> <td> 4661number of bytes of <a href="#SkPaint_breakText_text">text</a> to measure</td> 4662 </tr> <tr> <td><a name="SkPaint_breakText_maxWidth"> <code><strong>maxWidth </strong></code> </a></td> <td> 4663advance limit; <a href="#SkPaint_breakText_text">text</a> is measured while advance is less than <a href="#SkPaint_breakText_maxWidth">maxWidth</a></td> 4664 </tr> <tr> <td><a name="SkPaint_breakText_measuredWidth"> <code><strong>measuredWidth </strong></code> </a></td> <td> 4665returns the width of the <a href="#SkPaint_breakText_text">text</a> less than or equal to <a href="#SkPaint_breakText_maxWidth">maxWidth</a></td> 4666 </tr> 4667</table> 4668 4669### Return Value 4670 4671bytes of <a href="#SkPaint_breakText_text">text</a> that fit, always less than or equal to <a href="#SkPaint_breakText_length">length</a> 4672 4673### Example 4674 4675<div><fiddle-embed name="fd0033470ccbd5c7059670fdbf96cffc"><div><a href="undocumented#Line">Line</a> under "" shows desired width, shorter than available characters. 4676<a href="undocumented#Line">Line</a> under "" shows measured width after breaking <a href="#SkPaint_breakText_text">text</a>.</div></fiddle-embed></div> 4677 4678--- 4679 4680<a name="SkPaint_getTextWidths"></a> 4681## getTextWidths 4682 4683<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4684int getTextWidths(const void* text, size_t byteLength, SkScalar widths[], SkRect bounds[] = nullptr) const 4685</pre> 4686 4687Retrieves the advance and <a href="#SkPaint_getTextWidths_bounds">bounds</a> for each glyph in <a href="#SkPaint_getTextWidths_text">text</a>, and returns 4688the glyph count in <a href="#SkPaint_getTextWidths_text">text</a>. 4689Both <a href="#SkPaint_getTextWidths_widths">widths</a> and <a href="#SkPaint_getTextWidths_bounds">bounds</a> may be nullptr. 4690If <a href="#SkPaint_getTextWidths_widths">widths</a> is not nullptr, <a href="#SkPaint_getTextWidths_widths">widths</a> must be an array of glyph count entries. 4691if <a href="#SkPaint_getTextWidths_bounds">bounds</a> is not nullptr, <a href="#SkPaint_getTextWidths_bounds">bounds</a> must be an array of glyph count entries. 4692If <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> is clear, <a href="#SkPaint_getTextWidths_widths">widths</a> returns the horizontal advance. 4693If <a href="#SkPaint_kVerticalText_Flag">kVerticalText Flag</a> is set, <a href="#SkPaint_getTextWidths_widths">widths</a> returns the vertical advance. 4694Uses <a href="#Text_Encoding">Text Encoding</a> to decode <a href="#SkPaint_getTextWidths_text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the font metrics, 4695and <a href="#Text_Size">Text Size</a> to scale the <a href="#SkPaint_getTextWidths_widths">widths</a> and <a href="#SkPaint_getTextWidths_bounds">bounds</a>. 4696Does not scale the advance by <a href="#Fake_Bold">Fake Bold</a> or <a href="undocumented#Path_Effect">Path Effect</a>. 4697Does include <a href="#Fake_Bold">Fake Bold</a> and <a href="undocumented#Path_Effect">Path Effect</a> in the <a href="#SkPaint_getTextWidths_bounds">bounds</a>. 4698 4699### Parameters 4700 4701<table> <tr> <td><a name="SkPaint_getTextWidths_text"> <code><strong>text </strong></code> </a></td> <td> 4702character codes or glyph indices to be measured</td> 4703 </tr> <tr> <td><a name="SkPaint_getTextWidths_byteLength"> <code><strong>byteLength </strong></code> </a></td> <td> 4704number of bytes of <a href="#SkPaint_getTextWidths_text">text</a> to measure</td> 4705 </tr> <tr> <td><a name="SkPaint_getTextWidths_widths"> <code><strong>widths </strong></code> </a></td> <td> 4706returns <a href="#SkPaint_getTextWidths_text">text</a> advances for each glyph; may be nullptr</td> 4707 </tr> <tr> <td><a name="SkPaint_getTextWidths_bounds"> <code><strong>bounds </strong></code> </a></td> <td> 4708returns <a href="#SkPaint_getTextWidths_bounds">bounds</a> for each glyph relative to (0, 0); may be nullptr</td> 4709 </tr> 4710</table> 4711 4712### Return Value 4713 4714glyph count in <a href="#SkPaint_getTextWidths_text">text</a> 4715 4716### Example 4717 4718<div><fiddle-embed name="6b9e101f49e9c2c28755c5bdcef64dfb"><div>Bounds of <a href="undocumented#Glyph">Glyphs</a> increase for stroked <a href="#SkPaint_getTextWidths_text">text</a>, but <a href="#SkPaint_getTextWidths_text">text</a> advance remains the same. 4719The underlines show the <a href="#SkPaint_getTextWidths_text">text</a> advance, spaced to keep them distinct.</div></fiddle-embed></div> 4720 4721--- 4722 4723## <a name="Text_Path"></a> Text Path 4724 4725<a href="#Text_Path">Text Path</a> describes the geometry of <a href="undocumented#Glyph">Glyphs</a> used to draw text. 4726 4727<a name="SkPaint_getTextPath"></a> 4728## getTextPath 4729 4730<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4731void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y, SkPath* path) const 4732</pre> 4733 4734Returns the geometry as <a href="SkPath_Reference#Path">Path</a> equivalent to the drawn <a href="#SkPaint_getTextPath_text">text</a>. 4735Uses <a href="#Text_Encoding">Text Encoding</a> to decode <a href="#SkPaint_getTextPath_text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, 4736and <a href="#Text_Size">Text Size</a>, <a href="#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. 4737All of the glyph paths are stored in <a href="#SkPaint_getTextPath_path">path</a>. 4738Uses <a href="#SkPaint_getTextPath_x">x</a>, <a href="#SkPaint_getTextPath_y">y</a>, and <a href="#Text_Align">Text Align</a> to position <a href="#SkPaint_getTextPath_path">path</a>. 4739 4740### Parameters 4741 4742<table> <tr> <td><a name="SkPaint_getTextPath_text"> <code><strong>text </strong></code> </a></td> <td> 4743character codes or glyph indices</td> 4744 </tr> <tr> <td><a name="SkPaint_getTextPath_length"> <code><strong>length </strong></code> </a></td> <td> 4745number of bytes of <a href="#SkPaint_getTextPath_text">text</a></td> 4746 </tr> <tr> <td><a name="SkPaint_getTextPath_x"> <code><strong>x </strong></code> </a></td> <td> 4747<a href="#SkPaint_getTextPath_x">x</a>-coordinate of the origin of the <a href="#SkPaint_getTextPath_text">text</a></td> 4748 </tr> <tr> <td><a name="SkPaint_getTextPath_y"> <code><strong>y </strong></code> </a></td> <td> 4749<a href="#SkPaint_getTextPath_y">y</a>-coordinate of the origin of the <a href="#SkPaint_getTextPath_text">text</a></td> 4750 </tr> <tr> <td><a name="SkPaint_getTextPath_path"> <code><strong>path </strong></code> </a></td> <td> 4751geometry of the <a href="undocumented#Glyph">Glyphs</a></td> 4752 </tr> 4753</table> 4754 4755### Example 4756 4757<div><fiddle-embed name="7c9e6a399f898d68026c1f0865e6f73e"><div><a href="undocumented#Text">Text</a> is added to <a href="SkPath_Reference#Path">Path</a>, offset, and subtracted from <a href="SkPath_Reference#Path">Path</a>, then added at 4758the offset location. The result is rendered with one draw call.</div></fiddle-embed></div> 4759 4760--- 4761 4762<a name="SkPaint_getPosTextPath"></a> 4763## getPosTextPath 4764 4765<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4766void getPosTextPath(const void* text, size_t length, const SkPoint pos[], SkPath* path) const 4767</pre> 4768 4769Returns the geometry as <a href="SkPath_Reference#Path">Path</a> equivalent to the drawn <a href="#SkPaint_getPosTextPath_text">text</a>. 4770Uses <a href="#Text_Encoding">Text Encoding</a> to decode <a href="#SkPaint_getPosTextPath_text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, 4771and <a href="#Text_Size">Text Size</a>, <a href="#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. 4772All of the glyph paths are stored in <a href="#SkPaint_getPosTextPath_path">path</a>. 4773Uses <a href="#SkPaint_getPosTextPath_pos">pos</a> array and <a href="#Text_Align">Text Align</a> to position <a href="#SkPaint_getPosTextPath_path">path</a>. 4774<a href="#SkPaint_getPosTextPath_pos">pos</a> contains a position for each glyph. 4775 4776### Parameters 4777 4778<table> <tr> <td><a name="SkPaint_getPosTextPath_text"> <code><strong>text </strong></code> </a></td> <td> 4779character codes or glyph indices</td> 4780 </tr> <tr> <td><a name="SkPaint_getPosTextPath_length"> <code><strong>length </strong></code> </a></td> <td> 4781number of bytes of <a href="#SkPaint_getPosTextPath_text">text</a></td> 4782 </tr> <tr> <td><a name="SkPaint_getPosTextPath_pos"> <code><strong>pos </strong></code> </a></td> <td> 4783positions of each glyph</td> 4784 </tr> <tr> <td><a name="SkPaint_getPosTextPath_path"> <code><strong>path </strong></code> </a></td> <td> 4785geometry of the <a href="undocumented#Glyph">Glyphs</a></td> 4786 </tr> 4787</table> 4788 4789### Example 4790 4791<div><fiddle-embed name="7f27c93472aa99a7542fb3493076f072"><div>Simplifies three <a href="undocumented#Glyph">Glyphs</a> to eliminate overlaps, and strokes the result.</div></fiddle-embed></div> 4792 4793--- 4794 4795## <a name="Text_Intercepts"></a> Text Intercepts 4796 4797<a href="#Text_Intercepts">Text Intercepts</a> describe the intersection of drawn text <a href="undocumented#Glyph">Glyphs</a> with a pair 4798of lines parallel to the text advance. <a href="#Text_Intercepts">Text Intercepts</a> permits creating a 4799underline that skips Descenders. 4800 4801<a name="SkPaint_getTextIntercepts"></a> 4802## getTextIntercepts 4803 4804<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4805int getTextIntercepts(const void* text, size_t length, SkScalar x, SkScalar y, 4806 const SkScalar bounds[2], SkScalar* intervals) const 4807</pre> 4808 4809Returns the number of <a href="#SkPaint_getTextIntercepts_intervals">intervals</a> that intersect <a href="#SkPaint_getTextIntercepts_bounds">bounds</a>. 4810<a href="#SkPaint_getTextIntercepts_bounds">bounds</a> describes a pair of lines parallel to the <a href="#SkPaint_getTextIntercepts_text">text</a> advance. 4811The return count is zero or a multiple of two, and is at most twice the number of <a href="undocumented#Glyph">Glyphs</a> in 4812the string. 4813Uses <a href="#Text_Encoding">Text Encoding</a> to decode <a href="#SkPaint_getTextIntercepts_text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, 4814and <a href="#Text_Size">Text Size</a>, <a href="#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. 4815Uses <a href="#SkPaint_getTextIntercepts_x">x</a>, <a href="#SkPaint_getTextIntercepts_y">y</a>, and <a href="#Text_Align">Text Align</a> to position <a href="#SkPaint_getTextIntercepts_intervals">intervals</a>. 4816Pass nullptr for <a href="#SkPaint_getTextIntercepts_intervals">intervals</a> to determine the size of the interval array. 4817<a href="#SkPaint_getTextIntercepts_intervals">intervals</a> are cached to improve performance for multiple calls. 4818 4819### Parameters 4820 4821<table> <tr> <td><a name="SkPaint_getTextIntercepts_text"> <code><strong>text </strong></code> </a></td> <td> 4822character codes or glyph indices</td> 4823 </tr> <tr> <td><a name="SkPaint_getTextIntercepts_length"> <code><strong>length </strong></code> </a></td> <td> 4824number of bytes of <a href="#SkPaint_getTextIntercepts_text">text</a></td> 4825 </tr> <tr> <td><a name="SkPaint_getTextIntercepts_x"> <code><strong>x </strong></code> </a></td> <td> 4826<a href="#SkPaint_getTextIntercepts_x">x</a>-coordinate of the origin of the <a href="#SkPaint_getTextIntercepts_text">text</a></td> 4827 </tr> <tr> <td><a name="SkPaint_getTextIntercepts_y"> <code><strong>y </strong></code> </a></td> <td> 4828<a href="#SkPaint_getTextIntercepts_y">y</a>-coordinate of the origin of the <a href="#SkPaint_getTextIntercepts_text">text</a></td> 4829 </tr> <tr> <td><a name="SkPaint_getTextIntercepts_bounds"> <code><strong>bounds </strong></code> </a></td> <td> 4830lower and upper line parallel to the advance</td> 4831 </tr> <tr> <td><a name="SkPaint_getTextIntercepts_intervals"> <code><strong>intervals </strong></code> </a></td> <td> 4832returned intersections; may be nullptr</td> 4833 </tr> 4834</table> 4835 4836### Return Value 4837 4838number of intersections; may be zero 4839 4840### Example 4841 4842<div><fiddle-embed name="2a0b80ed20d193c688085b79deb5bdc9"><div>Underline uses intercepts to draw on either side of the glyph Descender.</div></fiddle-embed></div> 4843 4844--- 4845 4846<a name="SkPaint_getPosTextIntercepts"></a> 4847## getPosTextIntercepts 4848 4849<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4850int getPosTextIntercepts(const void* text, size_t length, const SkPoint pos[], 4851 const SkScalar bounds[2], SkScalar* intervals) const 4852</pre> 4853 4854Returns the number of <a href="#SkPaint_getPosTextIntercepts_intervals">intervals</a> that intersect <a href="#SkPaint_getPosTextIntercepts_bounds">bounds</a>. 4855<a href="#SkPaint_getPosTextIntercepts_bounds">bounds</a> describes a pair of lines parallel to the <a href="#SkPaint_getPosTextIntercepts_text">text</a> advance. 4856The return count is zero or a multiple of two, and is at most twice the number of <a href="undocumented#Glyph">Glyphs</a> in 4857the string. 4858Uses <a href="#Text_Encoding">Text Encoding</a> to decode <a href="#SkPaint_getPosTextIntercepts_text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, 4859and <a href="#Text_Size">Text Size</a>, <a href="#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. 4860Uses <a href="#SkPaint_getPosTextIntercepts_pos">pos</a> array and <a href="#Text_Align">Text Align</a> to position <a href="#SkPaint_getPosTextIntercepts_intervals">intervals</a>. 4861Pass nullptr for <a href="#SkPaint_getPosTextIntercepts_intervals">intervals</a> to determine the size of the interval array. 4862<a href="#SkPaint_getPosTextIntercepts_intervals">intervals</a> are cached to improve performance for multiple calls. 4863 4864### Parameters 4865 4866<table> <tr> <td><a name="SkPaint_getPosTextIntercepts_text"> <code><strong>text </strong></code> </a></td> <td> 4867character codes or glyph indices</td> 4868 </tr> <tr> <td><a name="SkPaint_getPosTextIntercepts_length"> <code><strong>length </strong></code> </a></td> <td> 4869number of bytes of <a href="#SkPaint_getPosTextIntercepts_text">text</a></td> 4870 </tr> <tr> <td><a name="SkPaint_getPosTextIntercepts_pos"> <code><strong>pos </strong></code> </a></td> <td> 4871positions of each glyph</td> 4872 </tr> <tr> <td><a name="SkPaint_getPosTextIntercepts_bounds"> <code><strong>bounds </strong></code> </a></td> <td> 4873lower and upper line parallel to the advance</td> 4874 </tr> <tr> <td><a name="SkPaint_getPosTextIntercepts_intervals"> <code><strong>intervals </strong></code> </a></td> <td> 4875returned intersections; may be nullptr</td> 4876 </tr> 4877</table> 4878 4879### Return Value 4880 4881number of intersections; may be zero 4882 4883### Example 4884 4885<div><fiddle-embed name="98b2dfc552d0540a7c041fe7a2839bd7"><div><a href="undocumented#Text">Text</a> intercepts draw on either side of, but not inside, <a href="undocumented#Glyph">Glyphs</a> in a run.</div></fiddle-embed></div> 4886 4887--- 4888 4889<a name="SkPaint_getPosTextHIntercepts"></a> 4890## getPosTextHIntercepts 4891 4892<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4893int getPosTextHIntercepts(const void* text, size_t length, const SkScalar xpos[], SkScalar constY, 4894 const SkScalar bounds[2], SkScalar* intervals) const 4895</pre> 4896 4897Returns the number of <a href="#SkPaint_getPosTextHIntercepts_intervals">intervals</a> that intersect <a href="#SkPaint_getPosTextHIntercepts_bounds">bounds</a>. 4898<a href="#SkPaint_getPosTextHIntercepts_bounds">bounds</a> describes a pair of lines parallel to the <a href="#SkPaint_getPosTextHIntercepts_text">text</a> advance. 4899The return count is zero or a multiple of two, and is at most twice the number of <a href="undocumented#Glyph">Glyphs</a> in 4900the string. 4901Uses <a href="#Text_Encoding">Text Encoding</a> to decode <a href="#SkPaint_getPosTextHIntercepts_text">text</a>, <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, 4902and <a href="#Text_Size">Text Size</a>, <a href="#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. 4903Uses <a href="#SkPaint_getPosTextHIntercepts_xpos">xpos</a> array, <a href="#SkPaint_getPosTextHIntercepts_constY">constY</a>, and <a href="#Text_Align">Text Align</a> to position <a href="#SkPaint_getPosTextHIntercepts_intervals">intervals</a>. 4904Pass nullptr for <a href="#SkPaint_getPosTextHIntercepts_intervals">intervals</a> to determine the size of the interval array. 4905<a href="#SkPaint_getPosTextHIntercepts_intervals">intervals</a> are cached to improve performance for multiple calls. 4906 4907### Parameters 4908 4909<table> <tr> <td><a name="SkPaint_getPosTextHIntercepts_text"> <code><strong>text </strong></code> </a></td> <td> 4910character codes or glyph indices</td> 4911 </tr> <tr> <td><a name="SkPaint_getPosTextHIntercepts_length"> <code><strong>length </strong></code> </a></td> <td> 4912number of bytes of <a href="#SkPaint_getPosTextHIntercepts_text">text</a></td> 4913 </tr> <tr> <td><a name="SkPaint_getPosTextHIntercepts_xpos"> <code><strong>xpos </strong></code> </a></td> <td> 4914positions of each glyph in x</td> 4915 </tr> <tr> <td><a name="SkPaint_getPosTextHIntercepts_constY"> <code><strong>constY </strong></code> </a></td> <td> 4916position of each glyph in y</td> 4917 </tr> <tr> <td><a name="SkPaint_getPosTextHIntercepts_bounds"> <code><strong>bounds </strong></code> </a></td> <td> 4918lower and upper line parallel to the advance</td> 4919 </tr> <tr> <td><a name="SkPaint_getPosTextHIntercepts_intervals"> <code><strong>intervals </strong></code> </a></td> <td> 4920returned intersections; may be nullptr</td> 4921 </tr> 4922</table> 4923 4924### Return Value 4925 4926number of intersections; may be zero 4927 4928### Example 4929 4930<div><fiddle-embed name="dc9851c43acc3716aca8c9a4d40d452d"><div><a href="undocumented#Text">Text</a> intercepts do not take stroke thickness into consideration.</div></fiddle-embed></div> 4931 4932--- 4933 4934<a name="SkPaint_getTextBlobIntercepts"></a> 4935## getTextBlobIntercepts 4936 4937<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4938int getTextBlobIntercepts(const SkTextBlob* blob, const SkScalar bounds[2], SkScalar* intervals) const 4939</pre> 4940 4941Returns the number of <a href="#SkPaint_getTextBlobIntercepts_intervals">intervals</a> that intersect <a href="#SkPaint_getTextBlobIntercepts_bounds">bounds</a>. 4942<a href="#SkPaint_getTextBlobIntercepts_bounds">bounds</a> describes a pair of lines parallel to the text advance. 4943The return count is zero or a multiple of two, and is at most twice the number of <a href="undocumented#Glyph">Glyphs</a> in 4944the string. 4945Uses <a href="undocumented#Typeface">Typeface</a> to get the glyph paths, 4946and <a href="#Text_Size">Text Size</a>, <a href="#Fake_Bold">Fake Bold</a>, and <a href="undocumented#Path_Effect">Path Effect</a> to scale and modify the glyph paths. 4947Uses run array and <a href="#Text_Align">Text Align</a> to position <a href="#SkPaint_getTextBlobIntercepts_intervals">intervals</a>. 4948<a href="#Text_Encoding">Text Encoding</a> must be set to <a href="#SkPaint_kGlyphID_TextEncoding">SkPaint::kGlyphID TextEncoding</a>. 4949 4950Pass nullptr for <a href="#SkPaint_getTextBlobIntercepts_intervals">intervals</a> to determine the size of the interval array. 4951<a href="#SkPaint_getTextBlobIntercepts_intervals">intervals</a> are cached to improve performance for multiple calls. 4952 4953### Parameters 4954 4955<table> <tr> <td><a name="SkPaint_getTextBlobIntercepts_blob"> <code><strong>blob </strong></code> </a></td> <td> 4956<a href="undocumented#Glyph">Glyphs</a>, positions, and text paint attributes</td> 4957 </tr> <tr> <td><a name="SkPaint_getTextBlobIntercepts_bounds"> <code><strong>bounds </strong></code> </a></td> <td> 4958lower and upper line parallel to the advance</td> 4959 </tr> <tr> <td><a name="SkPaint_getTextBlobIntercepts_intervals"> <code><strong>intervals </strong></code> </a></td> <td> 4960returned intersections; may be nullptr</td> 4961 </tr> 4962</table> 4963 4964### Return Value 4965 4966number of intersections; may be zero 4967 4968### Example 4969 4970<div><fiddle-embed name="71959a66b2290d70003887c0de339266"></fiddle-embed></div> 4971 4972--- 4973 4974<a name="SkPaint_nothingToDraw"></a> 4975## nothingToDraw 4976 4977<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4978bool nothingToDraw() const 4979</pre> 4980 4981Returns true if <a href="#Paint">Paint</a> prevents all drawing; 4982otherwise, the <a href="#Paint">Paint</a> may or may not allow drawing. 4983 4984Returns true if, for example, <a href="undocumented#Blend_Mode">Blend Mode</a> combined with <a href="undocumented#Alpha">Color Alpha</a> computes a 4985new <a href="undocumented#Alpha">Alpha</a> of zero. 4986 4987### Return Value 4988 4989true if <a href="#Paint">Paint</a> prevents all drawing 4990 4991### Example 4992 4993<div><fiddle-embed name="fc5a771b915ac341f56554f01d282831"> 4994 4995#### Example Output 4996 4997~~~~ 4998initial nothing to draw: false 4999blend dst nothing to draw: true 5000blend src over nothing to draw: false 5001alpha 0 nothing to draw: true 5002~~~~ 5003 5004</fiddle-embed></div> 5005 5006--- 5007 5008## <a name="Fast_Bounds"></a> Fast Bounds 5009 5010<a href="#Fast_Bounds">Fast Bounds</a> methods conservatively outset a drawing bounds by additional area 5011<a href="#Paint">Paint</a> may draw to. 5012 5013<a name="SkPaint_canComputeFastBounds"></a> 5014## canComputeFastBounds 5015 5016<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 5017bool canComputeFastBounds() const 5018</pre> 5019 5020Returns true if <a href="#Paint">Paint</a> does not include elements requiring extensive computation 5021to compute <a href="undocumented#Device">Device</a> bounds of drawn geometry. For instance, <a href="#Paint">Paint</a> with <a href="undocumented#Path_Effect">Path Effect</a> 5022always returns false. 5023 5024### Return Value 5025 5026true if <a href="#Paint">Paint</a> allows for fast computation of bounds 5027 5028--- 5029 5030<a name="SkPaint_computeFastBounds"></a> 5031## computeFastBounds 5032 5033<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 5034const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const 5035</pre> 5036 5037Only call this if <a href="#SkPaint_canComputeFastBounds">canComputeFastBounds</a> returned true. This takes a 5038raw rectangle (the raw bounds of a shape), and adjusts it for stylistic 5039effects in the paint (e.g. stroking). If needed, it uses the <a href="#SkPaint_computeFastBounds_storage">storage</a> 5040parameter. It returns the adjusted bounds that can then be used 5041for <a href="SkCanvas_Reference#SkCanvas_quickReject">SkCanvas::quickReject</a> tests. 5042 5043The returned <a href="SkRect_Reference#Rect">Rect</a> will either be <a href="#SkPaint_computeFastBounds_orig">orig</a> or <a href="#SkPaint_computeFastBounds_storage">storage</a>, thus the caller 5044should not rely on <a href="#SkPaint_computeFastBounds_storage">storage</a> being set to the result, but should always 5045use the returned value. It is legal for <a href="#SkPaint_computeFastBounds_orig">orig</a> and <a href="#SkPaint_computeFastBounds_storage">storage</a> to be the same 5046<a href="SkRect_Reference#Rect">Rect</a>. 5047 5048### Parameters 5049 5050<table> <tr> <td><a name="SkPaint_computeFastBounds_orig"> <code><strong>orig </strong></code> </a></td> <td> 5051geometry modified by <a href="#Paint">Paint</a> when drawn</td> 5052 </tr> <tr> <td><a name="SkPaint_computeFastBounds_storage"> <code><strong>storage </strong></code> </a></td> <td> 5053computed bounds of geometry; may not be nullptr</td> 5054 </tr> 5055</table> 5056 5057### Return Value 5058 5059fast computed bounds 5060 5061--- 5062 5063<a name="SkPaint_computeFastStrokeBounds"></a> 5064## computeFastStrokeBounds 5065 5066<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 5067const SkRect& computeFastStrokeBounds(const SkRect& orig, SkRect* storage) const 5068</pre> 5069 5070### Parameters 5071 5072<table> <tr> <td><a name="SkPaint_computeFastStrokeBounds_orig"> <code><strong>orig </strong></code> </a></td> <td> 5073geometry modified by <a href="#Paint">Paint</a> when drawn</td> 5074 </tr> <tr> <td><a name="SkPaint_computeFastStrokeBounds_storage"> <code><strong>storage </strong></code> </a></td> <td> 5075computed bounds of geometry</td> 5076 </tr> 5077</table> 5078 5079### Return Value 5080 5081fast computed bounds 5082 5083--- 5084 5085<a name="SkPaint_doComputeFastBounds"></a> 5086## doComputeFastBounds 5087 5088<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 5089const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage, Style style) const 5090</pre> 5091 5092Computes the bounds, overriding the <a href="#Paint">Paint</a> <a href="#SkPaint_Style">Style</a>. This can be used to 5093account for additional width required by stroking <a href="#SkPaint_doComputeFastBounds_orig">orig</a>, without 5094altering <a href="#SkPaint_Style">Style</a> set to fill. 5095 5096### Parameters 5097 5098<table> <tr> <td><a name="SkPaint_doComputeFastBounds_orig"> <code><strong>orig </strong></code> </a></td> <td> 5099geometry modified by <a href="#Paint">Paint</a> when drawn</td> 5100 </tr> <tr> <td><a name="SkPaint_doComputeFastBounds_storage"> <code><strong>storage </strong></code> </a></td> <td> 5101computed bounds of geometry</td> 5102 </tr> <tr> <td><a name="SkPaint_doComputeFastBounds_style"> <code><strong>style </strong></code> </a></td> <td> 5103overrides <a href="#SkPaint_Style">Style</a></td> 5104 </tr> 5105</table> 5106 5107### Return Value 5108 5109fast computed bounds 5110 5111--- 5112 5113## <a name="Utility"></a> Utility 5114 5115| name | description | 5116| --- | --- | 5117| <a href="#SkPaint_containsText">containsText</a> | returns if all text corresponds to <a href="undocumented#Glyph">Glyphs</a> | 5118| <a href="#SkPaint_countText">countText</a> | returns number of <a href="undocumented#Glyph">Glyphs</a> in text | 5119| <a href="#SkPaint_glyphsToUnichars">glyphsToUnichars</a> | converts <a href="undocumented#Glyph">Glyphs</a> into text | 5120| <a href="#SkPaint_nothingToDraw">nothingToDraw</a> | returns true if <a href="#Paint">Paint</a> prevents all drawing | 5121| <a href="#SkPaint_textToGlyphs">textToGlyphs</a> | converts text into glyph indices | 5122| <a href="#SkPaint_toString">toString</a> | converts <a href="#Paint">Paint</a> to machine readable form | 5123 5124<a name="SkPaint_toString"></a> 5125## toString 5126 5127<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 5128void toString(SkString* str) const 5129</pre> 5130 5131Creates string representation of <a href="#Paint">Paint</a>. The representation is read by 5132internal debugging tools. The interface and implementation may be 5133suppressed by defining SK_IGNORE_TO_STRING. 5134 5135### Parameters 5136 5137<table> <tr> <td><a name="SkPaint_toString_str"> <code><strong>str </strong></code> </a></td> <td> 5138storage for string representation of <a href="#Paint">Paint</a></td> 5139 </tr> 5140</table> 5141 5142### Example 5143 5144<div><fiddle-embed name="5670c04b4562908169a776c48c92d104"> 5145 5146#### Example Output 5147 5148~~~~ 5149text size = 12 5150~~~~ 5151 5152</fiddle-embed></div> 5153 5154### See Also 5155 5156<a href="undocumented#SkPathEffect_toString">SkPathEffect::toString</a> <a href="undocumented#SkMaskFilter_toString">SkMaskFilter::toString</a> <a href="undocumented#SkColorFilter_toString">SkColorFilter::toString</a> <a href="undocumented#SkImageFilter_toString">SkImageFilter::toString</a> 5157 5158--- 5159 5160