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

2 Ansichten (letzte 30 Tage)
Yair Treister
Yair Treister am 10 Okt. 2011
Kommentiert: juhisteri am 17 Jun. 2021
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..

Antworten (3)

Aurelien Queffurust
Aurelien Queffurust am 11 Okt. 2011
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;
  2 Kommentare
Jan
Jan am 11 Okt. 2011
Does this set the font property, such that you have to restart MATLAB to activate it?

Melden Sie sich an, um zu kommentieren.


Jan
Jan am 11 Okt. 2011
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 am 11 Okt. 2011
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.
  1 Kommentar
Jan
Jan am 11 Okt. 2011
This will not help, because the OP wants to change the general appearence of all output.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Desktop finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by