You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Also select font via unprettified family name #2098
Reacted by Joshua, Andrew Voynov, Michael Stopa, l0wx, +merlan #flirora, Marcin W. Dąbrowski, JeraBera / JeronimoBera, Tianyi, Tim Fischer, diquah and 9 more
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?
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
Note that Roboto Condensed is a variable font so even though it's only showing up at weight=400, it's valid for any weight.
Being able to select a weight by name is also be a nice to have and that would be captured by the PostScript name. Fonts like e.g. Bell Centennial have non-standard names (Address, Name & Number, Sub-Caption, Bold Listing) for their weights and it would be nice to not have to manually map them to numeric values. Others like FF Meta have two variants at the same weight with different names.
Reacted by Marcin W. Dąbrowski, TechnicJelle, Sean Clayton and Toon Verstraelen
I just installed Typst for the first time today, as well, to try and re-make my resume in it.
But my preferred font is Roboto, so I have also run into this issue now.
I do not know what to do to properly fix it.
My old resume, in LibreOffice:
What Typst makes of it:
The normal body text is fine, but any bold or heading text is condensed against my wishes.
My "code" is super simple for now, as I have not got further than this:
#setpage(
paper: "a4",
margin: (x: 0.5cm, y: 0.7cm),
)
#settext(
font: "Roboto",
size: 11pt,
)
// *snip*== Education=== Bachelor of Creative Media and Game Technologies Sept 2021 - Present
At *Saxion University of Applied Sciences*
I would love a fix for this issue. In my opinion font: "Roboto" should use the Roboto font, and not Roboto Condensed.
Yes, there is font duplication now, but the additional advantage of this (aside from it working) is that other devices can compile it as well, without having to have those fonts installed.
Roboto should be available in a non variable version and I would use that instead as variable fonts have limited support for now. Roboto vs Roboto Condensed comes down to ttf-parser not looking in every last location where a font can specify its stretch.
As of ttf-parser 0.25.0 the STAT table is parsed and can be checked. This should allow typst to get condensed versions of Roboto identified properly as condensed. This allows typst to check for correct information but has not (yet) been included in ttf-parser's is_bold and is_italic functions. See also #576. Unfortunately, I believe there are some breaking changes going from ttf-parser 0.24 to 0.25.
Related, I've not had the bandwidth recently to finish up the PANOSE support (harfbuzz/ttf-parser#172), so some older fonts are still out of luck if their OS/2 table only has correct information in the PANOSE field.
Short term the more more correct end-user fix is to use the static version of Roboto and add an exception to typst here for your local builds:
@terefang Whoever sold you those fonts should fix them. typst is getting the weight and/or slant wrong because ttf-parser is being fed incorrect information and not (as of 0.24) checking the additional places where correct information may (or may not) exist. typst currently uses ttf-parser 0.24.
As of 0.25 ttf-parser provides primitives to mitigate some of this, however looking at harfbuzz/ttf-parser#166, the changes to check STAT for weight and slant in the higher level functions didn't get included.
$ fc-scan --format="%{file} | %{family} | %{style} | %{width} | %{postscriptname}\n" *.ttf|sort
Bodoni-Antiqua-Pro-BoldItalic.ttf | Bodoni Antiqua Pro | Bold Italic | 100 | BodoniAntiquaPro-BoldItalic
Bodoni-Antiqua-Pro-Bold.ttf | Bodoni Antiqua Pro | Bold | 100 | BodoniAntiquaPro-Bold
Bodoni-Antiqua-Pro-Caps-Light.ttf | Bodoni Antiqua Pro Caps,Bodoni Antiqua Pro Caps Light | Light,Regular | 100 | BodoniAntiquaProCaps-Light
Bodoni-Antiqua-Pro-Caps-Regular.ttf | Bodoni Antiqua Pro Caps | Regular | 100 | BodoniAntiquaProCaps
Bodoni-Antiqua-Pro-Cd-BoldItalic.ttf | Bodoni Antiqua Pro Cd | Bold Italic | 100 | BodoniAntiquaProCd-BoldItalic
Bodoni-Antiqua-Pro-Cd-Bold.ttf | Bodoni Antiqua Pro Cd | Bold | 100 | BodoniAntiquaProCd-Bold
Bodoni-Antiqua-Pro-Cd-DemiItalic.ttf | Bodoni Antiqua Pro Cd,Bodoni Antiqua Pro Cd Demi | Demi Italic,Italic | 100 | BodoniAntiquaProCd-DemiItalic
Bodoni-Antiqua-Pro-Cd-Demi.ttf | Bodoni Antiqua Pro Cd,Bodoni Antiqua Pro Cd Demi | Demi,Regular | 100 | BodoniAntiquaProCd-Demi
Bodoni-Antiqua-Pro-Cd-Italic.ttf | Bodoni Antiqua Pro Cd | Italic | 100 | BodoniAntiquaProCd-Italic
Bodoni-Antiqua-Pro-Cd-Regular.ttf | Bodoni Antiqua Pro Cd | Regular | 100 | BodoniAntiquaProCd
Bodoni-Antiqua-Pro-Compress-Bold.ttf | Bodoni Antiqua Pro Compress | Bold | 100 | BodoniAntiquaProCompress-Bold
Bodoni-Antiqua-Pro-Compress-Regular.ttf | Bodoni Antiqua Pro Compress | Regular | 100 | BodoniAntiquaProCompress
Bodoni-Antiqua-Pro-DemiItalic.ttf | Bodoni Antiqua Pro,Bodoni Antiqua Pro Demi | Demi Italic,Italic | 100 | BodoniAntiquaPro-DemiItalic
Bodoni-Antiqua-Pro-Demi.ttf | Bodoni Antiqua Pro,Bodoni Antiqua Pro Demi | Demi,Regular | 100 | BodoniAntiquaPro-Demi
Bodoni-Antiqua-Pro-Italic.ttf | Bodoni Antiqua Pro | Italic | 100 | BodoniAntiquaPro-Italic
Bodoni-Antiqua-Pro-LightItalic.ttf | Bodoni Antiqua Pro,Bodoni Antiqua Pro Light | Light Italic,Italic | 100 | BodoniAntiquaPro-LightItalic
Bodoni-Antiqua-Pro-Light.ttf | Bodoni Antiqua Pro,Bodoni Antiqua Pro Light | Light,Regular | 100 | BodoniAntiquaPro-Light
Bodoni-Antiqua-Pro-Regular.ttf | Bodoni Antiqua Pro | Regular | 100 | BodoniAntiquaPro
@terefang It was just triaging and making use of the new label. It has no implications on priorities. I understand that you consider this important and it's true that font handling is quite broken, but there a lot of things to do and pinging me regularly will not make it go any faster.
although typst is somewhat "the new kid on the block", i consider it already an alternative if not the successor to latex and other pdf generating tools.
so many cheers to all the developers making this possible.
why is font handling so important to me ? because it is the only blocker that prohibits me from switching over to typst with all its glory and features.
i have written pdf generation libs in both Perl and Java in the past along with work in the LaTeX, HTML and CSS domains, so know my way around fonts both in format specs bit-by-bit wise and actual handling.
i would like to contribute code to make your life easier, but unfortunately learning rust from scratch isnt something that i can fit into my time-table.
so far i am only able to contribute ideas and suggestions, if that bandwidth is too high i will tone down the frequency.
sorry if i have bothered you too much.
Reacted by Laurenz, heynicebits, Scott Rubin, Michael Stopa and Leo Li
the problem really is that i have a kinda broken font family and actually
want to use all variants of it in a single document.
you suggestion does not help in that case
@terefang Just fix the font. It isn't very hard to modify the family name tables to something that works for your use case or just copy the different variants into your own face instances. Of course Typst should handle this more gracefully, but you aren't dependent on it getting fixed to move your project on.
@terefang Just fix the font. It isn't very hard to modify the family name tables to something that works for your use case or just copy the different variants into your own face instances. Of course Typst should handle this more gracefully, but you aren't dependent on it getting fixed to move your project on.
unfortunately in my case these are commercial fonts --- i dont have a license to modify that font, only use it as is.
do you see the dilemma ? even if i would technically be able to fix the fonts --- i cannot use them because i would be breaking the license agreement (and the law) and be wide open to litigation.
The suffix means that the font only covers the glyphs for characters used in the particular region — China in this case (region-specific SubsetOTF for China / Simplified Chinese). Adobe also publishes Source Sans Sans TW/HK/JP/KR.
It is not the condensed version of Source Han Sans. The latter is another font with full character coverage that sets Japanese glyphs as the defaults (language-specific OTF for Japan / Japanese).
The suffix means the Unicode block CJK Unified Ideographs Extension B. There is also SimSun-ExtG. There are too many Han/CJK characters, so SimSun split them into three files:
Activity
Leedehai commentedon Dec 12, 2023
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?
laurmaedje commentedon Dec 13, 2023
I'll open one.
tornaria commentedon Dec 15, 2023
Maybe related: there seems to be no way to select font by size. For example,
uses an 8pt font:
but I do have a "Latin Modern Sans" in 17pt installed:
In fact, it seems typst finds all of these fonts:
But it will only use the 8pt font
lmsans8-regular.otf. If I move away this file, it will then choose the 17pt onelmsans17-regular.otf.Note that the 17pt font is not the same as the 8pt scaled to 17pt (which is what typst produces).
inferiorhumanorgans commentedon Aug 10, 2024
With Roboto and Roboto Condensed installed there's no way to select a specific variant.
https://fonts.google.com/specimen/Roboto
https://fonts.google.com/specimen/Roboto+Condensed
Note that Roboto Condensed is a variable font so even though it's only showing up at weight=400, it's valid for any weight.
Being able to select a weight by name is also be a nice to have and that would be captured by the PostScript name. Fonts like e.g. Bell Centennial have non-standard names (Address, Name & Number, Sub-Caption, Bold Listing) for their weights and it would be nice to not have to manually map them to numeric values. Others like FF Meta have two variants at the same weight with different names.
TechnicJelle commentedon Nov 10, 2024
I just installed Typst for the first time today, as well, to try and re-make my resume in it.
But my preferred font is Roboto, so I have also run into this issue now.
I do not know what to do to properly fix it.
My old resume, in LibreOffice:

