Clear Filters
Clear Filters

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

9 views (last 30 days)
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.
title(['This is the title with unicode character',char(8240)],'Fontname','Arial')
print(gcf, '-dpdf', '-painters', 'testwith.pdf');
title(['This is the title without unicode character'],'Fontname','Arial')
print(gcf, '-dpdf', '-painters', 'testwithout.pdf');
Incorrect font:
Correct font:
  1 Comment
Bryan on 22 Nov 2019
Edited: Bryan on 23 Nov 2019
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.

Sign in to comment.

Answers (0)




Community Treasure Hunt

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

Start Hunting!