DioxusLabs / taffy

A high performance rust-powered UI layout library
https://docs.rs/taffy
Other
2.08k stars 104 forks source link

add support for dimensions relative to font size #240

Open mockersf opened 1 year ago

mockersf commented 1 year ago

What problem does this solve or what need does it fill?

To help with responsive design, dimensions relative to font size are useful

What solution would you like?

Add support for em and rem. Additionally, ex and ch exist but are less useful

What alternative(s) have you considered?

None

Additional context

Unit Description
em Relative to the font-size of the element (2em means 2 times the size of the current font)
rem Relative to font-size of the root element
ex Relative to the x-height of the current font (rarely used)
ch Relative to the width of the "0" (zero)

https://www.w3schools.com/cssref/css_units.php

TimJentzsch commented 1 year ago

I think this should be implemented client/Bevy-side, because taffy doesn't really have a concept of font size

geom3trik commented 1 year ago

I would agree that this is a client-side issue. The client, which knows about the font, would need to convert the values specified in font-relative units into points before layout occurs.