Matlab 2025a export figure as vector changes font

18 次查看(过去 30 天)
I have a figure configured the way that I want that I'm trying to export as an SVG. The new export window in 2025a lets me specify SVG and vector graphics, but when I do it changes my fonts from times new roman to something else (Arial I think?). I cannot find a way to make it preserve the font settings. Is there a solution I'm missing? In the meantime I'll have to go back to 2024b.

采纳的回答

Kevin Holly
Kevin Holly 2025-9-4,20:58
编辑:Kevin Holly 2025-9-4,21:02
Thomas,
I tested the exportgraphics on the following figure and it exported correctly for me. Are you on R2025a Update 1?
fig = figure; ax = axes(fig);title(ax,"Times New Romans Font");ax.FontName = 'Times New Roman';
exportgraphics(fig, 'myfigure.svg', 'ContentType', 'vector');
You can run this line in MATLAB Online to view results:
fig2 = uifigure; h = uihtml(fig2,"HTMLSource",'myfigure.svg'); h.Position = [ 0 0 fig2.Position(3) fig2.Position(4)];
  2 个评论
Thomas Best
Thomas Best about 2 hours 前
Thanks for the reply Kevin. I should've supplied a MWE.
If I run:
>> % Define the 1-D coordinate vectors for x and y
x = -2:0.2:2;
y = -2:0.2:2;
% Create the 2-D grid coordinates using meshgrid
[X, Y] = meshgrid(x, y);
% Evaluate the function over the grid
Z = X .* exp(-(X.^2 + Y.^2));
>> surf(X, Y, Z);
>> xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis (f(x,y))');
>> set(gca,'FontName','times')
In the figure window, I followed "Save As" -> Export To -> Format = SVG -> Content Type = Vector. When I make the final selection for vector, the font changes.
Content Type set to Auto, the fonts are preserved:
Changing to Vector, the fonts get reset:
Example run using R2025a Update 1 (25.1.0.2973910
Kevin Holly
Kevin Holly about 1 hour 前
编辑:Kevin Holly about 1 hour 前
Thomas,
I have reported the issue to development and they have identified the issue and are resolving it.
In the meantime, if you set(gca,'FontName','times') to set(gca,'FontName','Times') instead, you should not have an issue.
Best,
Kevin Holly

请先登录,再进行评论。

更多回答(0 个)

类别

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

产品


版本

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by