Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

c# - Embedded Font in WPF not working

I have a WPF application where I use icons from the font "Segoe UI Symbol". But when deploying to Windows 7 I realize the icons are missing because the font is updated in Windows 8.

I tried to embed font in WPF application as a resource following these instructions: http://msdn.microsoft.com/en-us/library/ms753303.aspx But it does not work.

Initially I had:

<TextBlock FontFamily="Segoe UI Symbol">

which works fine on Windows 8 computer. Then I added seguisym.ttf to directory "_Resources" and then use:

<TextBlock FontFamily="./_Resources/#Segoe UI Symbol">

This does not work on neither Windows 8 or Windows 7! I tried different settings for BuildAction: Resource, Embedded Resource and Content, but none of them work.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I finally found a way to use the newer version of "Segoe UI Symbol" even when older version is installed (i.e. on Windows 7). This approach works also in ClickOnce installation and requires no bootstrapping.

I guess the problem is caused by a name conflict with a font already loaded in Windows. So I renamed the newer version to avoid the conflict. It works.

1) Download utility program Typograf from this link: http://www.neuber.com/typograph/
2) Open directory where you have a copy of your font file
3) Click on font in list
4) Click Properties button in bar
5) Click Rename button, specify a new name (I chose "SegoeDynamic") and select where to save the new file
6) Add the new font file to your Visual Studio project directory (my directory is "/_Resources")
7) Use relative path or root path as you wish when referencing the font dynamically

 <TextBlock FontFamily="../_Resources/#SegoeDynamic">
 <TextBlock FontFamily="pack://application:,,,/_Resources/#SegoeDynamic">

Please observe that "Segoe UI Symbol" is released in several versions where each version adds more symbols. I have discovered at least the following:

Windows 7: 5.01 ( 823kb)

Windows 8: 5.90 (1660kb)

Windows 8.1: 6.09 (1740kb)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...