# Encode rem values derived from pixels using \`rems_from_px\` \(\#9367\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/404adbce5b4fd1c4396c46d9eec76775dc7824dd)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 404adbce5b4fd1c4396c46d9eec76775dc7824dd

Requested commit: 404adbce5b4fd1c4396c46d9eec76775dc7824dd

Commit: 404adbce5b4fd1c4396c46d9eec76775dc7824dd

Tree: 668a077e4f0d6b87454cc38c6fe00a616ff13350

Author: Marshall Bowers

Committer: GitHub

## Message

```
Encode rem values derived from pixels using `rems_from_px` (#9367)

This PR adds a new `rems_from_px` helper function that can be used to
compute rem values based on a pixel value.

This is something we do fairly commonly, where we want to express a size
that is a given pixel size at the base rem size (e.g., "14px when the
rem size is 16px").

`rems_from_px` helps make the intent more explicit, as well as prevent
the base rem size from being duplicated everywhere.

Note: Ideally we would want `rems_from_px` to be `const`, but that
depends on https://github.com/rust-lang/rust/issues/57241.

Release Notes:

- N/A
```

## Parents

- [a78576a6dbcfcce93a7d7fc3941fb0b1d6bd92b4](https://git.cafe/gitcafe/zed/commit/a78576a6dbcfcce93a7d7fc3941fb0b1d6bd92b4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/404adbce5b4fd1c4396c46d9eec76775dc7824dd?format=markdown)
