这是indexloc提供的服务,不要输入任何密码
Skip to content

[BUG] Measuring Text Width for Chinese Characters – Error #3288

@chriswang-

Description

@chriswang-

Description

Measuring Text Width for Chinese Characters – Error

Version: "skia-canvas": "^2.0.2"

I have two sentences that are nearly the same length—one in Chinese and one in English:

Chinese:
"在美国总统川普与电动车大厂特斯拉执行长马斯克闹A翻后,白宫官员今天表示,川普可能转。"

English:
"abc browsrs- and Blink browsers -based browsers, the non-st42andard. "

When I measure these two sentences, the result for the Chinese sentence is incorrect.
I used this line:
ctx.measureText(fullText, 952);

Please note the width for each line in the results. The first line of the Chinese sentence is already significantly beyond the specified maximum width of 952. The result of Egnlish sentence seems to be right.

Chinese sentence:

0 = {x: 1.1399999856948853, y: -25.44325828552246, width: 1654.2899169921875, height: 28.6200008392334, baseline: -0.000001430511474609375, …}
1 = {x: 1.2599999904632568, y: 16.706737518310547, width: 279.1499938964844, height: 28.470001220703125, baseline: 42, …}

English sentence:

0 = {x: 1.7699999809265137, y: -23.913259506225586, width: 818.519775390625, height: 29.579999923706055, baseline: -0.000001430511474609375, …}
1 = {x: 0.9600000381469727, y: 18.08673858642578, width: 163.5900115966797, height: 24.270000457763672, baseline: 42, …}

Code

The best way to share code for larger projects is a link to a GitHub repository: https://github.com/user/repo/tree/bug-123

But, you can also share a short block of code here:

// some C# code here

You can also share some XAML:

<!-- xaml code here -->

Expected Behavior

No response

Actual Behavior

No response

Version of SkiaSharp

3.116.0 (Current)

Last Known Good Version of SkiaSharp

2.88.9 (Previous)

IDE / Editor

Visual Studio Code (macOS)

Platform / Operating System

macOS

Platform / Operating System Version

No response

Devices

No response

Relevant Screenshots

No response

Relevant Log Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions