Skip to content

Add a font function #3488

Open
Open

Description

@peng1999

Currently text settings do not play well with font fallback list. There is no way to invoke font features for each font separately.

#set text(font: ("font1", "font2"), stylistic-set: "ss03") // Set to ss03 both fonts

I propose a new font function, which contains options that should apply to specific font. The above code would become:

#set font(stylistic-set: "ss03")
#set text(font: ("font1", "font2"))

Additionally we can set font features separately:

#let font1 = font("font1", stylistic-set: "ss03")
#let font2 = font("font2", stylistic-set: "ss01")
#set text(font: (font1, font2))

This change will also make #3331 easier by just add one more unicode-range option to font.

Activity

  1. added
    feature request
    on Feb 24, 2024
  2. added
    text
    on Feb 26, 2024
  3. bluebear94 commented on May 7, 2024

    @bluebear94
    Contributor

    Working on this right now.

  4. added
    change request
    and removed
    feature request
    on Jun 13, 2024
  5. Caellian commented on Mar 13, 2025

    @Caellian

    Note that different font names might resolve to the same font file. Event normalized font name can't be used as a key for font memoization. Not sure how to uniquely identify fonts (resolved file paths aren't a good choice either) besides hashing loaded glyph paths (not a performant option).

    I'm just pointing this out because I believe this step is important for avoiding the situation where font files are duplicated in the export PDF or CSS. Not sure if there's really any good way around this though besides the community authoring packages for fonts like TeX does.

  6. laurmaedje commented on Mar 13, 2025

    @laurmaedje
    Member

    Typst already deduplicates fonts, just by hashing the full bytes.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    change requesttext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions