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

Side by Side Diff: Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp

Issue 11419217: Merge 133494 - Implement SimpleFontData::platformBoundsForGlyph on skia (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1312/
Patch Set: Created 8 years 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) 2008, 2009, Google Inc. All rights reserved. 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 227 }
228 228
229 return true; 229 return true;
230 } 230 }
231 231
232 void SimpleFontData::determinePitch() 232 void SimpleFontData::determinePitch()
233 { 233 {
234 m_treatAsFixedPitch = platformData().isFixedPitch(); 234 m_treatAsFixedPitch = platformData().isFixedPitch();
235 } 235 }
236 236
237 FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const 237 FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
238 { 238 {
239 return FloatRect(); 239 if (!m_platformData.size())
240 return FloatRect();
241
242 SkASSERT(sizeof(glyph) == 2); // compile-time assert
243
244 SkPaint paint;
245
246 m_platformData.setupPaint(&paint);
247
248 paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
249 SkRect bounds;
250 paint.measureText(&glyph, 2, &bounds);
251 if (!paint.isSubpixelText()) {
252 SkIRect ir;
253 bounds.round(&ir);
254 bounds.set(ir);
255 }
256 return FloatRect(bounds);
240 } 257 }
241 258
242 float SimpleFontData::platformWidthForGlyph(Glyph glyph) const 259 float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
243 { 260 {
244 if (!m_platformData.size()) 261 if (!m_platformData.size())
245 return 0; 262 return 0;
246 263
247 SkASSERT(sizeof(glyph) == 2); // compile-time assert 264 SkASSERT(sizeof(glyph) == 2); // compile-time assert
248 265
249 SkPaint paint; 266 SkPaint paint;
(...skipping 29 matching lines...) Expand all
279 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); 296 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
280 if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) { 297 if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) {
281 addResult.iterator->value = true; 298 addResult.iterator->value = true;
282 return true; 299 return true;
283 } 300 }
284 return false; 301 return false;
285 } 302 }
286 #endif 303 #endif
287 304
288 } // namespace WebCore 305 } // namespace WebCore
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