Revert "remove SkPaint breakText, use SkFont instead (or don't call it)"

This reverts commit b17f5fd6181984bc47f930d6ca5241e68703b830.

Reason for revert: googe3 still uses this :(

Original change's description:
> remove SkPaint breakText, use SkFont instead (or don't call it)
> 
> Bug: skia:
> Change-Id: I906b8ea70be1f70043b77ca32cc214d15c256967
> Reviewed-on: https://skia-review.googlesource.com/c/175254
> Reviewed-by: Cary Clark <caryclark@google.com>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=caryclark@google.com,reed@google.com,caryclark@skia.org

Change-Id: Ifcb1bcecd92fef76b0dc92ee8d8d3644f763136f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/175429
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/docs/SkPaint_Reference.bmh b/docs/SkPaint_Reference.bmh
index 6e07a97..a09d7c9 100644
--- a/docs/SkPaint_Reference.bmh
+++ b/docs/SkPaint_Reference.bmh
@@ -3280,6 +3280,36 @@
 
 ##
 
+#Method size_t breakText(const void* text, size_t length, SkScalar maxWidth,
+                      SkScalar* measuredWidth = nullptr) const
+#In Measure_Text
+#Line # returns text that fits in a width ##
+#Populate
+
+#Example
+    #Description
+    Line under "Breakfast" shows desired width, shorter than available characters.
+    Line under "Bre" shows measured width after breaking text.
+    ##
+    #Height 128
+    #Width 280
+        void draw(SkCanvas* canvas) {
+            SkPaint paint;
+            paint.setAntiAlias(true);
+            paint.setTextSize(50);
+            const char str[] = "Breakfast";
+            const int count = sizeof(str) - 1;
+            canvas->drawText(str, count, 25, 50, paint);
+            SkScalar measuredWidth;
+            int partialBytes = paint.breakText(str, count, 100, &measuredWidth);
+            canvas->drawText(str, partialBytes, 25, 100, paint);
+            canvas->drawLine(25, 60, 25 + 100, 60, paint);
+            canvas->drawLine(25, 110, 25 + measuredWidth, 110, paint);
+        }
+    ##
+
+##
+
 #Method int getTextWidths(const void* text, size_t byteLength, SkScalar widths[],
                       SkRect bounds[] = nullptr) const
 #In Measure_Text
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index b9434f0..817f3f1 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -1027,6 +1027,23 @@
     }
 #endif
 
+    /** 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 SkTextEncoding 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 or SkPathEffect.
+
+        @param text           character codes or glyph indices to be measured
+        @param length         number of bytes of text to measure
+        @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, SkScalar maxWidth,
+                      SkScalar* measuredWidth = nullptr) const;
+
 #ifdef SK_SUPPORT_LEGACY_PAINT_TEXTMEASURE
     /** Retrieves the advance and bounds for each glyph in text, and returns
         the glyph count in text.
diff --git a/src/core/SkPaint_text.cpp b/src/core/SkPaint_text.cpp
index 530fc93..e4fc458 100644
--- a/src/core/SkPaint_text.cpp
+++ b/src/core/SkPaint_text.cpp
@@ -330,6 +330,12 @@
     return width;
 }
 
+size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth,
+                          SkScalar* measuredWidth) const {
+    return SkFont::LEGACY_ExtractFromPaint(*this).breakText(textD, length,
+                                                this->getTextEncoding(), maxWidth, measuredWidth);
+}
+
 SkScalar SkPaint::getFontMetrics(SkFontMetrics* metrics) const {
     return SkFont::LEGACY_ExtractFromPaint(*this).getMetrics(metrics);
 }