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
#set text(font: "Quadraat Pro") selects Quadraat Pro Italic. I did not manage to get the Regular style. Names in the system are: Regular, Italic, Demibold, Demibold Italic, Bold, Bold Italic.
I have a similar problem with googles Rubik font. It shows up as installed in Windows with numerous variants, but typst fonts --variants only finds one normal and italic. Consequently, specifying the font weight changes nothing.
Reacted by Mareike Picklum, Amos Navarre Hebb and Y.D.X.
as a temporary fix, you can set the TYPST_FONT_PATHS environment variable to point to a directory where you store the other font variants. I am using that as a workaround until this issue is fixed
Using "Source Sans Pro" in the online editor works, i.e., *strong* causes a bold font.
On my machine, the same code does not produce a bold font (I even manually installed the bold variant).
The following fonts are found with typst fonts --variants, which looks a little odd to me:
This issue has become the-issue-to-points-to of font selecting problem, and PR #3228 now provides a mechanism to solve the it. I propose to close this issue, and open per-font issue separately, to track whether a font with wrong metadata has been added to exception list.
cc @Enivex
@peng1999 Is there a way to see what metadata Typst sees for each font? I did not know which parameters were detected wrong so I had to blindly set overrides until the fonts were selected correctly. It did not take a lot of time but it would be nice not to fly blind.
E.g. for the fonts from the original post (#576 (comment))
What is more surprising is that originally, when I wrote #185 (comment), Typst would show an regular-italic version when regular-normal was set. Now (for normal style) regular, medium and bold weights work ok but instead of regular-italic and bold-italic Typst uses a semibold-italic.
I do not see anything obviously wrong here but I do not know how styles are matched. If on fontSubfamily then it looks correct. Note also windows and mac platforms have different conventions on fontFamily and fontSubfamily. I will try to test this font on windows and see if the behaviour is different.
This issue has become the-issue-to-points-to of font selecting problem, and PR #3228 now provides a mechanism to solve the it. I propose to close this issue, and open per-font issue separately, to track whether a font with wrong metadata has been added to exception list.
That makes sense. I don't really know which of these fonts are fixed and which are not, so if someone knows that a particular fonts is still unfixed, feel free to open an issue for that one.
This issue has become the-issue-to-points-to of font selecting problem, and PR #3228 now provides a mechanism to solve the it. I propose to close this issue, and open per-font issue separately, to track whether a font with wrong metadata has been added to exception list. cc @Enivex
After a bit of poking at things there appears to be correct information in many of these fonts, but not where ttf-parser and Typst are looking. Arial Black, for instance, lists a proper weight in the PANOSE field of the OS/2 table, but the ttf-parser only presents usWeightClass. Google's Roboto Condensed (both the static and variable versions) lists the correct stretch in the STAT table, but only the incorrect value in the OS/2 table's usWidthClass is presented.
As far as Quadraat is concerned, is_italic only checks the fsSelection value in the OS/2 table. If is_italic is failing then the italic bit isn't set, but there's probably an italic indicator somewhere else. Parsing human readable names is brittle, so it's to be expected that ttf-parser isn't going through the name table.
Rather than play whack-a-mole with exceptions, I think a more ideal solution would be to improve ttf-parser so that the desired information is exposed and then settle upon some sort of hierarchy (in ttf-parser or Typst) of authority for the various fields. I expect that would cut down on the number of exceptions greatly (although I wouldn't mind being able to opt-out of the font family elision).
To that end I'll have a PR for STAT support in ttf-parser soonish, and from the looks of it the PANOSE bits shouldn't be too difficult either.
On macOS it's available via homebrew and macports as well. The included ttx tool dumps an XML representation of a font that's more complete than what's presented with opentype.js. If you want to attach a ttx file I'd recommend limiting the dump to whatever tables are relevant.
Update typst to compile with ttf-parser 0.24+. I tried this the other day and it looks like some stuff got moved around? I'm not prepared to go too much further on this as it seems like it's got a pretty broad scope.
Collect more detailed information from the fonts in the exceptions list so we know where the correct information typically lives. ttx will dump the whole font (including bytecode and whatnot that's likely to be copyrighted) and so with commercial fonts its output shouldn't be shared in its entirety. However for the purposes of paring down the exceptions list there are probably only a few tables that are relevant. I'll come up with an xpath query for this, but I don't have access to some/all/many? of those fonts.
Determine where the additional logic should live. The main issue is that having to check multiple tables to catch the edge cases will slow down parsing and thus may not be suitable for ttf-parser. On the other hand having a more thorough check for e.g. stretch and slant is useful for other consumers beyond typst.
After a bit of poking at things there appears to be correct information in many of these fonts, but not where ttf-parser and Typst are looking. Arial Black, for instance, lists a proper weight in the PANOSE field of the OS/2 table, but the ttf-parser only presents usWeightClass. Google's Roboto Condensed (both the static and variable versions) lists the correct stretch in the STAT table, but only the incorrect value in the OS/2 table's usWidthClass is presented.
The logic behind getting "proper" values from TrueType fonts is a completely undocumented behavior to my knowledge. At least I haven't found anything useful. ttf-parser's high-level API is loosely based on FreeType2 and harfbuzz behavior.
And it seems like every system library simply does whatever it wants.
Not to mention that the same value can be stored in multiple places in a font, meaning that priority is a mystery is well.
For example, Face::is_italic is a bit wrong right now, since it ignores the Face::italic_angle, which does in fact affect some fonts. But it would be a breaking change, so I haven't done it yet.
I don't mind updating ttf-parser's logic, but each change would be a serious breaking change...
For example, Face::is_italic is a bit wrong right now, since it ignores the Face::italic_angle, which does in fact affect some fonts. But it would be a breaking change, so I haven't done it yet.
Yeah fonts are a bit of an unorganized mess. I suppose the first thing is to define what an italic font is. Sounds like there at least four places to check: panose and fsSelection in the OS2 table, italicAngle in the post table, and the STAT table.
Are there any open source (or open source friendly) fonts that demonstrate this? I'd like to build a corpus of fonts to test against (with the expectation that this would probably live in a repository outside of typst or ttf-parser).
(later, rinse, and repeat with the weight and width axes)
I don't mind updating ttf-parser's logic, but each change would be a serious breaking change...
Beyond breaking compatibility I wonder how much of a performance hit scanning multiple tables will incur.
Note that the STAT is relatively new and not many fonts use it.
As for a corpus of open source/free fonts - I wish there were something like that, but unfortunately no.
Your best bet is to simply scrape all open/free fonts until you find one that match your needs or generate one yourself via fonttools. In both cases that's a large time investment.
Beyond breaking compatibility I wonder how much of a performance hit scanning multiple tables will incur.
Performance impact will be neglectable. No need to worry about it.
Here's another one, these are all the 'italic' variant. Maybe supporting a way to manually punch in a bunch of paths would be nice? Anyway, thanks for making progress on this :)
Here's another one, these are all the 'italic' variant. Maybe supporting a way to manually punch in a bunch of paths would be nice? Anyway, thanks for making progress on this :)
I suspect this is a variable font, which typst does not currently support.
I don't think so, ls Fonts/Adobe Calson Pro* spits out individual files for bold and italic, to use these in fontspec I've got to load them all in individually.
'Adobe Caslon Pro Bold.ttf'
'Adobe Caslon Pro Bold Italic.ttf'
'Adobe Caslon Pro Italic.ttf'
'Adobe Caslon Pro Regular.ttf'
'Adobe Caslon Pro Semibold.ttf'
'Adobe Caslon Pro Semibold Italic.ttf'
@navh Can you run the variant-inspect utility on one or more of the italic files and post the results? The version of Caslon Pro I was able to find is an OpenType version that ttf-parser is correctly able to identify as italic.
That is what I got for my Quadraat Pro (bold+italic version). I am not sure what I should see here. If necessary, I can raise the issue with the foundry if this is an issue with the font.
❯ ./variant-inspect QuadraatPro-BoldIta.otf
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ QuadraatPro-BoldIta.otf: QuadraatPro-BoldIta (Version 7.504; 2011; Build 1024) │
├──────────────────┬──────────────────┬─────────────────────────────────────────────────────┬──────┬──────┤
│ │ ttf_parser::Face │ OS/2 │ post │ STAT │
│ │ │ fsSelection │ PANOSE │ usWeightClass │ usWidthClass │ │ │
├──────────────────┼──────────────────┼─────────────┼────────┼───────────────┼──────────────┼──────┼──────┤
│ bold │ F │ F │ T │ │ │ │ │
│ weight │ Bold │ │ Bold │ Bold │ │ │ │
│ italic / oblique │ F / F │ F / F │ F │ │ │ -3.5 │ │
│ monospaced │ F │ │ F │ │ │ F │ │
│ stretch │ Normal │ Normal │ │ │ Normal │ │ │
╰──────────────────┴──────────────────┴─────────────┴────────┴───────────────┴──────────────┴──────┴──────╯
@owiecc The second column (ttf_parser::Face) indicates how the font is identified with ttf-parser's high level functions (e.g. Face::is_bold, Face::is_italic, Face::width, etc.). This should match the other columns and the reality of what style the font actually is. If you look at the italic row you should see true values across the board (ignoring the distinction between italic and oblique for now).
The are two problems. First, ttf-parser's is_italic[1] function only checks one of the four (or more?) places where a font can indicate that it's slanted. The other is that Quadraat Pro has the wrong information in the two OS/2 fields, although a non-zero slant angle is set in the post table.
For ttf-parser (and/or typst) the is_italic logic should also check the post table and the PANOSE field on the OS/2 table.
For the foundry the fsSelection[2] field in the OS/2 table should have bit 0 or 1 (depending on the head table) set, and the PANOSE[3] field should have the letterform sub-digit set to indicate an italic/oblique variant. If they ever add a STAT[4] table it should have a non-zero entry for the ital axis. I'd also consider updating the full name to be a properly formatted, human readible string e.g. Quadraat Pro Bold Italic instead of just the filename.
For a short-term work around you can add an exception in typst/src/text/font/exceptions.rs that sets the italic style.
@navh Same as above, this looks like a regression or a bug in the TrueType versions of the font. However Adobe does set the PANOSE field (which ttf-parser should, IMO, be checking).
Activity
ararunaufc commentedon Apr 5, 2023
This could be (somehow) related to a problem I'm facing and that prompted #569 .
florg-32 commentedon Apr 28, 2023
I have a similar problem with googles Rubik font. It shows up as installed in Windows with numerous variants, but
typst fonts --variantsonly finds one normal and italic. Consequently, specifying the font weight changes nothing.navh commentedon Aug 3, 2023
Same thing, even after installing STIX Two manually, I still only see
mareikep commentedon Aug 4, 2023
as a temporary fix, you can set the
TYPST_FONT_PATHSenvironment variable to point to a directory where you store the other font variants. I am using that as a workaround until this issue is fixedJuliDi commentedon Oct 2, 2023
Using "Source Sans Pro" in the online editor works, i.e.,
*strong*causes a bold font.On my machine, the same code does not produce a bold font (I even manually installed the bold variant).
The following fonts are found with
typst fonts --variants, which looks a little odd to me:JuliDi commentedon Oct 4, 2023
Seems like this might have been some macos hiccup after installing the font, I guess tonights reboot is what fixed it.
owiecc commentedon Oct 6, 2023
To follow-up. The fonts from the original comment are shown as:
CircuitCoder commentedon Oct 17, 2023
Sorry, there was some other configuration that overrode the weight setting. Typst was apparently working fine with Source Han Sans.
Seeing the same problem with some CJK fonts. The fonts is installed as an OTC.typst fonts --variantsgives:peng1999 commentedon Feb 1, 2024
This issue has become the-issue-to-points-to of font selecting problem, and PR #3228 now provides a mechanism to solve the it. I propose to close this issue, and open per-font issue separately, to track whether a font with wrong metadata has been added to exception list.
cc @Enivex
owiecc commentedon Feb 2, 2024
@peng1999 Is there a way to see what metadata Typst sees for each font? I did not know which parameters were detected wrong so I had to blindly set overrides until the fonts were selected correctly. It did not take a lot of time but it would be nice not to fly blind.
E.g. for the fonts from the original post (#576 (comment))
I had to add
to fix Quadraat Pro selection.
What is more surprising is that originally, when I wrote #185 (comment), Typst would show an regular-italic version when regular-normal was set. Now (for normal style) regular, medium and bold weights work ok but instead of regular-italic and bold-italic Typst uses a semibold-italic.
mkroening commentedon Feb 2, 2024
For #3321, I used https://opentype.js.org/ as suggested in #3213 (comment).
owiecc commentedon Feb 2, 2024
I do not see anything obviously wrong here but I do not know how styles are matched. If on
fontSubfamilythen it looks correct. Note also windows and mac platforms have different conventions onfontFamilyandfontSubfamily. I will try to test this font on windows and see if the behaviour is different.peng1999 commentedon Feb 3, 2024
I believe the most straightforward approach is to insert a debug line in
book.rs:Then you can easily see which font to patch.
1 remaining item
laurmaedje commentedon Feb 14, 2024
That makes sense. I don't really know which of these fonts are fixed and which are not, so if someone knows that a particular fonts is still unfixed, feel free to open an issue for that one.
inferiorhumanorgans commentedon Aug 12, 2024
After a bit of poking at things there appears to be correct information in many of these fonts, but not where ttf-parser and Typst are looking. Arial Black, for instance, lists a proper weight in the
PANOSEfield of the OS/2 table, but the ttf-parser only presentsusWeightClass. Google's Roboto Condensed (both the static and variable versions) lists the correct stretch in theSTATtable, but only the incorrect value in the OS/2 table'susWidthClassis presented.As far as Quadraat is concerned,
is_italiconly checks thefsSelectionvalue in the OS/2 table. Ifis_italicis failing then the italic bit isn't set, but there's probably an italic indicator somewhere else. Parsing human readable names is brittle, so it's to be expected that ttf-parser isn't going through the name table.Rather than play whack-a-mole with exceptions, I think a more ideal solution would be to improve ttf-parser so that the desired information is exposed and then settle upon some sort of hierarchy (in ttf-parser or Typst) of authority for the various fields. I expect that would cut down on the number of exceptions greatly (although I wouldn't mind being able to opt-out of the font family elision).
To that end I'll have a PR for
STATsupport in ttf-parser soonish, and from the looks of it thePANOSEbits shouldn't be too difficult either.@owiecc I'd recommend this:
https://github.com/fonttools/fonttools
On macOS it's available via homebrew and macports as well. The included
ttxtool dumps an XML representation of a font that's more complete than what's presented with opentype.js. If you want to attach a ttx file I'd recommend limiting the dump to whatever tables are relevant.laurmaedje commentedon Aug 12, 2024
@inferiorhumanorgans sounds good!
inferiorhumanorgans commentedon Aug 13, 2024
PR for
STATtable:harfbuzz/ttf-parser#166
Next steps
PANOSE support. In progress.
Update typst to compile with ttf-parser 0.24+. I tried this the other day and it looks like some stuff got moved around? I'm not prepared to go too much further on this as it seems like it's got a pretty broad scope.
Collect more detailed information from the fonts in the exceptions list so we know where the correct information typically lives.
ttxwill dump the whole font (including bytecode and whatnot that's likely to be copyrighted) and so with commercial fonts its output shouldn't be shared in its entirety. However for the purposes of paring down the exceptions list there are probably only a few tables that are relevant. I'll come up with an xpath query for this, but I don't have access to some/all/many? of those fonts.Determine where the additional logic should live. The main issue is that having to check multiple tables to catch the edge cases will slow down parsing and thus may not be suitable for ttf-parser. On the other hand having a more thorough check for e.g. stretch and slant is useful for other consumers beyond typst.
RazrFalcon commentedon Aug 14, 2024
Just to clarify this one:
The logic behind getting "proper" values from TrueType fonts is a completely undocumented behavior to my knowledge. At least I haven't found anything useful. ttf-parser's high-level API is loosely based on FreeType2 and harfbuzz behavior.
And it seems like every system library simply does whatever it wants.
Not to mention that the same value can be stored in multiple places in a font, meaning that priority is a mystery is well.
For example,
Face::is_italicis a bit wrong right now, since it ignores theFace::italic_angle, which does in fact affect some fonts. But it would be a breaking change, so I haven't done it yet.I don't mind updating
ttf-parser's logic, but each change would be a serious breaking change...inferiorhumanorgans commentedon Aug 14, 2024
Yeah fonts are a bit of an unorganized mess. I suppose the first thing is to define what an italic font is. Sounds like there at least four places to check:
panoseandfsSelectionin theOS2table,italicAnglein theposttable, and theSTATtable.Are there any open source (or open source friendly) fonts that demonstrate this? I'd like to build a corpus of fonts to test against (with the expectation that this would probably live in a repository outside of typst or ttf-parser).
(later, rinse, and repeat with the weight and width axes)
Beyond breaking compatibility I wonder how much of a performance hit scanning multiple tables will incur.
RazrFalcon commentedon Aug 15, 2024
Note that the
STATis relatively new and not many fonts use it.As for a corpus of open source/free fonts - I wish there were something like that, but unfortunately no.
Your best bet is to simply scrape all open/free fonts until you find one that match your needs or generate one yourself via
fonttools. In both cases that's a large time investment.Performance impact will be neglectable. No need to worry about it.
navh commentedon Aug 30, 2024
Here's another one, these are all the 'italic' variant. Maybe supporting a way to manually punch in a bunch of paths would be nice? Anyway, thanks for making progress on this :)
Enivex commentedon Aug 30, 2024
I suspect this is a variable font, which typst does not currently support.
(But I may be wrong)
navh commentedon Aug 30, 2024
I don't think so,
ls Fonts/Adobe Calson Pro*spits out individual files for bold and italic, to use these in fontspec I've got to load them all in individually.inferiorhumanorgans commentedon Aug 30, 2024
@navh Can you run the
variant-inspectutility on one or more of the italic files and post the results? The version of Caslon Pro I was able to find is an OpenType version thatttf-parseris correctly able to identify as italic.https://git.sr.ht/~az1/variant-inspect
e.g.
navh commentedon Sep 1, 2024
owiecc commentedon Sep 1, 2024
That is what I got for my Quadraat Pro (bold+italic version). I am not sure what I should see here. If necessary, I can raise the issue with the foundry if this is an issue with the font.
inferiorhumanorgans commentedon Sep 1, 2024
@owiecc The second column (
ttf_parser::Face) indicates how the font is identified with ttf-parser's high level functions (e.g.Face::is_bold,Face::is_italic,Face::width, etc.). This should match the other columns and the reality of what style the font actually is. If you look at the italic row you should see true values across the board (ignoring the distinction between italic and oblique for now).The are two problems. First, ttf-parser's
is_italic[1] function only checks one of the four (or more?) places where a font can indicate that it's slanted. The other is that Quadraat Pro has the wrong information in the twoOS/2fields, although a non-zero slant angle is set in theposttable.For ttf-parser (and/or typst) the
is_italiclogic should also check theposttable and thePANOSEfield on theOS/2table.For the foundry the
fsSelection[2] field in theOS/2table should have bit 0 or 1 (depending on theheadtable) set, and thePANOSE[3] field should have the letterform sub-digit set to indicate an italic/oblique variant. If they ever add aSTAT[4] table it should have a non-zero entry for theitalaxis. I'd also consider updating the full name to be a properly formatted, human readible string e.g. Quadraat Pro Bold Italic instead of just the filename.For a short-term work around you can add an exception in
typst/src/text/font/exceptions.rsthat sets the italic style.1: https://docs.rs/ttf-parser/latest/ttf_parser/struct.Face.html#method.is_italic
2: https://learn.microsoft.com/en-us/typography/opentype/spec/os2#fsselection
3: https://monotype.github.io/panose/pan2.htm
4: https://learn.microsoft.com/en-us/typography/opentype/spec/stat
@navh Same as above, this looks like a regression or a bug in the TrueType versions of the font. However Adobe does set the
PANOSEfield (which ttf-parser should, IMO, be checking).