3

Im trying to "make mailing labels" with contacts with names in Bosnian and CiviCRM cannot create it.

Example:

  • Correct: Antolović
  • CiviCRM prints: Antolovi?

Instead, CiviCRM shows it correctly in most parts of the CRM, for example print/merge document in actions of contact summary view.

Any suggestions?

Tx!

| improve this question | | | | |
3

It's because it's using Helvetica font which doesn't have unicode characters - if you can use Deja Vu Sans or another font that has unicode it should work.

IGNORE rest of answer below. As per comments Cesar found that under Administer - Communications - Label Formats you can change the font in there.


You can try to hack CRM/Utils/PDF/Label.php to hardcode the font: https://github.com/civicrm/civicrm-core/blob/5.20.3/CRM/Utils/PDF/Label.php#L180

I'm not sure the right spelling to get the font. If you look in vendor/tecnickcom/tcpdf/fonts/dejavusans.php it seems like it might be DejaVuSans, without spaces.

You can also try this instead:

  1. Copy vendor/tecnickcom/tcpdf/config/tcpdf_config.php somewhere, e.g. /usr/local/tcpdf/tcpdf_config.php
  2. Edit the line inside it for PDF_FONT_NAME_MAIN so it reads define('PDF_FONT_NAME_MAIN', 'dejavusans'); (again I'm not sure of the exact spelling).
  3. In civicrm.settings.php add these lines:
define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
require_once('/usr/local/tcpdf/tcpdf_config.php');
| improve this answer | | | | |
  • Hello, thanks! Just now I was trying it, the problem, It does not seem good practice to directly modify the core file, I would like to find a hook that I can access without modifying Label.php I found this hook but I can't modifying the language: docs.civicrm.org/dev/en/latest/hooks/… Thanks for your help. – Cesar Dec 31 '19 at 16:20
  • 1
    I've updated answer with another thing to try that doesn't involve hacking core. And that hook looks like it only allows modifying certain things but not the font. – Demerit Dec 31 '19 at 16:56
  • 1
    Thanks mate, I found other solution, the admin panel for configure this: civicrm/admin/labelFormats?reset=1&action=browse I think is better solution for this. I hope it helps more people in the future and dont spend more time. Thanks for your help. – Cesar Dec 31 '19 at 17:05
  • 1
    Ahh under Communications. I see. – Demerit Dec 31 '19 at 17:15
  • 3
    I made a lab ticket suggesting Deja Vu be the default font for mailing labels: lab.civicrm.org/dev/core/issues/1502 – Demerit Dec 31 '19 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.