Ignore:
Timestamp:
06/12/12 07:55:14 (13 years ago)
Author:
Mathieu Morlighem
Message:

updated export_fig to newest version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/externalpackages/export_fig/print2eps.m

    r11803 r12407  
    4545% alias can lead to another font being swapped in.
    4646
     47% 10/4/2012 Make the font swapping case insensitive.
     48
    4749function print2eps(name, fig, varargin)
    4850options = {'-depsc2'};
     
    5759end
    5860% Find all the used fonts in the figure
    59 fonts = get(findall(fig, '-property', 'FontName'), 'FontName');
     61font_handles = findall(fig, '-property', 'FontName');
     62fonts = get(font_handles, 'FontName');
    6063if ~iscell(fonts)
    6164    fonts = {fonts};
    6265end
    63 fonts = unique(fonts);
    6466% Map supported font aliases onto the correct name
     67fontsl = lower(fonts);
    6568for a = 1:numel(fonts)
    66     f = lower(fonts{a});
     69    f = fontsl{a};
    6770    f(f==' ') = [];
    6871    switch f
    6972        case {'times', 'timesnewroman', 'times-roman'}
    70             fonts{a} = 'Times-Roman';
     73            fontsl{a} = 'times-roman';
    7174        case {'arial', 'helvetica'}
    72             fonts{a} = 'Helvetica';
     75            fontsl{a} = 'helvetica';
    7376        case {'newcenturyschoolbook', 'newcenturyschlbk'}
    74             fonts{a} = 'NewCenturySchlbk';
     77            fontsl{a} = 'newcenturyschlbk';
    7578        otherwise
    7679    end
    7780end
     81fontslu = unique(fontsl);
    7882% Determine the font swap table
    7983matlab_fonts = {'Helvetica', 'Times-Roman', 'Palatino', 'Bookman', 'Helvetica-Narrow', 'Symbol', ...
    8084                'AvantGarde', 'NewCenturySchlbk', 'Courier', 'ZapfChancery', 'ZapfDingbats'};
    81 require_swap = find(~ismember(fonts, matlab_fonts));
    82 unused_fonts = find(~ismember(matlab_fonts, fonts));
    83 font_swap = min(numel(require_swap), numel(unused_fonts));
    84 font_swap = [reshape(matlab_fonts(unused_fonts(1:font_swap)), 1, font_swap); reshape(fonts(require_swap(1:font_swap)), 1, font_swap)];
     85matlab_fontsl = lower(matlab_fonts);
     86require_swap = find(~ismember(fontslu, matlab_fontsl));
     87unused_fonts = find(~ismember(matlab_fontsl, fontslu));
     88font_swap = cell(3, 0);
     89for a = 1:min(numel(require_swap), numel(unused_fonts))
     90    ind = find(strcmp(fontslu{require_swap(a)}, fontsl));
     91    n = numel(ind);
     92    font_swap(1,end+1:end+n) = reshape(mat2cell(font_handles(ind), ones(n, 1)), 1, []);
     93    font_swap(2,end-n+1:end) = matlab_fonts(unused_fonts(a));
     94    font_swap(3,end-n+1:end) = reshape(fonts(ind), 1, []);
     95end
    8596% Swap the fonts
    8697for a = 1:size(font_swap, 2)
    87     set(findall(fig, 'FontName', font_swap{2,a}), 'FontName', font_swap{1,a});
     98    set(font_swap{1,a}, 'FontName', font_swap{2,a});
    8899end
    89100% Set paper size
     
    114125    % Reset the font names in the figure
    115126    for a = 1:size(font_swap, 2)
    116         set(findall(fig, 'FontName', font_swap{1,a}), 'FontName', font_swap{2,a});
     127        set(font_swap{1,a}, 'FontName', font_swap{3,a});
    117128    end
    118129    % Replace the font names in the eps file
     130    font_swap = font_swap(2:3,:);
    119131    try
    120132        swap_fonts(name, font_swap{:});
Note: See TracChangeset for help on using the changeset viewer.