What Typst makes of it:

The normal body text is fine, but any bold or heading text is condensed against my wishes.
My "code" is super simple for now, as I have not got further than this:
I would love a fix for this issue. In my opinion
font: "Roboto"should use the Roboto font, and not Roboto Condensed.terefang commentedon Nov 24, 2024
you might want also to look at my ticket #5455
TechnicJelle commentedon Nov 25, 2024
Currently, I worked around this issue by ignoring the system fonts, and supplying my own specific font files.
Like this:
My specific file structure
Yes, there is font duplication now, but the additional advantage of this (aside from it working) is that other devices can compile it as well, without having to have those fonts installed.
terefang commentedon Nov 25, 2024
if i remember correctly, variable font files are not valid for pdf embedding.
inferiorhumanorgans commentedon Nov 25, 2024
Roboto should be available in a non variable version and I would use that instead as variable fonts have limited support for now. Roboto vs Roboto Condensed comes down to
ttf-parsernot looking in every last location where a font can specify its stretch.As of
ttf-parser0.25.0 theSTATtable is parsed and can be checked.This should allowThis allowstypstto get condensed versions of Roboto identified properly as condensed.typstto check for correct information but has not (yet) been included inttf-parser'sis_boldandis_italicfunctions. See also #576. Unfortunately, I believe there are some breaking changes going fromttf-parser0.24 to 0.25.Related, I've not had the bandwidth recently to finish up the PANOSE support (harfbuzz/ttf-parser#172), so some older fonts are still out of luck if their
OS/2table only has correct information in thePANOSEfield.Short term the more more correct end-user fix is to use the static version of Roboto and add an exception to
typsthere for your local builds:https://github.com/typst/typst/blob/main/crates/typst-library/src/text/font/exceptions.rs
terefang commentedon Nov 27, 2024
let me add a reality check here – i recently bought a commercial grade font-bundle from a german manufacturer targetted at the SMB/KMU market.
1 - non of the files contains a STAT table.
2 - using (version 0.12.0)
typst fonts --ignore-system-fonts --font-path ./ --variantsi getfor
3 - i also took a "Pro" version font family to the test:
for
i am willing to work with the manufacturer to fix their fonts – what should i tell them exactly ?
inferiorhumanorgans commentedon Nov 27, 2024
@terefang Whoever sold you those fonts should fix them.
typstis getting the weight and/or slant wrong becausettf-parseris being fed incorrect information and not (as of 0.24) checking the additional places where correct information may (or may not) exist.typstcurrently usesttf-parser0.24.As of 0.25
ttf-parserprovides primitives to mitigate some of this, however looking at harfbuzz/ttf-parser#166, the changes to checkSTATfor weight and slant in the higher level functions didn't get included.For diagnostic information start here:
#576 (comment)
inferiorhumanorgans commentedon Nov 27, 2024
That said I think a mechanism to select a font by its Postscript name would be a big win.
terefang commentedon Nov 27, 2024
let me add:
inferiorhumanorgans commentedon Nov 27, 2024
Right, see my comment above for information on how to get more detailed information from your fonts.
terefang commentedon Nov 27, 2024
yeah ... but what about if the fonts cannot be fixed because of complex licensing issues ?
then it would make sense to have something in place like i proposed in #5455
terefang commentedon Nov 27, 2024
do you suggest that i need to install a complete rust dev environment just to get the debugging utility ?
which has build errors btw
terefang commentedon Nov 27, 2024
maybe a more common tool could be used like ttfdump ?
looks like the
usWidthClassis wrong.terefang commentedon Jan 24, 2025
any thoughts on this ? also referencing #5455
terefang commentedon Feb 26, 2025
thx @laurmaedje , your reassignment to "change request" gives me hope that this will be handled soon, or isnt it ?
laurmaedje commentedon Feb 26, 2025
@terefang It was just triaging and making use of the new label. It has no implications on priorities. I understand that you consider this important and it's true that font handling is quite broken, but there a lot of things to do and pinging me regularly will not make it go any faster.
terefang commentedon Mar 2, 2025
let me just clarify:
although typst is somewhat "the new kid on the block", i consider it already an alternative if not the successor to latex and other pdf generating tools.
so many cheers to all the developers making this possible.
why is font handling so important to me ? because it is the only blocker that prohibits me from switching over to typst with all its glory and features.
i have written pdf generation libs in both Perl and Java in the past along with work in the LaTeX, HTML and CSS domains, so know my way around fonts both in format specs bit-by-bit wise and actual handling.
i would like to contribute code to make your life easier, but unfortunately learning rust from scratch isnt something that i can fit into my time-table.
so far i am only able to contribute ideas and suggestions, if that bandwidth is too high i will tone down the frequency.
sorry if i have bothered you too much.
terefang commentedon May 27, 2025
alerque commentedon May 28, 2025
@terefang Just fix the font. It isn't very hard to modify the family name tables to something that works for your use case or just copy the different variants into your own face instances. Of course Typst should handle this more gracefully, but you aren't dependent on it getting fixed to move your project on.
terefang commentedon May 28, 2025
unfortunately in my case these are commercial fonts --- i dont have a license to modify that font, only use it as is.
do you see the dilemma ? even if i would technically be able to fix the fonts --- i cannot use them because i would be breaking the license agreement (and the law) and be wide open to litigation.
YDX-2147483647 commentedon Oct 25, 2026
Some counterexamples of the style suffixes assumed by Typst:
Noto Sans Old Italic becomes Noto Sans Old.
Old Italic (U+10300..U+1032F) is an ancient writing systems used in the Italian Peninsula. The alphabet starts with 𐌀𐌁𐌂𐌃𐌄𐌅𐌆𐌈.
It is not the italic version of Noto Sans Old. The latter does not exist.
Source Han Sans CN becomes Source Han Sans.
The suffix means that the font only covers the glyphs for characters used in the particular region — China in this case (region-specific SubsetOTF for China / Simplified Chinese). Adobe also publishes Source Sans Sans TW/HK/JP/KR.
It is not the condensed version of Source Han Sans. The latter is another font with full character coverage that sets Japanese glyphs as the defaults (language-specific OTF for Japan / Japanese).
SimSun-ExtB becomes SimSun (the exception added in Fix SimSun-ExtB being incorrectly merged with SimSun #8042).
The suffix means the Unicode block CJK Unified Ideographs Extension B. There is also SimSun-ExtG. There are too many Han/CJK characters, so SimSun split them into three files:
simsun.ttc(SimSun, NSimSun) covers CJK Unified Ideographs, CJK Compatibility Ideographs, Ideographic Description Characters, and CJK Unified Ideographs Extension A;simsunb.ttf(SimSun-ExtB) covers CJK Unified Ideographs Extension B to F;SimsunExtG.ttf(SimSun-ExtG) covers CJK Unified Ideographs Extension G to I.SimSun-ExtB is not the extra bold version of SimSun.