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

Side by Side Diff: Source/platform/fonts/shaping/HarfBuzzShaper.cpp

Issue 676343002: Use following font data and script for heading zero-width spaces while collecting candidate runs. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « LayoutTests/platform/linux/fast/text/international/bidi-neutral-run-expected.txt ('k') | 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) 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved.
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 are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * 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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 { 616 {
617 const UChar* normalizedBufferEnd = normalizedBuffer + bufferLength; 617 const UChar* normalizedBufferEnd = normalizedBuffer + bufferLength;
618 SurrogatePairAwareTextIterator iterator(normalizedBuffer, 0, bufferLength, b ufferLength); 618 SurrogatePairAwareTextIterator iterator(normalizedBuffer, 0, bufferLength, b ufferLength);
619 UChar32 character; 619 UChar32 character;
620 unsigned clusterLength = 0; 620 unsigned clusterLength = 0;
621 unsigned startIndexOfCurrentRun = 0; 621 unsigned startIndexOfCurrentRun = 0;
622 622
623 if (!iterator.consume(character, clusterLength)) 623 if (!iterator.consume(character, clusterLength))
624 return false; 624 return false;
625 625
626 bool collectionForHeadingZWS = false;
627 if (Character::treatAsZeroWidthSpace(character))
628 collectionForHeadingZWS = true;
629
626 const SimpleFontData* nextFontData = font->glyphDataForCharacter(character, false, isSpaceNormalize).fontData; 630 const SimpleFontData* nextFontData = font->glyphDataForCharacter(character, false, isSpaceNormalize).fontData;
627 UErrorCode errorCode = U_ZERO_ERROR; 631 UErrorCode errorCode = U_ZERO_ERROR;
628 UScriptCode nextScript = uscript_getScript(character, &errorCode); 632 UScriptCode nextScript = uscript_getScript(character, &errorCode);
629 if (U_FAILURE(errorCode)) 633 if (U_FAILURE(errorCode))
630 return false; 634 return false;
631 635
632 do { 636 do {
633 const UChar* currentCharacterPosition = iterator.characters(); 637 const UChar* currentCharacterPosition = iterator.characters();
634 const SimpleFontData* currentFontData = nextFontData; 638 const SimpleFontData* currentFontData = nextFontData;
635 UScriptCode currentScript = nextScript; 639 UScriptCode currentScript = nextScript;
636 640
637 UChar32 lastCharacter = character; 641 UChar32 lastCharacter = character;
638 for (iterator.advance(clusterLength); iterator.consume(character, cluste rLength); iterator.advance(clusterLength)) { 642 for (iterator.advance(clusterLength); iterator.consume(character, cluste rLength); iterator.advance(clusterLength)) {
639 if (Character::treatAsZeroWidthSpace(character)) 643 if (Character::treatAsZeroWidthSpace(character))
640 continue; 644 continue;
641 645
642 int length = handleMultipleUChar(character, clusterLength, currentFo ntData, currentCharacterPosition, iterator.characters() + clusterLength, normali zedBufferEnd); 646 int length = handleMultipleUChar(character, clusterLength, currentFo ntData, currentCharacterPosition, iterator.characters() + clusterLength, normali zedBufferEnd);
643 if (length) { 647 if (length) {
644 clusterLength = length; 648 clusterLength = length;
645 continue; 649 continue;
646 } 650 }
647 651
648 nextFontData = font->glyphDataForCharacter(character, false, isSpace Normalize).fontData; 652 nextFontData = font->glyphDataForCharacter(character, false, isSpace Normalize).fontData;
649 nextScript = uscript_getScript(character, &errorCode); 653 nextScript = uscript_getScript(character, &errorCode);
650 if (U_FAILURE(errorCode)) 654 if (U_FAILURE(errorCode))
651 return false; 655 return false;
652 if (lastCharacter == zeroWidthJoiner) 656 if (lastCharacter == zeroWidthJoiner)
653 currentFontData = nextFontData; 657 currentFontData = nextFontData;
654 if ((nextFontData != currentFontData) || ((currentScript != nextScri pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre ntScript)))) 658 if ((nextFontData != currentFontData) || ((currentScript != nextScri pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre ntScript)))) {
655 break; 659 if (!collectionForHeadingZWS)
660 break;
661 currentFontData = nextFontData;
662 currentScript = nextScript;
663 collectionForHeadingZWS = false;
664 }
656 currentCharacterPosition = iterator.characters(); 665 currentCharacterPosition = iterator.characters();
657 lastCharacter = character; 666 lastCharacter = character;
658 } 667 }
659 668
660 CandidateRun run = { character, startIndexOfCurrentRun, iterator.current Character(), currentFontData, currentScript }; 669 CandidateRun run = { character, startIndexOfCurrentRun, iterator.current Character(), currentFontData, currentScript };
661 runs->append(run); 670 runs->append(run);
662 671
663 startIndexOfCurrentRun = iterator.currentCharacter(); 672 startIndexOfCurrentRun = iterator.currentCharacter();
664 } while (iterator.consume(character, clusterLength)); 673 } while (iterator.consume(character, clusterLength));
665 674
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 fromX = 0; 1153 fromX = 0;
1145 if (!foundToX) 1154 if (!foundToX)
1146 toX = m_run.rtl() ? 0 : m_totalWidth; 1155 toX = m_run.rtl() ? 0 : m_totalWidth;
1147 1156
1148 if (fromX < toX) 1157 if (fromX < toX)
1149 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); 1158 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height);
1150 return FloatRect(point.x() + toX, point.y(), fromX - toX, height); 1159 return FloatRect(point.x() + toX, point.y(), fromX - toX, height);
1151 } 1160 }
1152 1161
1153 } // namespace blink 1162 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/platform/linux/fast/text/international/bidi-neutral-run-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698