danth / stylix

System-wide colorscheming and typography for NixOS
https://stylix.danth.me/
MIT License
1.11k stars 139 forks source link

stylix: support various `stylix.fonts.sizes` units #251

Open trueNAHO opened 7 months ago

trueNAHO commented 7 months ago

The config.stylix.fonts.sizes attribute set should be extended to support the pixel and point units due to various applications supporting different units.

Each exact value of the pixel and point units should have a complementary rounded value to account for the 1 point = (4 / 3) pixels conversion introducing floating point numbers. For reference, numbers can be efficiently rounded with number: builtins.floor (number + 0.5).

To avoid inconsistencies, an assertion should verify that only one of the pixel and point units is set by the end user.

Related: https://github.com/danth/stylix/pull/239#issuecomment-1931862955

danth commented 7 months ago

This could make use of black box types, which will be introduced by #102, to allow syntax like:

See here for the library function which implements this.