w3c / smufl

Standard Music Font Layout
https://w3c.github.io/smufl/latest/
214 stars 35 forks source link

On the relationship between glyphAdvanceWidths and standard OpenType tables #219

Open dbuenzli opened 2 years ago

dbuenzli commented 2 years ago

It seems to me that glyphAdvancesWidths is simply repeating the same information you can find in the OpenType hmtx table. Basically for a glyph this is simply:

   (advanceWidth / unitsPerEm) * 4 

Where advanceWidth is the value found in the hmtx table for the glyph and unitsPerEm the corresponding field in the unitsPerEm field of the head table and the multiplication by 4 to convert to staff space.

Is that correct ?

If it is, I'm not sure I understand the rationale of having such derived data, it increases the chances for metrics to go out of sync and poses the question of which one to use.

I tried to compute my own glyphAdvancesWidths on this Bravura.otf font using the above formula to compare it with this json metadata and all the computations match except for the following glyphs:

advances diff: otf:0.896 smufl:0.204 for glyph 2846 U+F42C caesuraSingleStroke
advances diff: otf:0.62 smufl:1.12 for glyph 3547 U+E3F9 accSagittal1TinaDown
advances diff: otf:0.62 smufl:1.12 for glyph 3548 U+E3F8 accSagittal1TinaUp
advances diff: otf:1.12 smufl:0.62 for glyph 3549 U+E3F7 accSagittal2MinasDown
advances diff: otf:1.12 smufl:0.62 for glyph 3550 U+E3F6 accSagittal2MinasUp

So which one should we trust ? The json metadata or the OpenType metrics ? Maybe the spec should have a few words on this.

dspreadbury commented 2 years ago

Your assertion about how to calculate the advance width value in the metadata is indeed correct. The data is reproduced in the JSON metadata files so that applications that don't have ready access to the internals of the font tables can have information about these values. These values were initially added to the specification at the request of developers from MakeMusic as it was important for the way that Finale's font annotation tables (in .fan files) work.