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

1 visualización (últimos 30 días)
Yair Treister
Yair Treister el 10 de Oct. de 2011
Comentada: juhisteri el 17 de Jun. de 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..

Respuestas (3)

Aurelien Queffurust
Aurelien Queffurust el 11 de Oct. de 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 comentarios
Jan
Jan el 11 de Oct. de 2011
Does this set the font property, such that you have to restart MATLAB to activate it?

Iniciar sesión para comentar.


Jan
Jan el 11 de Oct. de 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 el 11 de Oct. de 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 comentario
Jan
Jan el 11 de Oct. de 2011
This will not help, because the OP wants to change the general appearence of all output.

Iniciar sesión para comentar.

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by