function largefonts(state)
% LARGEFONTS ON   Turn on large fonts
% LARGEFONTS OFF  Turn off large fonts
% LARGEFONTS      Toggle large fonts
% LARGEFONTS FS   Turn on large fonts, with font size FS.  
%
% LARGEFONTS also automatically sets large fonts to use the MATLAB
% standards: Monospaced for Code, SansSerif for Text.  It should restore
% your font preferences when turned off.
 
% Get current fonts
codefont = com.mathworks.services.FontPrefs.getCodeFont;
textfont = com.mathworks.services.FontPrefs.getTextFont;
 
% Get largefonts preferences
FS = getpref('LargeFonts');
 
if isempty(FS)  % Create preferences if necessary
    setpref('LargeFonts','State','Off');
    setpref('LargeFonts','CodeFont',codefont);
    setpref('LargeFonts','TextFont',textfont);
end;
 
 
% Parse input arguments
if nargin==0            % Toggle state
    state = lower(getpref('LargeFonts','State'));
    switch state
        case 'on'
            state = 'off';
        case 'off'
            state = 'on';
    end;
elseif ~ischar(state)  % Specified font size.  Turn on.
    FontSize = state;
    state = 'on';       % Turn on
else                    % Go to specified state
    state= lower(state);
end;
 
if ~exist('FontSize','var')
    FontSize = 14;      % Default size for large fonts
end;
 
%% Toggle font sizes
switch state
    case 'on'
        % Get current state:
 
        % Big-
        com.mathworks.services.FontPrefs.setCodeFont(java.awt.Font('Monospaced',java.awt.Font.BOLD,FontSize))
        com.mathworks.services.FontPrefs.setTextFont(java.awt.Font('SansSerif',java.awt.Font.BOLD,FontSize))
 
        % Update preferences
        setpref('LargeFonts','State','On');
        setpref('LargeFonts','CodeFont',codefont);
        setpref('LargeFonts','TextFont',textfont);
 
    case 'off'
        % Small-
        % Set back to original state
        codefont = getpref('LargeFonts','CodeFont');
        textfont = getpref('LargeFonts','TextFont');
        com.mathworks.services.FontPrefs.setCodeFont(com.mathworks.services.FontPrefs.convertJavaToPointFont(codefont))
        com.mathworks.services.FontPrefs.setTextFont(com.mathworks.services.FontPrefs.convertJavaToPointFont(textfont))
        setpref('LargeFonts','State','Off');
 
end;