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

document how to troubleshoot Typst fonts, and Typst requiring exact font family name #11278

Open
cwickham opened this issue Nov 1, 2024 · 3 comments
Assignees
Labels
brand `_brand.yml` documentation Doc improvements & quarto-web triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. typst
Milestone

Comments

@cwickham
Copy link
Collaborator

cwickham commented Nov 1, 2024

Bug description

The docs suggest monospace-inline and monospace-block should inherit from monospace, but when format: typst, setting monospace: family doesn't seem to change the family in inline or block code.

Steps to reproduce

---
title: "Untitled"
format: 
  html: default
  typst: default
brand:
  typography: 
    fonts: 
      - family: Sono
        source: google
    monospace: Sono
---

```{.r}
library(tidyverse)
```

`library(tidyverse)`

Expected behavior

Code in blocks and inline is Sono as though:

brand:
  typography: 
    fonts: 
      - family: Sono
        source: google
    monospace-inline: Sono
    monospace-block: Sono

Actual behavior

Code inline and in blocks is not Sono:

Image

Your environment

  • OS Mac 15.0

Quarto check output

Quarto 99.9.9
[✓] Checking environment information...
      Quarto cache location: /Users/charlottewickham/Library/Caches/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.4.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.46.3: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 99.9.9
      commit: 19473984b54e37e97888a74a46fe58f68628899b
      Path: /Users/charlottewickham/Documents/posit/quarto-cli/package/dist/bin

[✓] Checking tools....................OK
      TinyTeX: v2024.03.13
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/charlottewickham/Library/TinyTeX/bin/universal-darwin
      Version: 2024

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.1
      Path: /Users/charlottewickham/Documents/posit/quarto-web/.venv/bin/python
      Jupyter: 5.7.2
      Kernels: julia-1.10, ark, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.3
      Path: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources
      LibPaths:
        - /Users/charlottewickham/Library/R/arm64/4.3/library
        - /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
      knitr: 1.45
      rmarkdown: 2.28

[✓] Checking Knitr engine render......OK
@cwickham cwickham added brand `_brand.yml` bug Something isn't working triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. typst labels Nov 1, 2024
@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented Nov 3, 2024

It's not a bug, but it's definitely a problem we should be aware of. I guess we should document "troubleshooting Typst fonts" somewhere.

You can see that Quarto and Typst are "working" in the sense of "expending effort" because that's not a monospace font, and you would get a monospace font if you didn't specify anything.

If you render using Typst 0.12 you will get helpful warnings:

[typst]: Compiling monospace-family.typ to monospace-family.pdf...warning: unknown font family: sono
    ┌─ monospace-family.typ:295:46
    │
295 │ #show raw.where(block: false): set text(font: "Sono", )
    │                                               ^^^^^^

warning: unknown font family: sono
    ┌─ monospace-family.typ:296:45
    │
296 │ #show raw.where(block: true): set text(font: "Sono", )
    │                                              ^^^^^^

Then list the available fonts

quarto typst fonts --ignore-system-fonts --variants --font-path .quarto/typst-font-cache/

(The helpful --ignore-system-fonts is also available with Typst 0.12, otherwise the output is somewhat unmanageable.)

This outputs:

...
some fallback fonts
...
Sono ExtraLight Monospace
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)

And it seems that Google Fonts allows a fuzzy search, but Typst does not. Spelling out the font family for Typst works:

brand:
  typography:
    fonts:
      - family: Sono
        source: google
    monospace:
      family: Sono Extralight Monospace

Image

@gordonwoodhull gordonwoodhull changed the title monospace-* doesn't seem to inherit from monospace in typst document how to troubleshoot Typst fonts, and Typst requiring exact font family name Nov 3, 2024
@gordonwoodhull gordonwoodhull added documentation Doc improvements & quarto-web and removed bug Something isn't working labels Nov 3, 2024
@gordonwoodhull gordonwoodhull added this to the v1.6 milestone Nov 3, 2024
@gordonwoodhull
Copy link
Contributor

On second thought, we might need to automate the discovery of the full family name, since

https://fonts.google.com/specimen/Sono

does not say "Sono Extralight Monospace" anywhere.

@gordonwoodhull gordonwoodhull added the enhancement New feature or request label Nov 3, 2024
@gordonwoodhull gordonwoodhull changed the title document how to troubleshoot Typst fonts, and Typst requiring exact font family name Typst needs full font family name Nov 3, 2024
@gordonwoodhull gordonwoodhull changed the title Typst needs full font family name document how to troubleshoot Typst fonts, and Typst requiring exact font family name Nov 3, 2024
@gordonwoodhull gordonwoodhull removed the enhancement New feature or request label Nov 3, 2024
@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented Nov 3, 2024

Update: I generated 41 test QMDs from the monospace font list at

https://www.notebookandpenguin.com/list-of-google-fonts/#monospace-google-font-list

and only encountered one font that failed due to inconsistent naming, "Nova Mono" needs to be "NovaMono".

I think it was bad luck with Sono, so I'll just document this for now. It would not be hard to implement an error or warning with "did you mean..." if this comes up frequently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brand `_brand.yml` documentation Doc improvements & quarto-web triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. typst
Projects
None yet
Development

No branches or pull requests

2 participants