Skip to content

Problems to use custom fonts. #335

@AndreCDiniz

Description

@AndreCDiniz

Hello, I'm trying to use a custom font from my work to create a PDF, but when I try to change the font from Bold to Regular, it never works.

I have a setup function that loads the fonts and then I use them. When I try to change, for example, from Arial to ArialItalic and use it, I always get a 'socket hang up' error and I don't receive any information in the logs.

func (i *InvoicePDFGenerator) Setup() {
	// Load custom fonts for the PDF
	i.Pdf.AddUTF8Font("Arial", "", Fonts+"/Sans_Prof_Roman.ttf")        // Regular font
	i.Pdf.AddUTF8Font("Arial", "B", Fonts+"/Sans_Prof_Bold.ttf")        // Bold font
	i.Pdf.AddUTF8Font("ArialItalic", "I", Fonts+"/Sans_Prof_Italic.ttf")      // Italic font
	i.Pdf.AddUTF8Font("Arial", "BI", Fonts+"/Sans_Prof_BoldItalic.ttf") // Bold-italic font
	// Add the title in white text on the blue background
	i.Pdf.SetFont("ArialItalic", "", 30)
	i.Pdf.Text(56, 162, i.Translate(httpentity.Key))

	// Set smaller font for the detail information
	i.Pdf.SetTextColor(FontOverPrimaryColor_R, FontOverPrimaryColor_G, 120)
	i.Pdf.SetFont("Arial", "", 10)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions