2012-03-02 43 views
9

我尝试在我的Ubuntu上使用希伯来语字符在Matlab图形图中无济于事。我想:在Linux(Ubuntu 11.10)中的Matlab不会在剧情图中显示Unicode(希伯来语)

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

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

类似于在the answer to this question建议。我收到了乱码文本(请参阅attached image)。

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

>> slCharacterEncoding 

ans = 

UTF-8 

我也可以通过ssh访问远程计算机,版本为R2011a。那也行不通。 (在那里我不得不slCharacterEncoding('UTF-8')

另一个选项,使用javax.swing.JLabel组件,是太难以用我的图形数量。

我可以继续生成带有英文坐标轴和标题的图表,但这太遗憾了。有什么建议?


编辑:埃贡·所建议的,如果我能print -deps,然后更换产生的EPS文件(内从Matlab的代码)的文本,这很酷。但我不知道如何放置在Unicode的EPS,我认为这是拉伸它...

Screenshot of figure screen showing rubbish


另一个编辑:我开始认为这是一个X-服务器问题。虽然不同,但如果这些问题相关,我不会感到惊讶:

我试图卸载Ubuntu的供应NVidia驱动程序(我有一个9300GS卡)并重新安装NVIDIA提供者(V295)。我尝试将xorg.conf中的DPI更改为"100 x 100"。安装HebrewLocalizationHowto中列出的所有软件包,然后安装一些软件包。没有工作。建议?位于matlab/sys/fonts/ttfmatlab/sys/fonts/type1


另一个编辑字体不能正确渲染。当我编辑图形并双击标题时,我看到字符在那里,但是当我完成编辑时,它会返回到坏渲染。此外,JLabel solution for rendering Unicode characters suggested here在同一图下正确呈现文本。

另一编辑 Matlab R2011a表现出同样的问题。这里的输出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' 
+5

你在开玩笑吧?我在我的引用这个问题... – Yuval 2012-03-02 21:11:33

+0

你试过其他字体吗?您的时间副本新罗马可能不包括这些字符或不在正确的代码点。 (除了是一个比较丑的字体,恕我直言,反正)。从你的列表中,我会用''yehuda''开始,因为这听起来好像它应该包含希伯来字母。 – 2012-04-09 17:31:28

回答

4

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

因此,或者将'interpreter', 'none'作为您呼叫的最后几个参数添加到text或将其设置为整个数字set(gcf,'defaulttextinterpreter','none')。 要全局应用,只需用0(即根窗口)替换gcf即可。

如果这不起作用,您可以尝试LateX解释器(用上面的'latex'代替none),它可能支持希伯来字符。

另一方面,但这是个人偏好,英文标签允许(几乎)任何人阅读您的数字,只允许您与其他人交换意见。

编辑 正如在你引用的问题中说的那样,这是一个字体问题,而不是MATLAB问题。 我在Arch安装(它有自己的字体问题)这里试过了,但我可以用Arial字体显示你的希伯来字符。

Proof of Hebrew

编辑2 再次,这是一个字体问题,而不是MATLAB。我再次在我的Arch安装中尝试了这一点,现在希伯来语可以在您的第一个代码中正常工作。所以我假设你安装的字体不是正确的版本。

enter image description here

拱,我已经安装了这些字体相关的软件包:

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-liberation,ttf-ms-contsmsttcorefonts在Ubuntu),xorg-fonts-100dpi,xorg-fonts-alias或他们的Debian/Ubuntu对应成功。

所以我认为有两种可能的解决方案:或者尝试另一种字体。 Arial之前为我工作过,Times New Roman现在也适用于我。或者在电脑上安装正确的字体。

编辑 为此,似乎在MATLAB中渲染几乎完美。但是,导出到PDF不起作用。任何位图格式都应该正常工作。

我的下一个猜测,确实是对于PDF的情况,MATLAB是应该负责的。我通过使用常规PDF保存并打印到文件做了一些测试。两者都表现出同样的问题。这并不奇怪,因为MATLAB中的PDF保存功能似乎生成PS,然后将其转换为PDF。据推测,PS世代中存在着一些腐败和unicode不兼容的问题。

我知道这不是一个完整的解决方案,但您至少可以将您的数据导出为PNG,如果您的分辨率足够高,大多数人都不会注意到。

如果您使用LaTeX生成您的报告,另一个解决方案是使用matlab2tikz来生成您的数字,在那里我能够将希伯来文本插入到LaTeX代码中。但是,由于我在TeX文件中没有使用希伯来语的经验,所以我不知道如何编译这些技巧。

+0

英文很好,但我正在撰写一篇用希伯来语写的实验报告,因此我的偏好是。我想过TeX和'没有'解释器,所以我已经尝试过了。尝试使用LaTeX是个不错的主意,但是如果没有抱怨“警告:无法解释TeX字符串”并且无法显示,我就无法放入非英文字符。 – Yuval 2012-03-02 19:44:33

+0

@Yuval:我明白这是个人偏好。有了LaTeX,你可能需要以某种方式编码你的希伯来字符,但我没有任何经验,因为我不能自己读/写希伯来文。您的报告的替代方案可能是将数据导出为支持希伯来语的格式(只是猜测:EMF/WMF,PowerPoint,TikZ)? – Egon 2012-03-02 20:31:34

+0

我不认为这是字体问题;我有大部分这些字体的安装以及('中的xfonts-base','中的xfonts-INTL-european','中的xfonts - 100DPI-transcoded','中的xfonts-efont-unicode','中的xfonts-mathml','的xfonts-75dpi ','的xfonts-efont-Unicode的ib','中的xfonts-scalable','中的xfonts-75dpi-transcoded','中的xfonts-encodings','中的xfonts-utils')。当我指定一个我已经安装的TTF字体('FreeSans')时,它呈现不好。否则,当我指定它时很好地呈现“Times New Roman”,但它会在字符上产生乱码,典型的应用程序不支持UTF-8。我相信这是一个X服务器问题。 – Yuval 2012-04-07 20:43:29

3

使用下面的代码片段,你可以看到哪些字体容易

x=listfonts 
for i=1:numel(x) 
    display(x{i}) 
    title('ירוק','Color','red','FontName',x{i},'FontSize',50) 
    pause 
end 

工作对我来说龙力三世工作。但是它会显示希伯来文翻转。

您可以出口到EPS(打印-deps - 我发现这是Windows不可用;还是那句话,你不必有问题),并做了一些修改:

  • 删除编码从Matlab的恐怖:简单删除的\327
  • 所有出现添加/Encoding部用Matlab

即希伯来语字符代码输出映射,改变该:

%%IncludeResource: font FreeSans 
/FreeSans /ISOLatin1Encoding 200 FMSR 

-6384 483 mt 
(\327\220\327\221\327\222\327\223\327\224\327\225\327\226\327\227\327\230\327\231\327\233\327\234\327\236\327\240\327\241\327\242\327\244\327\246\327\250\327\247\327\251\327\252\327\237\327\232\327\245\327\235\327\243) s 

这样:

/Encoding [ 
/.notdef /.notdef /.notdef /.notdef 
/.notdef /.notdef /.notdef /.notdef 
/.notdef /.notdef /.notdef /.notdef 
/.notdef /.notdef /.notdef /.notdef 
/.notdef /.notdef /.notdef /.notdef 
/.notdef /.notdef /.notdef /.notdef 
/.notdef /.notdef /.notdef /.notdef 
/.notdef /.notdef /.notdef /.notdef 
/space /exclam /quotedbl /numbersign 
/dollar /percent /ampersand /quoteright 
/parenleft /parenright /asterisk /plus 
/comma /minus /period /slash 
/zero /one /two /three 
/four /five /six /seven 
/eight /nine /colon /semicolon 
/less /equal /greater /question 
/at /A /B /C 
/D /E /F /G 
/H /I /J /K 
/L /M /N /O 
/P /Q /R /S 
/T /U /V /W 
/X /Y /Z /bracketleft 
/backslash /bracketright /asciicircum /underscore 
/quoteleft /a /b /c 
/d /e /f /g 
/h /i /j /k 
/l /m /n /o 
/p /q /r /s 
/t /u /v /w 
/x /y /z /braceleft 
/bar /braceright /asciitilde /.notdef 
/.notdef /.notdef /.notdef /.notdef 
/.notdef /.notdef /.notdef /.notdef 
/.notdef /.notdef /.notdef /.notdef 
/.notdef /.notdef /.notdef /.notdef 
/alefhebrew /bethebrew /gimelhebrew /dalethebrew 
/hehebrew /vavhebrew /zayinhebrew /hethebrew 
/tethebrew /yodhebrew /finalkafhebrew /kafhebrew /lamedhebrew 
/finalmemhebrew /memhebrew /finalnunhebrew /nunhebrew /samekhhebrew /ayinhebrew 
/finalpehebrew /pehebrew /finaltsadihebrew /tsadihebrew /qofhebrew /reshhebrew 
/shinhebrew /tavhebrew /.notdef /.notdef 
/.notdef /registered /macron 
/degree /plusminus /twosuperior /threesuperior 
/acute /mu /paragraph /periodcentered 
/cedilla /onesuperior /ordmasculine /guillemotright 
/onequarter /onehalf /threequarters /questiondown 
/Agrave /Aacute /Acircumflex /Atilde 
/Adieresis /Aring /AE /Ccedilla 
/Egrave /Eacute /Ecircumflex /Edieresis 
/Igrave /Iacute /Icircumflex /Idieresis 
/Eth /Ntilde /Ograve /Oacute 
/Ocircumflex /Otilde /Odieresis /multiply 
/Oslash /Ugrave /Uacute /Ucircumflex 
/Udieresis /Yacute /Thorn /germandbls 
/agrave /aacute /acircumflex /atilde 
/adieresis /aring /ae /ccedilla 
/egrave /eacute /ecircumflex /edieresis 
/igrave /iacute /icircumflex /idieresis 
/eth /ntilde /ograve /oacute 
/ocircumflex /otilde /odieresis /divide 
/oslash /ugrave /uacute /ucircumflex 
/udieresis /yacute /thorn /ydieresis 
] def 

%%IncludeResource: font FreeSans 
/FreeSans /Encoding 200 FMSR 
1016 483 mt 
(\220\221\222\223\224\225\226\227\230\231\233\234\236\240\241\242\244\246\250\247\251\252\237\232\245\235\243) s 

(编码部分可以是拷贝原样;和\327 OCCURENCES被拆除)

这工作,但由于某种原因最后一个字符显示不正确。这对我来说已经够好了。