Skip to content

Noto Sans JP not working #3152

Open
Open
@damien-monni

Description

@damien-monni

I can't find a way to use Japanese font with jsPDF.

I've created the font with the fontconverter using Noto Sans JP from Google Font, I've imported it but I can't use any Glyphs that I find on the Google Font page here: https://fonts.google.com/specimen/Noto+Sans+JP#glyphs

I can see that the font is imported because it changes if I remove the font script.

Here is a CodeSandbox that reproduces the error: https://codesandbox.io/s/busy-joliot-jwjy8?file=/main.js

I also tried with others fonts, without any better results.

I am using jsPDF in a web application with users from all around the world and I am gettings requests from Japanese to handle it. Any help would be very appreciated!

Thanks

Activity

HackbrettXXX

HackbrettXXX commented on May 4, 2021

@HackbrettXXX
Collaborator

Can reproduce the issue. Looks like jsPDF does not support this type of font. An exception is thrown:

sse-hooks.f648b14c15c640a14a557113a991cb8d.js:1 jsPDF PubSub Error Cannot use 'in' operator to search for '0' in undefined TypeError: Cannot use 'in' operator to search for '0' in undefined
    at e.glyphFor (ttffont.js:1478)
    at t.glyphsFor (ttffont.js:1809)
    at t.encode (ttffont.js:1848)
    at utf8.js:97
    at Object.<anonymous> (utf8.js:163)
    at P.publish (jspdf.js:70)
    at ae (jspdf.js:2005)
    at oe (jspdf.js:2036)
    at Ae (jspdf.js:2407)
    at b.__private__.buildDocument (jspdf.js:2990)
damien-monni

damien-monni commented on May 4, 2021

@damien-monni
Author

@HackbrettXXX Do you know a font that I could use that would handle Japanese characters and that looks like Noto Sans or Open Sans?

HackbrettXXX

HackbrettXXX commented on May 5, 2021

@HackbrettXXX
Collaborator

Not really.

SatorCube

SatorCube commented on May 6, 2021

@SatorCube

Here for a similar reason. The Noto Sans JP (and SC for Chinese) fonts are only available as .otf files. I don't think the font converter handles dealing with these types of files very well :(. Being able to support these types of fonts would be massive.

HackbrettXXX

HackbrettXXX commented on May 7, 2021

@HackbrettXXX
Collaborator
HosokawaR

HosokawaR commented on Jun 4, 2024

@HosokawaR

Thanks to your issue, I found out that jsPDF doesn't support NotoSans. Thank you.

I've also created a PR to address NotoSans TTF.
I'm not the maintainer of this project, so it may be incomplete, but it might be useful if you need it.

iniceice88

iniceice88 commented on Jun 7, 2024

@iniceice88

this font works for me
stackblitz demo

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @damien-monni@HackbrettXXX@iniceice88@HosokawaR@SatorCube

        Issue actions

          Noto Sans JP not working · Issue #3152 · parallax/jsPDF