フィルターのクリア

Undocumented style of changing matlab font

1 回表示 (過去 30 日間)
Rostislav Teryaev
Rostislav Teryaev 2018 年 1 月 10 日
編集済み: Adam Danz 2021 年 4 月 1 日
I'm reading "Undocumented Secrets of matlab-java programming" by Yair Altman and try to change editor's font by means which are described in this book, but it has explicit examples only for color. Anyway, I managed to change font in matlab.prf by the following code:
FontName = "Consolas";
javaLangString = java.lang.String(FontName);
javaAwtFont = java.awt.Font(javaLangString,0,10);
com.mathworks.services.Prefs.setFontPref('Desktop.Font.Code2',javaAwtFont);
It does change font in preferences but doesn't press "apply" button. In other words it doesn't refresh environment font but change it in configuration file (matlab.prf). In case of color it was solved by this:
com.mathworks.services.ColorPrefs.notifyColorListeners('ColorsBackground');
It there any way to do this for font?
  1 件のコメント
Greg
Greg 2018 年 1 月 10 日
What's wrong with the normal preferences option for changing Editor font?

サインインしてコメントする。

採用された回答

Yair Altman
Yair Altman 2018 年 1 月 10 日
com.mathworks.services.FontPrefs.setCodeFont(javaAwtFont)
The FontPrefs class contains other useful static methods to set/get the text and code fonts, and to convert from the display font to the [larger] Java font (note: only the font-size changes) or vice-versa. Use my checkClass or uiinspect utilities (on the File Exchange) to investigate what this class offers.
Yair Altman
  2 件のコメント
Rostislav Teryaev
Rostislav Teryaev 2018 年 1 月 10 日
Thank you for your answer and book!
Yair Altman
Yair Altman 2018 年 1 月 10 日
My pleasure - please be kind enough to place a positive review about the book on Amazon: http://amazon.com/Undocumented-Secrets-MATLAB-Java-Programming-Altman/product-reviews/1439869030/ref=cm_cr_dp_see_all_summary

サインインしてコメントする。

その他の回答 (1 件)

Adam Danz
Adam Danz 2021 年 4 月 1 日
編集済み: Adam Danz 2021 年 4 月 1 日
Starting in Matlab r2018a, another way to set the editor's font is to use the Settings group.
This change will be maintained until the Matlab session ends:
S = setting;
S.matlab.fonts.codefont.Name.TemporaryValue = 'Consolas';
This change will be persistent across Matlab sessions for an individual user:
S = setting;
S.matlab.fonts.codefont.Name.PersonalValue = 'Consolas';
For Live Script font sizes, see S.matlab.fonts.editor

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by