Make sure maxIntrinsicWidth is always no less than minIntrinsicWidth
Bug: skia:10992 Change-Id: Ifd3b8e799c76d09f6a01623747f646ce15de51b3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338045 Commit-Queue: Julia Lavrova <jlavrova@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
46787d5d7e
commit
748db70156
@ -202,6 +202,12 @@ void ParagraphImpl::layout(SkScalar rawWidth) {
|
||||
fMinIntrinsicWidth = fMaxIntrinsicWidth;
|
||||
}
|
||||
|
||||
// TODO: Since min and max are calculated differently it's possible to get a rounding error
|
||||
// that would make min > max. Sort it out later, make it the same for now
|
||||
if (fMaxIntrinsicWidth < fMinIntrinsicWidth) {
|
||||
fMaxIntrinsicWidth = fMinIntrinsicWidth;
|
||||
}
|
||||
|
||||
//SkDebugf("layout('%s', %f): %f %f\n", fText.c_str(), rawWidth, fMinIntrinsicWidth, fMaxIntrinsicWidth);
|
||||
}
|
||||
|
||||
|
@ -5555,3 +5555,24 @@ DEF_TEST(SkParagraph_FontResolutionInLTR, reporter) {
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
DEF_TEST(SkParagraph_Intrinsic, reporter) {
|
||||
sk_sp<ResourceFontCollection> fontCollection = sk_make_sp<ResourceFontCollection>();
|
||||
if (!fontCollection->fontsFound()) return;
|
||||
SkString text(std::string(3000, 'a'));
|
||||
|
||||
ParagraphStyle paragraph_style;
|
||||
paragraph_style.turnHintingOff();
|
||||
ParagraphBuilderImpl builder(paragraph_style, fontCollection);
|
||||
|
||||
TextStyle text_style;
|
||||
text_style.setFontFamilies({SkString("Google Sans")});
|
||||
text_style.setFontSize(12.0f);
|
||||
text_style.setColor(SK_ColorBLACK);
|
||||
builder.pushStyle(text_style);
|
||||
builder.addText(text.c_str());
|
||||
|
||||
auto paragraph = builder.Build();
|
||||
paragraph->layout(300000.0f);
|
||||
REPORTER_ASSERT(reporter, paragraph->getMinIntrinsicWidth() <= paragraph->getMaxIntrinsicWidth());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user