2

Using Prestashop 1.5.5.0 for a bilingual store (English/French), I noticed that the PDF generated for the invoice had a noticeably different presentation depending if it was generated in English or in French.

The most noticeable differences are:

  • the font family used is different in English: the letters are sensibly larger (esp. in lower case), and of different shapes; I was not able to identify which font it is, however.
  • in English, every text element that is supposed to be bold appears with a normal font-weight (not bold, then); my guess is that the font-family that is used in English doesn't have a bold variant.

Here's a comparison of both fonts (French left, English right):

font comparison

Just to be sure, I made a very small change to the invoice.tpl file (I just added a simple dot somewhere in the content), and then I re-downloaded the PDF invoice in both languages: the change appeared in both languages. So both languages use the same TPL file. Yet they do not use the same font-family.

My question is: where should I look in order to correct that?
I can't find any font-family declaration in the TPL files, and I don't understand why English would use a different font-family than French.

Edit: By the way, if somebody is able to identify (with reasonable certainty) which font is used in English (see image above), please let me know in the comments, as I may be able to use that information to search through all the files of the site and maybe get an idea where this problem comes from?...

s427
  • 1,454
  • 5
  • 17
  • 33
  • It would be best to post examples of each PDF file, its much more likely that we can tell you which font is used from the PDF than from looking at screen shots. Also, what application are you using to view the PDF files ? – KenS Dec 08 '14 at 18:50
  • I'm reluctant to post a PDF file as it may contain sensitive information (it's not my site). Anyway, I just discovered that you can display the list of used fonts through Acrobat, via the File > Properties menu item (Fonts tab). This has indeed allowed me to solve the issue (I'll post my answer right away), although it's still kind of a hack... – s427 Dec 09 '14 at 09:23

2 Answers2

3

So, I just discovered that you can get a list of the fonts used in the PDF document through Acrobat itself (menu File > Properties, Fonts tab).

This has allowed me to identify the font used in the English invoices PDF: DejaVuSans. I ran a search on this term across all the files of the site, and I found my culprit in classes/pdf/PDFGenerator.php, which has this variable defined:

public $font_by_lang = array(
    'ja' => 'cid0jp',
    'bg' => 'freeserif',
    'ru' => 'freeserif',
    'uk' => 'freeserif',
    'mk' => 'freeserif',
    'el' => 'freeserif',
    'en' => 'dejavusans',
    'vn' => 'dejavusans',
    'pl' => 'dejavusans',
    'ar' => 'dejavusans',
    'fa' => 'dejavusans',
    'ur' => 'dejavusans',
    'az' => 'dejavusans',
    'ca' => 'dejavusans',
    'gl' => 'dejavusans',
    'hr' => 'dejavusans',
    'sr' => 'dejavusans',
    'si' => 'dejavusans',
    'cs' => 'dejavusans',
    'sk' => 'dejavusans',
    'ka' => 'dejavusans',
    'he' => 'dejavusans',
    'lo' => 'dejavusans',
    'lv' => 'dejavusans',
    'tr' => 'dejavusans',
    'ko' => 'cid0kr',
    'zh' => 'cid0cs',
    'tw' => 'cid0cs',
    'th' => 'freeserif'
    );

Disabling (commenting) the 'en' => 'dejavusans', line did indeed solve the problem.

It's a bit of a hack obviously, so if anyone has information as to why English is in that list (and not French), and if there is a better way of handling this issue, I'm all ears. :)

Community
  • 1
  • 1
s427
  • 1,454
  • 5
  • 17
  • 33
  • ***1/*** -- You have been asked by KenS in the very first comment to provide a sample PDF. You haven't done so, so you will not get any more precise answers, but more likely some speculative musings (if any at all). French, using a lot of accented characters typically uses a different set of characters than English does (no accents). Hence, sometime in the far past, a developer may have decided to not support French because he didn't know how to handle accented characters. -- (continued) – Kurt Pfeifle Dec 09 '14 at 10:18
  • ***2/*** -- Possibly the font used for French now is some default font, and possibly it is not embedded into the PDF, and therefor the PDF viewer of the day will use some substitute font for the not-embedded one (different on each system you open the file on, and possibly different for each printer you print it on....) – Kurt Pfeifle Dec 09 '14 at 10:18
  • Come on... KenS asked for a sample PDF in order to help determining which font was used in it. That question has now been answered by another mean (it's DejaVuSans). So uploading a sample PDF would do nothing to help understanding the reasoning behind this specific bit of PHP programming in the Prestashop code. Thanks for your thoughts on the topic though. – s427 Dec 09 '14 at 11:02
  • **(1)** It wasn't clear from the beginning that you ask about *"this specific bit of PHP programming. -- **(2)** You asked specifically about fonts used in the two PDFs. -- **(3)** There may still more behind the problem than you can realize (based on your *very* limited understanding of PDF and PDF software that you have so far). -- Anyway, I'm glad you found a hackish workaround for now. Maybe you'll look for a proper solution later. Then ask again, if you like. – Kurt Pfeifle Dec 09 '14 at 11:56
  • Also, KenS asked some 17 hours ago about a PDF sample (which could easily be created without including sensitive information into it). Your "solution" came 2 hours ago... – Kurt Pfeifle Dec 09 '14 at 11:58
1

"By the way, if somebody is able to identify (with reasonable certainty) which font is used in English (see image above), please let me know"

You can identify with (almost) absolute certainty which fonts are used in both types of PDF files yourself. Just run this command:

pdffonts -f 1 -l 5 pdffile.pdf

(This shows you all fonts used from page 1 to page 5 of the PDF, in case you are not interested in the other pages...)

If you get a no for both columns, emb as well as sub, then the font is not embedded in the PDF, and your PDF viewer is free to use any suitable substitute font it deems appropriate.

pdffonts is available for Linux, Unix, Mac OSX and Windows.

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • Actually, it's even simpler than that: in Acrobat, you can just use the File > Properties menu item and go to the Fonts tab. I didn't know that. ^^ – s427 Dec 09 '14 at 09:21
  • @s427: Actually, in ***my*** opinion, this is not easier. And it works only in Acrobat. And it works only on platforms where Acrobat is installed. And it doesn't give you the option to see the result on a page-by-page basis. And it doesn't tell you as many details about the fonts. And it contains also some *confusing* information. (Or do you ***really*** understand what it exactly means, if an entry in this list is headlined `Helvetica`, and then below says: *`Actual font: Arial`* ??) – Kurt Pfeifle Dec 09 '14 at 10:10
  • I agree with everything you said, but the truth is that it took me 15 seconds, it gave me an information that I was able to use. I didn't have to search for, install, configure or learn anything. Seems really simpler to me. ;) – s427 Dec 09 '14 at 10:51
  • I do usually upvote useful answers, and I appreciate you taking the time to help me. Your advice actually put me on the path to finding the solution. Things were just a bit hectic at work this morning and I neglected upvoting your answer. – s427 Dec 09 '14 at 11:07