Java Draw All Glyphs of a Font
fonts, java
Solution
How about:
final Font f = new Font(...);
for (char c = 0x0000; c <= Character.MAX_VALUE; c++) {
if (f.canDisplay(c)) {
// draw it ...
}
}
See `Font.canDisplay()`
`public boolean canDisplay(int codePoint)`
Checks if this Font has a glyph for the specified character.
Parameters:
`codePoint` - the character (Unicode code point) for which a glyph is needed.
Returns:
`true` if this `Font` has a glyph for the character; `false` otherwise.
Throws:
`IllegalArgumentException` - if the code point is not a valid Unicode code point.
Since:
1.5
See Also:
`Character.isValidCodePoint(int)`
Problem
Question: Given a Font object, how do I draw all the glyphs/symbols/characters of the Font? I know the following: I know how to create a Font object from file. I know to use g.setFont(...) ; // g is a Graphics2D I know to use g.drawString(...); // g is a Graphics2D However, I don't want to draw just the A-Z, a-z, 0-9 characters. I want to draw all the glyphs of the font. Is there a way to do this? Thanks!