Repository: flutter
Issue: [Web][HTML] Hovering the cursor over Arabic characters causes an ArgumentError 
Labels: c: regression,engine,a: internationalization,a: typography,platform-web,e: web_html,has reproducible steps,P3,team-web,triaged-web,found in release: 3.19,found in release: 3.22

### Steps to reproduce

Hello everyone!

I found a very annoying bug when using Arabic characters in any widget with **HTML-RENDERER**. We had version 3.16.9 and did not have this bug, after we upgraded to 3.19.5, the error started to pop up.

To reproduce the bug you need to move the cursor over the Arabic characters. I only managed to find out that this happens with some specific Arabic characters. 

### Expected results

The expected behavior is exceptions will stop appearing when user move the cursor over the Arabic characters.

### Actual results

When I move cursor over arabic characters exceptions appear. 

```
The following ArgumentError was thrown while handling a pointer data packet:
Invalid argument: 16.62

When the exception was thrown, this was the stack: 
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3       throw_
dart-sdk/lib/_internal/js_dev_runtime/private/js_number.dart 145:7                clamp]
lib/_engine/engine/text/layout_fragmenter.dart 654:44                             [_getClosestCharacterInRange]
lib/_engine/engine/text/layout_fragmenter.dart 649:39                             [_getClosestCharacterInRange]
lib/_engine/engine/text/layout_fragmenter.dart 649:39                             [_getClosestCharacterInRange]
lib/_engine/engine/text/layout_fragmenter.dart 685:12                             getClosestCharacterBox
lib/_engine/engine/text/layout_service.dart 431:45                                getClosestGlyphInfo
lib/_engine/engine/text/canvas_paragraph.dart 200:82                              getClosestGlyphInfoForOffset
```

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';


void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Center(child: Text('الصفحة الرئيس')),
        ],
      ),
    );
  }
}

```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

![image](https://github.com/flutter/flutter/assets/33370114/c113331e-ec00-43d3-b31f-fb15bd0879bd)

</details>


### Logs

<details open><summary>Logs</summary>

```console
======== Exception caught by gestures library ======================================================
The following ArgumentError was thrown while handling a pointer data packet:
Invalid argument: 16.62

When the exception was thrown, this was the stack: 
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3       throw_
dart-sdk/lib/_internal/js_dev_runtime/private/js_number.dart 145:7                clamp]
lib/_engine/engine/text/layout_fragmenter.dart 655:45                             [_getClosestCharacterInRange]
lib/_engine/engine/text/layout_fragmenter.dart 649:39                             [_getClosestCharacterInRange]
lib/_engine/engine/text/layout_fragmenter.dart 685:12                             getClosestCharacterBox
lib/_engine/engine/text/layout_service.dart 431:45                                getClosestGlyphInfo
lib/_engine/engine/text/canvas_paragraph.dart 200:82                              getClosestGlyphInfoForOffset
packages/flutter/src/painting/text_painter.dart 1508:52                           getClosestGlyphForOffset
packages/flutter/src/rendering/paragraph.dart 736:43                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/shifted_box.dart 88:23                             <fn>
packages/flutter/src/rendering/box.dart 800:31                                    addWithPaintOffset
packages/flutter/src/rendering/shifted_box.dart 83:20                             hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/box.dart 2861:23                                   <fn>
packages/flutter/src/rendering/box.dart 800:31                                    addWithPaintOffset
packages/flutter/src/rendering/box.dart 2856:32                                   defaultHitTestChildren
packages/flutter/src/rendering/flex.dart 1035:12                                  hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/box.dart 2861:23                                   <fn>
packages/flutter/src/rendering/box.dart 800:31                                    addWithPaintOffset
packages/flutter/src/rendering/box.dart 2856:32                                   defaultHitTestChildren
packages/flutter/src/rendering/custom_layout.dart 414:12                          hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 1990:18                             hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 3604:31                             hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 3734:31                             hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/widgets/overlay.dart 985:80                                  childHitTest
packages/flutter/src/rendering/box.dart 800:31                                    addWithPaintOffset
packages/flutter/src/widgets/overlay.dart 986:21                                  hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 3857:17                             hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/proxy_box.dart 173:63                              hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/custom_paint.dart 559:18                           hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/widgets/tap_region.dart 214:72                               hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/view.dart 211:7                                    hitTest
packages/flutter/src/rendering/binding.dart 615:34                                hitTestInView
packages/flutter/src/gestures/binding.dart 391:7                                  [_handlePointerEventImmediately]
packages/flutter/src/gestures/binding.dart 383:5                                  handlePointerEvent
packages/flutter/src/gestures/binding.dart 330:7                                  [_flushPointerEventQueue]
packages/flutter/src/gestures/binding.dart 299:9                                  [_handlePointerDataPacket]
lib/_engine/engine/platform_dispatcher.dart 1361:5                                invoke1
lib/_engine/engine/platform_dispatcher.dart 286:5                                 invokeOnPointerDataPacket
lib/_engine/engine/pointer_binding.dart 398:30                                    [_sendToFramework]
lib/_engine/engine/pointer_binding.dart 224:7                                     onPointerData
lib/_engine/engine/pointer_binding.dart 978:16                                    <fn>
lib/_engine/engine/pointer_binding.dart 930:7                                     <fn>
lib/_engine/engine/pointer_binding.dart 531:9                                     loggedHandler
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 550:37  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 555:39  dcall
====================================================================================================

