How to specify image resolution in pixels?

With Typst is possible to create images for a certain resolution specified in pixels?
(as I noticed the lengths do not include pixels), what I have been doing is specifying the page size in mm then using the png export function with a specific ppi to target that resolution.

I mainly want to do this so my fonts are pixel perfect, and with this is it possible to use a bitmap font or similar (a .bdf font) - which are designed to be at certain pt sizes?

Maybe the easiest math is available if you specify the page size in pt. There is a fixed conversion of 1in = 72pt so then it’s easy to export with the correct ppi setting.

For example:

  • 144 ppi => 1 pt == 2 pixels
  • 288 ppi => 1 pt == 4 pixels

Any unit would work, you just have to figure out the integer valued conversion factors, but points is probably the easiest one because output resolution is measured in ppi.

1 Like

Typst only supports OTF and TTF fonts, so I don’t think that will be possible. At least it’s not implemented yet, unless you can convert the fonts to a format Typst supports.

1 Like