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

Unified Diff: Source/platform/fonts/shaping/SimpleShaper.cpp

Issue 255323004: Rendering text-justify:distribute for 8 bit characters. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: patch for landing 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/fonts/Character.cpp ('k') | Source/platform/text/TextRun.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/shaping/SimpleShaper.cpp
diff --git a/Source/platform/fonts/shaping/SimpleShaper.cpp b/Source/platform/fonts/shaping/SimpleShaper.cpp
index f4dce5d62f90c7a548ed231ada8e19ae7b733152..e60432830685c497726631141c47cf33a232c765 100644
--- a/Source/platform/fonts/shaping/SimpleShaper.cpp
+++ b/Source/platform/fonts/shaping/SimpleShaper.cpp
@@ -55,7 +55,7 @@ SimpleShaper::SimpleShaper(const Font* font, const TextRun& run,
m_expansionPerOpportunity = 0;
} else {
bool isAfterExpansion = m_isAfterExpansion;
- unsigned expansionOpportunityCount = m_run.is8Bit() ? Character::expansionOpportunityCount(m_run.characters8(), m_run.length(), m_run.direction(), isAfterExpansion) : Character::expansionOpportunityCount(m_run.characters16(), m_run.length(), m_run.direction(), isAfterExpansion);
+ unsigned expansionOpportunityCount = m_run.is8Bit() ? Character::expansionOpportunityCount(m_run.characters8(), m_run.length(), m_run.direction(), isAfterExpansion, m_run.textJustify()) : Character::expansionOpportunityCount(m_run.characters16(), m_run.length(), m_run.direction(), isAfterExpansion, m_run.textJustify());
if (isAfterExpansion && !m_run.allowsTrailingExpansion())
expansionOpportunityCount--;
@@ -104,11 +104,11 @@ float SimpleShaper::adjustSpacing(float width, const CharacterData& charData)
if (width)
width += m_font->fontDescription().letterSpacing();
- bool treatAsSpace = Character::treatAsSpace(charData.character);
- if (treatAsSpace) {
+ bool isExpansionOpportunity = Character::treatAsSpace(charData.character) || (m_run.textJustify() == TextJustifyDistribute);
+ if (isExpansionOpportunity) {
// Distribute the run's total expansion evenly over all expansion opportunities in the run.
if (m_expansion) {
- if (!treatAsSpace && !m_isAfterExpansion) {
+ if (!isExpansionOpportunity && !m_isAfterExpansion) {
// Take the expansion opportunity before this ideograph.
m_expansion -= m_expansionPerOpportunity;
m_runWidthSoFar += m_expansionPerOpportunity;
@@ -126,7 +126,7 @@ float SimpleShaper::adjustSpacing(float width, const CharacterData& charData)
// Account for word spacing.
// We apply additional space between "words" by adding width to the space character.
- if (treatAsSpace && (charData.character != '\t' || !m_run.allowTabs())
+ if (isExpansionOpportunity && (charData.character != '\t' || !m_run.allowTabs())
&& (charData.characterOffset || charData.character == noBreakSpace)
&& m_font->fontDescription().wordSpacing()) {
width += m_font->fontDescription().wordSpacing();
« no previous file with comments | « Source/platform/fonts/Character.cpp ('k') | Source/platform/text/TextRun.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698