Skip to content

Simplified Chinese characters with background do not display properly in RichText. #24337

@yumi0629

Description

@yumi0629

I want to add a background to text, here is my code:

RichText(
                text: TextSpan(
                        text: "不科学1111",
                        style: TextStyle(
                          color: Colors.black,
                          background: new Paint()..color = Colors.pinkAccent,
                        ),
                    children: [
                          TextSpan(
                            text: "不科学sdfsdfkd",
                            style: TextStyle(
                              color: Colors.lightGreenAccent,
                              background: new Paint()
                                ..color = Colors.pinkAccent,
                            ),
                          ),
                        ]),
                  ),

But the Simplified Chinese words do not display:
image

If I set the background color with opacity, it seems well:

RichText(
                text: TextSpan(
                      text: "不科学1111",
                      style: TextStyle(
                        color: Colors.black,
                        background: new Paint()..color = Colors.pinkAccent.withOpacity(0.5),
                      ),
                    children: [
                        TextSpan(
                          text: "不科学sdfsdfkd",
                          style: TextStyle(
                            color: Colors.lightGreenAccent,
                            background: new Paint()
                              ..color = Colors.pinkAccent,
                            ),
                          ),
                        ]),
                  )

image
But it still doesn't meet my expectation:
image

I have added app locales supports like this:

supportedLocales: [
            const Locale('zh', 'CH'),
            const Locale('en', 'US'),
          ],

Still doesn't work.

Metadata

Metadata

Assignees

Labels

a: typographyText rendering, possibly libtxtengineflutter/engine repository. See also e: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions