Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text overflow issue when text content combines different languages characters #114949

Closed
hlwhl opened this issue Nov 9, 2022 · 4 comments
Closed
Labels
a: typography Text rendering, possibly libtxt found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on r: duplicate Issue is closed as a duplicate of an existing issue

Comments

@hlwhl
Copy link
Contributor

hlwhl commented Nov 9, 2022

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Observe the text rendering

Expected results:
The "你abcdefsdasdsasas" text should be displayed as "你abcdefsdasdsa...".
The "한111111111111111111" text should be displayed as "한1111111111111111...".

Actual results:
The text has been clip too much when there has enough place to display more characters.
WX20221109-112500@2x

Code sample
import 'package:flutter/material.dart';

Future<void> main() async {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(children: [
        //clip issue when text combine different characters
        //Chinese characters with English characters
        Row(
          children: [
            Container(
              color: Colors.amber,
              constraints: const BoxConstraints(maxWidth: 120),
              child: const Text(
                "你abcdefsdasdsasas",
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
              ),
            )
          ],
        ),
        //Korean characters with digits
        Row(
          children: [
            Container(
              color: Colors.amber,
              constraints: const BoxConstraints(maxWidth: 120),
              child: const Text(
                "한111111111111111111",
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
              ),
            )
          ],
        ),
        //English with digits no issue
        Row(
          children: [
            Container(
              color: Colors.amber,
              constraints: const BoxConstraints(maxWidth: 120),
              child: const Text(
                "abcdefsdasds1112222",
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
              ),
            )
          ],
        ),
      ]),
    );
  }
}
Logs
➜  flutter_application_1 flutter doctor -v
[✓] Flutter (Channel master, 3.5.0-12.0.pre.175, on macOS 13.0 22A380 darwin-arm64, locale en-CN)
    • Flutter version 3.5.0-12.0.pre.175 on channel master at /Users/linwei/workspace/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 92f10ed712 (2 hours ago), 2022-11-08 17:57:52 -0800
    • Engine revision e7d7edab98
    • Dart version 2.19.0 (build 2.19.0-374.0.dev)
    • DevTools version 2.19.0
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/linwei/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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.13+0-b1751.21-8125866)

[✓] VS Code (version 1.73.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.0 22A380 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 107.0.5304.87

[!] HTTP Host Availability
    ✗ HTTP host "https://pub.flutter-io.cn" is not reachable. Reason: An error occurred while checking the HTTP host: Connection terminated during handshake

! Doctor found issues in 2 categories.
@hlwhl
Copy link
Contributor Author

hlwhl commented Nov 9, 2022

After investigate, this may caused by word boundary? If so, should we provide a option for Text that user can disable line clip based on word boundary since the current words break rule may not met user's intent.

Furthermore, have tried android Textview with code below, works as expected.

        <TextView
            android:id="@+id/textview_first"
            android:layout_width="100dp"
            android:background="@color/black"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:ellipsize="end"
            android:maxLines="1"
            android:text="你abcdefsdasdsasas"
            android:textColor="@color/white"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/button_first" />

@exaby73 exaby73 added the in triage Presently being triaged by the triage team label Nov 9, 2022
@exaby73
Copy link
Member

exaby73 commented Nov 9, 2022

Triage report

I can reproduce this issue with the latest Master (3.5.0-12.0.pre.175)

Code Sample
import 'package:flutter/material.dart';

Future<void> main() async {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            //clip issue when text combine different characters
            //Chinese characters with English characters
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Container(
                  color: Colors.amber,
                  constraints: const BoxConstraints(maxWidth: 120),
                  child: const Text(
                    "你abcdefsdasdsasas",
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                )
              ],
            ),
            //Korean characters with digits
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Container(
                  color: Colors.amber,
                  constraints: const BoxConstraints(maxWidth: 120),
                  child: const Text(
                    "한111111111111111111",
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                )
              ],
            ),
            //English with digits no issue
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Container(
                  color: Colors.amber,
                  constraints: const BoxConstraints(maxWidth: 120),
                  child: const Text(
                    "abcdefsdasds1112222",
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                )
              ],
            ),
          ],
        ),
      ),
    );
  }
}
Screenshot

@exaby73 exaby73 added framework flutter/packages/flutter repository. See also f: labels. a: typography Text rendering, possibly libtxt has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 and removed in triage Presently being triaged by the triage team labels Nov 9, 2022
@goderbauer
Copy link
Member

This looks like a duplicate of #18761.

@exaby73 exaby73 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 16, 2022
@exaby73 exaby73 added the r: duplicate Issue is closed as a duplicate of an existing issue label Nov 16, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: typography Text rendering, possibly libtxt found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on r: duplicate Issue is closed as a duplicate of an existing issue
Projects
None yet
Development

No branches or pull requests

3 participants