Getting the Mathematica front end to obey the FontFamily option

杀马特。学长 韩版系。学妹 提交于 2019-12-09 08:01:02

问题


When it comes to Chinese characters, I am unable to get the Front End of Mathematica to use the fonts of my choice. How can I get it to use the fonts I need?

Here I provide two screenshots to show the problem, one from Word (top), the other from Mathematica on WinXP, both displaying the same string. Note that Mathematica uses several different fonts (I guess it uses font substitution when the font it tries to use first doesn't contain a glyph---however the font I specified contains all glyphs I need!). Here I use the font Microsoft YaHei, which comes with Win7, but is downloadable for XP too.

EDIT: Here's some test code:

str = "肖诮陗俏削帩消峭捎绡莦弰悄焇琑逍㲖㲵䏴哨娋宵屑綃梢痟睄筲艄萷销䇌䘯趙揱旓硝稍踃輎矟䌃箾蛸誚榍蕱銷鞘潲碿糏霄䴛韒髾鮹鞩魈颵"

Style[str, Large, FontFamily -> "SimSun"]

(SimSun comes with XP and should contain all these characters too, although not sure if in all versions.)

EDIT 2: I am on Windows XP (with East Asian language support enabled), I wonder if the results are different on other OSs.


Summary: It appears that the behaviour depends on the particular OS and the fonts installed, and unfortunately there seems to be no way to make the fonts uniform (even if there exists a single font containing all the glyphs).


回答1:


It could be mathematica is replacing your Font-Family setting with a neighbouring font. Running

Options[$FrontEnd, FontSubstitutions]

will give you the replacement list mathematica uses.




回答2:


Font family names are not equivalent to system font files names. You can read those font names by the way below.

This is the easy way to get the right font family name is

  • Firstly, type some text, e.g."我们", edit to your "target font" using the Mathematica menu.
  • Secondly, add //InputForm. After running the cell, you will get the right font name. In my computer, the fontfamily name for "楷体" is "¿ [Not]Ìå_GB2312". Awesome.




回答3:


For your first edit, some SimSun font may not cover enough CJK range (some of the characters in str belong to CJK Unified Ideographs Extension A). There is a wonderful site summarized the covering ranges of many East Asian Unicode fonts.

For your second edit, I think maybe you would like to use

"\[CapitalIHat]\[Cent]\[CapitalEGrave]\[IAcute]\[CapitalNTilde]\[CapitalARing]\.ba\[CapitalUAcute]"

as the FontFamily, which is actually a Unicode representation of the fontname's ChineseSimplified version:

FromCharacterCode[ToCharacterCode["微软雅黑", "CP936"]]

It works fine for on my Windows 7 English version.

And I think, at least for English version Mathematica, the FrontEnd always tries to interpret a CJK character as a Japanese character first, if failed (which means the character does not appear in the # Japanese section of UnicodeLanguageFontMapping.tr), lookup the # Chinese simplified section. Then the default fonts for different languages are defined in UnicodeFontMapping.tr(there is even a Klingon entry LOL), which links to @JohnFultz 's suggestion.



来源:https://stackoverflow.com/questions/5857289/getting-the-mathematica-front-end-to-obey-the-fontfamily-option

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