Wrong line metrics in case of a force text wrapping
Change-Id: I8fb6530c46ba8fb7f6fa2894227193ca6a9e391b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/430220 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Julia Lavrova <jlavrova@google.com>
This commit is contained in:
parent
a9c2e3bf83
commit
fb4d380747
@ -3538,14 +3538,15 @@ protected:
|
||||
TextStyle text_style;
|
||||
text_style.setColor(SK_ColorBLACK);
|
||||
text_style.setFontFamilies({SkString("Ahem")});
|
||||
text_style.setFontSize(10.0f);
|
||||
text_style.setFontSize(12.0f);
|
||||
ParagraphStyle paragraph_style;
|
||||
paragraph_style.setTextStyle(text_style);
|
||||
ParagraphBuilderImpl builder(paragraph_style, fontCollection);
|
||||
builder.pushStyle(text_style);
|
||||
builder.addText("one two\n\nthree four\nwith spaces \n ");
|
||||
builder.addText("______________________");
|
||||
auto paragraph = builder.Build();
|
||||
paragraph->layout(width());
|
||||
paragraph->layout(132.0f);
|
||||
paragraph->paint(canvas, 0, 0);
|
||||
std::vector<LineMetrics> metrics;
|
||||
paragraph->getLineMetrics(metrics);
|
||||
for (auto& metric : metrics) {
|
||||
|
@ -361,6 +361,9 @@ void TextWrapper::breakTextIntoLines(ParagraphImpl* parent,
|
||||
clusters.end = clusters.start;
|
||||
}
|
||||
|
||||
// In case of a force wrapping we don't have a break cluster and have to use the end cluster
|
||||
text.end = std::max(text.end, textExcludingSpaces.end);
|
||||
|
||||
addLine(textExcludingSpaces,
|
||||
text,
|
||||
textIncludingNewlines, clusters, clustersWithGhosts, widthWithSpaces,
|
||||
|
@ -6348,10 +6348,10 @@ DEF_TEST(SkParagraph_LTRLineMetricsDoesNotIncludeNewLine, reporter) {
|
||||
text_style.setFontSize(20);
|
||||
text_style.setColor(SK_ColorBLACK);
|
||||
builder.pushStyle(text_style);
|
||||
builder.addText("one two\n\nthree four\nwith spaces \n ");
|
||||
builder.addText("one two\n\nthree four\nwith spaces \n \n______________________");
|
||||
builder.pop();
|
||||
auto paragraph = builder.Build();
|
||||
paragraph->layout(500);
|
||||
paragraph->layout(190);
|
||||
paragraph->paint(canvas.get(), 0, 0);
|
||||
|
||||
std::vector<std::tuple<size_t, size_t, size_t, size_t>> expected = {
|
||||
@ -6359,7 +6359,9 @@ DEF_TEST(SkParagraph_LTRLineMetricsDoesNotIncludeNewLine, reporter) {
|
||||
{ 8, 8, 8, 9 }, // \n
|
||||
{ 9, 19, 19, 20 }, // three four\n
|
||||
{ 20, 31, 36, 37 }, // with spaces \n
|
||||
{ 37, 37, 41, 41 }, // { just spaces }
|
||||
{ 37, 37, 41, 42 }, // { just spaces }\n
|
||||
{ 42, 63, 63, 63 }, // _____________________
|
||||
{ 63, 64, 64, 64 }, // _
|
||||
};
|
||||
std::vector<LineMetrics> metrics;
|
||||
paragraph->getLineMetrics(metrics);
|
||||
@ -6390,10 +6392,10 @@ DEF_TEST(SkParagraph_RTLLineMetricsDoesNotIncludeNewLine, reporter) {
|
||||
text_style.setFontSize(20);
|
||||
text_style.setColor(SK_ColorBLACK);
|
||||
builder.pushStyle(text_style);
|
||||
builder.addText(mirror("one two\n\nthree four\nwith spaces \n "));
|
||||
builder.addText(mirror("______________________\none two\n\nthree four\nwith spaces \n "));
|
||||
builder.pop();
|
||||
auto paragraph = builder.Build();
|
||||
paragraph->layout(500);
|
||||
paragraph->layout(190);
|
||||
paragraph->paint(canvas.get(), 0, 0);
|
||||
//auto impl = static_cast<ParagraphImpl*>(paragraph.get());
|
||||
|
||||
@ -6428,7 +6430,9 @@ DEF_TEST(SkParagraph_RTLLineMetricsDoesNotIncludeNewLine, reporter) {
|
||||
{ 5, 21, 21, 22 }, // with spaces \n
|
||||
{ 22, 32, 32, 33 }, // three four\n
|
||||
{ 33, 33, 33, 34 }, // \n
|
||||
{ 34, 41, 41, 41 }, // one two\n
|
||||
{ 34, 41, 41, 42 }, // one two\n
|
||||
{ 42, 63, 63, 63 }, // _____________________
|
||||
{ 63, 64, 64, 64 } // _
|
||||
};
|
||||
|
||||
std::vector<LineMetrics> metrics;
|
||||
|
Loading…
Reference in New Issue
Block a user