Visual Studio XAML设计器可以使用空格作为资源来处理字体族名称吗? [英] Can Visual Studio XAML designer handle font family names with spaces as a resource?

查看:232
本文介绍了Visual Studio XAML设计器可以使用空格作为资源来处理字体族名称吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能看起来像一个奇怪的问题,但我看到一个自定义的真正的字体,我已经加载作为我的WPF应用程序中的资源有麻烦,我想知道是否可能与字体名称中的空格。



如别处所述(数百个例子之一),我已经将字体添加到文件夹 Fonts 在我的应用程序中,并将其设置为 Build Action = Resource 。我可以用简单的 FontFamily =Fonts \#My Font来引用字体(例如,在 TextBlock 中)这里所解释的那样,这位作者也有类似的问题字体 Open Sans ,如果我在系统上安装字体,就可以在设计时看到它。



但是我宁愿不强迫开发者在他们的系统上安装字体。我注意到,就像上面的作者,我没有这个问题,一些自定义字体没有空格的名称。所以我想知道这是否是Visual Studio中的错误(我正在使用Community 2013)。有没有人能够得到这个名字包含一个空间的字体工作?或者有没有人找到一个更令人满意的解决方法(例如,引用字体的方式,没有类似于Windows短文件名称的空间)?

解决方案

<我有这个相同的问题。解决方案是取出空格,但不能只编辑文件名。下面是我做的:


  • 下载FontForge - http://fontforge.github.io/zh-CN/

  • 打开字体文件

  • 转到元素 - >字体信息

  • 在那里寻找xyz Names,我的TTF名字是Wingdings

  • 编辑它们到删除空格,我敢肯定唯一重要的是UniqueID,但我做了他们所有。
  • 转到文件 - >生成字体并保存字体为适当

  • 重新添加文件并引用不带空格的字体

    $ b 这是只有这样,我才能把它运用起来,但最终却顺利运作。祝你好运。


    This probably seems like a strange question, but I'm having trouble seeing a custom true-type font that I've loaded as a resource in my WPF application, and I'm wondering if it may have to do with the space in the font name.

    As described elsewhere (one of hundreds of examples), I've added the font to a folder Fonts in my application, and set it to Build Action = Resource. I'm able to reference the font (e.g., in a TextBlock) with a simple FontFamily="Fonts\#My Font".

    Unfortunately, the font only shows up at run time, not in the XAML designer (contrary to most people's problems). However, as explained here, this author had a similar problem with the font Open Sans, and if I install the font on my system, as he did, I can see it at design time.

    But I'd rather not force developers to install the font on their system. I noticed that, like the author above, I don't have this problem with a few custom fonts that have names without spaces. So I'm wonder if this is perhaps a bug in Visual Studio (I'm using Community 2013). Has anyone been able to get this to work with a font whose name contains a space? Or has anyone found a more satisfying workaround (e.g., way to reference the font without the space akin to Windows short files names)?

    解决方案

    I had this very same problem. The solution is taking out the spaces, although you can't just edit the file name. Here's how I did it:

    • Download FontForge - http://fontforge.github.io/en-US/.
    • Open the font file
    • Go to Elements -> Font Info
    • In there look for xyz Names, mine was TTF Names due to it being Wingdings
    • Edit them to remove the spaces, I'm pretty sure the only one that matters is the "UniqueID" but I did them all.
    • Go to File -> Generate Fonts and save the font as the proper type.
    • Re-add the file and reference the font without spaces

    This was the only way I could get it to work but it ended up working without a hitch. Best of luck.

    这篇关于Visual Studio XAML设计器可以使用空格作为资源来处理字体族名称吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