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/harfbuzz/HarfBuzzShaper.cpp

Issue 478823003: Shape across HarfBuzz runs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: w/o cache changes Created 6 years, 4 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 | Annotate | Revision Log
« 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) 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 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 UErrorCode errorCode = U_ZERO_ERROR; 629 UErrorCode errorCode = U_ZERO_ERROR;
630 UScriptCode nextScript = uscript_getScript(character, &errorCode); 630 UScriptCode nextScript = uscript_getScript(character, &errorCode);
631 if (U_FAILURE(errorCode)) 631 if (U_FAILURE(errorCode))
632 return false; 632 return false;
633 633
634 do { 634 do {
635 const UChar* currentCharacterPosition = iterator.characters(); 635 const UChar* currentCharacterPosition = iterator.characters();
636 const SimpleFontData* currentFontData = nextFontData; 636 const SimpleFontData* currentFontData = nextFontData;
637 UScriptCode currentScript = nextScript; 637 UScriptCode currentScript = nextScript;
638 638
639 UChar32 lastCharacter = character;
640 for (iterator.advance(clusterLength); iterator.consume(character, cluste rLength); iterator.advance(clusterLength)) { 639 for (iterator.advance(clusterLength); iterator.consume(character, cluste rLength); iterator.advance(clusterLength)) {
641 if (Character::treatAsZeroWidthSpace(character)) 640 if (Character::treatAsZeroWidthSpace(character))
642 continue; 641 continue;
643 642
644 int length = handleMultipleUChar(character, clusterLength, currentFo ntData, currentCharacterPosition, iterator.characters() + clusterLength, normali zedBufferEnd); 643 int length = handleMultipleUChar(character, clusterLength, currentFo ntData, currentCharacterPosition, iterator.characters() + clusterLength, normali zedBufferEnd);
645 if (length) { 644 if (length) {
646 clusterLength = length; 645 clusterLength = length;
647 continue; 646 continue;
648 } 647 }
649 648
650 nextFontData = font->glyphDataForCharacter(character, false).fontDat a; 649 nextFontData = font->glyphDataForCharacter(character, false).fontDat a;
651 nextScript = uscript_getScript(character, &errorCode); 650 nextScript = uscript_getScript(character, &errorCode);
652 if (U_FAILURE(errorCode)) 651 if (U_FAILURE(errorCode))
653 return false; 652 return false;
654 if (lastCharacter == zeroWidthJoiner)
655 currentFontData = nextFontData;
656 if ((nextFontData != currentFontData) || ((currentScript != nextScri pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre ntScript)))) 653 if ((nextFontData != currentFontData) || ((currentScript != nextScri pt) && (nextScript != USCRIPT_INHERITED) && (!uscript_hasScript(character, curre ntScript))))
657 break; 654 break;
658 currentCharacterPosition = iterator.characters(); 655 currentCharacterPosition = iterator.characters();
659 lastCharacter = character;
660 } 656 }
661 657
662 CandidateRun run = { character, startIndexOfCurrentRun, iterator.current Character(), currentFontData, currentScript }; 658 CandidateRun run = { character, startIndexOfCurrentRun, iterator.current Character(), currentFontData, currentScript };
663 runs->append(run); 659 runs->append(run);
664 660
665 startIndexOfCurrentRun = iterator.currentCharacter(); 661 startIndexOfCurrentRun = iterator.currentCharacter();
666 } while (iterator.consume(character, clusterLength)); 662 } while (iterator.consume(character, clusterLength));
667 663
668 return true; 664 return true;
669 } 665 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 850
855 runCache.remove(cachedResults); 851 runCache.remove(cachedResults);
856 } 852 }
857 853
858 // Add a space as pre-context to the buffer. This prevents showing dotte d-circle 854 // Add a space as pre-context to the buffer. This prevents showing dotte d-circle
859 // for combining marks at the beginning of runs. 855 // for combining marks at the beginning of runs.
860 static const uint16_t preContext = ' '; 856 static const uint16_t preContext = ' ';
861 hb_buffer_add_utf16(harfBuzzBuffer.get(), &preContext, 1, 1, 0); 857 hb_buffer_add_utf16(harfBuzzBuffer.get(), &preContext, 1, 1, 0);
862 858
863 if (fontDescription.variant() == FontVariantSmallCaps && u_islower(m_nor malizedBuffer[currentRun->startIndex()])) { 859 if (fontDescription.variant() == FontVariantSmallCaps && u_islower(m_nor malizedBuffer[currentRun->startIndex()])) {
864 String upperText = String(m_normalizedBuffer.get() + currentRun->sta rtIndex(), currentRun->numCharacters()).upper(); 860 String upperText = String(m_normalizedBuffer.get(), m_normalizedBuff erLength).upper();
865 ASSERT(!upperText.is8Bit()); // m_normalizedBuffer is 16 bit, theref ore upperText is 16 bit, even after we call makeUpper(). 861 ASSERT(!upperText.is8Bit()); // m_normalizedBuffer is 16 bit, theref ore upperText is 16 bit, even after we call makeUpper().
866 hb_buffer_add_utf16(harfBuzzBuffer.get(), toUint16(upperText.charact ers16()), currentRun->numCharacters(), 0, currentRun->numCharacters()); 862 hb_buffer_add_utf16(harfBuzzBuffer.get(), toUint16(upperText.charact ers16()), currentRun->startIndex(), currentRun->startIndex(), 0);
863 hb_buffer_add_utf16(harfBuzzBuffer.get(), toUint16(upperText.charact ers16() + currentRun->startIndex()), m_normalizedBufferLength - currentRun->star tIndex(), 0, currentRun->numCharacters());
867 } else { 864 } else {
868 hb_buffer_add_utf16(harfBuzzBuffer.get(), toUint16(m_normalizedBuffe r.get() + currentRun->startIndex()), currentRun->numCharacters(), 0, currentRun- >numCharacters()); 865 hb_buffer_add_utf16(harfBuzzBuffer.get(), toUint16(m_normalizedBuffe r.get()), currentRun->startIndex(), currentRun->startIndex(), 0);
866 hb_buffer_add_utf16(harfBuzzBuffer.get(), toUint16(m_normalizedBuffe r.get() + currentRun->startIndex()), m_normalizedBufferLength - currentRun->star tIndex(), 0, currentRun->numCharacters());
869 } 867 }
870 868
871 if (fontDescription.orientation() == Vertical) 869 if (fontDescription.orientation() == Vertical)
872 face->setScriptForVerticalGlyphSubstitution(harfBuzzBuffer.get()); 870 face->setScriptForVerticalGlyphSubstitution(harfBuzzBuffer.get());
873 871
874 HarfBuzzScopedPtr<hb_font_t> harfBuzzFont(face->createFont(), hb_font_de stroy); 872 HarfBuzzScopedPtr<hb_font_t> harfBuzzFont(face->createFont(), hb_font_de stroy);
875 873
876 hb_shape(harfBuzzFont.get(), harfBuzzBuffer.get(), m_features.isEmpty() ? 0 : m_features.data(), m_features.size()); 874 hb_shape(harfBuzzFont.get(), harfBuzzBuffer.get(), m_features.isEmpty() ? 0 : m_features.data(), m_features.size());
877 currentRun->applyShapeResult(harfBuzzBuffer.get()); 875 currentRun->applyShapeResult(harfBuzzBuffer.get());
878 setGlyphPositionsForHarfBuzzRun(currentRun, harfBuzzBuffer.get()); 876 setGlyphPositionsForHarfBuzzRun(currentRun, harfBuzzBuffer.get());
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 point.x() + fromX, point.x() + toX, 1139 point.x() + fromX, point.x() + toX,
1142 point.y(), height); 1140 point.y(), height);
1143 } 1141 }
1144 1142
1145 return Font::pixelSnappedSelectionRect( 1143 return Font::pixelSnappedSelectionRect(
1146 point.x() + toX, point.x() + fromX, 1144 point.x() + toX, point.x() + fromX,
1147 point.y(), height); 1145 point.y(), height);
1148 } 1146 }
1149 1147
1150 } // namespace blink 1148 } // 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