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

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

Issue 870523003: Check for Unicode in Font before ICU call (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Test patch - Convert to NFC for if diacritical marks are present Created 5 years, 10 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
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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 SkPaint paint; 453 SkPaint paint;
454 m_platformData.setupPaint(&paint); 454 m_platformData.setupPaint(&paint);
455 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding); 455 paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
456 if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) { 456 if (paint.textToGlyphs(&normalizedCharacters[0], normalizedLength * 2, 0)) {
457 addResult.storedValue->value = true; 457 addResult.storedValue->value = true;
458 return true; 458 return true;
459 } 459 }
460 return false; 460 return false;
461 } 461 }
462 462
463 bool SimpleFontData::fontHasGlyphForCharacter(UChar32 character) const
464 {
465 unsigned pageNumber = (character / GlyphPage::size);
eae 2015/02/10 15:40:12 Remove unnecessary parentheses.
h.joshi 2015/02/17 03:44:47 Done.
466
467 GlyphPageTreeNode* node = GlyphPageTreeNode::getNormalRootChild(this, pageNu mber);
468 GlyphPage* page = node->page();
469
470 return page && page->glyphForCharacter(character);
471 }
472
463 bool SimpleFontData::fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsig ned length, UChar* buffer, unsigned bufferLength) const 473 bool SimpleFontData::fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsig ned length, UChar* buffer, unsigned bufferLength) const
464 { 474 {
465 if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) { 475 if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) {
466 SkDebugf("%s last char is high-surrogate", __FUNCTION__); 476 SkDebugf("%s last char is high-surrogate", __FUNCTION__);
467 return false; 477 return false;
468 } 478 }
469 479
470 SkTypeface* typeface = platformData().typeface(); 480 SkTypeface* typeface = platformData().typeface();
471 if (!typeface) { 481 if (!typeface) {
472 WTF_LOG_ERROR("fillGlyphPage called on an empty Skia typeface."); 482 WTF_LOG_ERROR("fillGlyphPage called on an empty Skia typeface.");
473 return false; 483 return false;
474 } 484 }
475 485
476 SkAutoSTMalloc<GlyphPage::size, uint16_t> glyphStorage(length); 486 SkAutoSTMalloc<GlyphPage::size, uint16_t> glyphStorage(length);
477 uint16_t* glyphs = glyphStorage.get(); 487 uint16_t* glyphs = glyphStorage.get();
478 typeface->charsToGlyphs(buffer, SkTypeface::kUTF16_Encoding, glyphs, length) ; 488 typeface->charsToGlyphs(buffer, SkTypeface::kUTF16_Encoding, glyphs, length) ;
479 489
480 bool haveGlyphs = false; 490 bool haveGlyphs = false;
481 for (unsigned i = 0; i < length; i++) { 491 for (unsigned i = 0; i < length; i++) {
482 if (glyphs[i]) { 492 if (glyphs[i]) {
483 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this); 493 pageToFill->setGlyphDataForIndex(offset + i, glyphs[i], this);
484 haveGlyphs = true; 494 haveGlyphs = true;
485 } 495 }
486 } 496 }
487 497
488 return haveGlyphs; 498 return haveGlyphs;
489 } 499 }
490 500
491 } // namespace blink 501 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698