Alex Rivera | Logout

SWT - OS agnostic way to get monospaced font

Asked 2008-10-21T11:50:49.993
29

Is there a way in SWT to get a monospaced font simply, that works across various operating systems?

For example. this works on Linux, but not Windows:


Font mono = new Font(parent.getDisplay(), "Mono", 10, SWT.NONE);

or do I need to have a method that tries loading varying fonts (Consolas, Terminal, Monaco, Mono) until one isn't null? Alternatively I could specify it in a properties file on startup.

I tried getting the system font from Display, but that wasn't monospaced.

Edit
Report

1 Answer

1

If you want just a Monospaced font use "Courier" => new Font(display, "Courier", 10, SWT.NORMAL)

answered 2008-12-11T11:38:28.327

Your Answer