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

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

Issue 1310803003: Fix handling of word-spacing and nbsp for complex text (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | « LayoutTests/fast/text/word-spacing-nbsp-expected.html ('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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 source = run.characters16(); 595 source = run.characters16();
596 } 596 }
597 597
598 *destinationLength = 0; 598 *destinationLength = 0;
599 while (position < length) { 599 while (position < length) {
600 UChar32 character; 600 UChar32 character;
601 U16_NEXT(source, position, length, character); 601 U16_NEXT(source, position, length, character);
602 // Don't normalize tabs as they are not treated as spaces for word-end. 602 // Don't normalize tabs as they are not treated as spaces for word-end.
603 if (run.normalizeSpace() && Character::isNormalizedCanvasSpaceCharacter( character)) 603 if (run.normalizeSpace() && Character::isNormalizedCanvasSpaceCharacter( character))
604 character = spaceCharacter; 604 character = spaceCharacter;
605 else if (Character::treatAsSpace(character)) 605 else if (Character::treatAsSpace(character) && character != noBreakSpace Character)
606 character = spaceCharacter; 606 character = spaceCharacter;
607 else if (Character::treatAsZeroWidthSpaceInComplexScript(character)) 607 else if (Character::treatAsZeroWidthSpaceInComplexScript(character))
608 character = zeroWidthSpaceCharacter; 608 character = zeroWidthSpaceCharacter;
609 609
610 U16_APPEND(destination, *destinationLength, length, character, error); 610 U16_APPEND(destination, *destinationLength, length, character, error);
611 ASSERT_UNUSED(error, !error); 611 ASSERT_UNUSED(error, !error);
612 } 612 }
613 } 613 }
614 614
615 HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run) 615 HarfBuzzShaper::HarfBuzzShaper(const Font* font, const TextRun& run)
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 } 1165 }
1166 1166
1167 float HarfBuzzShaper::adjustSpacing(ShapeResult::RunInfo* run, size_t glyphIndex , unsigned currentCharacterIndex, float& offset, float& totalAdvance) 1167 float HarfBuzzShaper::adjustSpacing(ShapeResult::RunInfo* run, size_t glyphIndex , unsigned currentCharacterIndex, float& offset, float& totalAdvance)
1168 { 1168 {
1169 float spacing = 0; 1169 float spacing = 0;
1170 UChar32 character = m_normalizedBuffer[currentCharacterIndex]; 1170 UChar32 character = m_normalizedBuffer[currentCharacterIndex];
1171 if (m_letterSpacing && !Character::treatAsZeroWidthSpace(character)) 1171 if (m_letterSpacing && !Character::treatAsZeroWidthSpace(character))
1172 spacing += m_letterSpacing; 1172 spacing += m_letterSpacing;
1173 1173
1174 bool treatAsSpace = Character::treatAsSpace(character); 1174 bool treatAsSpace = Character::treatAsSpace(character);
1175 if (treatAsSpace && currentCharacterIndex && (character != '\t' || !m_textRu n.allowTabs())) 1175 if (treatAsSpace && (currentCharacterIndex || character == noBreakSpaceChara cter) && (character != '\t' || !m_textRun.allowTabs()))
pdr. 2015/08/22 02:29:46 This change took me a while to understand, but I'm
1176 spacing += m_wordSpacingAdjustment; 1176 spacing += m_wordSpacingAdjustment;
1177 1177
1178 if (!m_expansionOpportunityCount) 1178 if (!m_expansionOpportunityCount)
1179 return spacing; 1179 return spacing;
1180 1180
1181 if (treatAsSpace) { 1181 if (treatAsSpace) {
1182 spacing += nextExpansionPerOpportunity(); 1182 spacing += nextExpansionPerOpportunity();
1183 m_isAfterExpansion = true; 1183 m_isAfterExpansion = true;
1184 return spacing; 1184 return spacing;
1185 } 1185 }
(...skipping 28 matching lines...) Expand all
1214 return spacing; 1214 return spacing;
1215 } 1215 }
1216 1216
1217 // Don't need to check m_textRun.allowsTrailingExpansion() since it's covere d by !m_expansionOpportunityCount above 1217 // Don't need to check m_textRun.allowsTrailingExpansion() since it's covere d by !m_expansionOpportunityCount above
1218 spacing += nextExpansionPerOpportunity(); 1218 spacing += nextExpansionPerOpportunity();
1219 m_isAfterExpansion = true; 1219 m_isAfterExpansion = true;
1220 return spacing; 1220 return spacing;
1221 } 1221 }
1222 1222
1223 } // namespace blink 1223 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/text/word-spacing-nbsp-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698