简体   繁体   English

Visual Studio 2015无法识别OTF转换的字体(UWP)

[英]Visual Studio 2015 does not recognize OTF converted fonts (UWP)

I'm developing an Universal version of my WP8 Silverlight application, so I created a new Universal Windows Project (Windows / Windows Phone 8.1). 我正在开发WP8 Silverlight应用程序的通用版本,因此我创建了一个新的通用Windows项目 (Windows / Windows Phone 8.1)。

The problem is that some of my fonts that are correctly shown in my Silverlight project aren't rendered in the new project. 问题是在我的Silverlight项目中正确显示的某些字体没有在新项目中呈现。

All my fonts are in the Shared project in the folder Assets/Fonts with the Build Action set to Content . 我所有的字体都在“ 共享”项目中的“资产/字体”文件夹中,并且“ 构建操作”设置为“ 内容”

The weird thing is that two fonts work and other two fonts don't. 奇怪的是,两种字体有效,而其他两种字体无效。

Here's how I set the font in my Windows Phone project: 这是我在Windows Phone项目中设置字体的方法:

<Button Content="GIOCA" Style="{StaticResource MenuButton}" FontFamily="Assets/Fonts/nexa-thin.ttf#Nexa Thin" FontSize="36" HorizontalAlignment="Stretch" Margin="0,50,0,0" />

The font is correctly listed as part of the project, no errors, but the font that I see is just the default one. 字体已正确列为项目的一部分,没有错误,但是我看到的字体只是默认字体。

The fonts that don't work were .otf but I converted them to .ttf using an online tool. 无法使用的字体为.otf,但我使用在线工具将其转换为.ttf Otf fonts were not working in the Silverlight project either but the converted ones worked properly. Otf字体在Silverlight项目中也不起作用,但是转换后的字体可以正常工作。 Is there anything else I could try? 还有什么我可以尝试的吗?

I got it working! 我知道了! I just had to remove the "Light" from the name! 我只需要从名称中删除“ Light”! So, for example, FontFamily="./Assets/Fonts/NexaLight.ttf#Nexa Light" should be FontFamily="./Assets/Fonts/NexaLight.ttf#Nexa" 因此,例如, FontFamily =“ ./ Assets / Fonts / NexaLight.ttf#Nexa Light”应该是FontFamily =“ ./ Assets / Fonts / NexaLight.ttf#Nexa”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM