且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Linux(Ubuntu 11.10)中的Matlab在图中未显示Unicode(希伯来语)

更新时间:2023-02-26 12:27:18

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

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.