Skip to content

Commit 339e3c3

Browse files
egdanielSkCQ
authored andcommitted
Revert "Reland "[skparagraph] Render visible hyphen at soft hyphen (U+00AD) line breaks""
This reverts commit 9a0def8. Reason for revert: breaking ubuntu native font jobs with failures like ../../../../../skia/modules/skparagraph/tests/SkParagraphTest.cpp:8625 [SkParagraph_SoftHyphenAtLineBreak]: impl->lines().size() == 2 Original change's description: > Reland "[skparagraph] Render visible hyphen at soft hyphen (U+00AD) line breaks" > > This is a reland of commit cc0c72c > > The original CL was reverted because soft hyphen tests failed on > Ubuntu-NativeFonts bots. The fix: use ResourceFontCollection(true) > (test fonts only) instead of ResourceFontCollection() (which falls > back to native fonts with different metrics). > > Original change's description: > > When text is laid out and a line break occurs at a soft hyphen > > (U+00AD) position, a visible hyphen glyph ("-") is now shaped > > and appended to the end of that line. Soft hyphens that are not > > at line break positions remain invisible (zero-width), as before. > > > > This behavior is gated behind ParagraphStyle::setRenderSoftHyphens(), > > which defaults to false to preserve existing behavior for current > > consumers. Callers must opt in to enable visible hyphen rendering. > > > > The implementation follows the existing ellipsis pattern: > > - Added Cluster::isSoftHyphen() to detect U+00AD clusters > > - Added TextLine::fHyphen (parallel to fEllipsis) to store the > > shaped hyphen Run > > - TextLine::createSoftHyphen() reuses shapeEllipsis() to shape > > a "-" character with the correct font/style from the last cluster > > - The hyphen is included in line width calculation and visual > > run iteration for both LTR and RTL text > > - Ellipsis takes precedence over soft hyphen when both apply > > > > This addresses Flutter issue: > > flutter/flutter#18443 > > Change-Id: I04d20838985bf32710bd5045dbcd891fe0922016 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1202938 > Reviewed-by: Julia Lavrova <[email protected]> > Reviewed-by: Kaylee Lubick <[email protected]> > Commit-Queue: Julia Lavrova <[email protected]> No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: I35bc5cada37044dad7cf2c4988b740795a0207ca Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1206936 Bot-Commit: Rubber Stamper <[email protected]> Auto-Submit: Greg Daniel <[email protected]> Commit-Queue: Rubber Stamper <[email protected]>
1 parent 2c53f5f commit 339e3c3

8 files changed

Lines changed: 9 additions & 292 deletions

File tree

‎AUTHORS‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ Wey <[email protected]>
128128
LinXunFeng <[email protected]>
129129
Xiaohan Wang <[email protected]>
130130
Faijur Rahman <[email protected]>
131-
David Bebawy <[email protected]>
132131

133132
# Trusted service accounts.
134133
GitHub Dependabot <(\d+)\+dependabot\[bot\]@users.noreply.github.com>

‎modules/skparagraph/include/ParagraphStyle.h‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,14 @@ struct ParagraphStyle {
7979
ParagraphStyle();
8080

8181
bool operator==(const ParagraphStyle& rhs) const {
82-
return this->fHeight == rhs.fHeight && this->fEllipsis == rhs.fEllipsis &&
82+
return this->fHeight == rhs.fHeight &&
83+
this->fEllipsis == rhs.fEllipsis &&
8384
this->fEllipsisUtf16 == rhs.fEllipsisUtf16 &&
8485
this->fTextDirection == rhs.fTextDirection && this->fTextAlign == rhs.fTextAlign &&
8586
this->fDefaultTextStyle == rhs.fDefaultTextStyle &&
8687
this->fReplaceTabCharacters == rhs.fReplaceTabCharacters &&
87-
this->fFakeMissingFontStyles == rhs.fFakeMissingFontStyles &&
88-
this->fRenderSoftHyphens == rhs.fRenderSoftHyphens;
88+
this->fFakeMissingFontStyles == rhs.fFakeMissingFontStyles;
89+
8990
}
9091

9192
const StrutStyle& getStrutStyle() const { return fStrutStyle; }
@@ -134,9 +135,6 @@ struct ParagraphStyle {
134135
bool getLetterSpacingByCSSSpec() const { return fLetterSpacingByCSSSpec; }
135136
void setLetterSpacingByCSSSpec(bool value) { fLetterSpacingByCSSSpec = value; }
136137

137-
bool getRenderSoftHyphens() const { return fRenderSoftHyphens; }
138-
void setRenderSoftHyphens(bool value) { fRenderSoftHyphens = value; }
139-
140138
private:
141139
StrutStyle fStrutStyle;
142140
TextStyle fDefaultTextStyle;
@@ -152,7 +150,6 @@ struct ParagraphStyle {
152150
bool fFakeMissingFontStyles;
153151
bool fApplyRoundingHack = true;
154152
bool fLetterSpacingByCSSSpec = false;
155-
bool fRenderSoftHyphens = false;
156153
};
157154
} // namespace textlayout
158155
} // namespace skia

