adding fonts

adding fonts

by Gianpaolo Valero -
Number of replies: 24
Hi,

I was wondering if I could include fonts on the list of fonts that this plugin has available. If so, how do I do that.

I'm asking because I just found some nice creative fonts i wish my certificate would have

Thanks to anyone who answers
Average of ratings: -
In reply to Gianpaolo Valero

Re: adding fonts

by satish agrawal -
Hi,

I would also like to add some font so that the certificate can be customised a bit in looks. Any help would be appreciated!!!
In reply to satish agrawal

Re: adding fonts

by Chardelle Busch -
Picture of Core developers
See the moodle/lib/tcpdf/fonts folder for a utility to create new fonts for your certificates. Keep in mind that if you create a new font you must use the unicode type certificates (these embed the fonts into the pdf using tcpdf).
In reply to Chardelle Busch

Re: adding fonts

by satish agrawal -

I didn't find any utility in the path mentioned above.

Could you please name the file so that i can look for that specific utility file??

In reply to satish agrawal

Re: adding fonts

by Chardelle Busch -
Picture of Core developers
Its in the folder called utils

See the readme.txt file in this folder for further instructions:

moodle/lib/tcpdf/fonts/utils/
In reply to Chardelle Busch

Re: adding fonts

by satish agrawal -

There is no 'util' folder in the path mentioned by you.

We are using moodle 1.9.3.

In reply to satish agrawal

Re: adding fonts

by Chardelle Busch -
Picture of Core developers
It's too large a zip to attach here. You can find it in cvs:

http://cvs.moodle.org/moodle/lib/tcpdf/fonts/utils/
In reply to Chardelle Busch

Re: adding fonts

by Nikki Macfarlane -
Chardelle,

These files appear to be dead. Is there a place currently available where I can convert fonts for use in fpdf?

Thanks,

Nikki
In reply to Chardelle Busch

Re: adding fonts

by Matthew Morris -

I followed the instructions to a T! I created .php, .ctg.z and .z files and uploaded them to the lib/tcpdf/fonts directory. Then in the certificate.php file I changed the font in the code:

    cert_printtext(170, 500, 'C', 'freeserifi', '', 10, utf8_decode($code)); 

I then got this error: FPDF error: Unidefined font: freeserifi

Any suggestions would be greatly appreciated.

In reply to Matthew Morris

Re: adding fonts

by Raymond Fürst -
freeserifi may be the filename of the font, but not the name of the font itself.

Have you tried cert_printtext(... 'FreeSerifItalic' ...); instead?

In freeserifi.php there is a line $name='FreeSerifItalic';
In reply to Raymond Fürst

Re: adding fonts

by Ihsan Raharjo -

I have problem too with adding verdana fonts to the certificate, I have tried many possible ways using fpdf and this error made me stuck:

FPDF error: Could not include font metric file

can you or anyone help me in this?

Thanks

In reply to Ihsan Raharjo

Re: adding fonts

by Farhan Karmali -
Picture of Core developers Picture of Plugin developers Picture of Testers

I get this error, when I try to use a customfont that has been converted to .php, .gz, .z

TCPDF error: Could not include font definition file

 

Can someone help?

In reply to Farhan Karmali

Re: adding fonts

by Jean-Michel Védrine -

Hello,

Most probably TCPDF is trying to open a non existant fontfile (maybe a problem with the filename ?).

To understand what is happening, you need to enable debugging messages.

With Moodle 2.x go to :

Site Administration -> Development -> Debugging and set the Debug messages dropdown menu to DEVELOPER (if you have never changed it, it should be to NONE previously). Don't forget to click on Save changes.

Now additionnaly to the TCPDF error: Could not include font definition file error message you should see  something like :

Warning: TCPDF::include() [function.include]: Failed opening ~ and the complete path to the file TCPDF is trying to open.

That should help you to diagnoze and solve the problem.

