WPF:条形码字体错误?

问题描述 投票:0回答:1

情况

- 我在我的WPF应用程序中创建了一个文件夹“Fonts”,并添加了5种字体,如您所见。

- 然后我在我的资源中添加了字体。

enter image description here

XAML(我试过写包:app ,,, ..但它没有帮助)

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <FontFamily x:Key="Default">/Design/Fonts/#arial</FontFamily>
  <FontFamily x:Key="Rounded">/Design/Fonts/#BUNGASAI</FontFamily>
  <FontFamily x:Key="BarcodeCode39">/Design/Fonts/#Code39r</FontFamily>
  <FontFamily x:Key="Barcode3of9X">/Design/Fonts/#FRE3OF9X</FontFamily>
  <FontFamily x:Key="Barcode3of9">/Design/Fonts/#FREE3OF9</FontFamily>

</ResourceDictionary>

问题

事情是它对Arial和Bungasai或其他普通字体完美地工作,但每当我尝试使用那些“条形码”字体时它会显示arial字体。

可能有相关的信息

多数民众赞成我如何使用我的字体

XAML

不起作用:

<TextBlock Name="BarcodeContent"
           FontFamily="{StaticResource BarcodeCode39}"/>

完美的工作:

<TextBlock Name="BarcodeContent"
           FontFamily="{StaticResource Rounded}"/>
wpf xaml fonts barcode
1个回答
0
投票

使用ttf文件时,用于字体的名称(在#之后)是字体名称。这可以,但不一定与文件名相同。

例如。

我们的游戏使用一些自定义维多利亚风格字体其中之一是ephinol.ttf。

如果我右键单击文件浏览器中的ephinol.ttf文件并选择预览,我会看到其中一个字体对话框,其中包含不同大小的字体示例。

顶部是字体的全名。

哪个是Ephinol WF。

因此我会使用#Ephinol WF而不是#Ephinol

但是,我不这样做。

我现在所做的是安装字体文件。然后我不需要使用包符号来使用该字体。我这样做是为了保证没有内存泄漏。

否则我想要使用完整的文件路径或另一轮工作(参见链接)。

这是一个非常小的内存泄漏,但它是每次使用。

https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/746

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.