======== Exception caught by gestures library ======================================================
The following ArgumentError was thrown while handling a pointer data packet:
Invalid argument: 16.62

When the exception was thrown, this was the stack: 
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3       throw_
dart-sdk/lib/_internal/js_dev_runtime/private/js_number.dart 145:7                clamp]
lib/_engine/engine/text/layout_fragmenter.dart 655:45                             [_getClosestCharacterInRange]
lib/_engine/engine/text/layout_fragmenter.dart 649:39                             [_getClosestCharacterInRange]
lib/_engine/engine/text/layout_fragmenter.dart 685:12                             getClosestCharacterBox
lib/_engine/engine/text/layout_service.dart 431:45                                getClosestGlyphInfo
lib/_engine/engine/text/canvas_paragraph.dart 200:82                              getClosestGlyphInfoForOffset
packages/flutter/src/painting/text_painter.dart 1508:52                           getClosestGlyphForOffset
packages/flutter/src/rendering/paragraph.dart 736:43                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/shifted_box.dart 88:23                             <fn>
packages/flutter/src/rendering/box.dart 800:31                                    addWithPaintOffset
packages/flutter/src/rendering/shifted_box.dart 83:20                             hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/box.dart 2861:23                                   <fn>
packages/flutter/src/rendering/box.dart 800:31                                    addWithPaintOffset
packages/flutter/src/rendering/box.dart 2856:32                                   defaultHitTestChildren
packages/flutter/src/rendering/flex.dart 1035:12                                  hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/box.dart 2861:23                                   <fn>
packages/flutter/src/rendering/box.dart 800:31                                    addWithPaintOffset
packages/flutter/src/rendering/box.dart 2856:32                                   defaultHitTestChildren
packages/flutter/src/rendering/custom_layout.dart 414:12                          hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 1990:18                             hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 3604:31                             hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 3734:31                             hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/widgets/overlay.dart 985:80                                  childHitTest
packages/flutter/src/rendering/box.dart 800:31                                    addWithPaintOffset
packages/flutter/src/widgets/overlay.dart 986:21                                  hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 3857:17                             hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/proxy_box.dart 173:63                              hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/custom_paint.dart 559:18                           hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/widgets/tap_region.dart 214:72                               hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/proxy_box.dart 118:19                              hitTestChildren
packages/flutter/src/rendering/box.dart 2482:11                                   hitTest
packages/flutter/src/rendering/view.dart 211:7                                    hitTest
packages/flutter/src/rendering/binding.dart 615:34                                hitTestInView
packages/flutter/src/gestures/binding.dart 391:7                                  [_handlePointerEventImmediately]
packages/flutter/src/gestures/binding.dart 383:5                                  handlePointerEvent
packages/flutter/src/gestures/binding.dart 330:7                                  [_flushPointerEventQueue]
packages/flutter/src/gestures/binding.dart 299:9                                  [_handlePointerDataPacket]
lib/_engine/engine/platform_dispatcher.dart 1361:5                                invoke1
lib/_engine/engine/platform_dispatcher.dart 286:5                                 invokeOnPointerDataPacket
lib/_engine/engine/pointer_binding.dart 398:30                                    [_sendToFramework]
lib/_engine/engine/pointer_binding.dart 224:7                                     onPointerData
lib/_engine/engine/pointer_binding.dart 978:16                                    <fn>
lib/_engine/engine/pointer_binding.dart 930:7                                     <fn>
lib/_engine/engine/pointer_binding.dart 531:9                                     loggedHandler
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 550:37  _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 555:39  dcall
====================================================================================================

```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Version 10.0.22631.3296], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2022.1)
[√] IntelliJ IDEA Ultimate Edition (version 2023.1)
[√] VS Code (version 1.82.2)
[√] Connected device (3 available)
[√] Network resources

```

</details>