Skip to content

Error on using costume fonts Nuxt 3: Uncaught (in promise) TypeError: r.readFileSync is not a function #20

Description

@Shooteger

Hello, please help me. I tried using a costume font exactly as in the example code. I made a public/fonts folder and added the fonts. Even with the https://domain and full path it does not work. I get this error:

Uncaught (in promise) TypeError: r.readFileSync is not a function

And then the text just disappears and does not get rendered in my PDF.

Please, how to use a costume font? I wanna use Inter (free to use from google fonts) but on my server, not remote link.
I add the fonts like this:

    $pdf.addFonts([
      {
        name: 'Inter',
        normal: `fonts/Inter-Regular.ttf`,
        bold: `fonts/Inter-Bold.ttf`,
        italic: `fonts/Inter-Italic.ttf`,
        bolditalic: `fonts/Inter-BoldItalic.ttf`,
      }
    ]);

And then use it here:

$pdf.add([
     { raw: `TEST my font here`, text: { fontSize: 24, bold: true, font: 'Inter' } },
    ]);

But it does not work... see upper error. I just want my whole PDF using this font.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions