Why is my FontFamily “Arial”?

折月煮酒 提交于 2021-01-28 12:22:52

问题


I have the following chunk of code in which I was trying to set a font to size 8 Helvetica. I realized I don't have this font installed on my system so instead I get "Arial" for my FontFamily instead.

string family = "Helvetica";
Font font = new Font(family, 8f);
//font.FontFamily is now "Arial"

Fine... but, according to the MDSN documentation:

If the familyName parameter specifies a font that is not installed on the machine running the application or is not supported, Microsoft Sans Serif will be substituted.

It would sort of make sense to me of I was missing Microsoft Sans Serif, but I am not (I can specify "Microsoft Sans Serif" and that works). I'm simply getting Arial instead. Why is that?


回答1:


The reason is because certain popular, but not universally available fonts will get substituted for specific fonts that are close. In your case, Helvetica will by default be swapped to Arial. You can see a complete list of these swaps at:

HKLM/Software/Microsoft/Windows NT/CurrentVersion/FontSubstitutes


来源:https://stackoverflow.com/questions/32702528/why-is-my-fontfamily-arial

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!