stylix icon indicating copy to clipboard operation
stylix copied to clipboard

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

Open trueNAHO opened this issue 1 year ago • 17 comments

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

trueNAHO avatar Feb 07 '24 11:02 trueNAHO

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

  • fonts.sizes.applications = config.lib.stylix.types.size.from.points 12
  • config.stylix.fonts.sizes.applications.as.pixels
  • config.stylix.fonts.sizes.applications.as.points

See here for the library function which implements this.

danth avatar Feb 07 '24 13:02 danth