aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/views/SkTextBox.cpp
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-24 16:08:45 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-24 16:08:45 +0000
commit6fccbd1e569ae88b76a66571252bbc4b203272f9 (patch)
treeccaab954665f3da9c9422ad25e4a6bc333f30ba5 /src/views/SkTextBox.cpp
parent607fe077c893fdb230e29631be096de614a14e2a (diff)
SkTextBox to use public interfaces for line layout.
Diffstat (limited to 'src/views/SkTextBox.cpp')
-rw-r--r--src/views/SkTextBox.cpp49
1 files changed, 1 insertions, 48 deletions
diff --git a/src/views/SkTextBox.cpp b/src/views/SkTextBox.cpp
index 6a88c6ce39..47237a905e 100644
--- a/src/views/SkTextBox.cpp
+++ b/src/views/SkTextBox.cpp
@@ -1,4 +1,3 @@
-
/*
* Copyright 2006 The Android Open Source Project
*
@@ -6,11 +5,8 @@
* found in the LICENSE file.
*/
-
#include "SkTextBox.h"
-#include "../core/SkGlyphCache.h"
#include "SkUtils.h"
-#include "SkAutoKern.h"
static inline int is_ws(int c)
{
@@ -19,50 +15,7 @@ static inline int is_ws(int c)
static size_t linebreak(const char text[], const char stop[], const SkPaint& paint, SkScalar margin)
{
- const char* start = text;
-
- SkAutoGlyphCache ac(paint, NULL);
- SkGlyphCache* cache = ac.getCache();
- SkFixed w = 0;
- SkFixed limit = SkScalarToFixed(margin);
- SkAutoKern autokern;
-
- const char* word_start = text;
- int prevWS = true;
-
- while (text < stop)
- {
- const char* prevText = text;
- SkUnichar uni = SkUTF8_NextUnichar(&text);
- int currWS = is_ws(uni);
- const SkGlyph& glyph = cache->getUnicharMetrics(uni);
-
- if (!currWS && prevWS)
- word_start = prevText;
- prevWS = currWS;
-
- w += autokern.adjust(glyph) + glyph.fAdvanceX;
- if (w > limit)
- {
- if (currWS) // eat the rest of the whitespace
- {
- while (text < stop && is_ws(SkUTF8_ToUnichar(text)))
- text += SkUTF8_CountUTF8Bytes(text);
- }
- else // backup until a whitespace (or 1 char)
- {
- if (word_start == start)
- {
- if (prevText > start)
- text = prevText;
- }
- else
- text = word_start;
- }
- break;
- }
- }
- return text - start;
+ return paint.breakText(text, stop - text, margin);
}
int SkTextLineBreaker::CountLines(const char text[], size_t len, const SkPaint& paint, SkScalar width)