在 xaml 中使用自定义字体 [英] using custom font in xaml
问题描述
我需要在 xaml (c#) 中使用自定义字体.电脑上没有安装字体.
I need to use custom font in xaml (c#). The font is not installed on the computer.
如果字体在应用程序安装文件夹中,那么即使没有安装我也可以使用它(/Fonts/New12.ttf#New12)
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.
问题是我无法将 ttf 文件复制到应用程序安装文件夹,而且我不知道如何使用应用程序安装文件夹中没有的自定义字体
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
有人有想法吗?
推荐答案
将字体添加到您的项目中,将其构建操作更改为内容.然后只需内联或作为 Style 或 BasedOn 值的一部分引用它;
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!" />
这应该对你有用.
这篇关于在 xaml 中使用自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!