如何在 WPF 标签中添加新字体?
How to add new font to label in WPF?
我需要在 https://ru.fonts2u.com/8bitoperator-jve-regular.%D1%88%D1%80%D0%B8%D1%84%D1%82 的 WPF 标签中使用像素字体“8bitoperator_jve”。我已经下载了带有字体的 .ttf 文件并将其放入资源,在 Build Action 中设置 'Resource' 并尝试了以下代码:
<Label FontFamily="./#8bitoperator_jve" FontSize="100" Foreground="White"> Check </Label>
不行。我该如何解决?
您插入的字体名称不正确。您必须输入实际的字体名称,而不是文件名。打开字体并复制字体名称。试试这个:
<Label FontFamily="./#8bitoperator JVE" FontSize="100" Foreground="White"> Check </Label>
我不确定 ./
是否正确,如果上面的代码不起作用,请尝试删除它并只留下 #8bitoperator JVE
建议安装后直接使用
this.label1.FontFamily = new FontFamily("8bitoperator JVE Regular");
我需要在 https://ru.fonts2u.com/8bitoperator-jve-regular.%D1%88%D1%80%D0%B8%D1%84%D1%82 的 WPF 标签中使用像素字体“8bitoperator_jve”。我已经下载了带有字体的 .ttf 文件并将其放入资源,在 Build Action 中设置 'Resource' 并尝试了以下代码:
<Label FontFamily="./#8bitoperator_jve" FontSize="100" Foreground="White"> Check </Label>
不行。我该如何解决?
您插入的字体名称不正确。您必须输入实际的字体名称,而不是文件名。打开字体并复制字体名称。试试这个:
<Label FontFamily="./#8bitoperator JVE" FontSize="100" Foreground="White"> Check </Label>
我不确定 ./
是否正确,如果上面的代码不起作用,请尝试删除它并只留下 #8bitoperator JVE
建议安装后直接使用
this.label1.FontFamily = new FontFamily("8bitoperator JVE Regular");