altmany / export_fig

A MATLAB toolbox for exporting publication quality figures
BSD 3-Clause "New" or "Revised" License
1.27k stars 365 forks source link

Chinese characters are not correctly rendered in pdf #392

Closed wangshengseee closed 3 months ago

wangshengseee commented 3 months ago

Source Code

clear
clc

dod_io = [0.14 * (1:19) 2.8771] / 2.8771;
soc_io = [0.14 * (1:19) 2.8879] / 2.8879;
vd_io = [3.8001 3.7137 3.6410 3.5738 3.5068 3.4363 3.3601 3.2810 3.2005 3.1199...
         3.0375 2.9479 2.8457 2.7758 2.7108 2.6283 2.5310 2.4159 2.2910 2.0791];
vc_io = [2.2383 2.3759 2.5003 2.6181 2.7253 2.8015 2.8543 2.9199 3.0114 3.0972...
         3.1816 3.2647 3.3460 3.4242 3.4975 3.5652 3.6308 3.7002 3.7763 3.9307];

f = figure('Units','centimeters','Position', [15 10 8 5]);
hold on;
plot((1-dod_io)*100,vd_io,'o','Color',"#0072BD","MarkerSize",1.5);
plot(soc_io*100,vc_io,'o','Color',"#D95319","MarkerSize",1.5);
hold off;
set(gca,'fontname','times new roman','fontsize',7.5,'color','none','box','on');
xlabel('SoC (%)');
ylabel('OCV (V)');
legend({'增量法:放电','增量法:充电'},'fontname','SimSun','Color','none','Location','southeast','FontSize',6);

export_fig f1 -r600 -rgb -nocrop -transparent -pdf;

pdf file

f1.pdf

But it's normal when I export the figure as tiff format.

altmany commented 3 months ago

It works ok for me using the latest version of export_fig on Windows - see attached file test.pdf. test.pdf Perhaps your installation of ghostscript or Matlab do not have access to the SimSun font, or perhaps you run the code inside a live script and not in a standalone file or the Matlab console, I don't know...

altmany commented 3 months ago

image