Skip to content

Unable to get correct variants of macOS's Chinese fonts Kaiti SC and Kaiti TC #4532

Closed

Description

@duskmoon314

Description

macOS has two Chinese fonts, Kaiti SC and Kaiti TC. They both have three variants: regular, bold, and black.

I can use these variants in Word, but typst renders them the same:

#text("测试", font: "Kaiti SC", weight: "regular")
#text("测试", font: "Kaiti SC", weight: "bold")
#text("测试", font: "Kaiti SC", weight: "black")
image

And the expected result should be like Word:

image

So I wonder why this happens and print what fonts typst is using:

$ typst fonts --variants | rg Kaiti -A 5
Kaiti SC
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
Kaiti TC
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
Kannada MN
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)

Three Normal styles with the same weight? This seems incorrect! I also tried other fonts like Heiti SC/TC and they seem correct:

$ typst fonts --variants | rg Heiti -A 5
Heiti SC
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 300, Stretch: FontStretch(1000)
Heiti TC
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 300, Stretch: FontStretch(1000)
Helvetica
- Style: Normal, Weight: 400, Stretch: FontStretch(1000)
- Style: Normal, Weight: 700, Stretch: FontStretch(1000)

My environment:

  • macOS: 14.5 (23F79)
  • typst: 0.11.1

Reproduction URL

No response

Operating system

macOS

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Jul 10, 2024
  2. added
    text
    on Jul 14, 2024
  3. duskmoon314 commented on Jul 15, 2024

    @duskmoon314
    Author

    I just did a little experiment: I printed each face after the fontdb::Database loading.

    $ ./target/debug/typst fonts --font-path . --ignore-system-fonts --variants
    FaceInfo { id: ID(InnerId(1v1)), source: File("./Kaiti.ttc"), index: 0, families: [("Kaiti SC", English_UnitedStates), ("楷體-簡", Chinese_Taiwan), ("楷体-简", Chinese_PeoplesRepublicOfChina)], post_script_name: "STKaitiSC-Regular", style: Normal, weight: Weight(400), stretch: Normal, monospaced: false }
    FaceInfo { id: ID(InnerId(2v1)), source: File("./Kaiti.ttc"), index: 1, families: [("STKaiti", English_UnitedStates)], post_script_name: "STKaiti", style: Normal, weight: Weight(400), stretch: Normal, monospaced: false }
    FaceInfo { id: ID(InnerId(3v1)), source: File("./Kaiti.ttc"), index: 2, families: [("Kaiti TC", English_UnitedStates), ("楷體-繁", Chinese_Taiwan), ("楷体-繁", Chinese_PeoplesRepublicOfChina)], post_script_name: "STKaitiTC-Regular", style: Normal, weight: Weight(400), stretch: Normal, monospaced: false }
    FaceInfo { id: ID(InnerId(4v1)), source: File("./Kaiti.ttc"), index: 3, families: [("Kaiti SC", English_UnitedStates), ("楷體-簡", Chinese_Taiwan), ("楷体-简", Chinese_PeoplesRepublicOfChina)], post_script_name: "STKaitiSC-Bold", style: Normal, weight: Weight(400), stretch: Normal, monospaced: false }
    FaceInfo { id: ID(InnerId(5v1)), source: File("./Kaiti.ttc"), index: 4, families: [("Kaiti TC", English_UnitedStates), ("楷體-繁", Chinese_Taiwan), ("楷体-繁", Chinese_PeoplesRepublicOfChina)], post_script_name: "STKaitiTC-Bold", style: Normal, weight: Weight(400), stretch: Normal, monospaced: false }
    FaceInfo { id: ID(InnerId(6v1)), source: File("./Kaiti.ttc"), index: 5, families: [("Kaiti SC", English_UnitedStates), ("楷體-簡", Chinese_Taiwan), ("楷体-简", Chinese_PeoplesRepublicOfChina)], post_script_name: "STKaitiSC-Black", style: Normal, weight: Weight(400), stretch: Normal, monospaced: false }
    FaceInfo { id: ID(InnerId(7v1)), source: File("./Kaiti.ttc"), index: 6, families: [("Kaiti TC", English_UnitedStates), ("楷體-繁", Chinese_Taiwan), ("楷体-繁", Chinese_PeoplesRepublicOfChina)], post_script_name: "STKaitiTC-Black", style: Normal, weight: Weight(400), stretch: Normal, monospaced: false }
    DejaVu Sans Mono
    - Style: Normal, Weight: 700, Stretch: FontStretch(1000)
    - Style: Italic, Weight: 700, Stretch: FontStretch(1000)
    - Style: Italic, Weight: 400, Stretch: FontStretch(1000)
    - Style: Normal, Weight: 400, Stretch: FontStretch(1000)
    Kaiti SC
    - Style: Normal, Weight: 400, Stretch: FontStretch(1000)
    - Style: Normal, Weight: 400, Stretch: FontStretch(1000)
    - Style: Normal, Weight: 400, Stretch: FontStretch(1000)
    Kaiti TC
    - Style: Normal, Weight: 400, Stretch: FontStretch(1000)
    - Style: Normal, Weight: 400, Stretch: FontStretch(1000)
    - Style: Normal, Weight: 400, Stretch: FontStretch(1000)
    ...

    Kaiti.ttc doesn't include the correct style and weight metadata. I assume Word can work because it looks at the post_script_name field.

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

    bugtext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions