Skip to content

font-desc: Use local double values to store sizes

Marco Trevisan requested to merge 3v1n0/pango:approximated-sizes into main

Under i386 multiplying double and integer values and cast it to integer may end up to compute the wrong value when only 387 FPU is used, because the temporary value will be stored in a register whose precision isn't good enough. And so, some multiplications which are expected to produce an integer, will actually return a truncated value, that will be eventually floored.

An example is 1.2 * 12800 that is clearly 15360.0, but will produce 15359 when casted to int in the said i386 environment.

So use a temporary double variable to ensure that we do this computation in the double scope, before casting to int.

And this will avoid using the said register, even when using more aggressive optimizations.

Fixes: #580 (closed)

Edited by Marco Trevisan

Merge request reports