Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: src/views/SkTextBox.cpp

Issue 13856017: Fix a bug in SkTextBox. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkTextBox.h" 8 #include "SkTextBox.h"
9 #include "SkUtils.h" 9 #include "SkUtils.h"
10 10
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 for (;;) 225 for (;;)
226 { 226 {
227 size_t trailing; 227 size_t trailing;
228 len = linebreak(text, textStop, paint, marginWidth, &trailing); 228 len = linebreak(text, textStop, paint, marginWidth, &trailing);
229 if (y + metrics.fDescent + metrics.fLeading > 0) 229 if (y + metrics.fDescent + metrics.fLeading > 0)
230 canvas->drawText(text, len - trailing, x, y, paint); 230 canvas->drawText(text, len - trailing, x, y, paint);
231 text += len; 231 text += len;
232 if (text >= textStop) 232 if (text >= textStop)
233 break; 233 break;
234 y += scaledSpacing; 234 y += scaledSpacing;
235 if (y + metrics.fAscent >= height) 235 if (y + metrics.fAscent >= fBox.fBottom)
236 break; 236 break;
237 } 237 }
238 } 238 }
239 239
240 /////////////////////////////////////////////////////////////////////////////// 240 ///////////////////////////////////////////////////////////////////////////////
241 241
242 void SkTextBox::setText(const char text[], size_t len, const SkPaint& paint) { 242 void SkTextBox::setText(const char text[], size_t len, const SkPaint& paint) {
243 fText = text; 243 fText = text;
244 fLen = len; 244 fLen = len;
245 fPaint = &paint; 245 fPaint = &paint;
246 } 246 }
247 247
248 void SkTextBox::draw(SkCanvas* canvas) { 248 void SkTextBox::draw(SkCanvas* canvas) {
249 this->draw(canvas, fText, fLen, *fPaint); 249 this->draw(canvas, fText, fLen, *fPaint);
250 } 250 }
251 251
252 int SkTextBox::countLines() const { 252 int SkTextBox::countLines() const {
253 return SkTextLineBreaker::CountLines(fText, fLen, *fPaint, fBox.width()); 253 return SkTextLineBreaker::CountLines(fText, fLen, *fPaint, fBox.width());
254 } 254 }
255 255
256 SkScalar SkTextBox::getTextHeight() const { 256 SkScalar SkTextBox::getTextHeight() const {
257 SkScalar spacing = SkScalarMul(fPaint->getTextSize(), fSpacingMul) + fSpacin gAdd; 257 SkScalar spacing = SkScalarMul(fPaint->getTextSize(), fSpacingMul) + fSpacin gAdd;
258 return this->countLines() * spacing; 258 return this->countLines() * spacing;
259 } 259 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698