Repository navigation
Description
Description
When specifying the font Roboto with the option fallback: false while having both fonts Roboto and Roboto Condensed installed on the system the wrong font Roboto Condensed is selected.
Code to reproduce:
#text(
font: "Roboto",
fallback: false
)[
This is Roboto!
]The embedded font in the pdf is SUIXSO+RobotoCondensed-Regular.
When Roboto Condensed is removed from the system typst uses the correct font Roboto (embedded font in the pdf is SUIXSO+Roboto-Regular).
When both are installed on the system the output of fc-list : | grep Roboto is:
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-Thin.ttf: Roboto,Roboto Thin:style=Thin,Regular
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-MediumItalic.ttf: Roboto,Roboto Medium:style=Medium Italic,Italic
/usr/share/fonts/truetype/roboto/unhinted/RobotoCondensed-Italic.ttf: Roboto Condensed:style=Italic
/usr/share/fonts/truetype/roboto/unhinted/RobotoCondensed-Bold.ttf: Roboto Condensed:style=Bold
/usr/share/fonts/truetype/roboto/unhinted/RobotoCondensed-Medium.ttf: Roboto Condensed,Roboto Condensed Medium:style=Medium,Regular
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-ThinItalic.ttf: Roboto,Roboto Thin:style=Thin Italic,Italic
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-LightItalic.ttf: Roboto,Roboto Light:style=Light Italic,Italic
/usr/share/fonts/truetype/roboto/unhinted/RobotoCondensed-BoldItalic.ttf: Roboto Condensed:style=Bold Italic
/usr/share/fonts/truetype/roboto/unhinted/RobotoCondensed-LightItalic.ttf: Roboto Condensed,Roboto Condensed Light:style=Light Italic,Italic
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-Italic.ttf: Roboto:style=Italic
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-BlackItalic.ttf: Roboto,Roboto Black:style=Black Italic,Italic
/usr/share/fonts/truetype/roboto/unhinted/RobotoCondensed-Light.ttf: Roboto Condensed,Roboto Condensed Light:style=Light,Regular
/usr/share/fonts/truetype/roboto/unhinted/RobotoCondensed-MediumItalic.ttf: Roboto Condensed,Roboto Condensed Medium:style=Medium Italic,Italic
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-Medium.ttf: Roboto,Roboto Medium:style=Medium,Regular
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-Bold.ttf: Roboto:style=Bold
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-Black.ttf: Roboto,Roboto Black:style=Black,Regular
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-Light.ttf: Roboto,Roboto Light:style=Light,Regular
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-Regular.ttf: Roboto:style=Regular
/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-BoldItalic.ttf: Roboto:style=Bold Italic
/usr/share/fonts/truetype/roboto/unhinted/RobotoCondensed-Regular.ttf: Roboto Condensed:style=RegularAt the same time, typst does not seem to differentiate between the two fonts:
typst fonts | grep Roboto # when both fonts are installed
> RobotoAlso forcing typst to first look at the specific folder of one of the fonts does not change the list of discovered fonts.
Both seem to be interpreted as Roboto:
# folder with RobotoCondensed
typst fonts --font-path /usr/share/fonts/truetype/roboto/unhinted/ | grep Roboto
> Roboto
# folder with Roboto
typst fonts --font-path /usr/share/fonts/truetype/roboto/unhinted/RobotoTTF | grep Roboto
> RobotoUsed system: linux (22.04.1-Ubuntu)
Reproduction URL
No response
Operating system
Linux
Typst version
- I am using the latest version of Typst
Activity
Leedehai commentedon Dec 12, 2023
I did some digging and it turns out the font selection is based on font family and font variant. Both
RobotoandRoboto Condensed's family name is recognized as "Roboto" by Typst. In fact, both fonts are registered in Typst's internal font book asSo Typst has no way to differentiate the two.
Update: with
fc-scan --format="%{family}\n" [path][1] I can verify the family names are different. One isRoboto Condensedand the other is simplyRoboto. I can confirm Typst did pick up the correct family names from the fonts, buttypographic_family()strips away the suffix "condensed" afterwards before registering the fonts.Though it appears to be a WAI, in fact we probably need to change this behavior..
Update 2:
With
fc-scan --format="%{family} %{width}\n" [path]I can verify the "width" of both fonts are 100, despite [1] says "width" represents "Condensed, normal or expanded".[1] For a full list of possible properties ("names" in their jargon), see http://www.freedesktop.org/software/fontconfig/fontconfig-user.html#AEN21
laurmaedje commentedon Dec 12, 2023
Typst differentiates between the two via
#set text(stretch: 75%)(condensed) and#set text(stretch: 100%)(normal). Apparently, the metadata of Roboto Condensed is wrong if it also hasFontStretch(1000), which is 100%.laurmaedje commentedon Dec 12, 2023
While I want to retain this capability, I do agree that the current font grouping results in problems in some cases, because fonts are just such as mess. Also see: #2098
Enivex commentedon Dec 12, 2023
This is a duplicate of #576 I think?
JeyRunner commentedon Dec 12, 2023
Thank you both for looking into this :)
Yes #2098 would solve the issue. Maybe it would be nice to have a separate field in
textfor the full family name, likefont-full-name.Meanwhile, this could be fixed by just adding a separate case for the Roboto font in
typographic_family(note that I am new to the code base and not a rust expert...):But obviously, this is very hacky...
laurmaedje commentedon Dec 12, 2023
Closing in favor of #576