Inserting text on an image

Hi there!

I’m fairly new to typst, and I’m trying to add text to an image. For example, let’s say I have a firefox.png file with the Firefox logo, I’d like to be able to do something like (example on the right):

I haven’t found any examples that do this sort of thing, so I’m wondering if it’s possible.

To give more context, I want to define an image as the cover page of a template and use inputs such as title or date and place them on top of that cover page.

Let me know if anything is unclear here!

Actually, I think I’ve found a solution with this param in the page() function:

If you want to position text on an image, you can use block and place. The block will inherit the size from the image, and you can then place the text in the center of the block. If you want to further adjust the position of the text, you can use the parameters dx and dy.

#block({
  image("Mozilla_Firefox_Logo.png")
  place(center + horizon, text(white, size: 20pt, "My text goes here"))
})
2 Likes

Yep that would do it too! Thanks.

Or box, if inlining with text is needed.