Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF generated with dw2pdf doesn't display Japanese fonts #54

Closed
begntsly opened this issue Apr 25, 2013 · 4 comments
Closed

PDF generated with dw2pdf doesn't display Japanese fonts #54

begntsly opened this issue Apr 25, 2013 · 4 comments

Comments

@begntsly
Copy link

Hi,
dw2pdf (last version) is installed on Weatherwax RC1
It works well with English pages but not with Japanese texts.
Fonts embed in the PDF are only DejaVuSansCondensed, DejaVuSanCondensed-Bold and ZapfDingbats, therefore Japanese characters are rendered as squares.
I tried to change mpdf settings but i cannot solve the issue myself.

@samwilson
Copy link
Collaborator

I did some work on fixing this with the addition of a config_fonts.php file in your dw2pdf template. The format of it is describe on the mPDF site; for example:

<?php
$fontdata = array(
    'gillsans' => array(
        'R'  => 'GIL_____.ttf',
        'B'  => 'GILB____.ttf',
        'I'  => 'GILI____.ttf',
        'BI' => 'GILBI___.ttf',
    ),
);

You also need to define _MPDF_SYSTEM_TTFONTS in conf/local.protected.php to be the path of your font directory.

@begntsly
Copy link
Author

Thank you samwilson.
I exchanged action.php by yours and set up _MPDF_SYSTEM_TTFONTS in mpdf/config_fonts.php - indeed I cannot find any file named local_protected.php in conf/ (and anywhere else...) in my install (latest DW2PDF version in DWplugin)!?
But it still doesn't work, fonts embed in the pdf are only DejaVu... and don't support any CJK (all Japanese rendered as squares). I tried again to setup config_fonts.php by enabling CJK array fonts, installed Sun-ExtA & B ttf in mpdf/ttfonts... without any success.
Could you help me out for the settings to apply?

I've also tried another version of DW2PDF, the fork by Michitux, which is rendering well (using WenQuanYiZenHei font) for the first 381 characters, then squares reappeared, see here https://forum.dokuwiki.org/thread/9819

Any other idea?
Thanks

@samwilson
Copy link
Collaborator

I'm sorry it's not working. :(

You need to create conf/local.protected.php if it doesn't exist, and in it put:

define('_MPDF_SYSTEM_TTFONTS', '/path/to/your/fonts/directory');

If the example I have above, the files GIL_____.ttf, GILB____.ttf, etc. are in that directory. You should change these in the config_fonts.php file (in your dw2pdf template directory) for whatever your font files are called (for Regular, Bold, Italic, and Bold Italic).

@begntsly
Copy link
Author

Ok thanks,
I've made all of these changes and tried lot of fonts but even it's not working for me (I was just able to force a font set - sun-exta & b - by adding them on the array at $this->sans_fonts at the end of config_fonts.php, but the result was a bit ugly. Indeed sun-exta & b fonts were also used for latin text).
Finally I've used the fork by Michitux and changed the setting of useAdobeCJK (true instead of false) in mpdf/config.php
Thanks for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants