Does anybody know how to get JTextArea to display a fixed size
font on all platforms?
I want to make a simple code editor with save/open functionality,
which is simple enough, but I would like to get font to be
fixed-size, preferably courier new.
The problem is that courier new is proprietary apparently, and not
only is it not installed by default on many systems, but on most
modern systems, it is set to cleartype be default, which makes
it look like garbage.
I am tempted to make my own JPanel with update-render-paint and
reinvent the JTextArea, and save fonts as fixed-size bitmaps, but
this approach appears silly, and very time consuming.
I would like to include a free fixed-size font to the project and
use that font on all platforms, which appears possible. However,
modern systems appear to force-smooth all fonts, which I would
like to prevent it from doing.
Sadly, it appears that Swing automatically abides by system preferences
so without destroying user's settings, it appears to be a no go.
So in short, is there a way to get JTextArea to display a fixed-width
font and disable font smoothing/antialiasing (or at least toggle), or
is this task impossible using swing?
Thanks ahead of time!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…