How to prevent conflicts between emph and strong overrides for Chinese text?

This is not exactly the same, but maybe it could be used?

It shows that using set text() rules we can separate the four cases: emph, strong, strong(emph) and emph(strong). I don’t know if it’s sufficient, but if you can use the font’s covers options to set the font (instead of a regex rule), then you already have the separation of styles that you need.

  • Will not handle nested strong and nested emph
  • A style needs to be chosen for the combination of emphasis and strong. Pick a separate font for this case or other style tweak. We can’t of course apply two fonts at the same time, it has to be one or the other.

#let zhfont(x) = ((name: "Libertinus Serif", covers: "latin-in-cjk"), x)
#show strong: set text(red, font: zhfont("TW-MOE-Std-Kai"))
#show emph: set text(green, font: zhfont("MOESongUN"))

// Rules for both emph and strong
#show emph: it => {
  show strong: set text(blue, font: zhfont("TW-MOE-Std-Kai"))
  it
}
#show strong: it => {
  show emph: set text(blue, font: zhfont("TW-MOE-Std-Kai"))
  it
}

_Emph_

*Strong*

*_Strong Emph_*

_*Emph Strong*_

你好

_你好_

*你好*

*_你好_*

_*你好*_

(Note: my font selection was entirely random, just something that seemed to exist in the webapp. Happy to hear better suggestions.)

1 Like