typst / typst

A new markup-based typesetting system that is powerful and easy to learn.

Home Page:https://typst.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Also select font via unprettified family name

laurmaedje opened this issue · comments

Description

Typst prettifies some font names, but ideally the true name should also work, that is, in the example below both line 2 and 3 should render in New CM.

Hello \
#text(font: "NewComputerModern10")[Hello] \
#text(font: "New Computer Modern")[Hello]

Moreover, conceivably a font could be selectable via full name or perhaps also PostScript name:

_Hello_ \
#text(font: "Linux Libertine Italic")[Hello]

Use Case

More compatibility.

I can take a look at this. I kinda familiarized myself with the fonts while investigating #2917. If the maintainers are willing, let's open a Forge thread?

I'll open one.

Maybe related: there seems to be no way to select font by size. For example,

#set text(font: "Latin Modern Sans", size: 17pt)

Hello, world!

uses an 8pt font:

$ pdffonts LM17.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
AKPPLH+LMSans8-Regular-Identity-H    CID Type 0C       Identity-H       yes yes yes      4  0

but I do have a "Latin Modern Sans" in 17pt installed:

$ fc-scan --format="%{file} / %{family} / %{style}\n" /usr/share/fonts/latinmodern/lmsans[0-9]*.otf
/usr/share/fonts/latinmodern/lmsans10-bold.otf / Latin Modern Sans,LM Sans 10 / 10 Bold,Bold
/usr/share/fonts/latinmodern/lmsans10-boldoblique.otf / Latin Modern Sans,LM Sans 10 / 10 Bold Oblique,Bold Italic
/usr/share/fonts/latinmodern/lmsans10-oblique.otf / Latin Modern Sans,LM Sans 10 / 10 Oblique,Italic
/usr/share/fonts/latinmodern/lmsans10-regular.otf / Latin Modern Sans,LM Sans 10 / 10 Regular,Regular
/usr/share/fonts/latinmodern/lmsans12-oblique.otf / Latin Modern Sans,LM Sans 12 / 12 Oblique,Italic
/usr/share/fonts/latinmodern/lmsans12-regular.otf / Latin Modern Sans,LM Sans 12 / 12 Regular,Regular
/usr/share/fonts/latinmodern/lmsans17-oblique.otf / Latin Modern Sans,LM Sans 17 / 17 Oblique,Italic
/usr/share/fonts/latinmodern/lmsans17-regular.otf / Latin Modern Sans,LM Sans 17 / 17 Regular,Regular
/usr/share/fonts/latinmodern/lmsans8-oblique.otf / Latin Modern Sans,LM Sans 8 / 8 Oblique,Italic
/usr/share/fonts/latinmodern/lmsans8-regular.otf / Latin Modern Sans,LM Sans 8 / 8 Regular,Regular
/usr/share/fonts/latinmodern/lmsans9-oblique.otf / Latin Modern Sans,LM Sans 9 / 9 Oblique,Italic
/usr/share/fonts/latinmodern/lmsans9-regular.otf / Latin Modern Sans,LM Sans 9 / 9 Regular,Regular


In fact, it seems typst finds all of these fonts:

$ typst fonts --variants
[...]
Latin Modern Sans
- Style: Normal, Weight: 700, Stretch: FontStretch(1000)
- Style: Italic, Weight: 400, Stretch: FontStretch(1000)
- Style: Italic, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Italic, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Italic, Weight: 400, Stretch: FontStretch(1000)
- Style: Italic, Weight: 600, Stretch: FontStretch(1000)
- Style: Italic, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Italic, Weight: 700, Stretch: FontStretch(1000)
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 600, Stretch: FontStretch(1000)
[...]

But it will only use the 8pt font lmsans8-regular.otf. If I move away this file, it will then choose the 17pt one lmsans17-regular.otf.

Note that the 17pt font is not the same as the 8pt scaled to 17pt (which is what typst produces).