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 different platforms #707

Closed
selvarathinamm opened this issue Nov 26, 2018 · 10 comments
Closed

Comments

@selvarathinamm
Copy link

Description

I tried to measure a text range and I get different width for the same text range in windows and linux.

Code

MeasureText("This€is a€test line full of Text€")

Expected Behavior

In windows and mac I get almost the same width but in linux the measured width is more than the one from windows.

Actual Behavior

Values should be more or less within a tolerable limit.

Basic Information

  • Version with issue: 1.59.3
  • Last known good version:
  • IDE: Visual Studio 2017
  • Platform Target Frameworks: .net Core in linux and windows
@mattleibow
Copy link
Contributor

Looking at the text in the issue, there appears to be some special character?

If this character is supposed to be there, then it may be that Linux can/can't render it as a space and is replacing it with a block character. Also, are you using the same fonts? The default font on each platform is the platform-default font.

@selvarathinamm
Copy link
Author

@mattleibow Is there any way to get rid of block character and get the exact string width?
BTW The fonts are same in both systems.

@selvarathinamm
Copy link
Author

@mattleibow Yes. I need to measure those special characters also. Am I missing any property settings?

@mattleibow
Copy link
Contributor

Hmm. What is the font name and can you ensure that the font exists on linux? On my WSL, I only have 2 fonts. After installing Times New Roman, I got the same values as the Windows.

If you are setting the font, you can check the typeface via the SKTypeface.FamilyName property. If you are using SKTypeface.FromFamilyName to load the font, this will always return a valid font - just not the one you expect if the font is not available. If you use SKFontManager.Default.MatchFamily, it will return null if the font cannot be found.

@mattleibow
Copy link
Contributor

It may be the text... Maybe attach a text file with the exact string - maybe GitHub is processing the text.

@Gillibald
Copy link
Contributor

Make sure to test this with a font loaded by stream. That way you ensure the same typeface is used on both platforms. When that fails to produce the same measures there is an issue.

@mattleibow
Copy link
Contributor

I tried the same font file on both platforms, and I get the same values. What font are you using?

@selvarathinamm
Copy link
Author

I'm getting 190 as width in linux and 184 in windows for DejaVu sans font.

@mattleibow
Copy link
Contributor

Could you attach the font file you are using so I can have a look. I can't seem to replicate. Also, what other font properties are you using? It might be best just to create a sample project.

@Redth
Copy link
Contributor

Redth commented Dec 24, 2018

We are closing this issue since no response was received. Please open a new issue referring to this one if you have more information.

@Redth Redth closed this as completed Dec 24, 2018
@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants