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

Side by Side Diff: Source/core/platform/graphics/Font.cpp

Issue 54743004: Rendering text-justify:distribute for 8 bit characters. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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) 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 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 (UChar32*)cjkSymbolRanges, cjkSymbolRangesCount, c, keyExtractorUChar32) ; 594 (UChar32*)cjkSymbolRanges, cjkSymbolRangesCount, c, keyExtractorUChar32) ;
595 // Exact matches are CJK Symbols 595 // Exact matches are CJK Symbols
596 if (*boundingCharacter == c) 596 if (*boundingCharacter == c)
597 return true; 597 return true;
598 bool isEndOfRange = ((boundingCharacter - cjkSymbolRanges) % 2); 598 bool isEndOfRange = ((boundingCharacter - cjkSymbolRanges) % 2);
599 if (*boundingCharacter < c) 599 if (*boundingCharacter < c)
600 return !isEndOfRange; 600 return !isEndOfRange;
601 return isEndOfRange; 601 return isEndOfRange;
602 } 602 }
603 603
604 unsigned Font::expansionOpportunityCount(const LChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion) 604 unsigned Font::expansionOpportunityCount(const LChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion, bool distributeJustification)
605 { 605 {
606 unsigned count = 0; 606 unsigned count = 0;
607 if (direction == LTR) { 607 if (direction == LTR) {
608 for (size_t i = 0; i < length; ++i) { 608 for (size_t i = 0; i < length; ++i) {
609 if (treatAsSpace(characters[i])) { 609 if (treatAsSpace(characters[i]) || distributeJustification)
610 count++; 610 count++;
611 isAfterExpansion = true;
612 } else
613 isAfterExpansion = false;
614 } 611 }
612 if (treatAsSpace(characters[length - 1]))
613 isAfterExpansion = true;
614 else
615 isAfterExpansion = false;
615 } else { 616 } else {
616 for (size_t i = length; i > 0; --i) { 617 for (size_t i = length; i > 0; --i) {
617 if (treatAsSpace(characters[i - 1])) { 618 if (treatAsSpace(characters[i - 1]) || distributeJustification)
618 count++; 619 count++;
619 isAfterExpansion = true;
620 } else
621 isAfterExpansion = false;
622 } 620 }
621 if (treatAsSpace(characters[0]))
622 isAfterExpansion = true;
623 else
624 isAfterExpansion = false;
623 } 625 }
624 return count; 626 return count;
625 } 627 }
626 628
627 unsigned Font::expansionOpportunityCount(const UChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion) 629 unsigned Font::expansionOpportunityCount(const UChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion, bool distributeJustification)
628 { 630 {
629 static bool expandAroundIdeographs = canExpandAroundIdeographsInComplexText( ); 631 static bool expandAroundIdeographs = canExpandAroundIdeographsInComplexText( );
630 unsigned count = 0; 632 unsigned count = 0;
631 if (direction == LTR) { 633 if (direction == LTR) {
632 for (size_t i = 0; i < length; ++i) { 634 for (size_t i = 0; i < length; ++i) {
633 UChar32 character = characters[i]; 635 UChar32 character = characters[i];
634 if (treatAsSpace(character)) { 636 if (treatAsSpace(character)) {
635 count++; 637 count++;
636 isAfterExpansion = true; 638 isAfterExpansion = true;
637 continue; 639 continue;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 691 }
690 692
691 void Font::willUseFontData() const 693 void Font::willUseFontData() const
692 { 694 {
693 const FontFamily& family = fontDescription().family(); 695 const FontFamily& family = fontDescription().family();
694 if (m_fontFallbackList && m_fontFallbackList->fontSelector() && !family.fami lyIsEmpty()) 696 if (m_fontFallbackList && m_fontFallbackList->fontSelector() && !family.fami lyIsEmpty())
695 m_fontFallbackList->fontSelector()->willUseFontData(fontDescription(), f amily.family()); 697 m_fontFallbackList->fontSelector()->willUseFontData(fontDescription(), f amily.family());
696 } 698 }
697 699
698 } 700 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698