opentype.js icon indicating copy to clipboard operation
opentype.js copied to clipboard

Possible Issue in `parse.mjs::getFixed()`

Open indiscripts opened this issue 8 months ago • 0 comments

The function getFixed which deals with Fixed-Point representation (16.16) is implemented as follows:

function getFixed(dataView, offset) {
    const decimal = dataView.getInt16(offset, false);
    const fraction = dataView.getUint16(offset + 2, false);
    return decimal + fraction / 65535; // ⚠ Are you sure of that divider?
}

I can't figure out why the low uint16 part (fraction) is divided by 65535 (0xFFFF) rather than 65536 (0x10000). This means that the Fixed-Point 0000.FFFF will be converted to 1 (!) while it should be 0.9999847412109375 (i.e. 65535/65536) according to this conversion tool.

Do I miss something obvious? (Sorry if I'm wrong and thanks in advance for any clarification.)

indiscripts avatar Feb 24 '25 21:02 indiscripts