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

조회 수: 1 (최근 30일)
Yair Treister
Yair Treister 2011년 10월 10일
댓글: juhisteri 2021년 6월 17일
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;
  댓글 수: 2
Jan
Jan 2011년 10월 11일
Does this set the font property, such that you have to restart MATLAB to activate it?

댓글을 달려면 로그인하십시오.


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.
  댓글 수: 1
Jan
Jan 2011년 10월 11일
This will not help, because the OP wants to change the general appearence of all output.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by