Paul Reiners
Paul Reiners

Reputation: 7894

Determining in Java whether a particular font can render a particular character

Is there a way in Java to determine whether a particular font can render a particular character?

Upvotes: 2

Views: 352

Answers (1)

alphazero
alphazero

Reputation: 27234

Try

Font f = ... ; // you have your font
Character c = 'ن'; // Nun, N, in Farsi

if(!f.canDisplay(c)) {
    int gcode = f.getMissingGlyphCode();
    System.out.format("not supported.  Glyph code used: %d\n", gcode);
}

Upvotes: 4

Related Questions