Loading a font directly from a file in C#

后端 未结 2 916
失恋的感觉
失恋的感觉 2021-02-19 09:17

Is there a way to do something like this?

FontFamily fontFamily = new FontFamily(\"C:/Projects/MyProj/free3of9.ttf\");

I\'ve tried a variety of

2条回答
  •  爱一瞬间的悲伤
    2021-02-19 09:49

    This piece of code works for me (WPF):

    FontFamily fontFamily = new FontFamily(@"C:\#FONTNAME")
    

    In your example, it would be:

    FontFamily fontFamily = new FontFamily(@"C:\Projects\MyProj\#free3of9");
    

    The font name without the file extension, and keep the '#' symbol.

提交回复
热议问题