Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the Mathematica front end to obey the FontFamily option

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.

Fonts in WordFonts in Mathematica


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).

like image 782
Szabolcs Avatar asked May 02 '11 12:05

Szabolcs


2 Answers

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.

like image 58
Phil Avatar answered Nov 02 '22 16:11

Phil


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.

image

like image 29
nanohc Avatar answered Nov 02 '22 16:11

nanohc