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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/SimpleFontData.cpp

Issue 1889793006: Use SkPaint::measureText() for glyph overflow computations Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: let's see what else breaks Created 4 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
« 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 (C) 2005, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2006 Alexey Proskuryakov 3 * Copyright (C) 2006 Alexey Proskuryakov
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const Fo ntDescription& fontDescription, float scaleFactor) const 374 PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const Fo ntDescription& fontDescription, float scaleFactor) const
375 { 375 {
376 const float scaledSize = lroundf(fontDescription.computedSize() * scaleFacto r); 376 const float scaledSize = lroundf(fontDescription.computedSize() * scaleFacto r);
377 return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize), isCustomFont() ? CustomFontData::create() : nullptr); 377 return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize), isCustomFont() ? CustomFontData::create() : nullptr);
378 } 378 }
379 379
380 static inline void getSkiaBoundsForGlyph(SkPaint& paint, Glyph glyph, SkRect& bo unds) 380 static inline void getSkiaBoundsForGlyph(SkPaint& paint, Glyph glyph, SkRect& bo unds)
381 { 381 {
382 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); 382 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
383 383
384 SkPath path; 384 paint.measureText(&glyph, sizeof(glyph), &bounds);
385 paint.getTextPath(&glyph, sizeof(glyph), 0, 0, &path); 385 bounds = SkRect::MakeLTRB(bounds.left() - 5, bounds.top() - 5, bounds.right( ) + 10, bounds.bottom() + 10);
386 bounds = path.getBounds();
387
388 if (!paint.isSubpixelText()) { 386 if (!paint.isSubpixelText()) {
389 SkIRect ir; 387 SkIRect ir;
390 bounds.round(&ir); 388 bounds.round(&ir);
391 bounds.set(ir); 389 bounds.set(ir);
392 } 390 }
393 } 391 }
394 392
395 FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const 393 FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
396 { 394 {
397 if (!m_platformData.size()) 395 if (!m_platformData.size())
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 if (glyphs[i]) { 445 if (glyphs[i]) {
448 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); 446 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this);
449 haveGlyphs = true; 447 haveGlyphs = true;
450 } 448 }
451 } 449 }
452 450
453 return haveGlyphs; 451 return haveGlyphs;
454 } 452 }
455 453
456 } // namespace blink 454 } // namespace blink
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