‎modules/skparagraph/src/ParagraphImpl.cpp‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,6 @@ void ParagraphImpl::breakShapedTextIntoLines(SkScalar maxWidth) {
673673
if (addEllipsis) {
674674
line.createEllipsis(maxWidth, this->getEllipsis(), true);
675675
}
676-
if (this->paragraphStyle().getRenderSoftHyphens()) {
677-
line.createSoftHyphen();
678-
}
679676
fLongestLine = std::max(fLongestLine, nearlyZero(line.width()) ? widthWithSpaces : line.width());
680677
});
681678

‎modules/skparagraph/src/Run.cpp‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -365,17 +365,6 @@ bool Cluster::isSoftBreak() const {
365365
SkUnicode::CodeUnitFlags::kSoftLineBreakBefore);
366366
}
367367

368-
bool Cluster::isSoftHyphen() const {
369-
auto text = fOwner->text();
370-
const char* p = text.begin() + fTextRange.start;
371-
const char* end = text.begin() + fTextRange.end;
372-
if (p >= end) {
373-
return false;
374-
}
375-
SkUnichar cp = SkUTF::NextUTF8(&p, end);
376-
return cp == 0x00AD && p == end;
377-
}
378-
379368
bool Cluster::isGraphemeBreak() const {
380369
return fOwner->codeUnitHasProperty(fTextRange.end, SkUnicode::CodeUnitFlags::kGraphemeStart);
381370
}

