vikrambalye / dompdf

Automatically exported from code.google.com/p/dompdf
0 stars 0 forks source link

Any advice on displaying Cyrillic characters? #249

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I can't seem to get Cyrillic characters to display no matter what I try. I have 
DOMPDF_UNICODE_ENABLED set to true, I have ttf2pt1 installed in the 
lib/ttf2ufm/bin/ directory, I have TTF2AFM set to DOMPDF_LIB_DIR 
."/ttf2ufm/bin/ttf2pt1", I used load_font.php to convert a TrueType font that I 
know supports Cyrillic to a Unicode font (though the files generated had .afm 
extensions not .ufm), and of course I set the font-family to that font in the 
body. And still after all that effort, the characters display as question 
marks. Does anyone know of a font that they've been able to use for Cyrillic 
characters? I'm trying to figure out whether the issue is with the font itself 
or whether I somehow incorrectly converted it.

Original issue reported on code.google.com by wbeau...@gmail.com on 24 Mar 2011 at 2:42

GoogleCodeExporter commented 9 years ago
Your problem appears to be the version of ttf2pt1 on your system. The version 
included with DOMPDF is modified to support Unicode font metrics out of the 
box. Did you compile from scratch or use a copy already on your system? You 
would have to jump through some hoops to get the same out of the standard 
executable

The modified version creates font metrics in both .afm and .ufm format. The UFM 
format is required in order to render Unicode text correctly. Without it, 
DOMPDF will fall back to Windows ANSI encoding.

If you are unable to compile from source then you might try the web-based font 
prep tool:
http://eclecticgeek.com/dompdf/load_font.php

Original comment by eclecticgeek on 25 Mar 2011 at 6:06

GoogleCodeExporter commented 9 years ago

Original comment by eclecticgeek on 25 Mar 2011 at 6:07

GoogleCodeExporter commented 9 years ago
I uploaded Unicode-friendly Arial font files that I got from another source and 
changed the font to Arial and it still didn't fix things.

Original comment by wbeau...@gmail.com on 25 Mar 2011 at 6:13

GoogleCodeExporter commented 9 years ago
It's not just the font that needs to be Unicode friendly. You also have to 
process your font using ttf2ufm to get the Unicode font metrics (*.ufm) that 
DOMPDF needs to process text that uses the font. Without the *.ufm files DOMPDF 
will fall back to Windows ANSI encoding.

Original comment by eclecticgeek on 25 Mar 2011 at 6:24

GoogleCodeExporter commented 9 years ago
I know that. That's what I meant: the files I uploaded are .ufm files.

Original comment by wbeau...@gmail.com on 25 Mar 2011 at 6:33

GoogleCodeExporter commented 9 years ago
Ok. Just wanted to clarify that you were uploading all the necessary files.

So to review the requirements for working enabling Unicode support.
1) make sure the MBString PHP extension is enabled
2) set DOMPDF_UNICODE_ENABLED to true
3) install a Unicode font (ttf + ufm)
4) ensure your HTML document includes a meta header indicating the content 
type, e.g. <meta http-equiv="Content-Type" content="charset=utf-8" />

You're ok on 2 & 3. What about 1 & 4?

Original comment by eclecticgeek on 25 Mar 2011 at 7:43

GoogleCodeExporter commented 9 years ago
Yes, all of those conditions are satisfied.

Original comment by wbeau...@gmail.com on 25 Mar 2011 at 7:57

GoogleCodeExporter commented 9 years ago
Can you post a sample of your HTML document and font files so we can try it out 
on our systems?

Original comment by eclecticgeek on 25 Mar 2011 at 8:37

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Shows blank pdf =(

<html>
<head>
<meta http-equiv="Content-Type" content="charset=utf-8" />
<style>

body {
  font-family: "DejaVu sans" /* unicode font from the box */
}
</style>
</head>

<body>
Я наконец-то did it!

</body>
</html>

Original comment by pavel.fr...@gmail.com on 12 Jul 2012 at 8:31

GoogleCodeExporter commented 9 years ago
@pavel.frankov which version of dompdf? This seems to render fine on my copy of 
dompdf 0.6.0 beta 3 (the most recent). You might also check to see if you have 
any PHP errors.

Original comment by eclecticgeek on 12 Jul 2012 at 5:42

GoogleCodeExporter commented 9 years ago
The latest one: 0.6.0 beta 3. No PHP errors.
Works fine for latin letters, but even one cyrillic letter is breaks everything.
When I've remove <meta http-equiv="Content-Type" content="charset=utf-8" /> it 
works only for latin letters.

Original comment by pavel.fr...@gmail.com on 12 Jul 2012 at 5:54

GoogleCodeExporter commented 9 years ago
Are errors enabled? Seems you should get *some* kind of error if the characters 
are being stripped. Also, can you post your PDF?

Original comment by eclecticgeek on 13 Jul 2012 at 3:06

GoogleCodeExporter commented 9 years ago
Here is screenshot from setup.php
http://speedcap.net/img/e63b6e397b5b9143d7f78497f866bf4f/7a660ded.png
PDF in attachment.

Original comment by pavel.fr...@gmail.com on 13 Jul 2012 at 7:21

Attachments:

GoogleCodeExporter commented 9 years ago
Hm, I've changed my WAMP from XAMPP to latest OpenServer and now all is ok. 
Thank you!

Original comment by pavel.fr...@gmail.com on 13 Jul 2012 at 9:42

GoogleCodeExporter commented 9 years ago
Thanks for the update. I'll make a note of the issue. If we have a chance we'll 
investigate further. Which version of XAMPP were you using?

Original comment by eclecticgeek on 13 Jul 2012 at 5:15

GoogleCodeExporter commented 9 years ago
XAMPP (Basispaket) version 1.7.4 

Original comment by pavel.fr...@gmail.com on 13 Jul 2012 at 5:20

GoogleCodeExporter commented 9 years ago
I've fully reinstalled XAMPP and now all works fine. Thank you again!

Original comment by pavel.fr...@gmail.com on 16 Jul 2012 at 5:14

GoogleCodeExporter commented 9 years ago
Thanks for the update. Odd that a reinstall would have fixed the problem. Maybe 
a missing library. At any rate, glad you got it working again.

Original comment by eclecticgeek on 16 Jul 2012 at 5:00

GoogleCodeExporter commented 9 years ago

Original comment by eclecticgeek on 30 May 2013 at 5:15