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

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

Issue 1206883002: Fix default text orientation that do not conform Unicode Technical Report #50 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 | « Source/platform/fonts/Character.cpp ('k') | Source/platform/fonts/FontDescription.h » ('j') | 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return Character::characterRangeCodePath(run.characters16(), run.length()); 337 return Character::characterRangeCodePath(run.characters16(), run.length());
338 } 338 }
339 339
340 void Font::willUseFontData(UChar32 character) const 340 void Font::willUseFontData(UChar32 character) const
341 { 341 {
342 const FontFamily& family = fontDescription().family(); 342 const FontFamily& family = fontDescription().family();
343 if (m_fontFallbackList && m_fontFallbackList->fontSelector() && !family.fami lyIsEmpty()) 343 if (m_fontFallbackList && m_fontFallbackList->fontSelector() && !family.fami lyIsEmpty())
344 m_fontFallbackList->fontSelector()->willUseFontData(fontDescription(), f amily.family(), character); 344 m_fontFallbackList->fontSelector()->willUseFontData(fontDescription(), f amily.family(), character);
345 } 345 }
346 346
347 static inline GlyphData glyphDataForNonCJKCharacterWithGlyphOrientation(UChar32 character, FontOrientation orientation, GlyphData& data, unsigned pageNumber) 347 static inline GlyphData glyphDataForNonCJKCharacterWithGlyphOrientation(UChar32 character, bool isUpright, GlyphData& data, unsigned pageNumber)
348 { 348 {
349 if (isVerticalNonCJKUpright(orientation) || Character::shouldIgnoreRotation( character)) { 349 if (isUpright) {
350 RefPtr<SimpleFontData> uprightFontData = data.fontData->uprightOrientati onFontData(); 350 RefPtr<SimpleFontData> uprightFontData = data.fontData->uprightOrientati onFontData();
351 GlyphPageTreeNode* uprightNode = GlyphPageTreeNode::getNormalRootChild(u prightFontData.get(), pageNumber); 351 GlyphPageTreeNode* uprightNode = GlyphPageTreeNode::getNormalRootChild(u prightFontData.get(), pageNumber);
352 GlyphPage* uprightPage = uprightNode->page(); 352 GlyphPage* uprightPage = uprightNode->page();
353 if (uprightPage) { 353 if (uprightPage) {
354 GlyphData uprightData = uprightPage->glyphDataForCharacter(character ); 354 GlyphData uprightData = uprightPage->glyphDataForCharacter(character );
355 // If the glyphs are the same, then we know we can just use the hori zontal glyph rotated vertically to be upright. 355 // If the glyphs are the same, then we know we can just use the hori zontal glyph rotated vertically to be upright.
356 if (data.glyph == uprightData.glyph) 356 if (data.glyph == uprightData.glyph)
357 return data; 357 return data;
358 // The glyphs are distinct, meaning that the font has a vertical-rig ht glyph baked into it. We can't use that 358 // The glyphs are distinct, meaning that the font has a vertical-rig ht glyph baked into it. We can't use that
359 // glyph, so we fall back to the upright data and use the horizontal glyph. 359 // glyph, so we fall back to the upright data and use the horizontal glyph.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 m_fontFallbackList->setPageNode(pageNumber, node); 411 m_fontFallbackList->setPageNode(pageNumber, node);
412 } 412 }
413 413
414 GlyphPage* page = 0; 414 GlyphPage* page = 0;
415 if (variant == NormalVariant) { 415 if (variant == NormalVariant) {
416 // Fastest loop, for the common case (normal variant). 416 // Fastest loop, for the common case (normal variant).
417 while (true) { 417 while (true) {
418 page = node->page(m_fontDescription.script()); 418 page = node->page(m_fontDescription.script());
419 if (page) { 419 if (page) {
420 GlyphData data = page->glyphDataForCharacter(c); 420 GlyphData data = page->glyphDataForCharacter(c);
421 if (data.fontData && (!data.fontData->platformData().isVerticalA nyUpright() || data.fontData->isTextOrientationFallback())) 421 if (data.fontData) {
422 return data; 422 if (!data.fontData->platformData().isVerticalAnyUpright() || data.fontData->isTextOrientationFallback())
423 return data;
423 424
424 if (data.fontData) { 425 bool isUpright = m_fontDescription.isVerticalUpright(c);
425 if (Character::isCJKIdeographOrSymbol(c)) { 426 if (isUpright && Character::isCJKIdeographOrSymbol(c)) {
426 if (!data.fontData->hasVerticalGlyphs()) { 427 if (!data.fontData->hasVerticalGlyphs()) {
427 // Use the broken ideograph font data. The broken id eograph font will use the horizontal width of glyphs 428 // Use the broken ideograph font data. The broken id eograph font will use the horizontal width of glyphs
428 // to make sure you get a square (even for broken gl yphs like symbols used for punctuation). 429 // to make sure you get a square (even for broken gl yphs like symbols used for punctuation).
429 variant = BrokenIdeographVariant; 430 variant = BrokenIdeographVariant;
430 break; 431 break;
431 } 432 }
432 } else { 433 } else {
433 return glyphDataForNonCJKCharacterWithGlyphOrientation(c , m_fontDescription.orientation(), data, pageNumber); 434 return glyphDataForNonCJKCharacterWithGlyphOrientation(c , isUpright, data, pageNumber);
434 } 435 }
435 436
436 return data; 437 return data;
437 } 438 }
438 439
439 if (node->isSystemFallback()) 440 if (node->isSystemFallback())
440 break; 441 break;
441 } 442 }
442 443
443 // Proceed with the fallback list. 444 // Proceed with the fallback list.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 characterFontData = characterFontData->variantFontData(m_fontDes cription, variant); 505 characterFontData = characterFontData->variantFontData(m_fontDes cription, variant);
505 } 506 }
506 if (characterFontData) { 507 if (characterFontData) {
507 // Got the fallback glyph and font. 508 // Got the fallback glyph and font.
508 GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterF ontData.get(), pageNumber)->page(); 509 GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterF ontData.get(), pageNumber)->page();
509 GlyphData data = fallbackPage && fallbackPage->glyphForCharacter(c) ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData() ; 510 GlyphData data = fallbackPage && fallbackPage->glyphForCharacter(c) ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData() ;
510 // Cache it so we don't have to do system fallback again next time. 511 // Cache it so we don't have to do system fallback again next time.
511 if (variant == NormalVariant) { 512 if (variant == NormalVariant) {
512 page->setGlyphDataForCharacter(c, data.glyph, data.fontData); 513 page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
513 data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData-> maxGlyphPageTreeLevel(), node->level())); 514 data.fontData->setMaxGlyphPageTreeLevel(std::max(data.fontData-> maxGlyphPageTreeLevel(), node->level()));
514 if (!Character::isCJKIdeographOrSymbol(c) && data.fontData->plat formData().isVerticalAnyUpright() && !data.fontData->isTextOrientationFallback() ) 515 if (data.fontData->platformData().isVerticalAnyUpright() && !dat a.fontData->isTextOrientationFallback() && !Character::isCJKIdeographOrSymbol(c) )
515 return glyphDataForNonCJKCharacterWithGlyphOrientation(c, m_ fontDescription.orientation(), data, pageNumber); 516 return glyphDataForNonCJKCharacterWithGlyphOrientation(c, m_ fontDescription.isVerticalUpright(c), data, pageNumber);
516 } 517 }
517 return data; 518 return data;
518 } 519 }
519 } 520 }
520 521
521 // Even system fallback can fail; use the missing glyph in that case. 522 // Even system fallback can fail; use the missing glyph in that case.
522 // FIXME: It would be nicer to use the missing glyph from the last resort fo nt instead. 523 // FIXME: It would be nicer to use the missing glyph from the last resort fo nt instead.
523 ASSERT(primaryFont()); 524 ASSERT(primaryFont());
524 GlyphData data = primaryFont()->missingGlyphData(); 525 GlyphData data = primaryFont()->missingGlyphData();
525 if (variant == NormalVariant) { 526 if (variant == NormalVariant) {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 { 841 {
841 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); 842 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts();
842 } 843 }
843 844
844 bool Font::isFallbackValid() const 845 bool Font::isFallbackValid() const
845 { 846 {
846 return !m_fontFallbackList || m_fontFallbackList->isValid(); 847 return !m_fontFallbackList || m_fontFallbackList->isValid();
847 } 848 }
848 849
849 } // namespace blink 850 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/Character.cpp ('k') | Source/platform/fonts/FontDescription.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698