Skip to content

More efficient font subsetting #895

Closed

Description

@0ip

Based on my own oberservations and this discussion (#404), I am wondering if font subsetting in Typst is working adequately right now.

Brief demonstration: a simple document containing two embedded fonts results in a file size of 207 KB:

image

By applying font subsetting (which the online tool apparently does), the file size can be drastically reduced to 13 KB:

image

Raw files:

Activity

  1. laurmaedje commented on Apr 20, 2023

    @laurmaedje
    Member

    The subsetter indeed doesn't produce minimal sizes, yet.

  2. added
    pdf
    on Apr 20, 2023
  3. changed the title [-]Large file sizes: font subsetting faulty?[/-] [+]More efficient font subsetting[/+] on May 8, 2023
  4. added
    feature request
    on May 8, 2023
  5. Wybxc commented on Nov 2, 2023

    @Wybxc

    This issue is more severe on the CJK character set. I tested it on the Source Han Serif font, and the original font file is about 18MB. The document generated by typst contains 2MB of fonts, but after further compression, the actual used glyph data is only 47KB.

  6. laurmaedje commented on Nov 2, 2023

    @laurmaedje
    Member

    CFF font subsetting is unfortunately rather complicated.

  7. Andrew15-5 commented on Nov 2, 2023

    @Andrew15-5
    Contributor

    Consider using binary prefixes to remove any confusion with the legacy SI prefixes (for size of digital information). See https://en.m.wikipedia.org/wiki/Binary_prefix. Also note that KB is not an existing unit of measurement. There is either kB or KiB (which are 1000 B and 1024 B respectively).

  8. laurmaedje commented on Nov 2, 2023

    @laurmaedje
  9. Andrew15-5 commented on Nov 2, 2023

    @Andrew15-5
  10. laurmaedje commented on Nov 2, 2023

    @laurmaedje
  11. Andrew15-5 commented on Nov 2, 2023

    @Andrew15-5
  12. wdscxsj commented on Nov 3, 2023

    @wdscxsj

    CFF font subsetting is unfortunately rather complicated.

    I agree. Just for the record, it took over a year for PrinceXML to implement good CFF subsetting. And for Affinity Designer, it's still an issue after 3 years since it's reported.

  13. 0ip commented on Nov 3, 2023

    @0ip
    Author

    Just for the record, it took over a year for PrinceXML to implement good CFF subsetting

    The subsetter, together with other font tools, for PrinceXML has apparently been extracted into a Rust library called allsorts. I am not well-versed in font shaping and subsetting, nor do I have extensive knowledge in Rust, so I apologize in advance if this library has already been deemed unsuitable for Typst, but perhaps the library is still worth considering.

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

    feature requestpdf

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions