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

measureText method returns different values in windows and linux container #752

Open
selvarathinamm opened this issue Jan 11, 2019 · 5 comments

Comments

@selvarathinamm
Copy link

selvarathinamm commented Jan 11, 2019

Description

Values returned by measureText in linux container and in windows are not same.

Code

SKPaint paint = new SKPaint();
paint.Typeface = SKTypeface.FromFamilyName("Calibri", SKTypefaceStyle.Bold);
paint.IsAntialias = true;
paint.TextSize = 19;
SKRect rect = new SKRect();
float width = paint.MeasureText("Progressive Report Template", ref rect);

Expected Behavior

Values should be same

Actual Behavior

In windows I'm getting 228.213379 and in linux container the same code returns 231 as width.

Basic Information

  • Version with issue: 1.59.3
  • Last known good version:
  • IDE: Visual Studio

I'm using these fonts in both windows and linux container.
Calibri.zip

@mattleibow
Copy link
Contributor

List linking this issue fore reference: #707

@mattleibow
Copy link
Contributor

Thanks for the repro, I'll investigate.

@selvarathinamm
Copy link
Author

Thank you for looking into it. Please do let me know if you need any additional info.

@mattleibow
Copy link
Contributor

When measuring fonts, there are 2 components that influence the values - the font and the measuring logic.

The line:

SKTypeface.FromFamilyName("Calibri", SKTypefaceStyle.Bold);

assume the font is installed? Is this the case?

And then it may also be the case that Windows DirectWrite and Linux FontConfig may be doing different things.

SkiaSharp does not do much in the way of fonts and rendering, and in order to measure some string it needs to be shaped. This is probably a reason to use RichTextKit.

@Gillibald
Copy link
Contributor

FromFamilyName asks the current font manager for a typeface that is matching the name. This will be an installed font and it can be any font that relates to the specified name. On Linux this can be an alias.

To be sure to get the same rendering on all platforms you need to load a typeface via stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: New
Development

No branches or pull requests

3 participants