|
|
|
|
|
by Guidii
1128 days ago
|
|
Font sizes get scaled in the browser. So when you ask for a 9px font, the browser treats that as 9px in virtual pixels, then maps it into 18px physical pixels. It mostly works, but gets weird when you have non-scaled content in the design. |
|
You don’t have non-scaled content in the design. Everything is scaled. <img width="32" height="32"> will be 32px (as in, CSS pixels) wide, whether that means 32dpx (device pixels) or 64dpx or something else.
(OK, so there are a few escape hatches; you have things like <img srcset> which allow you to choose different image sources for different scaling factors, and you can also query devicePixelRatio and change things based on it—though all of this isn’t actually guaranteed to map to physical pixels, e.g. my system uses 1.5× scaling but Firefox hasn’t finished implementing fractional scaling under Wayland so it renders at 2× and then scales down to 1.5×, so any line that is carefully made “one device pixel wide” will actually only be ⅔ of a device pixel.)