# Wrong font selection for some characters in Mathematica 10 for Linux

I've just started using Mathematica 10 on Linux and have immediately run into problems with the fonts. Fonts on Linux are always a headache, but I had managed to find a reasonable one in "Century Schoolbook L". However, in Mathematica 10, this font and many others are being displayed with incorrect special characters and punctuation.

It seems like Mathematica is trying to assign sans-serif default (that is, not appearing in the font specified) characters when it needs to be using serif.

I have tried messing with "OperatorSubstitution" and "FontSerifed". The former can change the parentheses, but neither affects the Greek. My only current recourse is to select one of the fonts that (seemingly randomly) does not suffer this problem; "Linux Libertine O", for example.

Is this a bug? Is there a workaround?

-
not so relevant but I have found using LaTeX fonts in Mathematica to be useful. So that when writing papers using LaTeX, your figure captions has exactly the same font (latin modern roman, which is sans-serif font). –  Yi Wang Jul 24 '14 at 17:27

The answer to this question is inspired by @DBM answering on a related issue: How to write plain Greek in a text cell

I had a similiar problem, in summary:

1. I use Style["Some text with greek letters", FontFamily->"Some font, which includes greek letters"] and export it in pdf.
2. As the result the greek letters are shown with Mathematica font, and the rest with the chosen font.
3. Hence Mathematica replaces greek letters automatically into Mathematica font.

Not always a desired behaviour.

Moreover, since version 10: 1) PDF export has improved significantly, but 2) Internal fonts and encodings are stored differently.

Solution:

1. Find the file called FontMap.tr In linux I have it in "/usr/local/Wolfram/Mathematica/10.0/SystemFiles/FrontEnd/TextResources/FontMap.tr" , in Mac OS @DBM had it in "/Applications/Mathematica.app/FontMap.tr", and in Windows it is probably in the installation folder. Make a backup copy of it, e.g. FontMapBACKUP.tr

2. Open the file in a text editor. It contains the string CompressedData["Lots of weird characters"].

3. Open mathematica and define FontMap=Uncompress["Lots of weird characters"] . I.e. copy-paste the string and run Uncompress on it.

4. FontMap[[1,2]] contains character codes of the symbols, which will be replaced into Mathematica font. You can see, what characters are they exactly by running ReplacedCharacters = FromCharacterCode[#] & /@ FontMap[[1, 2]] . Furthermore, you can check, what do character codes signify by looking at http://reference.wolfram.com/language/tutorial/CharacterCodes.html .

5. For Mathematica not to replace the characters you like, you need to remove them from the list in FontMap. For example, I want Mathematica to replace only the characters which are not unicode characters. This means I should keep the characters with the code larger than 59391 (see the character codes web page): FontMap[[1, 2]] = Cases[FontMap[[1, 2]], x_ /; 59391 < x] . Now greek letters and other unicode symbols do not get replaced.

6. Call Compress[FontMap] , this will produce "Lots of new weird characters". Replace "Lots of weird characters" by "Lots of new weird characters" in FontMap.tr file. Restart Mathematica.

Done, now the fonts should look as they should!

Disclaimer: The above, however, solves my problem but not yours. It seems like the font you were using does not contain greek letters as a part of it. To see, which available fonts contain greek letters at all, one can go to Format-> Font and choose writing system to be Greek. The listed fonts are the ones, which include greek symbols.

-
It worked perfectly Alexey. A million thanks. It was driving me crazy. –  Zet Nov 2 '14 at 3:06
@Zet: Actually, I had very similar feelings here :) –  Alexey Bobrick Nov 2 '14 at 10:37

Mathematica 10.0.1 makes this issue worse by eliminating altogether the Serif Mathematica font. My notebooks now have Sans symbols by default or, using the strategy suggested by Alexey Bobrick and modifying FontMap.tr, some symbols like [Phi] or [CurlyTheta] appear as small rectangles even if I use a Serif font that has greek symbols.

This, I think, is a regression of the FrontEnd editing capabilities. I even tried replacing the new 10.0.1 Fonts with the 10.0 version, but it doesn't make a difference, so it seems that the Mathematica/MathematicaSans fonts are embedded in the executable FE code.

• Mathematica 10.0 with original FontMap.tr

• Mathematica 10.0 with new FontMap.tr

• Mathematica 10.0.1 with original/new FontMap.tr

-
One way not to get greek symbols while controlling them is to actually modify Fonts.tr in such a way that greek symbols are substituded by a preferred font. This is in complete analogy to how back in the past one had to modify Unicode.tr, I believe. –  Alexey Bobrick Oct 7 '14 at 13:31

Just for reference, let me post about what I do here as well.

I'm using Mathematica 10.0.1 for Mac. FontMap.tr is located at /Applications/Mathematica.app/Contents/SystemFiles/FrontEnd/TextResources.

Step 5 of Alexey's solution doesn't work for me. I have to remove FontMap[[3, 2]] instead:

FontMap[[3, 2]] = {}


And instead of removing all parts of FontMap[[1, 2]] whose values are less than 59391, I only remove the first 37 entries:

FontMap[[1, 2]] = Drop[FontMap[[1, 2]], 37]


to use my own typeface for the following common characters:

For some reason renaming the file to FontMap-backup.tr doesn't work. I use FontMap.trbackup instead.

-