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

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

Issue 1317833003: Fix   fallback glyph lookup (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 ASSERT(node->isSystemFallback()); 506 ASSERT(node->isSystemFallback());
507 507
508 // System fallback is character-dependent. When we get here, we 508 // System fallback is character-dependent. When we get here, we
509 // know that the character in question isn't in the system fallback 509 // know that the character in question isn't in the system fallback
510 // font's glyph page. Try to lazily create it here. 510 // font's glyph page. Try to lazily create it here.
511 511
512 // FIXME: Unclear if this should normalizeSpaces above 0xFFFF. 512 // FIXME: Unclear if this should normalizeSpaces above 0xFFFF.
513 // Doing so changes fast/text/international/plane2-diffs.html 513 // Doing so changes fast/text/international/plane2-diffs.html
514 UChar32 characterToRender = c; 514 UChar32 characterToRender = c;
515 if (characterToRender <= 0xFFFF) 515 if (characterToRender <= 0xFFFF)
516 characterToRender = Character::normalizeSpaces(characterToRender); 516 characterToRender = Character::normalizeSpaces(characterToRender);
kochi 2015/08/26 12:02:59 &nbsp; is translated to U+00A0, but at this point
517 517
518 const FontData* fontData = fontDataAt(0); 518 const FontData* fontData = fontDataAt(0);
519 if (fontData) { 519 if (fontData) {
520 const SimpleFontData* fontDataToSubstitute = fontData->fontDataForCharac ter(characterToRender); 520 const SimpleFontData* fontDataToSubstitute = fontData->fontDataForCharac ter(characterToRender);
521 RefPtr<SimpleFontData> characterFontData = FontCache::fontCache()->fallb ackFontForCharacter(m_fontDescription, characterToRender, fontDataToSubstitute); 521 RefPtr<SimpleFontData> characterFontData = FontCache::fontCache()->fallb ackFontForCharacter(m_fontDescription, characterToRender, fontDataToSubstitute);
522 if (characterFontData && variant != NormalVariant) { 522 if (characterFontData && variant != NormalVariant) {
523 characterFontData = characterFontData->variantFontData(m_fontDescrip tion, variant); 523 characterFontData = characterFontData->variantFontData(m_fontDescrip tion, variant);
524 } 524 }
525 if (characterFontData) { 525 if (characterFontData) {
526 // Got the fallback glyph and font. 526 // Got the fallback glyph and font.
527 GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterF ontData.get(), pageNumber)->page(); 527 GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterF ontData.get(), pageNumber)->page();
528 GlyphData data = fallbackPage && fallbackPage->glyphForCharacter(c) ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData() ; 528 GlyphData data = fallbackPage && fallbackPage->glyphForCharacter(cha racterToRender) ? fallbackPage->glyphDataForCharacter(characterToRender) : chara cterFontData->missingGlyphData();
kochi 2015/08/26 12:02:59 On this line, fallbackPage->glyphForCharacter(0xa0
kojii 2015/08/26 13:45:09 Yeah, this code path looks ok, so the caller shoul
kochi 2015/08/26 16:06:07 I think on Linux fallbackPage->glyphForCharacter(c
529 // Cache it so we don't have to do system fallback again next time. 529 // Cache it so we don't have to do system fallback again next time.
530 if (variant == NormalVariant) { 530 if (variant == NormalVariant) {
531 page->setGlyphDataForCharacter(c, data.glyph, data.fontData); 531 page->setGlyphDataForCharacter(characterToRender, data.glyph, da ta.fontData);
532 data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData-> maxGlyphPageTreeLevel(), node->level())); 532 data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData-> maxGlyphPageTreeLevel(), node->level()));
533 if (data.fontData->platformData().isVerticalAnyUpright() && !dat a.fontData->isTextOrientationFallback() && !Character::isCJKIdeographOrSymbol(c) ) 533 if (data.fontData->platformData().isVerticalAnyUpright() && !dat a.fontData->isTextOrientationFallback() && !Character::isCJKIdeographOrSymbol(ch aracterToRender))
534 return glyphDataForNonCJKCharacterWithGlyphOrientation(c, m_ fontDescription.isVerticalUpright(c), data, pageNumber); 534 return glyphDataForNonCJKCharacterWithGlyphOrientation(chara cterToRender, m_fontDescription.isVerticalUpright(characterToRender), data, page Number);
535 } 535 }
536 return data; 536 return data;
537 } 537 }
538 } 538 }
539 539
540 // Even system fallback can fail; use the missing glyph in that case. 540 // Even system fallback can fail; use the missing glyph in that case.
541 // FIXME: It would be nicer to use the missing glyph from the last resort fo nt instead. 541 // FIXME: It would be nicer to use the missing glyph from the last resort fo nt instead.
542 ASSERT(primaryFont()); 542 ASSERT(primaryFont());
543 GlyphData data = primaryFont()->missingGlyphData(); 543 GlyphData data = primaryFont()->missingGlyphData();
544 if (variant == NormalVariant) { 544 if (variant == NormalVariant) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 { 820 {
821 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); 821 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts();
822 } 822 }
823 823
824 bool Font::isFallbackValid() const 824 bool Font::isFallbackValid() const
825 { 825 {
826 return !m_fontFallbackList || m_fontFallbackList->isValid(); 826 return !m_fontFallbackList || m_fontFallbackList->isValid();
827 } 827 }
828 828
829 } // namespace blink 829 } // 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