How to measure available height and width in a context?

Thank you very much for your example. It does exactly what I would like, but unfortunately the API is not what I’ve been looking for. Sorry to be pedantic, but I would like it to be like a setting:

#show raw.where(block: true): scaled-content // or autofit whatever the function name is

to make all raw blocks automatically resize when the content is about to move out of bounds.

I apologize that this might not work with Typst.

That’s because there’s no maximum size defined in that measure call, so 1fr doesn’t make much sense in this case and Typst decides to give it a size of zero (measure is a pure function, when you call it it just measures something based on the given arguments).

Maybe I misunderstand it, but in your other example from here: How to auto-size text and images you have this call to measure

measure(width: size.width, { set text(text-size); it }).height <= size.height

where you size the text, measure it, but don’t actually apply it to . So I thought this behavior could be accomplished with measure(block(height: 1fr)) too. I apologize for not fully understanding the concept and what the difference is.