How to change font weight associated with #strong?

There is a bit of documentation showing how to override *this*. E.g.

#show strong: set text(red)

All good. But what I typically want is override font weight:

#show strong: set text(weight: "semibold")

and that fails (it is ignored). I suspect this is because strong is implemented by explicitly defining weight instead of “setting” a new text default value for those environments. Would it make sense to open a ticket on github to ask for strong to be converted to a show rule instead? Or is there another way to redefine what actual weight strong uses?

you can set strong(delta: ...) to a new value; see:

The default delta is to make the font heavier by 300 (whatever that weight unit used by font is called).

Note that fonts come in discrete weights – or rather, Typst doesn’t yet support variable fonts – so setting e.g. 400 may not change anything since the nearest available weight may still be the same. In that case, increase the change until it works.

1 Like

Ah brilliant! In this instance, I use a font which provides a semibold variant. I did not think you’d use delta instead of a named weight for strong.

I understand that working with continuous values sounds extremely compelling (especially with variable fonts, when they get supported) but I have a sneaky suspicion that defaulting to an explicit “bold” variant, when it exists, instead of a set delta, would lead to better typographic results overall.

Anyway, this solves that. Thanks!

1 Like

I just tried something because I had a suspicion why your approach didn’t work: the strong.delta and text.weight stack. So your code changed the weight from 400+300 to 600+300. Since the font probably didn’t have a “black” weight, that was still bold and it looked like your setting was ignored.

So if you absolutely want semibold, you can do this:

#set strong(delta: 0)
#show strong: set text(weight: "semibold")

Why is that not the default? Because nested strongs stack too:

*This is #[*really*] important*

That would result in weights 400+300 and 400+2*300.

Since the weight names in Typst are defined to correspond to certain numerical values, you could do the following to have a semibold → bold → extrabold progression for strong text:

#set strong(delta: 100)
#show strong: set text(weight: 500)  // or "medium"

Yes, I had come up with those rules for semibold :slight_smile: (once you know how it works, it’s pretty easy to navigate).

Ooooh, ok… I’m not sure how much strong-stacking is going to be a revelation or a major typography footgun but I have to say that this kind of composition appeals greatly to my math hemisphere… Yeah… Setting it up so that it does semibold by default and turns to bold if I stack them sounds great actually hehehe

1 Like

Is there a way, in terms of context, to display what specific font file (or variant) is being used? I’m puzzled… I see 4 variants where there should be only 3…

I don’t think there is, but that’s out of my area of expertise…

(also that’s more of a separate question; if you really need this, maybe make a new topic for it since this solved thread will probably not get the required visibility)

1 Like