I'm using Mathematica from Ubuntu. I need a normal font to display cyrillics inside PDFs. Any default font is very ugly, letters are too close together:

  ExportString[Style["Русский", FontFamily -> #, FontSize -> 50], 
   "PDF"]&/@ {"Times", "Courier", "Arial"}

enter image description here

Here is the longer example with also Latin mixed in:

enter image description here

As you can see Cyrillics letters are much bigger somehow.

It's happening to every text inside the notebook including graphics, even though it looks fine in the editor.

This is how it looks on MacOSX-x86-64 and Mathematica 8.0.4 which can be used as reference:

Mathematica graphics

  • $\begingroup$ Possible duplicate: mathematica.stackexchange.com/q/5660/121 (Sadly, no answers.) $\endgroup$
    – Mr.Wizard
    Oct 21, 2012 at 11:01
  • 1
    $\begingroup$ @Mr.Wizard I've seen it. I don't have nonsense in the output I just got ugly fonts. $\endgroup$
    – swish
    Oct 21, 2012 at 11:05
  • $\begingroup$ I understand now. Hopefully this one will be answered. $\endgroup$
    – Mr.Wizard
    Oct 21, 2012 at 11:07
  • $\begingroup$ This may be system dependent. On my OS, Win7-64 using Mathematica 8.0.4. I get this result which looks good to me. $\endgroup$ Oct 21, 2012 at 13:15
  • $\begingroup$ @SjoerdC.deVries Yes, I'm on linux $\endgroup$
    – swish
    Oct 21, 2012 at 14:07

1 Answer 1


In my opinion you don't have many options here and honestly, I would not try to achieve this with Mathematica and Linux because the font-rendering was, is and will at least for some time be crappy. In the examples, I use the "Liberation Serif" which is the default serif font on my system.

Let me give some ideas: The easiest thing I know is to use FontTracking to widen the characters.

    Style["Русский", FontFamily -> "Liberation Serif",
      FontSize -> 50, FontTracking -> "Wide"], "PDF"] // 
  First // Framed

Mathematica graphics

As you see the "y" is still touching the "P" and "Wide" is the maximal possible setting to this option. This brought me to my second idea where you adjust the low-level boxes to make the spacing right. Basically it works like that:

You split your string into characters and Riffle and invisible space between each character. This invisible space is wrapped in an AdjustmentBox where you have the option to set margins to all directions.

An outer StyleBox takes all your options for FontSize and so on. To see the spacing even to the left, right, bottom and top of the string, I used a FrameBox

         BoxMargins -> {{0.15, 0}, {1, 1.5}}], {2, -1, 2}]], 
      FontFamily -> "Liberation Serif", FontWeight -> Plain, 
      FontSize -> 50] // DisplayForm, "PDF"] // First

Mathematica graphics

How to implement the method 1

Try first the easy way which is to select appropriate fonts and setting the FontTracking to "Wide". This is more fiddling than a science but what I basically tried was the following. I created two text-cells with the same content. I leave the first one as it is and adjust the second to try what changes. If you find settings which are acceptable, you can transfer them into a stylesheet and use it.

So here is my test-environment. Create a new document from within a notebook, this will make saving the pdf and looking at the result much easier:

nb = CreateDocument[];
Button["SAVE ME!",
 Export["/home/oliviaWild/Desktop/cyrillicTest.pdf", nb]]

Create 3 text-cells, where the first and the second one contain the same cyrillic text and the last one maybe an upper-case (see ToUpperCase) English text for comparison.

First thing is, to set the font manually by marking the second cell and using Format->Font. Then save the document and check in you pdf viewer, whether the font is embedded (in evince, File->Properties->Fonts). I used DejaVu Serif and get the following font properties in the pdf viewer

enter image description here

See, that the default text-cells use Times which could not be embedded since it is not installed.

Go again in the second text cell and press Ctrl+Shift+E. You can append the FontTracking option there

 FontFamily->"DejaVu Serif",FontTracking->"Wide"]

Press Ctrl+Shift+E again and see the pdf. Like this you can play with all settings, either by marking the cell and use the *Format` menu or by adding the appropriat option directly in the cell expression.

When you are finished, you can store this in a style-sheet by using Format->Edit Stylesheet and selecting Text under "Choose a style". Click on this text cell, press Ctrl+Shift+E and add the font options at the end:

Cell[StyleData["Text"],FontFamily->"DejaVu Serif",FontTracking->"Wide"]

Press Ctrl+Shift+E and store the stylesheet.

How to implement the method 2

This is more work and I don't have time to investigate in this right now but what you basically have to do is to implement a function which transforms your text into this low-level box style. For some words Mathematica is doing this automatically. Make to text-cells, in the first you type "Latex is nice", in the other "LaTeX is nice". Look at the underlying expressions and you see that the word "LaTeX" was transformed in the same way I did above.

  • $\begingroup$ It's surely looks great but how to apply it to every cyrillic text in the notebook before printing? $\endgroup$
    – swish
    Oct 26, 2012 at 18:38
  • 1
    $\begingroup$ Can you updated your question by giving a longer text, maybe 3-4 sentences, and by explaining exactly where the text appears? Is it in input-cells, text-cells, ..? $\endgroup$
    – halirutan
    Oct 26, 2012 at 19:21
  • $\begingroup$ It still doesn't solve an oversized letters over Latin. I think what requires tweaking are some font system settings and not Mathematica. $\endgroup$
    – swish
    Oct 29, 2012 at 19:36
  • $\begingroup$ @swish And it would really help to some of the developers, which works on the front-end in Linux. Unfortunately, John Fultz is the only FE expert I know and he is working on Windows only to my knowledge. $\endgroup$
    – halirutan
    Oct 30, 2012 at 0:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.