add breaktext doc skeleton
copy paragraph from paint, add empty
example to docs. Fixes bot
TBR=reed@google.com
Docs-Preview: https://skia.org/?cl=173771
Bug: skia:
Change-Id: I4a79f7f8f32f860d0390dbce44669e03bb3a281e
Reviewed-on: https://skia-review.googlesource.com/c/173771
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
diff --git a/docs/SkFont_Reference.bmh b/docs/SkFont_Reference.bmh
index 484bf93..dc14d81 100644
--- a/docs/SkFont_Reference.bmh
+++ b/docs/SkFont_Reference.bmh
@@ -569,6 +569,22 @@
#Method ##
# ------------------------------------------------------------------------------
+
+#Method size_t breakText(const void* text, size_t length, SkTextEncoding encoding, SkScalar maxWidth,
+ SkScalar* measuredWidth = nullptr) const
+#In incomplete
+#Line # incomplete ##
+#Populate
+
+#Example
+// incomplete
+##
+
+#SeeAlso incomplete
+
+#Method ##
+
+# ------------------------------------------------------------------------------
#Method SkScalar measureText(const void* text, size_t byteLength, SkTextEncoding encoding,
SkRect* bounds = nullptr) const
diff --git a/include/core/SkFont.h b/include/core/SkFont.h
index 908b569..a16fc0c 100644
--- a/include/core/SkFont.h
+++ b/include/core/SkFont.h
@@ -295,7 +295,22 @@
*/
bool containsText(const void* text, size_t byteLength, SkTextEncoding encoding) const;
- size_t breakText(const void* text, size_t length, SkTextEncoding, SkScalar maxWidth,
+ /** Returns the bytes of text that fit within maxWidth.
+ 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,
+ and text size to scale the metrics.
+ Does not scale the advance or bounds by fake bold.
+
+ @param text character codes or glyph indices to be measured
+ @param length number of bytes of text to measure
+ @param encoding text encoding
+ @param maxWidth advance limit; text is measured while advance is less than maxWidth
+ @param measuredWidth returns the width of the text less than or equal to maxWidth
+ @return bytes of text that fit, always less than or equal to length
+ */
+ size_t breakText(const void* text, size_t length, SkTextEncoding encoding, SkScalar maxWidth,
SkScalar* measuredWidth = nullptr) const;
/** Returns the advance width of text.
diff --git a/site/user/api/SkFont_Reference.md b/site/user/api/SkFont_Reference.md
index 7107f02..334c2e3 100644
--- a/site/user/api/SkFont_Reference.md
+++ b/site/user/api/SkFont_Reference.md
@@ -60,7 +60,7 @@
uint16_t <a href='#SkFont_unicharToGlyph'>unicharToGlyph</a>(<a href='undocumented#SkUnichar'>SkUnichar</a> uni) const;
int <a href='#SkFont_countText'>countText</a>(const void* <a href='undocumented#Text'>text</a>, size_t byteLength, <a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding) const;
bool <a href='#SkFont_containsText'>containsText</a>(const void* <a href='undocumented#Text'>text</a>, size_t byteLength, <a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding) const;
- size_t breakText(const void* <a href='undocumented#Text'>text</a>, size_t length, <a href='undocumented#SkTextEncoding'>SkTextEncoding</a>, <a href='undocumented#SkScalar'>SkScalar</a> maxWidth,
+ size_t <a href='#SkFont_breakText'>breakText</a>(const void* <a href='undocumented#Text'>text</a>, size_t length, <a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding, <a href='undocumented#SkScalar'>SkScalar</a> maxWidth,
<a href='undocumented#SkScalar'>SkScalar</a>* measuredWidth = nullptr) const;
<a href='undocumented#SkScalar'>SkScalar</a> <a href='#SkFont_measureText'>measureText</a>(const void* <a href='undocumented#Text'>text</a>, size_t byteLength, <a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding,
<a href='SkRect_Reference#SkRect'>SkRect</a>* bounds = nullptr) const;
@@ -1007,6 +1007,54 @@
incomplete
+<a name='SkFont_breakText'></a>
+
+---
+
+<pre style="padding: 1em 1em 1em 1em; width: 62.5em;background-color: #f0f0f0">
+size_t <a href='#SkFont_breakText'>breakText</a>(const void* <a href='undocumented#Text'>text</a>, size_t length, <a href='undocumented#SkTextEncoding'>SkTextEncoding</a> encoding, <a href='undocumented#SkScalar'>SkScalar</a> maxWidth,
+ <a href='undocumented#SkScalar'>SkScalar</a>* measuredWidth = nullptr)const
+</pre>
+
+Returns the bytes of <a href='#SkFont_breakText_text'>text</a> that fit within <a href='#SkFont_breakText_maxWidth'>maxWidth</a>.
+The <a href='#SkFont_breakText_text'>text</a> fragment fits if its advance width is less than or equal to <a href='#SkFont_breakText_maxWidth'>maxWidth</a>.
+Measures only while the advance is less than or equal to <a href='#SkFont_breakText_maxWidth'>maxWidth</a>.
+Returns the advance or the <a href='#SkFont_breakText_text'>text</a> fragment in <a href='#SkFont_breakText_measuredWidth'>measuredWidth</a> if it not nullptr.
+Uses <a href='#SkFont_breakText_encoding'>encoding</a> to decode <a href='#SkFont_breakText_text'>text</a>, <a href='undocumented#SkTypeface'>SkTypeface</a> to get the <a href='SkFont_Reference#Font'>font</a> metrics,
+and <a href='#SkFont_breakText_text'>text</a> <a href='undocumented#Size'>size</a> to scale the metrics.
+Does not scale the advance or bounds by fake bold.
+
+### Parameters
+
+<table> <tr> <td><a name='SkFont_breakText_text'><code><strong>text</strong></code></a></td>
+ <td>character codes or <a href='undocumented#Glyph'>glyph</a> indices to be measured</td>
+ </tr>
+ <tr> <td><a name='SkFont_breakText_length'><code><strong>length</strong></code></a></td>
+ <td>number of bytes of <a href='#SkFont_breakText_text'>text</a> to measure</td>
+ </tr>
+ <tr> <td><a name='SkFont_breakText_encoding'><code><strong>encoding</strong></code></a></td>
+ <td><a href='#SkFont_breakText_text'>text</a> <a href='#SkFont_breakText_encoding'>encoding</a></td>
+ </tr>
+ <tr> <td><a name='SkFont_breakText_maxWidth'><code><strong>maxWidth</strong></code></a></td>
+ <td>advance limit; <a href='#SkFont_breakText_text'>text</a> is measured while advance is less than <a href='#SkFont_breakText_maxWidth'>maxWidth</a></td>
+ </tr>
+ <tr> <td><a name='SkFont_breakText_measuredWidth'><code><strong>measuredWidth</strong></code></a></td>
+ <td>returns the width of the <a href='#SkFont_breakText_text'>text</a> less than or equal to <a href='#SkFont_breakText_maxWidth'>maxWidth</a></td>
+ </tr>
+</table>
+
+### Return Value
+
+bytes of <a href='#SkFont_breakText_text'>text</a> that fit, always less than or equal to <a href='#SkFont_breakText_length'>length</a>
+
+### Example
+
+<div><fiddle-embed name="882e8e0103048009a25cfc20400492f7"></fiddle-embed></div>
+
+### See Also
+
+incomplete
+
<a name='SkFont_measureText'></a>
---
diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm
index b2272c2..ed1ad79 100644
--- a/site/user/api/catalog.htm
+++ b/site/user/api/catalog.htm
@@ -1842,8 +1842,8 @@
"stdout": "paint.isAntiAlias()\\npaint.isDither()\\n"
},
"SkPaint_setHinting": {
- "code": "void draw(SkCanvas* canvas) {\n SkPaint paint1, paint2;\n paint2.setHinting(kNormal_SkFontHinting);\n SkDebugf(\"paint1 %c= paint2\\n\", paint1 == paint2 ? '=' : ':');\n}",
- "hash": "197268a89c3343f600b9bade61c513ae",
+ "code": "void draw(SkCanvas* canvas) {\n SkPaint paint1, paint2;\n paint2.setHinting(SkFontHinting::kNormal);\n SkDebugf(\"paint1 %c= paint2\\n\", paint1 == paint2 ? '=' : ':');\n}",
+ "hash": "bb179ec5698ec1398ff18f3657ab73f7",
"file": "SkPaint_Reference",
"name": "SkPaint::setHinting",
"stdout": "paint1 == paint2\\n"
@@ -5795,14 +5795,6 @@
"file": "SkFont_Reference",
"name": "SkFont::Edging"
},
- "SkFont_Hinting": {
- "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}",
- "width": 256,
- "height": 256,
- "hash": "882e8e0103048009a25cfc20400492f7",
- "file": "SkFont_Reference",
- "name": "SkFont::Hinting"
-},
"SkFont_SkTypeface_SkScalar": {
"code": "void draw(SkCanvas* canvas) {\n // incomplete\n}",
"width": 256,
@@ -5819,6 +5811,14 @@
"file": "SkFont_Reference",
"name": "SkFont::SkFont(sk_sp<SkTypeface> typeface, SkScalar size, SkScalar scaleX, SkScalar skewX)"
},
+ "SkFont_breakText": {
+ "code": "void draw(SkCanvas* canvas) {\n // incomplete\n}",
+ "width": 256,
+ "height": 256,
+ "hash": "882e8e0103048009a25cfc20400492f7",
+ "file": "SkFont_Reference",
+ "name": "SkFont::breakText"
+},
"SkFont_containsText": {
"code": "void draw(SkCanvas* canvas) {\n // incomplete\n}",
"width": 256,