Skip to content

Conversation

@gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Jan 21, 2025

This is a minimal implementation of generic font families for Typst, using Noto Sans as the sans-serif font and the built-in Typst fonts for serif, math, monospace.

Each has a synonym, e.g. ui-sans-serif

Other generic font families (or font stack names) could be added in the future, and we could ship fonts to replace the built-in Typst fonts.

Fixes #11683 "big numbers" in gt. I can't figure out a way to automate this test but at least we have a visual test.

@gordonwoodhull gordonwoodhull changed the title typst: generic font families / font stack aliases typst: generic font families / font stack names Jan 21, 2025
Copy link
Collaborator

@cscheid cscheid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some minor comments, but LGTM.

fontdirs.add(font_cache);
}
const srcDir = Deno.env.get("QUARTO_SRC_PATH") ||
join(quartoConfig.sharePath(), "../../src");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use Deno.env.get("QUARTO_SRC_PATH") || join(quartoConfig.sharePath(), "../../src") in a few different places in our codebase. I wonder if we should be adding a srcPath() to quartoConfig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented quartoConfig.srcPath() in a separate commit on this PR. (I only found one other use?)

@gordonwoodhull gordonwoodhull force-pushed the feature/typst-generic-font-families branch 2 times, most recently from 1d7b76a to f9f0bea Compare March 28, 2025 16:14
@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Mar 28, 2025

@cscheid, my only remaining reservation about this PR is that Noto Sans takes up 44MB of disk space.

This is because it's is a non-variable font, which is what we currently need for Typst, and it has almost 80 variants (and lots of glyphs, being international).

What do you think?

@gordonwoodhull gordonwoodhull marked this pull request as ready for review March 28, 2025 16:19
@gordonwoodhull gordonwoodhull force-pushed the feature/typst-generic-font-families branch 2 times, most recently from 9bcb6df to 778cd2d Compare March 28, 2025 16:25
this is a minimal implementation using Noto Sans as the sans-serif font
and the built-in Typst fonts for serif, math, monospace

each has a synonym, e.g. ui-sans-serif

other generic font families could be added
and we could ship fonts to replace the built-in Typst fonts

fixes #11683 "big numbers"

i can't figure out a way to automate this test
but we should have it for visual testing
@gordonwoodhull gordonwoodhull force-pushed the feature/typst-generic-font-families branch from 778cd2d to 0140417 Compare March 28, 2025 19:40
@cscheid
Copy link
Collaborator

cscheid commented Mar 31, 2025

Yikes. Thanks for catching that, and I agree it's bad. I don't think a 33% installation size increase is worth it, unless every other alternative is similarly large.

Could you get an estimate of those sizes?

@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Mar 31, 2025

We need to use the static version of a font because of typst/typst#185 not supporting variable fonts. Each font has 54-72 variants.

Noto Sans is 44MB
Inter is 18MB
Roboto is 8MB

@gordonwoodhull
Copy link
Contributor Author

Turning this back to draft. It worked, but it required distributing big font files.

We could automatically download a font when needed (using the brand mechanism) but it seems strange to do that for a built-in feature. (And it also seems strange to make this an opt-in feature when it's supposed to catch cases where users are not specifying a valid font, and don't know it because it's one of their packages that is doing it.)

@gordonwoodhull gordonwoodhull marked this pull request as draft August 26, 2025 14:17
@ethanc8
Copy link

ethanc8 commented Sep 3, 2025

Could you distribute a small subset of Noto Sans (for example, just the Latin, Greek, Cyrillic glyphs in only Regular, Bold, Italic, BoldItalic), or would that still be too big?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

font issue in typst tables with gt with strings containing numbers and letters

4 participants