FontStyle
is just a collection of 3 enum values.
enum Weight {
kInvisible_Weight = 0,
// ...
kExtraBlack_Weight = 1000,
};
enum Width {
kUltraCondensed_Width = 1,
// ...
kUltraExpanded_Width = 9,
};
enum Slant {
kUpright_Slant,
kItalic_Slant,
kOblique_Slant,
};
You just use first byte for slant, second byte for width and final two bytes for weight. Now, the class stores it as an int inside. OTOH, SkColor
is simply a typedef for u32.
At present, we just treat FontStyle
as another class, and allocate it on heap. But it just feels weird to do that, when its an int. So, we can just typedef it to u32 too, for the sake of FFI and convert it appropriately in the FFI implementation by unpacking it into a class. The compiler should be able to optimize the redundant constructor away.