Java, Standard Music Font Layout (SMuFL) and Fonts

Viewed 8

I am trying to use SMuFL with a Java application, but I am rather confused about how to determine the staff space size.

According to the SMuFL spec:

Dividing the em in four provides an analogue for a five-line staff: if a font uses 1000 upm (design units per em), as is conventional for a PostScript font, one staff space is equal to 250 design units; if a font uses 2048 upm, as is conventional for a TrueType font, one staff space is equal to 512 design units.

However, I am unsure how I find either the "em" or the "design units" within a Java application.

In my code I am loading the reference font (Bravura) thus:

Font f = Font.createFont(Font.TRUETYPE_FONT, JPanel.class.getResourceAsStream("/bravura/Bravura.otf"));
f = f.deriveFont(40f);

So I have a 40 point font, but I don't know how I can use that to determine how big the staff space should be for that font.

Thanks,

Carl

1 Answers

You can't, standard Java comes with an OpenType interface but no classes that implement it. However, you should also not need it because the em quad is literally your point size: it doesn't matter how many internal font units it measures, a font rendered at 40pt will scale "whatever the internal number of font units are for the em quad" so that it renders as 40pt high, and so your recommended staff height (in this case) is 10pt.

Related