marcheiligers / dr-input

A simple input control for DragonRuby.
MIT License
4 stars 2 forks source link

Introduce FontStyle object & fix size_enum bug #14

Closed kfischer-okarin closed 6 months ago

kfischer-okarin commented 6 months ago

Extracted a FontStyle object to encapsulate string size calculations (in preparation for supporting size_px)

  1. Wrote a few tests covering most of the features involving string size calculation (except rendering - so please check if it all still looks alright :D)
  2. Use @font and @size_enum to construct a FontStyle object which can calculate string width & font_height
  3. Use @font_style.string_width instead of calcstringbox everywhere and pass around @font_style instead of @font and @size_enum
  4. Also added a FontStyle#label method as convenience to construct a label primitive hash with the correct values added

Also fixed a bug which prevented you from specifying size_enum as a number