N0rbert
N0rbert

Reputation: 579

How should I setup MATLAB for correct display of Russian (Cyrillic) characters on figures in Linux?

I have installed MATLAB R2008b on Ubuntu 12.04.4 LTS and Windows XP. The system locale in Ubuntu is Unicode - en_US.UTF-8.

For compatibility with Windows I launch MATLAB in Ubuntu with ru_RU.CP1251 locale - so I have simple script to launch MATLAB:

 cat /opt/MATLAB_R2008b/bin/matlab-run
 #!/bin/bash
 export LANG="ru_RU.CP1251";
 export LC_ALL="ru_RU.CP1251";
 /opt/MATLAB_R2008b/bin/matlab -desktop

After that slCharacterEncoding and feature('DefaultCharacterSet') returns desired windows-1251 as expected.

There are many fonts in my system, almost all support Russian (Cyrillic) glyphs. Russian text displays normally in uicontrol (see screenshot enter image description here )

uicontrol('String','Русский=Russian','Position',[0 0 200 200])

but does not in figure labels and title, so

 x = linspace(0,2*pi,100); y = sin(x);
 xlabel('x, в радианах','interpreter','none');
 ylabel('y, значение sin(x)','interpreter','none');
 title('y, значение sin(x)','interpreter','none');

produce wrong characters in labels and title see screenshot.

I have no idea how to fix this. How should I setup MATLAB for correct display of Russian (Cyrillic) characters on figures in Linux?

Upvotes: 3

Views: 3277

Answers (1)

N0rbert
N0rbert

Reputation: 579

I solved my problem.

I installed all recommended fonts - packages xfonts-100dpi, xfonts-75dpi, xfonts-cyrillic, t1-cyrillic, cm-super, ttf-freefont, gsfonts-x11.

But what is interesting these fonts work only for UTF-8, so I can use the following fonts for displaying Russian (Cyrillic) text in figures:

  • clean
  • free avant garde
  • free bookman
  • free chancery
  • free courier
  • free helvetian
  • free paladin
  • free schoolbook
  • free times
  • oldslavic
  • tahoma guap
  • teams
  • terminus

For my original problem I found special ttf-font file, which works as expected and Russian (Cyrillic) text looks as expected in CP/Windows-1251 charset.screenshot

I placed this font in /usr/local/share/fonts/truetype, ran mkfontscale, mkfontdir and fc-cache -vf and added this location to /etc/X11/xorg.conf:

    Section "Files"
        FontPath "/usr/share/fonts/truetype"
        FontPath "/usr/local/share/fonts/truetype"
    EndSection

.

I installed language-pack-ru and edited /var/lib/locales/supported.d/local as follows:

en_US.UTF-8 UTF-8
ru_RU ISO-8859-5
ru_RU.CP1251 CP1251
ru_RU.KOI8-R KOI8-R

Upvotes: 2

Related Questions