-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
font issue in typst tables with gt with strings containing numbers and letters #11683
Comments
Thanks. I was also not sure where to post this issue but just wanted to be sure that this is not on the quarto side. I will check what my system is doing. |
Let's keep this open at least for now - the behavior does feel unintuitive to me, so I'd like to understand it better. |
ReproOkay, I have a simple repro in Typst on macOS. #[
#set text(font: ("Apple Color Emoji") , size: 12pt); #table(
columns: 2,
align: (left,right,),
table.header(table.cell(align: bottom + left, fill: rgb("#ffffff"))[#set text(size: 1.0em , fill: rgb("#333333")); a], table.cell(align: bottom + right, fill: rgb("#ffffff"))[#set text(size: 1.0em , fill: rgb("#333333")); b],),
table.hline(),
table.cell(align: horizon + left, stroke: (top: (paint: rgb("#d3d3d3"), thickness: 0.75pt)))[aa111bbb], table.cell(align: horizon + right, stroke: (top: (paint: rgb("#d3d3d3"), thickness: 0.75pt)))[1],
table.cell(align: horizon + left, stroke: (top: (paint: rgb("#d3d3d3"), thickness: 0.75pt)))[abcdef], table.cell(align: horizon + right, stroke: (top: (paint: rgb("#d3d3d3"), thickness: 0.75pt)))[2],
)
] Root causeThe Apple Color Emoji font, installed on Macs, supports numbers but not letters. This is probably true of other emoji fonts. If the first available font in the list is an emoji font, then the numbers will be bigger than the rest of the text. because emoji fonts have large glyph sizes. ![]() The rest of the text will have a fallback font provided by Typst, unless disabled with #set text(fallback: false) If my theory is correct, then none of the fonts
are installed on @schochastics's machine, or they are not available to Typst. But at least one of the emoji fonts
is installed and available. ( Font stacksIf there is a Quarto issue here, it is we translate CSS font lists into Typst font lists verbatim. But "font stacks" like Conceivably, we could substitute lists of appropriate fonts for "font stacks", at the mild maintenance burden of having to maintain such lists. Our current behavior is surprising because the intent of the font list
is clearly "choose a nice looking or at least sans serif font for text, and one of these emoji fonts for emoji". Not "use an emoji font for the numbers and a fallback font for the text". For now I can add a note about this to the advanced docs on troubleshooting Typst fonts tracked in #11278. Similar to that issue, we again see that the letters have an unexpected serif font (the Typst default font). |
fixes quarto-dev/quarto-cli#11083 fixes quarto-dev/quarto-cli#11278 addresses quarto-dev/quarto-cli#11683 addresses quarto-dev/quarto-cli#11616 (reply in thread) just a draft - some of this stuff might belong better elsewhere
fixes quarto-dev/quarto-cli#11083 fixes quarto-dev/quarto-cli#11278 addresses quarto-dev/quarto-cli#11683 addresses quarto-dev/quarto-cli#11616 (reply in thread) just a draft - some of this stuff might belong better elsewhere
fixes quarto-dev/quarto-cli#11083 fixes quarto-dev/quarto-cli#11278 addresses quarto-dev/quarto-cli#11683 addresses https://github.com/quarto-dev/quarto-cli/discussions/11616#discussioncomment-11473859 just a draft - some of this stuff might belong better elsewhere (cherry picked from commit 1f34e20)
Correction: it's called
Comprehensive and helpful blog post on the subject: https://blog.jim-nielsen.com/2020/system-fonts-on-the-web/ Corresponding Typst issue: typst/typst#3342 Sounds like they don't want to implement it because it hurts reproducibility, but fonts always introduce a dependency external to the document. (There is even an OS dependency on the web, because you want to choose a system font that the user has.) I'm tempted just to replace generic font families and font stacks with names of fonts that Typst ships, if possible. |
fixes quarto-dev/quarto-cli#11083 fixes quarto-dev/quarto-cli#11278 addresses quarto-dev/quarto-cli#11683 addresses quarto-dev/quarto-cli#11616 (reply in thread) just a draft - some of this stuff might belong better elsewhere (cherry picked from commit 1f34e20)
I think that's a great idea. Alternatively, we can ship a few chosen open-source fonts with Quarto itself, so that these are more clearly "Quarto's defaults" (I happen to not like the default typefaces from Typst, but that's a super personal thing). |
I like the idea of shipping some fonts. From that blog post, the generic font families according to CSS spec:
I count about 8 or 9 distinct, since we don't care about Some will have sufficient defaults shipped with Typst, so we don't need to choose all of them. |
Okay, Typst ships two serif fonts and a monospace sans-serif font, but no variable-width sans-serif font. So we need to ship at least one font in order to fix the bug.
This is going to be really easy, since we just have to pass Typst another another Is there anywhere to put static configuration like the font mapping? (i.e. that gets checked in and distributed with Quarto.) No practical difference from defining it in Lua, just seems icky to do that. Making them defaultIn order for Quarto's Typst output to use default fonts, we would have brand defaults like brand:
typography:
base: serif
headings: sans-serif
monospace: monospace (or Then these would get picked up by the Typst CSS layer, which is the main topic of this issue. Currently brand doesn't have default font families, although there is some ugly bleed of Linux Libertine / Libertinus Serif in Typst due to the way parameters to functions can't be left unset. |
i can't figure out a way to automate this test but we should have it for visual testing
Bug description
When I render a gt table in typst that contains strings that mix letters and digits (e.g. "aaa111aaa") the font switches and the string renders weirdly.
Steps to reproduce
I get the following result:

The produced typst code for the gt table looks like this:
Expected behavior
When I remove
from the intermediate typ file, I get the correct table when I compile that file
after playing around a bit, setting the font explicitly via
gt::opt_table_font()
also removes the weird behavio.Actual behavior
No response
Your environment
Positron Version 2024.12.0 build 80
Quarto check output
The text was updated successfully, but these errors were encountered: