How do I change the Matlab Desktop font preferences using commands?

2 次查看(过去 30 天)
I want to be able to create a shortcut which changes my Matlab Desktop (layout, font sizes, etc..) so that I can have a "Presentor" version of Matlab when I am presenting in a conference room, or to others, and a "Working" version of Matlab Desktop for when I am working..

回答(3 个)

Aurelien Queffurust
Aurelien Queffurust 2011-10-11
To display MATLAB on a screen for a public , I run this function :
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.
% Get largefonts preferences
FS = getpref('LargeFonts');
if isempty(FS) % Create preferences if necessary
setpref('LargeFonts','State','Off');
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 ~isstr(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 = 16; % Default size for large fonts
end;
%%Toggle font sizes
switch state
case 'on'
% 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))
setpref('LargeFonts','State','On');
case 'off'
% Small-
com.mathworks.services.FontPrefs.setCodeFont(java.awt.Font('Monospaced',java.awt.Font.PLAIN,10))
com.mathworks.services.FontPrefs.setTextFont(java.awt.Font('SansSerif',java.awt.Font.PLAIN,10))
setpref('LargeFonts','State','Off');
end;

Jan
Jan 2011-10-11
Font:
F = java.awt.Font('Arial', java.awt.Font.PLAIN, 16);
matchClass = 'javax.swing.JTextArea$AccessibleJTextArea';
cmdWinDoc = com.mathworks.mde.cmdwin.CmdWinDocument.getInstance;
cmdWinListener = cmdWinDoc.getDocumentListeners;
for iL = 1:length(cmdWinListener)
if isa(cmdWinListener(iL), matchClass)
cmdWinListener(iL).setFont(F);
break;
end
end
Layout:
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
desktop.restoreLayout('Command Window Only');
pause(0.1); % This might take some time
You can save the layout under an individual name. Note that the restoreLayout function is case-sensitive.
I'm going to add this to FEX: CmdWinTool. This tool can be used to create a lean desktop also.

Harry MacDowel
Harry MacDowel 2011-10-11
You know what, Yair, I bet you gonna love this extraordinary File Exchange function called
cprintf
Till today it still amazes me the length the author of that file went to achieve that.

类别

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

产品

Community Treasure Hunt

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

Start Hunting!

Translated by