diff --git a/docs/SkCanvas_Reference.bmh b/docs/SkCanvas_Reference.bmh index 2ad2b20cb4..dbce6a8b18 100644 --- a/docs/SkCanvas_Reference.bmh +++ b/docs/SkCanvas_Reference.bmh @@ -4078,7 +4078,7 @@ void draw(SkCanvas* canvas) { Draws Text_Blob blob at (x, y), using Clip, Matrix, and Paint paint. blob contains Glyphs, their positions, and paint attributes specific to text: -#paint_font_metrics#. +#font_metrics#. Paint_Text_Encoding must be set to kGlyphID_SkTextEncoding. @@ -4133,7 +4133,7 @@ void draw(SkCanvas* canvas) { Draws Text_Blob blob at (x, y), using Clip, Matrix, and Paint paint. blob contains Glyphs, their positions, and paint attributes specific to text: -#paint_font_metrics#. +#font_metrics#. Paint_Text_Encoding must be set to kGlyphID_SkTextEncoding. diff --git a/docs/SkFont_Reference.bmh b/docs/SkFont_Reference.bmh index dc14d8111f..1d69f3488d 100644 --- a/docs/SkFont_Reference.bmh +++ b/docs/SkFont_Reference.bmh @@ -1,6 +1,17 @@ #Topic Font #Alias Font_Reference ## +#Code +#Populate +## + +#PhraseDef font_metrics +Typeface, Font_Size, Font_Scale_X, +Font_Skew_X, Font_Hinting, Paint_Anti_Alias, Font_Embolden, Font_Force_Hinting, +Font_Embedded_Bitmaps, Font_Hinting_Spacing, Font_Anti_Alias, Font_Linear, +and Font_Subpixel +## + #Subtopic Advance # incomplete, should probably be in overview, not reference ## @@ -8,8 +19,111 @@ # incomplete, should probably be in overview, not reference ## -#Code -#Populate +#Subtopic Size +#Line # overall height in points ## +Font_Size adjusts the overall text size in points. +Font_Size can be set to any positive value or zero. +Font_Size defaults to 12. +Font_Size +## + +#Subtopic Scale_X +#Line # text horizontal scale ## +Font_Scale_X adjusts the text horizontal scale. +Text scaling approximates condensed and expanded type faces when the actual face +is not available. +Font_Scale_X can be set to any value. +Font_Scale_X defaults to 1. +## + +#Subtopic Skew_X +#Line # text horizontal slant ## +Font_Skew_X adjusts the text horizontal slant. +Text skewing approximates italic and oblique type faces when the actual face +is not available. +Font_Skew_X can be set to any value. +Font_Skew_X defaults to 0. +## + +#Subtopic Embolden +#Line # approximate font styles ## + +Font_Embolden approximates the bold font style accompanying a normal font when a bold font face +is not available. Skia does not provide font substitution; it is up to the client to find the +bold font face using the platform Font_Manager. + +Use Font_Skew_X to approximate an italic font style when the italic font face +is not available. + +A FreeType based port may define SK_USE_FREETYPE_EMBOLDEN at compile time to direct +the font engine to create the bold Glyphs. Otherwise, the extra bold is computed +by increasing the stroke width and setting the SkPaint::Style to +SkPaint::kStrokeAndFill_Style as needed. + +Font_Embolden is disabled by default. +#Subtopic Embolden ## + +#Subtopic Hinting_Spacing +#Line # glyph spacing affected by hinting ## + +If Hinting is set to SkFontHinting::kFull, Hinting_Spacing adjusts the character +spacing by the difference of the hinted and unhinted Left_Side_Bearing and +Right_Side_Bearing. Hinting_Spacing only applies to platforms that use +FreeType as their Font_Engine. + +Hinting_Spacing is not related to text kerning, where the space between +a specific pair of characters is adjusted using data in the font kerning tables. +#Subtopic Hinting_Spacing ## + +#Subtopic Linear +#Line # selects text rendering as Glyph or Path ## +Font_Linear selects whether text is rendered as a Glyph or as a Path. +If Font_Linear is set, it has the same effect as setting Hinting to SkFontHinting::kNormal. +If Font_Linear is clear, it is the same as setting Hinting to SkFontHinting::kNone. +#Subtopic Linear ## + +#Subtopic Subpixel +#Line # uses pixel transparency to represent fractional offset ## +#Substitute sub-pixel +Font_Subpixel uses the pixel transparency to represent a fractional offset. +As the opaqueness of the color increases, the edge of the glyph appears to move +towards the outside of the pixel. +#Subtopic Subpixel ## + +#Subtopic Anti_Alias +#Line # text relying on the order of RGB stripes ## +When set, Anti_Alias positions glyphs within a pixel, using alpha and +possibly RGB striping. It can take advantage of the organization of RGB stripes +that create a color, and relies on the small size of the stripe and visual perception +to make the color fringing imperceptible. + +Anti_Alias can be enabled on devices that orient stripes horizontally +or vertically, and that order the color components as RGB or BGR. Internally, the +glyph cache may store multiple copies of the same glyph with different sub-pixel +positions, requiring more memory. +#Subtopic Anti_Alias ## + +#Subtopic Force_Hinting +#Line # always adjust glyph paths ## + +If Hinting is set to SkFontHinting::kNormal or SkFontHinting::kFull, Force_Hinting +instructs the Font_Manager to always hint Glyphs. +Force_Hinting has no effect if Hinting is set to SkFontHinting::kNone or +SkFontHinting::kSlight. + +Force_Hinting only affects platforms that use FreeType as the Font_Manager. +#Subtopic Force_Hinting ## + +#Subtopic Embedded_Bitmaps +#Line # custom sized bitmap Glyphs ## +Embedded_Bitmaps allows selecting custom sized bitmap Glyphs. +Embedded_Bitmaps when set chooses an embedded bitmap glyph over an outline contained +in a font if the platform supports this option. + +FreeType selects the bitmap glyph if available when Embedded_Bitmaps is set, and selects +the outline glyph if Embedded_Bitmaps is clear. +Windows may select the bitmap glyph but is not required to do so. +OS_X and iOS do not support this option. ## # ------------------------------------------------------------------------------ diff --git a/docs/SkPaint_Reference.bmh b/docs/SkPaint_Reference.bmh index b6f179d3fb..a09d7c938f 100644 --- a/docs/SkPaint_Reference.bmh +++ b/docs/SkPaint_Reference.bmh @@ -1,13 +1,6 @@ #Topic Paint #Alias Paint_Reference ## -#PhraseDef paint_font_metrics -Typeface, Paint_Text_Size, Paint_Text_Scale_X, -Paint_Text_Skew_X, Paint_Hinting, Anti_Alias, Paint_Fake_Bold, -Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text, -and Subpixel_Text -## - #Class SkPaint #Code @@ -55,29 +48,29 @@ Constructs Paint with default values. # Color_Filter # nullptr ## # Dither # false ## # Draw_Looper # nullptr ## -# Fake_Bold # false ## # Filter_Quality # kNone_SkFilterQuality ## +# Font_Force_Hinting # false ## # Font_Embedded_Bitmaps # false ## -# Automatic_Hinting # false ## -# Full_Hinting_Spacing # false ## -# Hinting # SkFontHinting::kNormal ## +# Font_Embolden # false ## +# Font_Hinting # SkFontHinting::kNormal ## +# Font_Hinting_Spacing # false ## +# Font_Anti_Alias # false ## +# Font_Linear # false ## +# Font_Scale_X # 1 ## +# Font_Size # 12 ## +# Font_Skew_X # 0 ## +# Font_Subpixel # false ## # Image_Filter # nullptr ## -# LCD_Text # false ## -# Linear_Text # false ## # Miter_Limit # 4 ## # Mask_Filter # nullptr ## # Path_Effect # nullptr ## # Shader # nullptr ## # Style # kFill_Style ## # Text_Encoding # kUTF8_SkTextEncoding ## -# Text_Scale_X # 1 ## -# Text_Size # 12 ## -# Text_Skew_X # 0 ## # Typeface # nullptr ## # Stroke_Cap # kButt_Cap ## # Stroke_Join # kMiter_Join ## # Stroke_Width # 0 ## -# Subpixel_Text # false ## #Table ## The flags, text size, hinting, and miter limit may be overridden at compile time by defining @@ -353,22 +346,22 @@ multiple settings at once. #Line # mask for setting Dither ## ## #Const kFakeBoldText_Flag 0x0020 - #Line # mask for setting Fake_Bold ## + #Line # mask for setting Font_Embolden ## ## #Const kLinearText_Flag 0x0040 - #Line # mask for setting Linear_Text ## + #Line # mask for setting Font_Linear ## ## #Const kSubpixelText_Flag 0x0080 - #Line # mask for setting Subpixel_Text ## + #Line # mask for setting Font_Subpixel ## ## #Const kLCDRenderText_Flag 0x0200 - #Line # mask for setting LCD_Text ## + #Line # mask for setting Font_Anti_Alias ## ## #Const kEmbeddedBitmapText_Flag 0x0400 #Line # mask for setting Font_Embedded_Bitmaps ## ## #Const kAutoHinting_Flag 0x0800 - #Line # mask for setting Automatic_Hinting ## + #Line # mask for setting Font_Force_Hinting ## ## #Const kAllFlags 0xFFFF #Line # mask of all Flags ## @@ -645,12 +638,12 @@ void draw(SkCanvas* canvas) { #Subtopic Device_Text #Line # increase precision of glyph position ## -LCD_Text and Subpixel_Text increase the precision of glyph position. +Font_Anti_Alias and Font_Subpixel increase the precision of glyph position. When set, Flags kLCDRenderText_Flag takes advantage of the organization of RGB stripes that create a color, and relies on the small size of the stripe and visual perception to make the color fringing imperceptible. -LCD_Text can be enabled on devices that orient stripes horizontally or vertically, and that order +Font_Anti_Alias can be enabled on devices that orient stripes horizontally or vertically, and that order the color components as RGB or BGR. Flags kSubpixelText_Flag uses the pixel transparency to represent a fractional offset. @@ -659,14 +652,14 @@ of the color increases, the edge of the glyph appears to move towards the outsid Either or both techniques can be enabled. kLCDRenderText_Flag and kSubpixelText_Flag are clear by default. -LCD_Text or Subpixel_Text can be enabled by default by setting SkPaintDefaults_Flags to +Font_Anti_Alias or Font_Subpixel can be enabled by default by setting SkPaintDefaults_Flags to kLCDRenderText_Flag or kSubpixelText_Flag (or both) at compile time. #Example #Description - Four commas are drawn normally and with combinations of LCD_Text and Subpixel_Text. - When Subpixel_Text is disabled, the comma Glyphs are identical, but not evenly spaced. - When Subpixel_Text is enabled, the comma Glyphs are unique, but appear evenly spaced. + Four commas are drawn normally and with combinations of Font_Anti_Alias and Font_Subpixel. + When Font_Subpixel is disabled, the comma Glyphs are identical, but not evenly spaced. + When Font_Subpixel is enabled, the comma Glyphs are unique, but appear evenly spaced. ## SkBitmap bitmap; @@ -691,12 +684,11 @@ kLCDRenderText_Flag or kSubpixelText_Flag (or both) at compile time. #Subtopic Device_Text ## #Subtopic Linear_Text -#Alias Linear_Text ## #Line # selects text rendering as Glyph or Path ## -Linear_Text selects whether text is rendered as a Glyph or as a Path. -If kLinearText_Flag is set, it has the same effect as setting Hinting to SkFontHinting::kNormal. -If kLinearText_Flag is clear, it is the same as setting Hinting to SkFontHinting::kNone. +Font_Linear selects whether text is rendered as a Glyph or as a Path. +If Font_Linear is set, it has the same effect as setting Hinting to SkFontHinting::kNormal. +If Font_Linear is clear, it is the same as setting Hinting to SkFontHinting::kNone. #Subtopic Linear_Text ## #Method bool isLinearText() const @@ -755,7 +747,6 @@ If kLinearText_Flag is clear, it is the same as setting Hinting to SkFontHinting ## #Subtopic Subpixel_Text -#Alias Subpixel_Text ## #Line # uses pixel transparency to represent fractional offset ## Flags kSubpixelText_Flag uses the pixel transparency to represent a fractional offset. @@ -765,7 +756,7 @@ of the color increases, the edge of the glyph appears to move towards the outsid #Method bool isSubpixelText() const #In Subpixel_Text -#Line # returns true if Subpixel_Text is set ## +#Line # returns true if Font_Subpixel is set ## #Populate #Example @@ -786,7 +777,7 @@ SkDebugf("paint.isSubpixelText() %c= !!(paint.getFlags() & SkPaint::kSubpixelTex #Method void setSubpixelText(bool subpixelText) #In Subpixel_Text -#Line # sets or clears Subpixel_Text ## +#Line # sets or clears Font_Subpixel ## #Populate #Example @@ -805,21 +796,16 @@ SkDebugf("paint.isSubpixelText() %c= !!(paint.getFlags() & SkPaint::kSubpixelTex #Subtopic LCD_Text #Line # text relying on the order of RGB stripes ## -# make this a top level name, since it is under subtopic Device_Text -#Alias LCD_Text -#Substitute LCD text -## - -When set, Flags kLCDRenderText_Flag takes advantage of the organization of RGB stripes that +When set, Font_Anti_Alias takes advantage of the organization of RGB stripes that create a color, and relies on the small size of the stripe and visual perception to make the color fringing imperceptible. -LCD_Text can be enabled on devices that orient stripes horizontally or vertically, and that order +Font_Anti_Alias can be enabled on devices that orient stripes horizontally or vertically, and that order the color components as RGB or BGR. #Subtopic LCD_Text ## #Method bool isLCDRenderText() const #In LCD_Text -#Line # returns true if LCD_Text is set ## +#Line # returns true if Font_Anti_Alias is set ## #Populate #Example @@ -840,7 +826,7 @@ SkDebugf("paint.isLCDRenderText() %c= !!(paint.getFlags() & SkPaint::kLCDRenderT #Method void setLCDRenderText(bool lcdText) #In LCD_Text -#Line # sets or clears LCD_Text ## +#Line # sets or clears Font_Anti_Alias ## #Populate #Example @@ -858,9 +844,8 @@ SkDebugf("paint.isLCDRenderText() %c= !!(paint.getFlags() & SkPaint::kLCDRenderT ## # ------------------------------------------------------------------------------ -#Subtopic Font_Embedded_Bitmaps +#Subtopic Embedded_Bitmaps #Line # custom sized bitmap Glyphs ## -#Alias Font_Embedded_Bitmaps ## # long-winded enough, alias so I don't type Paint_Font_... Font_Embedded_Bitmaps allows selecting custom sized bitmap Glyphs. Flags kEmbeddedBitmapText_Flag when set chooses an embedded bitmap glyph over an outline contained @@ -903,10 +888,10 @@ kEmbeddedBitmapText_Flag at compile time. canvas->scale(10, 10); canvas->drawBitmap(bitmap, -2, 1); ## -#Subtopic Font_Embedded_Bitmaps ## +#Subtopic Embedded_Bitmaps ## #Method bool isEmbeddedBitmapText() const -#In Font_Embedded_Bitmaps +#In Embedded_Bitmaps #Line # returns true if Font_Embedded_Bitmaps is set ## #Populate @@ -931,7 +916,7 @@ kEmbeddedBitmapText_Flag at compile time. ## #Method void setEmbeddedBitmapText(bool useEmbeddedBitmapText) -#In Font_Embedded_Bitmaps +#In Embedded_Bitmaps #Line # sets or clears Font_Embedded_Bitmaps ## #Populate @@ -951,14 +936,13 @@ kEmbeddedBitmapText_Flag at compile time. # ------------------------------------------------------------------------------ #Subtopic Automatic_Hinting #Line # always adjust glyph paths ## -#Substitute auto-hinting -If Hinting is set to SkFontHinting::kNormal or SkFontHinting::kFull, Automatic_Hinting +If Hinting is set to SkFontHinting::kNormal or SkFontHinting::kFull, Font_Force_Hinting instructs the Font_Manager to always hint Glyphs. -Automatic_Hinting has no effect if Hinting is set to SkFontHinting::kNone or +Font_Force_Hinting has no effect if Hinting is set to SkFontHinting::kNone or SkFontHinting::kSlight. -Automatic_Hinting only affects platforms that use FreeType as the Font_Manager. +Font_Force_Hinting only affects platforms that use FreeType as the Font_Manager. #Subtopic Automatic_Hinting ## #Method bool isAutohinted() const @@ -1017,7 +1001,7 @@ Automatic_Hinting only affects platforms that use FreeType as the Font_Manager. #Subtopic Fake_Bold #Line # approximate font styles ## -Fake_Bold approximates the bold font style accompanying a normal font when a bold font face +Font_Embolden approximates the bold font style accompanying a normal font when a bold font face is not available. Skia does not provide font substitution; it is up to the client to find the bold font face using the platform Font_Manager. @@ -1028,7 +1012,7 @@ A FreeType based port may define SK_USE_FREETYPE_EMBOLDEN at compile time to dir the font engine to create the bold Glyphs. Otherwise, the extra bold is computed by increasing the stroke width and setting the Style to kStrokeAndFill_Style as needed. -Fake_Bold is disabled by default. +Font_Embolden is disabled by default. #Example #Height 128 @@ -1050,7 +1034,7 @@ void draw(SkCanvas* canvas) { #Method bool isFakeBoldText() const #In Fake_Bold -#Line # returns true if Fake_Bold is set ## +#Line # returns true if Font_Embolden is set ## #Populate #Example @@ -1071,7 +1055,7 @@ void draw(SkCanvas* canvas) { #Method void setFakeBoldText(bool fakeBoldText) #In Fake_Bold -#Line # sets or clears Fake_Bold ## +#Line # sets or clears Font_Embolden ## #Populate #Example @@ -1087,20 +1071,6 @@ void draw(SkCanvas* canvas) { ## -# ------------------------------------------------------------------------------ -#Subtopic Full_Hinting_Spacing -#Line # glyph spacing affected by hinting ## -#Alias Full_Hinting_Spacing ## # long winded enough -- maybe things with two underscores auto-aliased? - -if Hinting is set to SkFontHinting::kFull, Full_Hinting_Spacing adjusts the character -spacing by the difference of the hinted and unhinted Left_Side_Bearing and -Right_Side_Bearing. Full_Hinting_Spacing only applies to platforms that use -FreeType as their Font_Engine. - -Full_Hinting_Spacing is not related to text kerning, where the space between -a specific pair of characters is adjusted using data in the font kerning tables. -#Subtopic Full_Hinting_Spacing ## - # ------------------------------------------------------------------------------ #Subtopic Filter_Quality_Methods #Line # get and set Filter_Quality ## @@ -3106,7 +3076,7 @@ void draw(SkCanvas* canvas) { } ## - #SeeAlso Text_Size Typeface Typeface_Methods + #SeeAlso Font_Size Typeface Typeface_Methods ## diff --git a/docs/SkTextBlobBuilder_Reference.bmh b/docs/SkTextBlobBuilder_Reference.bmh index 7874313f5c..cb5ceb5286 100644 --- a/docs/SkTextBlobBuilder_Reference.bmh +++ b/docs/SkTextBlobBuilder_Reference.bmh @@ -25,9 +25,9 @@ Helper class for constructing SkTextBlob. RunBuffer supplies storage for Glyphs and positions within a run. -A run is a sequence of Glyphs sharing Paint_Font_Metrics and positioning. +A run is a sequence of Glyphs sharing Font_Metrics and positioning. Each run may position its Glyphs in one of three ways: -by specifying where the first Glyph is drawn, and allowing Paint_Font_Metrics to +by specifying where the first Glyph is drawn, and allowing Font_Metrics to determine the advance to subsequent Glyphs; by specifying a baseline, and the position on that baseline for each Glyph in run; or by providing Point array, one per Glyph. diff --git a/docs/SkTextBlob_Reference.bmh b/docs/SkTextBlob_Reference.bmh index 41a0a5b0e9..f8797f5350 100644 --- a/docs/SkTextBlob_Reference.bmh +++ b/docs/SkTextBlob_Reference.bmh @@ -104,7 +104,7 @@ for (int index = 0; index < 2; ++index) { Creates Text_Blob with a single run. text meaning depends on Text_Encoding; by default, text is encoded as UTF-8. -font contains attributes used to define the run text: #paint_font_metrics#. +font contains attributes used to define the run text: #font_metrics#. #Param text character code points or Glyphs drawn ## #Param byteLength byte length of text array ## @@ -137,10 +137,10 @@ font contains attributes used to define the run text: #paint_font_metrics#. #In Constructors #Line # constructs Text_Blob with one run ## -Creates Text_Blob with a single run. string meaning depends on Paint_Text_Encoding; +Creates Text_Blob with a single run. string meaning depends on Text_Encoding; by default, string is encoded as UTF-8. -font contains Paint_Font_Metrics used to define the run text: #paint_font_metrics#. +font contains Font_Metrics used to define the run text: #font_metrics#. #Param string character code points or Glyphs drawn ## #Param font text size, typeface, text scale, and so on, used to draw ## diff --git a/docs/undocumented.bmh b/docs/undocumented.bmh index 1a434c17db..c6e3fe6ab5 100644 --- a/docs/undocumented.bmh +++ b/docs/undocumented.bmh @@ -328,7 +328,7 @@ FT_Load_Glyph ## #Topic ## -#Topic Font_Types +#Topic Text_Encoding #Enum SkTextEncoding #Const kUTF8_SkTextEncoding 0 ## @@ -358,8 +358,11 @@ encodes each character as one 32-bit word. Font_Manager uses font data to convert character code points into glyph indices. A glyph index is a 16-bit word. -## +#Enum SkTextEncoding ## +#Topic Text_Encoding ## +#Topic Font_Hinting +#Line # glyph outline adjustment ## #EnumClass SkFontHinting #Const kNone 0 #Line # glyph outlines unchanged ## @@ -392,8 +395,10 @@ A glyph index is a 16-bit word. horizontally decimated LCD displays; FT_LOAD_TARGET_LCD_V is a variant of FT_LOAD_TARGET_NORMAL optimized for vertically decimated LCD displays. ## -## +#EnumClass SkFontHinting ## +#Topic Font_Hinting ## +#Topic Font_Metrics #Struct SkFontMetrics #Line # values computed by Font_Manager using Typeface ## diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index 736541784d..817f3f1933 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -219,7 +219,7 @@ public: kSubpixelText_Flag = 0x80, //!< mask for setting subpixel text kLCDRenderText_Flag = 0x200, //!< mask for setting LCD text kEmbeddedBitmapText_Flag = 0x400, //!< mask for setting font embedded bitmaps - kAutoHinting_Flag = 0x800, //!< mask for setting auto-hinting + kAutoHinting_Flag = 0x800, //!< mask for setting force hinting // 0x1000 used to be kVertical kAllFlags = 0xFFFF, //!< mask of all Flags }; @@ -379,7 +379,7 @@ public: /** Sets whether to always hint glyphs. If SkPaint::Hinting is set to SkFontHinting::kNormal or SkFontHinting::kFull and useAutohinter is set, instructs the font manager to always hint glyphs. - auto-hinting has no effect if SkPaint::Hinting is set to SkFontHinting::kNone or + useAutohinter has no effect if SkPaint::Hinting is set to SkFontHinting::kNone or SkFontHinting::kSlight. Only affects platforms that use FreeType as the font manager. @@ -877,7 +877,7 @@ public: /** * Returns the text encoding. Text encoding describes how to interpret the text bytes pass - * to methods like measureText() and drawText(). + * to methods like measureText() and SkCanvas::drawText(). * @return the text encoding */ SkTextEncoding getTextEncoding() const { @@ -886,7 +886,7 @@ public: /** * Sets the text encoding. Text encoding describes how to interpret the text bytes pass - * to methods like measureText() and drawText(). + * to methods like measureText() and SkCanvas::drawText(). * @param encoding the new text encoding */ void setTextEncoding(SkTextEncoding encoding); diff --git a/site/user/api/SkCanvas_Reference.md b/site/user/api/SkCanvas_Reference.md index efbd48fef3..24e6bf8e11 100644 --- a/site/user/api/SkCanvas_Reference.md +++ b/site/user/api/SkCanvas_Reference.md @@ -1645,7 +1645,7 @@ int saveLayerPreserveLCDTex Saves SkMatrix and clip, and allocates a SkBitmap for subsequent drawing. -LCD text is preserved when the layer is drawn to the prior layer. +LCD text is preserved when the layer is drawn to the prior layer. Calling restore() discards changes to SkMatrix and clip, and draws layer. @@ -1661,8 +1661,8 @@ Optional SkPaint restoreToCount() with returned value to restore this and subsequent saves. -Draw text on an opaque background so that LCD text blends correctly with the -prior layer. LCD text drawn on a background with transparency may result in +Draw text on an opaque background so that LCD text blends correctly with the +prior layer. LCD text drawn on a background with transparency may result in incorrect blending. ### Parameters @@ -1763,7 +1763,7 @@ defining how Layer allocated by SkCanvas::kPreserveLCDText_SaveLayerFlag 2 -Creates Layer for LCD text. Flag is ignored if Layer Paint contains +Creates Layer for LCD text. Flag is ignored if Layer Paint contains Image_Filter or Color_Filter. @@ -1864,7 +1864,7 @@ without introducing artifacts. fCli fSaveLayerFlags fSaveLayerFlags are used to create Layer without transparency, -create Layer for LCD text, and to create Layer with the +create Layer for LCD text, and to create Layer with the contents of the previous Layer. @@ -5219,13 +5219,13 @@ void drawTextBlob(const Text_Blob blob at (x, y), using Clip, Matrix, and Paint paint. -blob contains Glyphs, their positions, and paint attributes specific to text: Typeface, Paint_Text_Size, Paint_Text_Scale_X, -Paint_Text_Skew_X, Paint_Hinting, Anti_Alias, Paint_Fake_Bold, -Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text, -and Subpixel_Text +blob contains Glyphs, their positions, and paint attributes specific to text: Typeface, Font_Size, Font_Scale_X, +Font_Skew_X, Font_Hinting, Paint_Anti_Alias, Font_Embolden, Font_Force_Hinting, +Font_Embedded_Bitmaps, Font_Hinting_Spacing, Font_Anti_Alias, Font_Linear, +and Font_Subpixel . -Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding. +Paint_Text_Encoding must be set to kGlyphID_SkTextEncoding. Elements of paint: Anti_Alias, Blend_Mode, Color including Color_Alpha, Color_Filter, Paint_Dither, Draw_Looper, Mask_Filter, Path_Effect, Shader, and @@ -5251,7 +5251,7 @@ apply to Path created from drawTextBlob(const Text_Blob blob at (x, y), using Clip, Matrix, and Paint paint. -blob contains Glyphs, their positions, and paint attributes specific to text: Typeface, Paint_Text_Size, Paint_Text_Scale_X, -Paint_Text_Skew_X, Paint_Hinting, Anti_Alias, Paint_Fake_Bold, -Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text, -and Subpixel_Text +blob contains Glyphs, their positions, and paint attributes specific to text: Typeface, Font_Size, Font_Scale_X, +Font_Skew_X, Font_Hinting, Paint_Anti_Alias, Font_Embolden, Font_Force_Hinting, +Font_Embedded_Bitmaps, Font_Hinting_Spacing, Font_Anti_Alias, Font_Linear, +and Font_Subpixel . -Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding. +Paint_Text_Encoding must be set to kGlyphID_SkTextEncoding. Elements of paint: Path_Effect, Mask_Filter, Shader, Color_Filter, Image_Filter, and Draw_Looper; apply to blob. diff --git a/site/user/api/SkFont_Reference.md b/site/user/api/SkFont_Reference.md index de960f1961..260f0e93cd 100644 --- a/site/user/api/SkFont_Reference.md +++ b/site/user/api/SkFont_Reference.md @@ -2,16 +2,109 @@ SkFont Reference === - - - -
 class SkFont {
     // SkFont interface
 };
 
+ + + + + + +Font_Size adjusts the overall text size in points. +Font_Size can be set to any positive value or zero. +Font_Size defaults to 12. +Font_Size + + + +Font_Scale_X adjusts the text horizontal scale. +Text scaling approximates condensed and expanded type faces when the actual face +is not available. +Font_Scale_X can be set to any value. +Font_Scale_X defaults to 1. + + + +Font_Skew_X adjusts the text horizontal slant. +Text skewing approximates italic and oblique type faces when the actual face +is not available. +Font_Skew_X can be set to any value. +Font_Skew_X defaults to 0. + + + +Font_Embolden approximates the bold font style accompanying a normal font when a bold font face +is not available. Skia does not provide font substitution; it is up to the client to find the +bold font face using the platform Font_Manager. + +Use Font_Skew_X to approximate an italic font style when the italic font face +is not available. + +A FreeType based port may define SK_USE_FREETYPE_EMBOLDEN at compile time to direct +the font engine to create the bold Glyphs. Otherwise, the extra bold is computed +by increasing the stroke width and setting the SkPaint::Style to +SkPaint::kStrokeAndFill_Style as needed. + +Font_Embolden is disabled by default. + + + +If Hinting is set to SkFontHinting::kFull, Hinting_Spacing adjusts the character +spacing by the difference of the hinted and unhinted Left_Side_Bearing and +Right_Side_Bearing. Hinting_Spacing only applies to platforms that use +FreeType as their Font_Engine. + +Hinting_Spacing is not related to text kerning, where the space between +a specific pair of characters is adjusted using data in the font kerning tables. + + + +Font_Linear selects whether text is rendered as a Glyph or as a Path. +If Font_Linear is set, it has the same effect as setting Hinting to SkFontHinting::kNormal. +If Font_Linear is clear, it is the same as setting Hinting to SkFontHinting::kNone. + + + +Font_Subpixel uses the pixel transparency to represent a fractional offset. +As the opaqueness of the color increases, the edge of the glyph appears to move +towards the outside of the pixel. + + + +When set, Anti_Alias positions glyphs within a pixel, using alpha and +possibly RGB striping. It can take advantage of the organization of RGB stripes +that create a color, and relies on the small size of the stripe and visual perception +to make the color fringing imperceptible. + +Anti_Alias can be enabled on devices that orient stripes horizontally +or vertically, and that order the color components as RGB or BGR. Internally, the +glyph cache may store multiple copies of the same glyph with different sub-pixel +positions, requiring more memory. + + + +If Hinting is set to SkFontHinting::kNormal or SkFontHinting::kFull, Force_Hinting +instructs the Font_Manager to always hint Glyphs. +Force_Hinting has no effect if Hinting is set to SkFontHinting::kNone or +SkFontHinting::kSlight. + +Force_Hinting only affects platforms that use FreeType as the Font_Manager. + + + +Embedded_Bitmaps allows selecting custom sized bitmap Glyphs. +Embedded_Bitmaps when set chooses an embedded bitmap glyph over an outline contained +in a font if the platform supports this option. + +FreeType selects the bitmap glyph if available when Embedded_Bitmaps is set, and selects +the outline glyph if Embedded_Bitmaps is clear. +Windows may select the bitmap glyph but is not required to do so. +OS_X and iOS do not support this option. + --- @@ -300,7 +393,7 @@ incomplete bool isSubpixel()const -Returns true if glyphs at different sub-pixel positions may differ on pixel edge coverage. +Returns true if glyphs at different sub-pixel positions may differ on pixel edge coverage. ### Return Value @@ -420,12 +513,12 @@ incomplete void setSubpixel(bool subpixel) -Requests, but does not require, that glyphs respect sub-pixel positioning. +Requests, but does not require, that glyphs respect sub-pixel positioning. ### Parameters - +
subpixelsetting for sub-pixel positioningsetting for sub-pixel positioning
@@ -991,7 +1084,7 @@ Returns true if byteLength is zero number of bytes in text array encoding - text encoding + text encoding @@ -1020,7 +1113,7 @@ Returns the bytes of text that fit within < The text fragment fits if its advance width is less than or equal to maxWidth. Measures only while the advance is less than or equal to maxWidth. Returns the advance or the text fragment in measuredWidth if it not nullptr. -Uses encoding to decode text, SkTypeface to get the font metrics, +Uses encoding to decode text, SkTypeface to get the font metrics, and text size to scale the metrics. Does not scale the advance or bounds by fake bold. @@ -1033,7 +1126,7 @@ Does not scale the advance or bounds by fake bold. number of bytes of text to measure encoding - text encoding + text encoding maxWidth advance limit; text is measured while advance is less than maxWidth diff --git a/site/user/api/SkPaint_Reference.md b/site/user/api/SkPaint_Reference.md index fb370bf244..689554bb35 100644 --- a/site/user/api/SkPaint_Reference.md +++ b/site/user/api/SkPaint_Reference.md @@ -131,16 +131,8 @@ class SkPaint { void setTextScaleX(SkScalar scaleX); SkScalar getTextSkewX() const; void setTextSkewX(SkScalar skewX); - - enum TextEncoding : uint8_t { - kUTF8_TextEncoding, - kUTF16_TextEncoding, - kUTF32_TextEncoding, - kGlyphID_TextEncoding, - }; - - TextEncoding getTextEncoding() const; - void setTextEncoding(TextEncoding encoding); + SkTextEncoding getTextEncoding() const; + void setTextEncoding(SkTextEncoding encoding); typedef SkFontMetrics FontMetrics; @@ -219,29 +211,29 @@ Constructs Paint with default values. | Color_Filter | nullptr | | Dither | false | | Draw_Looper | nullptr | -| Fake_Bold | false | | Filter_Quality | kNone_SkFilterQuality | -| Font_Embedded_Bitmaps | false | -| Automatic_Hinting | false | -| Full_Hinting_Spacing | false | -| Hinting | SkFontHinting::kNormal | +| Font_Force_Hinting | false | +| Font_Embedded_Bitmaps | false | +| Font_Embolden | false | +| Font_Hinting | SkFontHinting::kNormal | +| Font_Hinting_Spacing | false | +| Font_Anti_Alias | false | +| Font_Linear | false | +| Font_Scale_X | 1 | +| Font_Size | 12 | +| Font_Skew_X | 0 | +| Font_Subpixel | false | | Image_Filter | nullptr | -| LCD_Text | false | -| Linear_Text | false | | Miter_Limit | 4 | | Mask_Filter | nullptr | | Path_Effect | nullptr | | Shader | nullptr | | Style | kFill_Style | -| Text_Encoding | kUTF8_TextEncoding | -| Text_Scale_X | 1 | -| Text_Size | 12 | -| Text_Skew_X | 0 | +| Text_Encoding | kUTF8_SkTextEncoding | | Typeface | nullptr | | Stroke_Cap | kButt_Cap | | Stroke_Join | kMiter_Join | | Stroke_Width | 0 | -| Subpixel_Text | false | The flags, text size, hinting, and miter limit may be overridden at compile time by defining paint default values. The overrides may be included in "SkUserConfig.h" or predefined by the @@ -678,25 +670,25 @@ mask for setting Dither SkPaint::kFakeBoldText_Flag 0x0020 -mask for setting Fake_Bold +mask for setting Font_Embolden SkPaint::kLinearText_Flag 0x0040 -mask for setting Linear_Text +mask for setting Font_Linear SkPaint::kSubpixelText_Flag 0x0080 -mask for setting Subpixel_Text +mask for setting Font_Subpixel SkPaint::kLCDRenderText_Flag 0x0200 -mask for setting LCD_Text +mask for setting Font_Anti_Alias SkPaint::kEmbeddedBitmapText_Flag @@ -708,7 +700,7 @@ mask for setting Font_Embedded_Bitmaps SkPaint::kAutoHinting_Flag 0x0800 -mask for setting Automatic_Hinting +mask for setting Font_Force_Hinting SkPaint::kAllFlags @@ -979,12 +971,12 @@ paint1 == paint2 --- -LCD_Text and Subpixel_Text increase the precision of glyph position. +Font_Anti_Alias and Font_Subpixel increase the precision of glyph position. When set, Flags kLCDRenderText_Flag takes advantage of the organization of RGB stripes that create a color, and relies on the small size of the stripe and visual perception to make the color fringing imperceptible. -LCD_Text can be enabled on devices that orient stripes horizontally or vertically, and that order +Font_Anti_Alias can be enabled on devices that orient stripes horizontally or vertically, and that order the color components as RGB or BGR. Flags kSubpixelText_Flag uses the pixel transparency to represent a fractional offset. @@ -993,21 +985,21 @@ of the color increases, the edge of the kLCDRenderText_Flag and kSubpixelText_Flag are clear by default. -LCD_Text or Subpixel_Text can be enabled by default by setting SkPaintDefaults_Flags to +Font_Anti_Alias or Font_Subpixel can be enabled by default by setting SkPaintDefaults_Flags to kLCDRenderText_Flag or kSubpixelText_Flag (or both) at compile time. ### Example -
Four commas are drawn normally and with combinations of LCD_Text and Subpixel_Text. -When Subpixel_Text is disabled, the comma Glyphs are identical, but not evenly spaced. -When Subpixel_Text is enabled, the comma Glyphs are unique, but appear evenly spaced. +
Four commas are drawn normally and with combinations of Font_Anti_Alias and Font_Subpixel. +When Font_Subpixel is disabled, the comma Glyphs are identical, but not evenly spaced. +When Font_Subpixel is enabled, the comma Glyphs are unique, but appear evenly spaced.
-Linear_Text selects whether text is rendered as a Glyph or as a Path. -If kLinearText_Flag is set, it has the same effect as setting Hinting to SkFontHinting::kNormal. -If kLinearText_Flag is clear, it is the same as setting Hinting to SkFontHinting::kNone. +Font_Linear selects whether text is rendered as a Glyph or as a Path. +If Font_Linear is set, it has the same effect as setting Hinting to SkFontHinting::kNormal. +If Font_Linear is clear, it is the same as setting Hinting to SkFontHinting::kNone. @@ -1077,7 +1069,7 @@ of the color increases, the edge of the isSubpixelText()const -Returns true if glyphs at different sub-pixel positions may differ on pixel edge coverage. +Returns true if glyphs at different sub-pixel positions may differ on pixel edge coverage. Equivalent to getFlags() masked with kSubpixelText_Flag. @@ -1106,7 +1098,7 @@ paint.isSubpixelText() == !!(paint.getFlags() & SkPaint::kSubpixelText_Flag) void setSubpixelText(bool subpixelText) -Requests, but does not require, that glyphs respect sub-pixel positioning. +Requests, but does not require, that glyphs respect sub-pixel positioning. Sets kSubpixelText_Flag if subpixelText is true. Clears kSubpixelText_Flag if subpixelText is false. @@ -1132,10 +1124,10 @@ paint1 == paint2 -When set, Flags kLCDRenderText_Flag takes advantage of the organization of RGB stripes that +When set, Font_Anti_Alias takes advantage of the organization of RGB stripes that create a color, and relies on the small size of the stripe and visual perception to make the color fringing imperceptible. -LCD_Text can be enabled on devices that orient stripes horizontally or vertically, and that order +Font_Anti_Alias can be enabled on devices that orient stripes horizontally or vertically, and that order the color components as RGB or BGR. @@ -1199,11 +1191,11 @@ paint1 == paint2
- + --- -Font_Embedded_Bitmaps allows selecting custom sized bitmap Glyphs. +Font_Embedded_Bitmaps allows selecting custom sized bitmap Glyphs. Flags kEmbeddedBitmapText_Flag when set chooses an embedded bitmap glyph over an outline contained in a font if the platform supports this option. @@ -1212,8 +1204,8 @@ the outline glyph if bitmap glyph but is not required to do so. OS_X and iOS do not support this option. -Font_Embedded_Bitmaps is disabled by default. -Font_Embedded_Bitmaps can be enabled by default by setting SkPaintDefaults_Flags to +Font_Embedded_Bitmaps is disabled by default. +Font_Embedded_Bitmaps can be enabled by default by setting SkPaintDefaults_Flags to kEmbeddedBitmapText_Flag at compile time. ### Example @@ -1304,12 +1296,12 @@ paint1 == paint2 -If Hinting is set to SkFontHinting::kNormal or SkFontHinting::kFull, Automatic_Hinting +If Hinting is set to SkFontHinting::kNormal or SkFontHinting::kFull, Font_Force_Hinting instructs the Font_Manager to always hint Glyphs. -Automatic_Hinting has no effect if Hinting is set to SkFontHinting::kNone or +Font_Force_Hinting has no effect if Hinting is set to SkFontHinting::kNone or SkFontHinting::kSlight. -Automatic_Hinting only affects platforms that use FreeType as the Font_Manager. +Font_Force_Hinting only affects platforms that use FreeType as the Font_Manager. @@ -1357,7 +1349,7 @@ void setAutohinted(bool useAutohinter) Sets whether to always hint glyphs. If SkPaint::Hinting is set to SkFontHinting::kNormal or SkFontHinting::kFull and useAutohinter is set, instructs the font manager to always hint glyphs. -auto-hinting has no effect if SkPaint::Hinting is set to SkFontHinting::kNone or +useAutohinter has no effect if SkPaint::Hinting is set to SkFontHinting::kNone or SkFontHinting::kSlight. Only affects platforms that use FreeType as the font manager. @@ -1384,7 +1376,7 @@ Clears kAutoHinting_Flag if Fake_Bold approximates the bold font style accompanying a normal font when a bold font face +Font_Embolden approximates the bold font style accompanying a normal font when a bold font face is not available. Skia does not provide font substitution; it is up to the client to find the bold font face using the platform Font_Manager. @@ -1395,7 +1387,7 @@ A FreeType based port may define SK_USE_FREETYPE_EMBOLDEN at compile time to dir the font engine to create the bold Glyphs. Otherwise, the extra bold is computed by increasing the stroke width and setting the Style to kStrokeAndFill_Style as needed. -Fake_Bold is disabled by default. +Font_Embolden is disabled by default. ### Example @@ -1463,16 +1455,6 @@ paint1 == paint2
- - -if Hinting is set to SkFontHinting::kFull, Full_Hinting_Spacing adjusts the character -spacing by the difference of the hinted and unhinted Left_Side_Bearing and -Right_Side_Bearing. Full_Hinting_Spacing only applies to platforms that use -FreeType as their Font_Engine. - -Full_Hinting_Spacing is not related to text kerning, where the space between -a specific pair of characters is adjusted using data in the font kerning tables. - --- @@ -3577,74 +3559,9 @@ Default value is zero. --- - - ---- - -
-    enum TextEncoding : uint8_t {
-        kUTF8_TextEncoding,
-        kUTF16_TextEncoding,
-        kUTF32_TextEncoding,
-        kGlyphID_TextEncoding,
-    };
-
-
- -TextEncoding determines whether text specifies character codes and their encoded -size, or glyph indices. Characters are encoded as specified by the -Unicode standard . - -Character codes encoded size are specified by UTF-8, UTF-16, or UTF-32. -All character code formats are able to represent all of Unicode, differing only -in the total storage required. - -UTF-8 (RFC 3629) encodes each character as one or more 8-bit bytes. - -UTF-16 (RFC 2781) encodes each character as one or two 16-bit words. - -UTF-32 encodes each character as one 32-bit word. - -Font_Manager uses font data to convert character code points into glyph indices. -A glyph index is a 16-bit word. - -TextEncoding is set to kUTF8_TextEncoding by default. - -### Constants - - - - - - - - - - - - - - - - - - - - - - - - - -
ConstValueDescription
SkPaint::kUTF8_TextEncoding0 -uses bytes to represent UTF-8 or ASCII
SkPaint::kUTF16_TextEncoding1 -uses two byte words to represent most of Unicode
SkPaint::kUTF32_TextEncoding2 -uses four byte words to represent all of Unicode
SkPaint::kGlyphID_TextEncoding3 -uses two byte words to represent glyph indices
- ### Example -
First line is encoded in UTF-8. +
First line is encoded in UTF-8. Second line is encoded in UTF-16. Third line is encoded in UTF-32. Fourth line has 16-bit glyph indices. @@ -3655,27 +3572,25 @@ Fourth line has 16-bit TextEncoding getTextEncoding()const +SkTextEncoding getTextEncoding()const -Returns SkPaint::TextEncoding. -SkPaint::TextEncoding determines how character code points are mapped to font glyph indices. +Returns the text encoding. Text encoding describes how to interpret the text bytes pass +to methods like measureText() and SkCanvas::drawText(). ### Return Value -one of: kUTF8_TextEncoding, kUTF16_TextEncoding, kUTF32_TextEncoding, or - -kGlyphID_TextEncoding +the text encoding ### Example -
+
#### Example Output ~~~~ -kUTF8_TextEncoding == text encoding -kGlyphID_TextEncoding == text encoding +kUTF8_SkTextEncoding == text encoding +kGlyphID_SkTextEncoding == text encoding ~~~~
@@ -3685,25 +3600,22 @@ kGlyphID_TextEncoding == text encoding ---
-void setTextEncoding(TextEncoding encoding)
+void setTextEncoding(SkTextEncoding encoding)
 
-Sets SkPaint::TextEncoding to encoding. -SkPaint::TextEncoding determines how character code points are mapped to font glyph indices. -Invalid values for encoding are ignored. +Sets the text encoding. Text encoding describes how to interpret the text bytes pass +to methods like measureText() and SkCanvas::drawText(). ### Parameters - +
encodingone of: kUTF8_TextEncoding, kUTF16_TextEncoding, kUTF32_TextEncoding, orthe new text encoding
-kGlyphID_TextEncoding - ### Example -
+
#### Example Output @@ -3752,7 +3664,7 @@ recommended spacing between lines ### See Also -Text_Size Typeface Typeface_Methods +Font_Size Typeface Typeface_Methods @@ -3827,7 +3739,7 @@ number of glyphs represented by
+
@@ -3912,7 +3824,7 @@ corresponding to the Unicode surrogate code po ### Example -
containsText returns true that glyph index is greater than zero, not +
containsText returns true that glyph index is greater than zero, not that it corresponds to an entry in Typeface.
@@ -3960,7 +3872,7 @@ Only supported on platforms that use FreeType as the text to glyphs; then convert glyphs to Unichar code points. +
Convert UTF-8 text to glyphs; then convert glyphs to Unichar code points.
@@ -4378,7 +4290,7 @@ Uses SkTypeface to get the text size, fake bold, and SkPathEffect to scale and modify the glyph paths. Uses run array to position intervals. -SkTextEncoding must be set to SkPaint::kGlyphID_TextEncoding. +SkTextEncoding must be set to kGlyphID_SkTextEncoding. Pass nullptr for intervals to determine the size of the interval array. diff --git a/site/user/api/SkSurface_Reference.md b/site/user/api/SkSurface_Reference.md index 52d2bf0757..9b60db50dc 100644 --- a/site/user/api/SkSurface_Reference.md +++ b/site/user/api/SkSurface_Reference.md @@ -798,7 +798,7 @@ fonts; may be nullptr ### Example -
LCD text takes advantage of raster striping to improve resolution. Only one of +
LCD text takes advantage of raster striping to improve resolution. Only one of the four combinations is correct, depending on whether monitor LCD striping is horizontal or vertical, and whether the order of the stripes is red blue green or red green blue. diff --git a/site/user/api/SkTextBlobBuilder_Reference.md b/site/user/api/SkTextBlobBuilder_Reference.md index 2fe2395469..479d316e3d 100644 --- a/site/user/api/SkTextBlobBuilder_Reference.md +++ b/site/user/api/SkTextBlobBuilder_Reference.md @@ -39,9 +39,9 @@ Helper class for constructing SkTextBl RunBuffer supplies storage for Glyphs and positions within a run. -A run is a sequence of Glyphs sharing Paint_Font_Metrics and positioning. +A run is a sequence of Glyphs sharing Font_Metrics and positioning. Each run may position its Glyphs in one of three ways: -by specifying where the first Glyph is drawn, and allowing Paint_Font_Metrics to +by specifying where the first Glyph is drawn, and allowing Font_Metrics to determine the advance to subsequent Glyphs; by specifying a baseline, and the position on that baseline for each Glyph in run; or by providing Point array, one per Glyph. @@ -183,7 +183,7 @@ Returns run with storage for glyphs. Caller mus Glyphs share metrics in font. -Glyphs are positioned on a baseline at (x, y), using font metrics to +Glyphs are positioned on a baseline at (x, y), using font metrics to determine their relative placement. bounds defines an optional bounding box, used to suppress drawing when SkTextBlob diff --git a/site/user/api/SkTextBlob_Reference.md b/site/user/api/SkTextBlob_Reference.md index 085e9a368c..a9e2160c00 100644 --- a/site/user/api/SkTextBlob_Reference.md +++ b/site/user/api/SkTextBlob_Reference.md @@ -45,7 +45,7 @@ conservative bounding box ### Example -
+
### See Also @@ -67,7 +67,7 @@ identifier for SkTextBlob ### Example -
+
### See Also @@ -82,13 +82,13 @@ static sk_sp<SkTextEncoding encoding = kUTF8_SkTextEncoding) -Creates Text_Blob with a single run. text meaning depends on Paint_Text_Encoding; +Creates Text_Blob with a single run. text meaning depends on Text_Encoding; by default, text is encoded as UTF-8. -font contains attributes used to define the run text: Typeface, Paint_Text_Size, Paint_Text_Scale_X, -Paint_Text_Skew_X, Paint_Hinting, Anti_Alias, Paint_Fake_Bold, -Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text, -and Subpixel_Text +font contains attributes used to define the run text: Typeface, Font_Size, Font_Scale_X, +Font_Skew_X, Font_Hinting, Paint_Anti_Alias, Font_Embolden, Font_Force_Hinting, +Font_Embedded_Bitmaps, Font_Hinting_Spacing, Font_Anti_Alias, Font_Linear, +and Font_Subpixel . ### Parameters @@ -130,13 +130,13 @@ static sk_sp<SkTextEncoding encoding = kUTF8_SkTextEncoding) -Creates Text_Blob with a single run. string meaning depends on Paint_Text_Encoding; +Creates Text_Blob with a single run. string meaning depends on Text_Encoding; by default, string is encoded as UTF-8. -font contains Paint_Font_Metrics used to define the run text: Typeface, Paint_Text_Size, Paint_Text_Scale_X, -Paint_Text_Skew_X, Paint_Hinting, Anti_Alias, Paint_Fake_Bold, -Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text, -and Subpixel_Text +font contains Font_Metrics used to define the run text: Typeface, Font_Size, Font_Scale_X, +Font_Skew_X, Font_Hinting, Paint_Anti_Alias, Font_Embolden, Font_Force_Hinting, +Font_Embedded_Bitmaps, Font_Hinting_Spacing, Font_Anti_Alias, Font_Linear, +and Font_Subpixel . ### Parameters diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm index 9b039f391d..2c2bb5352d 100644 --- a/site/user/api/catalog.htm +++ b/site/user/api/catalog.htm @@ -1401,8 +1401,8 @@ "stdout": "[ 1.0000 0.0000 3.0000][ 0.0000 2.0000 4.0000][ 0.0000 0.0000 1.0000]\\n" }, "SkPaint_containsText": { - "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const uint16_t goodGlyph = 511;\n const uint16_t zeroGlyph = 0;\n const uint16_t badGlyph = 65535; // larger than glyph count in font\n paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);\n SkDebugf(\"0x%04x %c= has glyph\\n\", goodGlyph,\n paint.containsText(&goodGlyph, 2) ? '=' : '!');\n SkDebugf(\"0x%04x %c= has glyph\\n\", zeroGlyph,\n paint.containsText(&zeroGlyph, 2) ? '=' : '!');\n SkDebugf(\"0x%04x %c= has glyph\\n\", badGlyph,\n paint.containsText(&badGlyph, 2) ? '=' : '!');\n}", - "hash": "083557b6f653d6fc00a34e01f87b74ff", + "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const uint16_t goodGlyph = 511;\n const uint16_t zeroGlyph = 0;\n const uint16_t badGlyph = 65535; // larger than glyph count in font\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n SkDebugf(\"0x%04x %c= has glyph\\n\", goodGlyph,\n paint.containsText(&goodGlyph, 2) ? '=' : '!');\n SkDebugf(\"0x%04x %c= has glyph\\n\", zeroGlyph,\n paint.containsText(&zeroGlyph, 2) ? '=' : '!');\n SkDebugf(\"0x%04x %c= has glyph\\n\", badGlyph,\n paint.containsText(&badGlyph, 2) ? '=' : '!');\n}", + "hash": "6a68cb3c8b81a5976c81ee004f559247", "file": "SkPaint_Reference", "name": "SkPaint::containsText", "stdout": "0x01ff == has glyph\\n0x0000 != has glyph\\n0xffff == has glyph\\n" @@ -1576,11 +1576,11 @@ "stdout": "SkPaint::kFill_Style == paint.getStyle()\\n" }, "SkPaint_getTextEncoding": { - "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n SkDebugf(\"kUTF8_TextEncoding %c= text encoding\\n\",\n SkPaint::kUTF8_TextEncoding == paint.getTextEncoding() ? '=' : '!');\n paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);\n SkDebugf(\"kGlyphID_TextEncoding %c= text encoding\\n\",\n SkPaint::kGlyphID_TextEncoding == paint.getTextEncoding() ? '=' : '!');\n}", - "hash": "c6cc2780a9828b3af8c4621c12b29a1b", + "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n SkDebugf(\"kUTF8_SkTextEncoding %c= text encoding\\n\",\n kUTF8_SkTextEncoding == paint.getTextEncoding() ? '=' : '!');\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n SkDebugf(\"kGlyphID_SkTextEncoding %c= text encoding\\n\",\n kGlyphID_SkTextEncoding == paint.getTextEncoding() ? '=' : '!');\n}", + "hash": "0d21e968e9a4c78c902ae3ef494941a0", "file": "SkPaint_Reference", "name": "SkPaint::getTextEncoding", - "stdout": "kUTF8_TextEncoding == text encoding\\nkGlyphID_TextEncoding == text encoding\\n" + "stdout": "kUTF8_SkTextEncoding == text encoding\\nkGlyphID_SkTextEncoding == text encoding\\n" }, "SkPaint_getTextScaleX": { "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n SkDebugf(\"1 %c= default text scale x\\n\", 1 == paint.getTextScaleX() ? '=' : '!');\n}", @@ -1884,8 +1884,8 @@ "stdout": "paint1 == paint2\\n" }, "SkPaint_setTextEncoding": { - "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setTextEncoding((SkPaint::TextEncoding) 4);\n SkDebugf(\"4 %c= text encoding\\n\", (SkPaint::TextEncoding) 4 == paint.getTextEncoding() ? '=' : '!');\n}", - "hash": "6d9ffdd3c5543e9f12972a06dd4a0ce5", + "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setTextEncoding((SkTextEncoding) 4);\n SkDebugf(\"4 %c= text encoding\\n\", (SkTextEncoding) 4 == paint.getTextEncoding() ? '=' : '!');\n}", + "hash": "a5d1ba0dbf42afb797ffdb07647b5cb9", "file": "SkPaint_Reference", "name": "SkPaint::setTextEncoding", "stdout": "4 != text encoding\\n" @@ -4245,10 +4245,10 @@ "name": "Stroke_Width" }, "Paint_Text_Encoding": { - "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const char hello8[] = \"Hello\" \"\\xE2\" \"\\x98\" \"\\xBA\";\n const uint16_t hello16[] = { 'H', 'e', 'l', 'l', 'o', 0x263A };\n const uint32_t hello32[] = { 'H', 'e', 'l', 'l', 'o', 0x263A };\n paint.setTextSize(24);\n canvas->drawText(hello8, sizeof(hello8) - 1, 10, 30, paint);\n paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);\n canvas->drawText(hello16, sizeof(hello16), 10, 60, paint);\n paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);\n canvas->drawText(hello32, sizeof(hello32), 10, 90, paint);\n uint16_t glyphs[SK_ARRAY_COUNT(hello32)];\n paint.textToGlyphs(hello32, sizeof(hello32), glyphs);\n paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);\n canvas->drawText(glyphs, sizeof(glyphs), 10, 120, paint);\n}\n", + "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const char hello8[] = \"Hello\" \"\\xE2\" \"\\x98\" \"\\xBA\";\n const uint16_t hello16[] = { 'H', 'e', 'l', 'l', 'o', 0x263A };\n const uint32_t hello32[] = { 'H', 'e', 'l', 'l', 'o', 0x263A };\n paint.setTextSize(24);\n canvas->drawText(hello8, sizeof(hello8) - 1, 10, 30, paint);\n paint.setTextEncoding(kUTF16_SkTextEncoding);\n canvas->drawText(hello16, sizeof(hello16), 10, 60, paint);\n paint.setTextEncoding(kUTF32_SkTextEncoding);\n canvas->drawText(hello32, sizeof(hello32), 10, 90, paint);\n uint16_t glyphs[SK_ARRAY_COUNT(hello32)];\n paint.textToGlyphs(hello32, sizeof(hello32), glyphs);\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n canvas->drawText(glyphs, sizeof(glyphs), 10, 120, paint);\n}\n", "width": 256, "height": 128, - "hash": "b29294e7f29d160a1b46abf2dcec9d2a", + "hash": "767fa4e7b6300e16a419f9881f0f9d3d", "file": "SkPaint_Reference", "name": "Text_Encoding" }, @@ -5237,10 +5237,10 @@ "name": "SkCanvas::drawText" }, "SkCanvas_drawTextBlob": { - "code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);\n SkFont font;\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 100 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n paint.setTextSize(1 == runLen ? 20 : 50);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp blob = textBlobBuilder.make();\n paint.reset();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n}\n", + "code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n SkFont font;\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 100 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n paint.setTextSize(1 == runLen ? 20 : 50);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp blob = textBlobBuilder.make();\n paint.reset();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n}\n", "width": 256, "height": 120, - "hash": "a207bbd7317bfbdadbda8af884631e46", + "hash": "005502b502c1282cb8d306d6c8d998fb", "file": "SkCanvas_Reference", "name": "SkCanvas::drawTextBlob" }, @@ -7445,10 +7445,10 @@ "name": "SkPaint::getTextWidths" }, "SkPaint_glyphsToUnichars": { - "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const char hello[] = \"Hello!\";\n const int count = sizeof(hello) - 1;\n SkGlyphID glyphs[count];\n if (count != paint.textToGlyphs(hello, count, glyphs)) {\n return;\n }\n SkUnichar unichars[count];\n paint.glyphsToUnichars(glyphs, count, unichars);\n paint.setTextEncoding(SkPaint::kUTF32_TextEncoding);\n canvas->drawText(unichars, sizeof(unichars), 10, 30, paint);\n}\n", + "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const char hello[] = \"Hello!\";\n const int count = sizeof(hello) - 1;\n SkGlyphID glyphs[count];\n if (count != paint.textToGlyphs(hello, count, glyphs)) {\n return;\n }\n SkUnichar unichars[count];\n paint.glyphsToUnichars(glyphs, count, unichars);\n paint.setTextEncoding(kUTF32_SkTextEncoding);\n canvas->drawText(unichars, sizeof(unichars), 10, 30, paint);\n}\n", "width": 256, "height": 64, - "hash": "c12686b0b3e0a87d0a248bbfc57e9492", + "hash": "79c550ec6c34054ab60fbcd1b81adc03", "file": "SkPaint_Reference", "name": "SkPaint::glyphsToUnichars" }, @@ -7549,10 +7549,10 @@ "name": "SkPaint::setTypeface" }, "SkPaint_textToGlyphs": { - "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const uint8_t utf8[] = { 0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0xC2, 0xA5, 0xC2, 0xA3 };\n std::vector glyphs;\n int count = paint.textToGlyphs(utf8, sizeof(utf8), nullptr);\n glyphs.resize(count);\n (void) paint.textToGlyphs(utf8, sizeof(utf8), &glyphs.front());\n paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);\n paint.setTextSize(32);\n canvas->drawText(&glyphs.front(), glyphs.size() * sizeof(SkGlyphID), 10, 40, paint);\n}\n", + "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n const uint8_t utf8[] = { 0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0xC2, 0xA5, 0xC2, 0xA3 };\n std::vector glyphs;\n int count = paint.textToGlyphs(utf8, sizeof(utf8), nullptr);\n glyphs.resize(count);\n (void) paint.textToGlyphs(utf8, sizeof(utf8), &glyphs.front());\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n paint.setTextSize(32);\n canvas->drawText(&glyphs.front(), glyphs.size() * sizeof(SkGlyphID), 10, 40, paint);\n}\n", "width": 256, "height": 64, - "hash": "343e9471a7f7b5f09abdc3b44983433b", + "hash": "d11136d8a74f63009da2a7f550710823", "file": "SkPaint_Reference", "name": "SkPaint::textToGlyphs" }, @@ -9341,10 +9341,10 @@ "name": "SkTextBlob::MakeFromText" }, "SkTextBlob_bounds": { - "code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);\n SkFont font;\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 50 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n paint.setTextSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp blob = textBlobBuilder.make();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n paint.setStyle(SkPaint::kStroke_Style);\n canvas->drawRect(blob->bounds(), paint);\n}", + "code": "void draw(SkCanvas* canvas) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n SkFont font;\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 50 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n paint.setTextSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp blob = textBlobBuilder.make();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n paint.setStyle(SkPaint::kStroke_Style);\n canvas->drawRect(blob->bounds(), paint);\n}", "width": 256, "height": 70, - "hash": "a22a490fd43bcc1cd3e26430debfb99e", + "hash": "fb8b2502bbe52d2029aecdf569dd9fdb", "file": "SkTextBlob_Reference", "name": "SkTextBlob::bounds()" }, @@ -9365,10 +9365,10 @@ "name": "SkTextBlob::serialize_2" }, "SkTextBlob_uniqueID": { - "code": "void draw(SkCanvas* canvas) {\n for (int index = 0; index < 2; ++index) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);\n paint.setTextScaleX(0.5);\n SkFont font;\n font.setScaleX(0.5);\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 50 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n paint.setTextSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp blob = textBlobBuilder.make();\n paint.reset();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n std::string id = \"unique ID:\" + std::to_string(blob->uniqueID());\n canvas->drawString(id.c_str(), 30, blob->bounds().fBottom + 15, paint);\n canvas->translate(blob->bounds().fRight + 10, 0);\n }\n}", + "code": "void draw(SkCanvas* canvas) {\n for (int index = 0; index < 2; ++index) {\n SkTextBlobBuilder textBlobBuilder;\n const char bunny[] = \"/(^x^)\\\\\";\n const int len = sizeof(bunny) - 1;\n uint16_t glyphs[len];\n SkPaint paint;\n paint.textToGlyphs(bunny, len, glyphs);\n paint.setTextEncoding(kGlyphID_SkTextEncoding);\n paint.setTextScaleX(0.5);\n SkFont font;\n font.setScaleX(0.5);\n int runs[] = { 3, 1, 3 };\n SkPoint textPos = { 20, 50 };\n int glyphIndex = 0;\n for (auto runLen : runs) {\n font.setSize(1 == runLen ? 20 : 50);\n paint.setTextSize(1 == runLen ? 20 : 50);\n const SkTextBlobBuilder::RunBuffer& run =\n textBlobBuilder.allocRun(font, runLen, textPos.fX, textPos.fY);\n memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen);\n textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr);\n glyphIndex += runLen;\n }\n sk_sp blob = textBlobBuilder.make();\n paint.reset();\n canvas->drawTextBlob(blob.get(), 0, 0, paint);\n std::string id = \"unique ID:\" + std::to_string(blob->uniqueID());\n canvas->drawString(id.c_str(), 30, blob->bounds().fBottom + 15, paint);\n canvas->translate(blob->bounds().fRight + 10, 0);\n }\n}", "width": 256, "height": 256, - "hash": "fdd9c8c4470cc4f725af779e9d6db6e4", + "hash": "6e12cceca981ddabc0fc18c380543f34", "file": "SkTextBlob_Reference", "name": "SkTextBlob::uniqueID" },