using custom font in xaml

一笑奈何 提交于 2019-12-23 20:15:46

问题


I need to use custom font in xaml (c#). The font is not installed on the computer.

If the font is in the application installed folder,then i can use it even if it is not installed (/Fonts/New12.ttf#New12)

My problem is that the custom font is been created on the local computer and can't be in the installed folder.

The problem is that i can't copy the ttf file to the application installed folder , and i don't know how to use custom font that is not on the application installed folder

Is anyone have an idea ?


回答1:


Add the font to your project, change its Build Action to Content. Then just reference it inline or as part of a Style or BasedOn value like;

<TextBlock FontFamily="/Fonts/New12.ttf#New12" Text="Check out my awesome font!" />

That should do it for you.




回答2:


I found the solution,

For the FontFamily value you can write

"ms-appdata:///local/MyFont.ttf#FontName"

(where local is ApplicationData::Current->LocalFolder)



来源:https://stackoverflow.com/questions/12752397/using-custom-font-in-xaml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!