Skip to content

Commit 5dc68a2

Browse files
committed
(3.52) Fixed: sgtitle was cropped in transparent PDF/EPS output (thanks @JohanWesto)
1 parent a612bea commit 5dc68a2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

export_fig.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@
413413
% 31/03/25: (3.49) Fixed(?) -transparency in PDF/EPS files (issue #401); override Matlab's default Title & Creator meta-data (issue #402)
414414
% 31/03/25: (3.50) Revert bad fix for issue #401
415415
% 08/07/25: (3.51) Fixed: figure with non-default colormap exported with default colormap in some cases (issue #389)
416+
% 07/09/25: (3.52) Fixed: sgtitle was cropped in transparent PDF/EPS output (thanks @JohanWesto)
416417
%}
417418

418419
if nargout
@@ -450,7 +451,7 @@
450451
[fig, options] = parse_args(nargout, fig, argNames, varargin{:});
451452

452453
% Check for newer version and exportgraphics/copygraphics compatibility
453-
currentVersion = 3.51;
454+
currentVersion = 3.52;
454455
if options.version % export_fig's version requested - return it and bail out
455456
imageData = currentVersion;
456457
return
@@ -1141,6 +1142,10 @@
11411142
try hCBs = getappdata(hAxes,'LayoutPeers'); catch, hCBs=[]; end %issue #383
11421143
hCBs = unique([findall(fig,'tag','Colorbar'), hCBs]);
11431144
hCbTxt = fixBlackText(hCBs,'Title'); % issue #382
1145+
1146+
% Fix subplot grid title (sgtitle) issue #406
1147+
hSpTxt = findobj(fig,'Type','subplottext');
1148+
hSpTxt = fixBlackText(hSpTxt,'');
11441149
end
11451150
% Generate an eps
11461151
print2eps(tmp_nam, fig, options, printArgs{:}); %winopen(tmp_nam)
@@ -1158,6 +1163,7 @@
11581163
set(hZrs, 'Color', [0,0,0]);
11591164
set(hTitle,'Color',[0,0,0]);
11601165
set(hCbTxt,'Color',[0,0,0]);
1166+
set(hSpTxt,'Color',[0,0,0]);
11611167
end
11621168
%}
11631169
% Restore the figure's previous background color (if modified)
@@ -2596,7 +2602,11 @@ function change_rgb_to_cmyk(fname) % convert RGB => CMYK within an EPS file
25962602

25972603
function hText = fixBlackText(hObject, propName)
25982604
try
2599-
hText = get(hObject, propName);
2605+
if isempty(propName) %issue #406
2606+
hText = hObject;
2607+
else
2608+
hText = get(hObject, propName);
2609+
end
26002610
try hText = [hText{:}]; catch, end %issue #383
26012611
for idx = numel(hText) : -1 : 1
26022612
hThisText = hText(idx);

0 commit comments

Comments
 (0)