Repository: flutter
Issue: [Web] [HTML Renderer] renderParagraph.getMinIntrinsicWidth not calculating correctly
Labels: engine,a: typography,platform-web,e: web_html,has reproducible steps,P2,found in release: 2.5,found in release: 2.6,team-web,triaged-web

Hi,

I have an issue where renderParagraph.getMinIntrinsicWidth not calculating correctly in the HTML renderer? I've tried 2.2.3, 2.5.1 and the latest master and the results are consistent. Is there another approach I should be using or a workaround?

CanvasKit Renderer:
![image](https://user-images.githubusercontent.com/81489824/135918290-72cba809-d8df-4ee7-b950-b988388849f2.png)

HTML Renderer:
![image](https://user-images.githubusercontent.com/81489824/135917985-19668579-d586-45dd-b3ad-2452075d21a3.png)

<details> 
<summary>minimal code sample</summary> 

```dart
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    calculateWidth(context, 'a kinda reasonably long sentence');
    calculateWidth(context, 'a kinda reasonably long sentence a kinda reasonably long sentence');

    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(),
      home: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          //I am aware that the sizes will not match the size of these Text widgets
          Text('short:' + calculateWidth(context, 'short').toInt().toString()),
          Text('short sentence:' + calculateWidth(context, 'short sentence').toInt().toString()),
          Text('a kinda reasonably long sentence:' + calculateWidth(context, 'a kinda reasonably long sentence').toInt().toString()),
          Text('a kinda reasonably long sentence a kinda reasonably long sentence:' +
              calculateWidth(context, 'a kinda reasonably long sentence a kinda reasonably long sentence').toInt().toString()),
        ],
      ),
    );
  }

  double calculateWidth(BuildContext context, String text) {
    final theme = Theme.of(context);
    final fontSize = theme.textTheme.button!.fontSize!;
    final renderParagraph = RenderParagraph(
      TextSpan(
        text: text,
        style: TextStyle(
          fontSize: fontSize,
          fontWeight: theme.textTheme.button!.fontWeight,
          letterSpacing: theme.textTheme.button!.letterSpacing,
        ),
      ),
      textDirection: TextDirection.ltr,
      maxLines: 1,
    );

    renderParagraph.layout(const BoxConstraints(minWidth: 120.0));

    // text width based on fontSize, plus 45.0 for padding
    return renderParagraph.getMinIntrinsicWidth(fontSize).ceilToDouble() + 45.0;
  }
}
```

</details>

<details> 
<summary>flutter doctor</summary> 

```console
[√] Flutter (Channel master, 2.6.0-12.0.pre.185, on Microsoft Windows [Version 10.0.17763.2183], locale en-IE)
    • Flutter version 2.6.0-12.0.pre.185 at C:\Code\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 91dd3276fd (2 days ago), 2021-10-02 10:18:03 -0700
    • Engine revision 6f4143e800
    • Dart version 2.15.0 (build 2.15.0-172.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\Omega\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • CHROME_EXECUTABLE = C:\Code\FlutterTesting\ChromeCORS.bat

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[√] VS Code (version 1.60.2)
    • VS Code at C:\Users\Omega\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.26.0

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 94.0.4606.71
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 94.0.992.38

• No issues found!

```
</details>