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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/graphics/Font.cpp
diff --git a/Source/core/platform/graphics/Font.cpp b/Source/core/platform/graphics/Font.cpp
index 3ba67d93f3a28aaae6fdd7adb7ce6b4ed78e10a2..f08e1c078634a5c0b0f305c7871c955818e6c59e 100644
--- a/Source/core/platform/graphics/Font.cpp
+++ b/Source/core/platform/graphics/Font.cpp
@@ -601,30 +601,32 @@ bool Font::isCJKIdeographOrSymbol(UChar32 c)
return isEndOfRange;
}
-unsigned Font::expansionOpportunityCount(const LChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion)
+unsigned Font::expansionOpportunityCount(const LChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion, bool distributeJustification)
{
unsigned count = 0;
if (direction == LTR) {
for (size_t i = 0; i < length; ++i) {
- if (treatAsSpace(characters[i])) {
+ if (treatAsSpace(characters[i]) || distributeJustification)
count++;
- isAfterExpansion = true;
- } else
- isAfterExpansion = false;
}
+ if (treatAsSpace(characters[length - 1]))
+ isAfterExpansion = true;
+ else
+ isAfterExpansion = false;
} else {
for (size_t i = length; i > 0; --i) {
- if (treatAsSpace(characters[i - 1])) {
+ if (treatAsSpace(characters[i - 1]) || distributeJustification)
count++;
- isAfterExpansion = true;
- } else
- isAfterExpansion = false;
}
+ if (treatAsSpace(characters[0]))
+ isAfterExpansion = true;
+ else
+ isAfterExpansion = false;
}
return count;
}
-unsigned Font::expansionOpportunityCount(const UChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion)
+unsigned Font::expansionOpportunityCount(const UChar* characters, size_t length, TextDirection direction, bool& isAfterExpansion, bool distributeJustification)
{
static bool expandAroundIdeographs = canExpandAroundIdeographsInComplexText();
unsigned count = 0;

Powered by Google App Engine
This is Rietveld 408576698