avalonia-docs icon indicating copy to clipboard operation
avalonia-docs copied to clipboard

Improve Custom Font Documentation

Open HoofedEar opened this issue 2 years ago • 1 comments

https://docs.avaloniaui.net/docs/guides/styles-and-resources/how-to-use-fonts

This guide could use more details about how the notation here works, for App.axaml:

<Application.Resources>
        <FontFamily x:Key="NunitoFont">avares://GoogleFonts/Assets/Fonts#Nunito</FontFamily>
</Application.Resources>

There are no details about how the #Nunito portion works. Since there is not file named Nunito.ttf in the GoogleFonts/Assets/Fonts folder, it could be assumed that Nunito is the name of the font. However, how would this work with a font that has spaces in its name? Etc etc. It would be useful to have a more in-depth explanation for requirements on the syntax.

HoofedEar avatar Apr 25 '24 02:04 HoofedEar

Would also like to hint at the "Adding a Font to the Font Collection" part of that page, which shows how to create a font inside a package but is misleading in terms of how it is used due to similar reasons.

In the example only the font name is given FontFamily="Nunito" while in reality it is necessary to provide a resource indentification (as discussed here) similar to the direct resource usage at the top of the page.

Which results in something like this instead: FontFamily="fonts:Nunito#Nunito" This should be fixed in the documentation if this is the expected way of using a font from a package.

samtun avatar Mar 14 '25 10:03 samtun