3

I want to use Terminal face to display read-in strings in my program (on Windows, platform independence not important).

If I use Font font = Font.decode("Terminal-10"); It is not monospaced.

IF I use Font font = new Font(Font.MONOSPACED, Font.PLAIN, 11); All is well but it looks like Courier.

If I use (probably Im misinterpreting the API docs)

HashMap attr = new HashMap<TextAttribute,TextAttribute>();
attr.put("FAMILY", Font.MONOSPACED);
attr.put("FONT", Font.decode("Terminal-10"));

font = new Font(attr);

it's just using default values (some 12 point plain font). How to properly set attributes to a Terminal font? I'm drawing strings on a Graphics2D and saving them with ImageIO.

Recct
  • 913
  • 1
  • 16
  • 40

1 Answers1

1

Looks like you Java AWT doesn't support bitmap fonts at all - judging from what I see in Font class - it handles only TRUETYPE_FONT and TYPE1_FONT. Terminal is a bitmap font, so there's no easy way to use it using AWT's Font machinery.

I'm currently trying to solve a similar problem with rolling my own simple bitmap font engine with limited success in this question.

Community
  • 1
  • 1
GreyCat
  • 16,622
  • 18
  • 74
  • 112