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

Xamarin.Forms - FontFamily #111

Closed
marcosgerene opened this issue Jan 27, 2022 · 2 comments
Closed

Xamarin.Forms - FontFamily #111

marcosgerene opened this issue Jan 27, 2022 · 2 comments

Comments

@marcosgerene
Copy link

Hi everyone,

I am trying to use the library on a mobile application (Xamarin.Forms) to run on iOS and Android Plataform.

Using the library I faced this problem:

image

So I tried this:

private static string _FontFamily = Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.iOS ? "Helvetica" :
                                            Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.Android ? "Droid Sans" :
                                            throw new NotImplementedException();

public void Compose(IDocumentContainer container)
{
	container
		.Page(page =>
		{
			page.Margin(50);
		   
			page.DefaultTextStyle(TextStyle.Default.FontType(_FontFamily));

			page.Header().Element(ComposeHeader);
			page.Content().Element(ComposeElement);
			page.Footer().Element(ComposeFooter);
		});
}

And I tried some fonts, but all I tried did not work, I got the same error: The typeface (font's name) could not be found...
Can someone please tell me any font that I can use?

@marcosgerene
Copy link
Author

I changed to "sans-serif" on Android and I got another error, so I guess the font-family is okay now.

@MarcinZiabek
Copy link
Member

Hello 😁 Loading a font by name assumes that the given font is available in the runtime environment. Sometimes, e.g. on the cloud services, there are no fonts preinstalled - hence the exception. You can attach a font file to your project and then load it in QuestPDF. Please read this article and try it.

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

No branches or pull requests

2 participants