Linux(Ubuntu 11.10)中的Matlab在图中未显示Unicode(希伯来语) [英] Matlab in Linux (Ubuntu 11.10) doesn't display Unicode (Hebrew) in plot figure

查看:117
本文介绍了Linux(Ubuntu 11.10)中的Matlab在图中未显示Unicode(希伯来语)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的Ubuntu上的Matlab图形图中使用希伯来语字符,但无济于事.我试过了:

I try to use Hebrew characters in a Matlab figure plot on my Ubuntu to no avail. I tried:

text(0.6,0.5,'ירוק','fontname','times new roman','rotation',180,'fontsize',50,'color','r')

title('ירוק','fontname','times new roman','fontsize',50,'color','r')

类似于该问题的答案中提出的建议.我出现乱码(请参见附加的图像).

similar to what was proposed in the answer to this question. I got garbled text (see attached image).

Matlab的版本为R2009b.当然,我设置为UTF-8编码.

Matlab is in version R2009b. Of course I'm set to UTF-8 encoding.

>> slCharacterEncoding

ans =

UTF-8

我还可以通过ssh访问R2011a版本的远程计算机.那也不起作用. (我必须要slCharacterEncoding('UTF-8'))

I also have access to a remote computer via ssh, with version R2011a. That didn't work either. (There I had to slCharacterEncoding('UTF-8'))

使用javax.swing.JLabel组件的另一种选项很难与我拥有的图形数量一起使用.

The other option, using a javax.swing.JLabel component, is too difficult to use with the amount of graphing I have.

我可以继续制作带有英文坐标轴和标题的图形,但这很可惜.有什么建议吗?

I can continue producing graphs with English axes and titles, but that's a pity. Any advice?

编辑:按照Egon的建议,如果我可以print -deps然后替换文本(来自Matlab中的代码)到生成的EPS文件中,那也很酷.但是我不知道如何将Unicode放在EPS中,我认为这正在扩展它...

Edit: as suggested by Egon, if I can print -deps and then replace the text (from code within Matlab) in the resulting EPS file, that's pretty cool too. But I don't know how to place Unicode in EPS and I think that's stretching it...

又一次编辑:我开始认为这是X服务器问题.尽管有所不同,但是如果这些问题相关,我不会感到惊讶:

Yet another edit: I'm starting to think this is an X-server issue. Though different, I wouldn't be surprised if these issues are related:

  • Matlab figure fonts: broken in 11.04 contd. here
  • How to fix MATLAB small figures and small fonts in Ubuntu linux
  • View Full Version : [ubuntu] huge fonts in matlab

我尝试卸载Ubuntu提供的NVidia驱动程序(我有9300GS卡),然后重新安装NVidia提供的驱动程序(v295).我尝试将xorg.conf中的DPI更改为"100 x 100".安装了 HebrewLocalizationHowto 中列出的所有软件包,然后安装了一些软件包.没事.有建议吗?

I tried uninstalling Ubuntu supplied NVidia drivers (I have an 9300GS card) and re-installing NVidia supplied ones (v295). I tried changing DPI in xorg.conf to "100 x 100". Installed all packages listed in HebrewLocalizationHowto and then some. Nothing worked. Suggestions?

另一种编辑 matlab/sys/fonts/ttfmatlab/sys/fonts/type1下的字体显示不正确.当我编辑图形并双击标题时,我看到那里的字符,但是当我完成编辑后,它将返回错误的渲染.另外,建议使用呈现Unicode字符的JLabel解决方案这里在同一图形下正确显示文本.

Another edit Fonts located under matlab/sys/fonts/ttf or matlab/sys/fonts/type1 aren't rendered correctly. When I edit the figure and double click the title, I see the characters are there, but when I finish editing it returns to the bad rendering. Also, the JLabel solution for rendering Unicode characters suggested here renders text correctly under the same figure.

另一个编辑 Matlab R2011a出现了同样的问题.这是listfonts

Another edit Matlab R2011a exhibits the same issue. Here's the output of listfonts

>> listfonts