‎modules/skparagraph/src/Run.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ class Cluster {
315315
bool isIdeographic() const { return fIsIdeographic; }
316316

317317
bool isSoftBreak() const;
318-
bool isSoftHyphen() const;
319318
bool isGraphemeBreak() const;
320319
bool canBreakLineAfter() const { return isHardBreak() || isSoftBreak(); }
321320
size_t startPos() const { return fStart; }

‎modules/skparagraph/src/TextLine.cpp‎

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@ void TextLine::ensureTextBlobCachePopulated() {
237237
if (fTextBlobCachePopulated) {
238238
return;
239239
}
240-
if (fBlockRange.width() == 1 && fRunsInVisualOrder.size() == 1 && fEllipsis == nullptr &&
241-
fHyphen == nullptr && fOwner->run(fRunsInVisualOrder[0]).placeholderStyle() == nullptr) {
240+
if (fBlockRange.width() == 1 &&
241+
fRunsInVisualOrder.size() == 1 &&
242+
fEllipsis == nullptr &&
243+
fOwner->run(fRunsInVisualOrder[0]).placeholderStyle() == nullptr) {
242244
if (fClusterRange.width() == 0) {
243245
return;
244246
}
@@ -629,27 +631,6 @@ void TextLine::createEllipsis(SkScalar maxWidth, const SkString& ellipsis, bool)
629631
}
630632
}
631633

632-
void TextLine::createSoftHyphen() {
633-
if (fEllipsis) {
634-
return;
635-
}
636-
if (fClusterRange.width() == 0) {
637-
return;
638-
}
639-
640-
auto& lastCluster = fOwner->cluster(fClusterRange.end - 1);
641-
if (!lastCluster.isSoftHyphen()) {
642-
return;
643-
}
644-
645-
SkString hyphenStr("-");
646-
fHyphen = this->shapeEllipsis(hyphenStr, &lastCluster);
647-
if (fHyphen) {
648-
fHyphen->setOwner(fOwner);
649-
fHyphen->fClusterStart = lastCluster.textRange().start;
650-
}
651-
}
652-
653634
std::unique_ptr<Run> TextLine::shapeEllipsis(const SkString& ellipsis, const Cluster* cluster) {
654635

655636
class ShapeHandler final : public SkShaper::RunHandler {
@@ -1085,13 +1066,6 @@ void TextLine::iterateThroughVisualRuns(bool includingGhostSpaces, const RunVisi
10851066
}
10861067
}
10871068

1088-
if (this->hyphen() != nullptr &&
1089-
fOwner->paragraphStyle().getTextDirection() == TextDirection::kRtl) {
1090-
runOffset = this->hyphen()->offset().fX;
1091-
if (visitor(hyphen(), runOffset, hyphen()->textRange(), &width)) {
1092-
}
1093-
}
1094-
10951069
for (auto& runIndex : fRunsInVisualOrder) {
10961070

10971071
const auto run = &this->fOwner->run(runIndex);
@@ -1127,13 +1101,6 @@ void TextLine::iterateThroughVisualRuns(bool includingGhostSpaces, const RunVisi
11271101
}
11281102
}
11291103

1130-
if (this->hyphen() != nullptr &&
1131-
fOwner->paragraphStyle().getTextDirection() == TextDirection::kLtr) {
1132-
if (visitor(hyphen(), runOffset, hyphen()->textRange(), &width)) {
1133-
totalWidth += width;
1134-
}
1135-
}
1136-
11371104
if (!includingGhostSpaces && compareRound(totalWidth, this->width(), fOwner->getApplyRoundingHack()) != 0) {
11381105
// This is a very important assert!
11391106
// It asserts that 2 different ways of calculation come with the same results

‎modules/skparagraph/src/TextLine.h‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,13 @@ class TextLine {
7070
ClusterRange clusters() const { return fClusterRange; }
7171
ClusterRange clustersWithSpaces() const { return fGhostClusterRange; }
7272
Run* ellipsis() const { return fEllipsis.get(); }
73-
Run* hyphen() const { return fHyphen.get(); }
7473
InternalLineMetrics sizes() const { return fSizes; }
7574
bool empty() const { return fTextExcludingSpaces.empty(); }
7675

7776
SkScalar spacesWidth() const { return fWidthWithSpaces - width(); }
7877
SkScalar height() const { return fAdvance.fY; }
7978
SkScalar width() const {
80-
return fAdvance.fX + (fEllipsis != nullptr ? fEllipsis->fAdvance.fX : 0) +
81-
(fHyphen != nullptr ? fHyphen->fAdvance.fX : 0);
79+
return fAdvance.fX + (fEllipsis != nullptr ? fEllipsis->fAdvance.fX : 0);
8280
}
8381
SkScalar widthWithoutEllipsis() const { return fAdvance.fX; }
8482
SkVector offset() const;
@@ -110,7 +108,6 @@ class TextLine {
110108
void ensureTextBlobCachePopulated();
111109

112110
void createEllipsis(SkScalar maxWidth, const SkString& ellipsis, bool ltr);
113-
void createSoftHyphen();
114111

115112
// For testing internal structures
116113
void scanStyles(StyleType style, const RunStyleVisitor& visitor);
@@ -185,7 +182,6 @@ class TextLine {
185182
SkScalar fShift; // Let right
186183
SkScalar fWidthWithSpaces;
187184
std::unique_ptr<Run> fEllipsis; // In case the line ends with the ellipsis
188-
std::unique_ptr<Run> fHyphen; // Visible hyphen for soft hyphen line breaks
189185
InternalLineMetrics fSizes; // Line metrics as a max of all run metrics and struts
190186
InternalLineMetrics fMaxRunMetrics; // No struts - need it for GetRectForRange(max height)
191187
bool fHasBackground;

0 commit comments

Comments
 (0)