[open-type] More tweaks to fixed types

Add set_int().
This commit is contained in:
Behdad Esfahbod 2023-01-07 14:27:15 -07:00
parent c8486b6301
commit 004cdc10f8
1 changed files with 2 additions and 2 deletions

View File

@ -147,10 +147,10 @@ struct HBFixed : Type
static constexpr float shift = (float) (1 << fraction_bits);
static_assert (Type::static_size * 8 > fraction_bits, "");
HBFixed& operator = (typename Type::type i ) { Type::operator= (i); return *this; }
operator signed () const = delete;
operator unsigned () const = delete;
int32_t to_int () const { return Type::v; }
typename Type::type to_int () const { return Type::v; }
void set_int (typename Type::type i ) { Type::v = i; }
float to_float (float offset = 0) const { return ((int32_t) Type::v + offset) / shift; }
void set_float (float f) { Type::v = roundf (f * shift); }
public: