When using New Computer Modern font, raw text block renders single quote after a Greek letter differently

https://typst.app/project/rzdmVHNbZkSSYlwzZhdBUp

As is shown in the image and the share link project, in raw blocks, if a single quote (') appears after a Greek letter, it renders differently. This reproduces on the Web application and on my Linux desktop. Disabling ligatures with

#show raw: text.with(font: "New Computer Modern Mono", ligatures: false, features: (liga: 0,  dlig: 0, clig: 0, calt: 0))

does not change this behavior. Any clue?


Weirdly, this does not reproduce on my Windows PC (via VSCode typst extension, in both preview and PDF generation), even if I don’t disable ligatures explicitly.

dunno why but you can use this workaround for now

#show raw: it => {
  set text(font: "New Computer Modern Mono")
  show "'": "'"
  it
}
1 Like

It relates to the script.

#show raw: set text(font: "New Computer Modern Mono")
= script: auto // Guess the script from the surrounding characters
`greek: τ'` vs. `latin: t'`
= script: `grek`
#show raw: set text(script: "grek")
`greek: τ'` vs. `latin: t'`
= script: `latn`
#show raw: set text(script: "latn")
`greek: τ'` vs. `latin: t'`

You can disable the locl Localized Forms feature if you don’t want any script-specific differences:

#show raw: set text(font: "New Computer Modern Mono", features: (locl: 0))
`greek: τ'` vs. `latin: t'`

图片

The workaround above relies on this bug: The inferred writing script is not passed to HarfBuzz, making `locl` ineffective · Issue #7396 · typst/typst · GitHub


Besides, I recommend that you replace the show-function rule (show raw: text.with(…) with a show-set rule (show raw: set text(…)).
Show-set rules can be overridden later when needed, but once you apply a function, you can never undo it.
See Which show rule takes precedence? - #15 by Y.D.X for explanation.

3 Likes

I see the reason behind the design:
For Greek texts, the font maps ' (the quotesingle glyph) to U+1FBD Greek Script GREEK KORONIS (the uni1FBD glyph).

#set text(font: "New Computer Modern Mono")
#"greek: τ'(\u{1fbd})" vs. #"latin: t'(\u{1fbd})"

图片

1 Like