ans = 

    'aharoni'
    'andale mono'
    'anka clm'
    'arial'
    'arial black'
    'avant garde gothic'
    'AvantGarde'
    'batang'
    'bitstream charter'
    'biwidth'
    'Bookman'
    'caladings'
    'century schoolbook l'
    'charter'
    'clean'
    'clearlyu'
    'clearlyu alternate glyphs'
    'clearlyu arabic'
    'clearlyu arabic extra'
    'clearlyu devanagari'
    'clearlyu devangari extra'
    'clearlyu ligature'
    'clearlyu pua'
    'cmex10'
    'cmmi10'
    'cmr10'
    'cmsy10'
    'comic sans ms'
    'comix no2 clm'
    'Courier'
    'courier 10 pitch'
    'courier new'
    'dingbats'
    'dorian clm'
    'dotum'
    'drugulin'
    'ellinia'
    'fangsong ti'
    'fixed'
    'frank ruehl'
    'gan clm'
    'georgia'
    'gladia clm'
    'gothic'
    'Helvetica'
    'Helvetica-Narrow'
    'impact'
    'itc avant garde gothic'
    'itc bookman'
    'itc zapf chancery'
    'itc zapf dingbats'
    'ktav yad clm'
    'latin modern roman'
    'latin modern sans'
    'latin modern sansquotation'
    'latin modern typewriter'
    'latin modern typewriter variable width'
    'lucida'
    'lucida bright'
    'lucidabright'
    'lucidasans'
    'lucidasans typewriter'
    'lucidatypewriter'
    'mincho'
    'msam10'
    'msbm10'
    'nachlieli'
    'new century schoolbook'
    'newcenturyschlbk'
    'NewCenturySchoolBook'
    'newspaper'
    'nil'
    'nimbus mono l'
    'nimbus roman no9 l'
    'nimbus sans l'
    'open look cursor'
    'open look glyph'
    'ozrad clm'
    'Palatino'
    'song ti'
    'standard symbols l'
    'Symbol'
    'terminal'
    'texgyreadventor'
    'texgyrebonum'
    'texgyrecursor'
    'texgyreheros'
    'texgyrepagella'
    'texgyreschola'
    'texgyretermes'
    'Times'
    'times new roman'
    'trebuchet ms'
    'urw bookman l'
    'urw chancery l'
    'urw gothic l'
    'urw palladio l'
    'verdana'
    'wasy10'
    'webdings'
    'yehuda'
    'zapf chancery'
    'zapf dingbats'
    'ZapfChancery'
    'ZapfDingbats'

推荐答案

您是否尝试过禁用文本解释器?

Have you tried disabling the text interpreter?

因此,要么将'interpreter', 'none'添加为对text的调用的最后几个参数,要么将其设置为整个图形set(gcf,'defaulttextinterpreter','none'). 要将其全局应用,只需将gcf替换为0(这是根窗口).

So either adding 'interpreter', 'none' as the last few arguments of your call to text or setting this for the entire figure set(gcf,'defaulttextinterpreter','none'). To apply that globally, just replace gcf by 0 (that is the root window).

如果这不起作用,则可以尝试LateX解释器(在上面的'latex'处将none替换为),该解释器可能支持希伯来语字符.

If that doesn't work, you might try the LateX interpreter (replace none by 'latex' above), which might have support for Hebrew characters.

另一方面,但这是个人喜好,英文标签允许(实际上)任何人都可以阅读您的数字,仅允许您与他人交流思想.

On the other hand, but this is a personal preference, English labels allow (virtually) anyone to read your figures which only allows you to exchange ideas with other people.

修改 如您所提到的问题中所述,这是字体问题,而不是MATLAB问题. 我在Arch安装中尝试了此操作(它本身就有字体问题),但是我可以使用Arial字体很好地显示希伯来语字符.

edit As said in the question you referenced, it is a font problem, not a MATLAB problem. I tried it here on my Arch install (which has its fonts problems of its own), but I can get it to display your Hebrew characters just fine using the Arial font.

修改2 同样,这是一个字体问题,而不是MATLAB.我在Arch安装中再次尝试了此操作,现在希伯来语在您的第一个代码中工作正常.因此,我认为您安装的字体不是正确的版本.

