解决方法为单声道PrivateFontCollection.AddFontFile错误 [英] Workaround for the Mono PrivateFontCollection.AddFontFile bug

查看:647
本文介绍了解决方法为单声道PrivateFontCollection.AddFontFile错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我称之为PrivateFontCollection.AddFontFile方法Mono.net它总是返回一个标准的FONT-FAMILY。这个bug已经报道了几个网站,但据我所知没有办法去解决它。该漏洞本身并没有固定在单声道库呢。 ?是否有任何解决办法

When I call the PrivateFontCollection.AddFontFile method in Mono.net It always returns a standard font-family. This bug has already been reported on several websites, but as far as I know without a way to solve it. The bug itself isn't fixed in the Mono-libraries yet. Is there any workaround for it?

编辑:作为心腹的回答反应,我将发布的代码:

As a reaction on henchman's answer I will post the code:

PrivateFontCollection pfc = new PrivateFontCollection();
pfc.AddFontFile("myFontFamily.ttf");
myFontFamily = pfc.Families[0x00];
Font myFont = new Font(myFontFamily,14.0f);



我知道这个代码将正常工作的Microsoft.Net框架,但在Mono执行时,只是给出了一个标准的FONT-FAMILY(我认为这是宋体)与myFontFamily.ttf的名称

I know this code will work fine on the Microsoft.Net framework, but when executing on Mono, it just gives a standard font-family (I think it is Arial) with the name of myFontFamily.ttf

推荐答案

发现这个职位从谷歌。如果它的任何安慰,我遇到AddMemoryFont同样的问题(在Windows上运行正常,单给我一个通用字体)。如果它的任何安慰,它看起来就像是用单声道出了问题,而不是你的代码。

Found this post from google. If it's any consolation, I'm experiencing the same issue with AddMemoryFont (works fine on Windows, mono gives me a generic font.) If it's any consolation, it looks like it's a problem with Mono, and not your code.

通源挖掘,System.Windows.Drawing.PrivateFontCollection大多只是围绕GDIPlus.GdipPrivateAddFontFile,这本身就是各地的fontconfig的FcConfigAppFontAddFile包装的包装。它似乎没有抛出任何错误的原因是,GDIplus不检查从fontconfig的返回值,所以它看起来的Fontconfig无法读取无论出于何种原因字体,但GDIplus不知道这件事,所以同样没有PrivateFontCollection。

Digging through the source, System.Windows.Drawing.PrivateFontCollection is mostly just a wrapper around GDIPlus.GdipPrivateAddFontFile, which itself is a wrapper around fontconfig's FcConfigAppFontAddFile. The reason it doesn't appear to throw any errors is that GDIplus doesn't check for a return value from fontconfig, so it seems like fontconfig isn't able to read the font for whatever reason, but GDIplus doesn't know about it, so neither does PrivateFontCollection.

这篇关于解决方法为单声道PrivateFontCollection.AddFontFile错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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