| OLD | NEW |
| 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 } | 366 } |
| 367 | 367 |
| 368 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri
ption& fontDescription, float scaleFactor) const | 368 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri
ption& fontDescription, float scaleFactor) const |
| 369 { | 369 { |
| 370 const float scaledSize = lroundf(fontDescription.computedSize() * scaleFacto
r); | 370 const float scaledSize = lroundf(fontDescription.computedSize() * scaleFacto
r); |
| 371 return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize),
isCustomFont() ? CustomFontData::create() : nullptr); | 371 return SimpleFontData::create(FontPlatformData(m_platformData, scaledSize),
isCustomFont() ? CustomFontData::create() : nullptr); |
| 372 } | 372 } |
| 373 | 373 |
| 374 FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const | 374 FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const |
| 375 { | 375 { |
| 376 if (!m_platformData.size()) |
| 377 return FloatRect(); |
| 378 |
| 379 static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated."); |
| 380 |
| 376 SkRect bounds; | 381 SkRect bounds; |
| 377 SkiaTextMetrics(&m_paint).getSkiaBoundsForGlyph(glyph, &bounds); | 382 SkiaTextMetrics(&m_paint).getSkiaBoundsForGlyph(glyph, &bounds); |
| 378 return FloatRect(bounds); | 383 return FloatRect(bounds); |
| 379 } | 384 } |
| 380 | 385 |
| 381 float SimpleFontData::platformWidthForGlyph(Glyph glyph) const | 386 float SimpleFontData::platformWidthForGlyph(Glyph glyph) const |
| 382 { | 387 { |
| 388 if (!m_platformData.size()) |
| 389 return 0; |
| 390 |
| 391 static_assert(sizeof(glyph) == 2, "Glyph id should not be truncated."); |
| 392 |
| 383 return SkiaTextMetrics(&m_paint).getSkiaWidthForGlyph(glyph); | 393 return SkiaTextMetrics(&m_paint).getSkiaWidthForGlyph(glyph); |
| 384 } | 394 } |
| 385 | 395 |
| 386 | 396 |
| 387 bool SimpleFontData::fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsig
ned length, UChar* buffer, unsigned bufferLength) const | 397 bool SimpleFontData::fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsig
ned length, UChar* buffer, unsigned bufferLength) const |
| 388 { | 398 { |
| 389 if (U16_IS_LEAD(buffer[bufferLength-1])) { | 399 if (U16_IS_LEAD(buffer[bufferLength-1])) { |
| 390 DLOG(ERROR) << "Last UTF-16 code unit is high-surrogate."; | 400 DLOG(ERROR) << "Last UTF-16 code unit is high-surrogate."; |
| 391 return false; | 401 return false; |
| 392 } | 402 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 406 if (glyphs[i]) { | 416 if (glyphs[i]) { |
| 407 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); | 417 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); |
| 408 haveGlyphs = true; | 418 haveGlyphs = true; |
| 409 } | 419 } |
| 410 } | 420 } |
| 411 | 421 |
| 412 return haveGlyphs; | 422 return haveGlyphs; |
| 413 } | 423 } |
| 414 | 424 |
| 415 } // namespace blink | 425 } // namespace blink |
| OLD | NEW |