Skip to content
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

typst: generic font families / font stack names #11918

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Jan 21, 2025

Fixes #11683

This is complete except for choice of fonts.

For demo purposes, this PR uses Roboto as the sans-serif font. (No endorsement implied.)

In order to implement generic font families we need to ship a variable-width sans-serif font because Typst does not.

These are called "generic font families" when they are part of the CSS spec, and are called "font stacks" when they come from a third party. This PR only implements the four major generic font families

  • sans-serif
  • serif
  • math
  • monospace

and aliases ui-sans-serif / system-ui, ui-serif, ui-monospace, but other generic font families and font stack names could be added to the input data.

this is complete except for choice of fonts

for purposes of testing, this commit uses Roboto as the sans-serif font

in order to implement this feature we need to ship a variable-width
sans-serif font because Typst does not
@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.

@@ -1513,6 +1514,9 @@ async function resolveExtras(
}
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

@@ -593,6 +593,10 @@ local function quote(s)
return '"' .. s .. '"'
end

local function dequote(s)
return s:gsub('^["\']', ''):gsub('["\']$', '')
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is safe here, but it's always terrifying to consider the full implications of quoting, escaping, etc. There's no chance that fonts can have , in their titles, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

(this is also about L662 below)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:shudder:

The spec does not seem to ban commas in font family names. In practice this seems to be something that happens in PostScript because of weights and styles of a family, but CSS handles this differently (and better).

i can't figure out a way to automate this test
but we should have it for visual testing
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
2 participants