Figure saved to PDF with wrong font when using special characters.
68 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everyone!
I'm currently generating some plots for my thesis. I set figure properties inside the code and then print it with the print function. It looks something like this:
figure(PaperSize=[xdim ydim],PaperUnits="inches",PaperPosition=[0 0 xdim ydim]);
%plotting and plot settings
print(name,'-dpdf')
Recently I noticed I need to change the font in my figures to match the one I use in my thesis. I used fontname function for that. First, using a custom font didn't work so I opted for Times New Roman as it's the closest one to the font I'm using right now. Now Times New Roman works but only when I don't use special characters from my native language which is polish. So when I name xaxis with something like
xlabel(Moc wejściowa [dB])
it gets printed to pdf in default font which I don't want. If I exclude the "ś" character, it prints in Times New Roman just fine.
So far I haven't been successful with battling this issue. I tried using fontname with figure and gca as targets and printing using "Microsoft to PDF Printer" as a print option.
Problem does not appear when printing to png. However, I really need vector graphics and since it's easiest for me to use and I already made a lot of figures this way I really want to stay with pdf.
I appreciate your help.
Thank you!
0 Commenti
Risposte (1)
Kanishk
il 11 Nov 2024 alle 5:29
I reproduced the issue of the “Times New Roman” font not working with special characters.
I found a workaround by using ‘exportgraphics’ and ‘ContentType’ property.
font = 'Times New Roman';
set(gca, 'FontName', font);
title('Moc wejściowa [dB]', 'FontName', font);
xlabel('Moc wejściowa [dB]', 'FontName', font);
ylabel('Y-axis Label', 'FontName', font);
exportgraphics(gca, 'figure_name.pdf', 'ContentType', 'vector');
To learn more, please follow this official MATLAB Documentation for ‘exportgraphics’.
Hope this helps!!
Thanks
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!