Skiasharp: [BUG] Text size measured improperly while using skiasharp

Created on 3 Dec 2019  路  4Comments  路  Source: mono/SkiaSharp

Description

Particular text width is calculated wrongly when using skiasharp to measure the text size.
Got the same result when using with SKTypeface.FromStream and SKTypeface.FromFamilyName.

Code

        SKPaint paint = new SKPaint();
        paint.Typeface = SKTypeface.FromFamilyName("B Sina",SKTypefaceStyle.Normal);
        paint.TextSize = 11;
        float size = paint.MeasureText("爻賱丕賲 丿賳蹖丕");

Expected Behavior
The width of the text should be same as GDI measure.

Expected Width
| --
49.2260742

Actual Behavior

Actual Width
| --
63

Basic Information
Version with issue: 1.59.3
IDE: Visual studio 2017
Platform Target Frameworks: .NET Core 2.0

Most helpful comment

Hehe, I think I must. I _just_ found out about them recently as well. I'll update the readme - I think it is a bit old right now...

All 4 comments

Are you sure that GDI isn't shaping the text?

I think @Gillibald is right, SkiaSharp does not actually do any text shaping - and will always be wrong.

I would suggest having a look at https://github.com/toptensoftware/RichTextKit to draw text in SkiaSharp.

We are having a look at what we can do to improve text in SkiaSharp, but for now the best option is probably RichTextKit as that does probably more than what SkiaSharp will ever do,

Have you considered adding README links to other libraries that are useful? I wouldn't have known about RichTextKit or the SVG one (I already forgot its name, hah) without watching this repo.

Hehe, I think I must. I _just_ found out about them recently as well. I'll update the readme - I think it is a bit old right now...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michaldobrodenka picture michaldobrodenka  路  3Comments

joshminor picture joshminor  路  3Comments

joreg picture joreg  路  4Comments

parthipanr picture parthipanr  路  4Comments

pilotshamn picture pilotshamn  路  4Comments