Help me read the doc on matlab.fonts Settings

1 Ansicht (letzte 30 Tage)
per isakson
per isakson am 18 Okt. 2020
Kommentiert: Yair Altman am 14 Nov. 2020
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
In the documentation I found the following example (It looks identical to that of R2018b.)
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 Kommentare
per isakson
per isakson am 19 Okt. 2020
Bearbeitet: per isakson am 20 Okt. 2020
Hello Mario,
I use cprintf - display formatted colored text in the Command Window, by Yair Altman to print to the command window. To apply different colors and plain/bold to different text fragments of a single line, I use several calls to cprintf().
Access and Modify Settings provides some answers.
Maybe, I should postpone the idea of switching fonts, since "Add font support" is on the TODO-list of cprintf() and most Matlab users use Monospaced anyway.
Yair Altman
Yair Altman am 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Steven Lord
Steven Lord am 20 Okt. 2020
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.
See the explanation of the purpose of each of the four levels here. Basically:
If you're querying for what value the setting has right now get the ActiveValue.
ActiveValue depends on the other three and will be the first of TemporaryValue, PersonalValue, and FactoryValue (in that order) that is set.
TemporaryValue gets cleared when MATLAB exits, PersonalValue and FactoryValue do not.

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by