-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Closed
flutter/engine
#31272Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work lista: typographyText rendering, possibly libtxtText rendering, possibly libtxtcustomer: sameheree: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for WebCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webe: web_htmlHTML rendering backend for WebHTML rendering backend for Webengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-webWeb applications specificallyWeb applications specifically
Description
On the web, in HTML mode, the bounds estimation logic uses Paragraph.width and Paragraph.height to estimate the paint bounds of the paragraph. This is not precise, and leads to two issues:
- It overestimates the size of the canvas it needs for painting, which is inefficient.
- When
double.infinityis passed as the width constraint it estimates 1000000000 as its paint bounds, which later can lead toNaNresults down in the engine compositor math.
Instead, bounds should be estimated based on the line metrics. For example, if text is aligned to be in the center the bounding rectangle would be something smaller than the width and also in the center.
Here's a test case that passes today, but shouldn't (I don't have the expected figures right now without an actual fix; I just know that these are wrong):
test('infinite width', () {
final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle(
fontFamily: 'Ahem',
fontSize: 10,
));
builder.addText('Hello, World!');
final Paragraph paragraph = builder.build();
paragraph.layout(const ParagraphConstraints(width: double.infinity));
underTest.drawParagraph(paragraph, Offset.zero);
underTest.endRecording();
expect(underTest.pictureBounds, const Rect.fromLTRB(0, 0, 1000000000, 11));
});
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work lista: typographyText rendering, possibly libtxtText rendering, possibly libtxtcustomer: sameheree: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for WebCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webe: web_htmlHTML rendering backend for WebHTML rendering backend for Webengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-webWeb applications specificallyWeb applications specifically