EaDesgin / magento2-pdf-generator2

Invoice PDF Generator For Magento 2
https://www.eadesign.ro/magento2-invoice-credit-memo-shipping-and-product-pdf-generator-pro.html
Apache License 2.0
67 stars 60 forks source link

Try to use custom font #90

Closed mj-dev closed 4 years ago

mj-dev commented 5 years ago

I am using your Magento PDF Generator module in version 1.2.9. And I want to use a custom font: Futura. I tried with css rules and modifications directly in your module, but without success. The default_font config doesnt work for my font. And my css rule are override by default font.

Is it possible to use a custom font with your module? If so, how is this possible? I haven't seen any information related to this topic in your documentation.

Thank you in advance

twocs commented 5 years ago

I know that there for creating pdfs, there are some additional steps involved. This module uses mPDF (https://mpdf.github.io/fonts-languages/fonts-in-mpdf-6-x.html). To achieve custom fonts with mPDF we need to upload the ttf font file. I see some places where people have put this file on the web, but technically it is not a free font. It is $385 for a server installation license via Microsoft. https://docs.microsoft.com/en-us/typography/font-list/futura

Since there is no statement like define('_MPDF_TTFONTPATH', __DIR__ . '/fonts'); in the code, it appears that this module does not currently support custom fonts per se. I'd look into adding the define in module-pdfgenerator\Helper\pdf.php or to add the font in the mpdf library.

By the way, the free fonts included in vendor/mpdf/mpdf/ttfonts do not include Futura but are as follows:

AboriginalSansREGULAR.ttf Abyssinica_SIL.ttf Aegean.otf Aegyptus.otf Akkadian.otf ayar.ttf damase_v.2.ttf DBSILBR.ttf DejaVuinfo.txt DejaVuSans.ttf DejaVuSans-Bold.ttf DejaVuSans-BoldOblique.ttf DejaVuSansCondensed.ttf DejaVuSansCondensed-Bold.ttf DejaVuSansCondensed-BoldOblique.ttf DejaVuSansCondensed-Oblique.ttf DejaVuSansMono.ttf DejaVuSansMono-Bold.ttf DejaVuSansMono-BoldOblique.ttf DejaVuSansMono-Oblique.ttf DejaVuSans-Oblique.ttf DejaVuSerif.ttf DejaVuSerif-Bold.ttf DejaVuSerif-BoldItalic.ttf DejaVuSerifCondensed.ttf DejaVuSerifCondensed-Bold.ttf DejaVuSerifCondensed-BoldItalic.ttf DejaVuSerifCondensed-Italic.ttf DejaVuSerif-Italic.ttf Dhyana-Bold.ttf DhyanaOFL.txt Dhyana-Regular.ttf FreeMono.ttf FreeMonoBold.ttf FreeMonoBoldOblique.ttf FreeMonoOblique.ttf FreeSans.ttf FreeSansBold.ttf FreeSansBoldOblique.ttf FreeSansOblique.ttf FreeSerif.ttf FreeSerifBold.ttf FreeSerifBoldItalic.ttf FreeSerifItalic.ttf Garuda.ttf Garuda-Bold.ttf Garuda-BoldOblique.ttf Garuda-Oblique.ttf GNUFreeFontinfo.txt Jomolhari.ttf Jomolhari-OFL.txt kaputaunicode.ttf KhmerOFL.txt KhmerOS.ttf lannaalif-v1-03.ttf "Lateef font OFL.txt" LateefRegOT.ttf Lohit-Kannada.ttf LohitKannadaOFL.txt ocrb10.ttf ocrbinfo.txt Padauk-book.ttf Pothana2000.ttf Quivira.otf SundaneseUnicode-1.0.5.ttf Sun-ExtA.ttf Sun-ExtB.ttf SyrCOMEdessa.otf SyrCOMEdessa_license.txt TaameyDavidCLM-LICENSE.txt TaameyDavidCLM-Medium.ttf TaiHeritagePro.ttf TharlonOFL.txt Tharlon-Regular.ttf UnBatang_0613.ttf Uthman.otf "XB Riyaz.ttf" "XB RiyazBd.ttf" "XB RiyazBdIt.ttf" "XB RiyazIt.ttf" "XW Zar Font Info.txt" ZawgyiOne.ttf

eadesignro commented 4 years ago

You need to follow the mpdf documentation to add additional fonts.