Programmatic Check For Monospace Font?

1 回表示 (過去 30 日間)
Tom
Tom 2011 年 10 月 9 日
I'm looking for a method to programmatically check if the console font in use is a monospace font. I want to print a warning that my script's ouput may not look correct if a monospace font is not in use. Can this be done?

採用された回答

Malcolm Lidierth
Malcolm Lidierth 2011 年 10 月 9 日
listeners=com.mathworks.mde.cmdwin.CmdWinDocument.getInstance().getDocumentListeners();
listeners(3).getFont()
  2 件のコメント
Tom
Tom 2011 年 10 月 9 日
Your solution didn't quite work for me, but led me to find a viable answer. I decided to simply force the font to be Monospaced at the top of my script, as shown below. Thanks for the link!
com.mathworks.services.Prefs.setFontPref('CommandWindow',java.awt.Font('Monospaced',java.awt.Font.PLAIN))
Walter Roberson
Walter Roberson 2011 年 10 月 9 日
Some day I'll have to figure out what the difference is between .services and .mlservices and .mde and ....

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 10 月 9 日
I do not see one at the moment, but if a way exists it might be found under com.mathworks.mlservices

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by