Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

SkiaStringSizeService and measuring strings in general seems off. #459

Open
lucapivato opened this issue Jun 24, 2022 · 2 comments
Open

Comments

@lucapivato
Copy link

Apparently Skia is used in Chrome as well. However, it seems that the measuring of strings in Microsoft.Maui.Graphics.Skia.SkiaStringSizeService incorrectly uses the passed in font size as the height.

In Chrome or Edge

var el = document.createElement("div");
document.body.append(el);
el.innerText = "Hello, Maui.Graphics!"
el.style.fontFamily="Arial"
el.style.fontSize="13px"
el.clientHeight

15

15 is the correct height of the text when setting the font size to 13px for Arial. This value is returned by Chrome and Edge, both apparently using Skia.

I get the same correct value the good old gdi+ and libgdiplus setting the font size to 13 pixels, the height is 15.

image

But Microsoft.Maui.Graphics.Skia.SkiaStringSizeService always returns the incorrect height simply returning the size.

Is there a settings I'm missing or an additional way to measure a string correctly?

@janseris
Copy link

Use libgdiplus. this library is broken and incomplete

@lucapivato
Copy link
Author

lucapivato commented Jun 26, 2022 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants