Unicode character changes font when saving to PDF with -painters (Ubuntu)

8 次查看(过去 30 天)
When I save a figure to PDF in 2019a on Ubuntu 18.04 using the print() command and -painters renderer, using any kind of unicode character causes the font (Arial in this case) to change to some kind of default when the PDF is save.
It seems that that Matlab can see the font, but whatever Matlab calls in -painters to parse unicode characters does not see the font and reverts to using something else. It seems to be a problem restricted to -painters, because -opengl functions correctly, but that only prints to bitmap and I need -painters for the vector graphics.
I previously used Windows 7, and there was no problem there.
I have installed the Arial font on my Ubuntu system. It is at /usr/share/fonts/truetype/
Perhaps it should also be installed somewhere else, where -painters can also see it? I also added it to ~/.fonts and rebuilt the font cache but that doesn't seem to help. Although, other Linux fonts don't appear to work either.
figure
plot(NaN,NaN)
xticklabels([])
yticklabels([])
title(['This is the title with unicode character',char(8240)],'Fontname','Arial')
print(gcf, '-dpdf', '-painters', 'testwith.pdf');
figure
plot(NaN,NaN)
xticklabels([])
yticklabels([])
title(['This is the title without unicode character'],'Fontname','Arial')
print(gcf, '-dpdf', '-painters', 'testwithout.pdf');
Incorrect font:
unicode.jpg
Correct font:
without.jpg
  1 个评论
Bryan
Bryan 2019-11-22
编辑:Bryan 2019-11-23
After a lot of experimenting, it seems to work when I install Helvetica on my system and use that as the output font. That seems to be the font that -painters tries to revert to in Linux if it has trouble plotting symbols such as per mil. If Helvetica is not on your system, it will revert to using some random ugly font.
Still have no idea why it won't work with Arial, seeing as Arial also has the per mil symbol, but Helvetica is almost the same font, so I can use that I guess.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by