Help me read the doc on matlab.fonts Settings
Show older comments
Background
I use the font, Inconsolata, in the Command Window and the Editor. It's very readable (imo), however there is a problem. The character width of the bold font is somewhat larger than that of the plain font. Now, I'm making a tool that outputs text to the command window. I mix bold and plain and requires "columns" to line up. That's not possible with Inconsolata. Thus, I want to temporarily switch to Monospaced.
Approach
s = settings;
s.matlab.fonts.codefont.Name.TemporaryValue = 'Times New Roman'

In the Preferens/Fonts GUI I reset the value. And inspected the codefont values.
>> s.matlab.fonts.codefont.Name
ans =
Setting 'matlab.fonts.codefont.Name' with properties:
ActiveValue: 'Inconsolata'
TemporaryValue: <no value>
PersonalValue: 'Inconsolata'
FactoryValue: 'Monospaced'
Questions
- What is the purpose of TemporaryValue ? The name itself indicates that its value will only be used for a limited time. Setting TemporaryValue obviously sets ActiveValue to the same value. ActiveValue is read-only.
- Should I use something like this
s = settings;
old_value = s.matlab.fonts.codefont.Name.ActiveValue;
s.matlab.fonts.codefont.Name.TemporaryValue = 'Monospaced';
% my print
s.matlab.fonts.codefont.Name.TemporaryValue = old_value;
EDIT: This approach won't work, since resetting the font will change all text in the Command Window.
3 Comments
Mario Malic
on 19 Oct 2020
Edited: Mario Malic
on 19 Oct 2020
Hello Per,
How do you print your data to command window?
I use the disp(X;Y) combined with Preferences - Command Window - Set matrix display width... (unchecked) that gives me this output, where X and Y are vectors 1x10.
% With format long
Function evaluation : 7
0.042840000000000 0.042840000000000 0.036280000000000 0.021000000000000 0
0 0.021710000000000 0.034440000000000 0.042000000000000 0.042000000000000
Interesting thing about it is that output varies depending on the width of command window. Function disp also supports HTML code if that would be of interest to you.
per isakson
on 19 Oct 2020
Edited: per isakson
on 20 Oct 2020
Yair Altman
on 14 Nov 2020
@Per - the reason this is not [yet] implemented in cprintf is because, as you've seen, the updated font applies to the entire Command Window text, not simply to the text from that point onward. I have not discovered a way to modify the font of just part of the Command Window.
Accepted Answer
More Answers (0)
Categories
Find more on System Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!