Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,377 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have an xamarin forms application.
I am using Skiasharp for drawing.
I am trying too import a font and I cannot get the Typeface to set.
I have followed the online guide, I am not sure what I am doing wrong.
The ttf file is an embedded resource
Please see the code below:
public static SKPaint SelectedText => new SKPaint { Color = SKColors.Black, FakeBoldText = true, Style = SKPaintStyle.Stroke, StrokeWidth = .6f };
private static SKTypeface GetFont()
{
SKTypeface sKTypeface = null;
using (var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("MyApp.Resources.Fonts.Roboto-Regular.ttf"))
{
SKTypeface result = SKTypeface.FromStream(resource);
}
return sKTypeface;
}
// even though the resource is found and returned, TypeFace is still null. Why? What am I doing wrong?
SelectedWidgetText.Typeface = GetFont();