Index: cc/font_atlas.cc |
diff --git a/cc/font_atlas.cc b/cc/font_atlas.cc |
index 0b483c9bb04c4e35940d29fa81b6452d7333f2a9..7bae07b2d19a62733f82d55cfde70b5cf466eb52 100644 |
--- a/cc/font_atlas.cc |
+++ b/cc/font_atlas.cc |
@@ -60,6 +60,25 @@ void FontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const SkPaint& paint |
} |
} |
+IntSize FontAtlas::textSize(const std::string& text) |
egraether
2012/10/26 00:06:52
This new method calculates the screen text size of
|
+{ |
+ int maxWidth = 0; |
+ std::vector<std::string> lines; |
+ base::SplitString(text, '\n', &lines); |
+ |
+ for (size_t i = 0; i < lines.size(); ++i) { |
+ int lineWidth = 0; |
+ for (size_t j = 0; j < lines[i].size(); ++j) { |
+ int asciiIndex = (lines[i][j] < 128) ? lines[i][j] : 0; |
+ lineWidth += m_asciiToRectTable[asciiIndex].width(); |
+ } |
+ if (lineWidth > maxWidth) |
+ maxWidth = lineWidth; |
+ } |
+ |
+ return IntSize(maxWidth, m_fontHeight * lines.size()); |
+} |
+ |
void FontAtlas::drawDebugAtlas(SkCanvas* canvas, const gfx::Point& destPosition) const |
{ |
DCHECK(Proxy::isImplThread()); |