If you get any other error message and you can't figure what to do, post the complete error message on this forum and I will try to help you.

One other problem I had when using custom generated fonts with TCPDF (not only in Moodle) was that .php, .gz and .z files were not generated correctly due to the font utility having trouble with the name of the .ttf file. Just renaming the .ttf file with an all lowercase and no spaces characters string solved the problem. Usually just looking at the .php file content you can tell if everything is OK or not. As said in another mesage this will also give you the correct font name also.

In reply to Jean-Michel Védrine

Re: adding fonts

by Jean-Michel Védrine -

I forgot to add that if you are using Moodle 2.2, TCPDF library has been updated to a more recent version and you can use the new addTTFfont method to directly add a new font without using the old utility, and that makes using customized fonts a lot easier. See doc here.

In reply to Jean-Michel Védrine

Re: adding fonts

by Farhan Karmali -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hello jean-michel vedrine , thank you so much, the problem was that the module was referring to the TCPDF in the lib folder and not the TCPDF within this module

In reply to Farhan Karmali

Re: adding fonts

by Jean-Michel Védrine -

Hello,

I don't know what Moodle version you are using but with moodle 2.1/2.2 you should not have a TCPDF folder inside the mod/certificate folder because as you said certificate module is using the one in the lib folder wich is a good thing because if different modules use different TCPDF files you will get errors and it will break.

See https://github.com/PukunuiAustralia/moodle-mod_certificate to download the latest version and remove any old file/folder left over from a previous version (but of course be carefull not to remove your customized certificate types, guess why I say that wink)

In reply to Chardelle Busch

Re: adding fonts

by Farhad Arshad -
Thank so much mam you gave me road map Its done smile .


HOW TO ADD CUSTOM FONT IN MOODLE CERTIFICATE.

Guys its very simple

Step 1: Download font from google. Download font's filenamee.ttf file. Please find the 

url below.http://ufonts.com/download/old-english-text-mt/31243.html

Step 2: convert the FontFileName.ttf to TCPDF readable format from following URL below.

http://fonts.snm-portal.com/

Step3:copy all three files that have been created by above URL against your filename.ttf file to your moodle TCPDF folder (moodle\lib\tcpdf\fonts).

Now add the below line to  moodle/mod/certificate/type/custom/certificate.php

certificate_print_text($pdf, $x, $y+50, 'C', 'NameOfFont', '', 30, "Certificate of Completion");

//enjoy guys

Average of ratings: Useful (2)
In reply to Gianpaolo Valero

Re: adding fonts

by Tlacaelel Flores -

I know this thread is old but wanted to tell the way I did it

Go to lib/tcpdf/fonts and upload in that folder your ttf font so you will endup with

lib/tcpdf/fonts/yourfont.ttf

Then in your certificate.php file add this line

$pdf->addTTFfont('../../lib/tcpdf/fonts/yourfont.ttf', 'TrueTypeUnicode', '', 32);

run the certificate once then change previous line to

//$pdf->addTTFfont('../../lib/tcpdf/fonts/yourfont.ttf', 'TrueTypeUnicode', '', 32);

Next time you want to add a new font just uncomment the line, upload your new font, and change the font name to that line, then you can use the fonts without having to download the tcpdf package

Average of ratings: Useful (6)
In reply to Tlacaelel Flores

Re: adding fonts

by Melvyn Gomez -

thanks for that info Tlacaelel,

i did that and that line created the .z folders, now when i'm trying to use the new fonts in my certificate don't work, i need to create the php font?

if the answer is yes, how i can create the php font?


Regards

In reply to Melvyn Gomez

إعادة: Re: adding fonts

by D.ALI ALAMRI -

HI

where is  certificate.php ?

thanks

In reply to D.ALI ALAMRI

Re: إعادة: Re: adding fonts

by Farhad Arshad -
in moodle folder please go to the path below. 

mod/certificate/type/custom/certificate.php