Reputation: 1507
I'm trying to get true type font glyph outlines using sample code from here.
There are some small errors in the code, including the fact that it only considers the whole part of the fixed point values that represent point positions of the glyphs.
There seem to be lots of examples of converting floating point values to fixed, but not vice-versa. How can I convert the whole FIXED value to a floating point value?
Upvotes: 2
Views: 2662
Reputation: 31428
I guess it's a
public struct FIXED
{
public short fract;
public short value;
}
that you want to convert to floating point. Such fixed-point numbers can be converted like this
var fix = new FIXED { value = 42, fract = 16384 };
double floating = fix.value + (double)fix.fract / 65536;
I divide by 65536
because a short
is 16 bits (2^16). It's actually kind of strange that's it a short
and not a ushort
since a fraction can't be negative.
Upvotes: 3