I'm using SkiaSharp in Xamarin Forms. My goal is to ensure that the font displayed in Xamarin controls, e.g. a Label, matches the font used in SkiaSharp drawing.
In addition, I want to use the default font so that the app looks right on its respective platform and adheres to user preferences.
In my simple app, I have some Xamarin labels and I have a custom control drawn by SkiaSharp. The two have different fonts, though they are very close. SkiaSharp has the same look but is about 10% smaller. And Xamarin has wider antialiasing.
See clip of screenshot (top: SkiaSharp, bottom: Xamarin):
I'm not sure how to solve this. There are at least a couple approaches:
- How can I determine the font being used for a Xamarin Label ? If I can determine this, I should be able to set it for SkiaSharp drawing.
- Or, how do I set the Xamarin font to that being used by SkiaSharp. I can get the font family from SkiaSharp during runtime but I don't know how to set it in Xamarin during runtime.
I guess a third alternative is to do all fonts via SkiaSharp. But then I won't be able to use any Xamarin controls that display text.