edit 2 Again, this is a font problem, not MATLAB. I again tried this on my Arch install, and now Hebrew works fine with your first code. So I assume the fonts you have installed are not the right versions.

在Arch上,我安装了这些与字体相关的软件包:

On Arch, I have these font-related packages installed:

extra/cantarell-fonts 0.0.7-1
extra/font-bitstream-speedo 1.0.1-2
extra/fontsproto 2.1.2-1
extra/gsfonts 1.0.7pre44-3
extra/sdl_ttf 2.0.11-2
extra/t1lib 5.1.2-3
extra/ttf-bitstream-vera 1.10-8
extra/ttf-dejavu 2.33-2
extra/ttf-freefont 20100919-2
extra/xorg-font-util 1.3.0-1
extra/xorg-fonts-100dpi 1.0.1-4
extra/xorg-fonts-75dpi 1.0.1-4
extra/xorg-fonts-alias 1.0.2-2
extra/xorg-fonts-encodings 1.0.4-3
extra/xorg-fonts-misc 1.0.1-2
extra/xorg-fonts-type1 7.4-2
extra/xorg-mkfontscale 1.1.0-1
extra/xorg-xfontsel 1.0.4-1
extra/xorg-xlsfonts 1.0.3-2
community/ttf-liberation 1.07.2-1
aur/ttf-microsoft-wingding 1.55-1
aur/ttf-ms-fonts 2.0-9

对于Ubuntu,我不记得正确的软件包,但是我想您使用ttf-liberationttf-ms-conts(在Ubuntu中为msttcorefonts),xorg-fonts-100dpixorg-fonts-alias的成功机率最高.或他们的Debian/Ubuntu同行.

For Ubuntu, I don't remember the correct packages, but I guess you'd have the highest chances of success with ttf-liberation, ttf-ms-conts (msttcorefonts in Ubuntu), xorg-fonts-100dpi, xorg-fonts-alias or their Debian/Ubuntu counterparts.

因此,我认为有两种可能的解决方案:要么尝试另一种字体. Arial以前为我工作,T​​imes New Roman现在也为我工作.或在计算机上安装正确的字体.

So I think there are two possible solutions: either try another font. Arial worked for me before, Times New Roman now also works for me. Or install the proper fonts on your computer.

修改 为此,似乎在MATLAB中的渲染效果几乎完美.但是,导出到PDF无效.任何位图格式都可以正常工作.

edit On this end, it seems that rendering in MATLAB works almost perfectly. However, export to PDF doesn't work. Any bitmap formats should work fine.

我的下一个猜测确实是,对于PDF案例,应归咎于MATLAB.我通过使用常规的PDF保存并打印到文件进行了一些测试.两者都表现出相同的问题.这并不奇怪,因为MATLAB中的PDF保存功能似乎会生成PS,然后将其转换为PDF.大概在PS代中发生了一些烂烂和Unicode不兼容的事情.

My next guess, is indeed that for the PDF case, MATLAB is to blame. I did some tests by using the regular PDF save and printing to a file. Both exhibit the same problem. This is not surprising, since the PDF save feature in MATLAB seems to generate PS which is converted to PDF afterwards. Presumably, there is something rotten and unicode incompatible going on in the PS generation.

我知道这并不是您问题的完整解决方案,但是您至少可以将数字导出到PNG,如果您的分辨率足够高,大多数人不会注意到.

I know it is not a complete solution to your problem, but you can at least export your figures into PNG, if your resolution is high enough, most people won't notice.

如果您使用LaTeX生成报告,则另一种解决方案是使用 matlab2tikz 生成您的图形,就可以将希伯来语文本插入到LaTeX代码中.但是,由于我没有在TeX文件中使用希伯来语的经验,因此我不知道如何进行希伯来语编译的方法.

Another solution, if you use LaTeX to generate your report, is to use matlab2tikz to generate your figures, there I was able to get the Hebrew text to be inserted into LaTeX code. However, since I don't have experience with Hebrew in my TeX files, I don't know the tricks to get that to compile.

这篇关于Linux(Ubuntu 11.10)中的Matlab在图中未显示Unicode(希伯来语)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