Jeckky / dompdf

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

DOMPDF_DEFAULT_FONT is ignored due to class defaults in Style #449

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Adding Greek text in #header or #footer using CSS appears as ????. However 
Greek text on the body of the PDF is actually shown properly

Related configuration of dompdf is:

def("DOMPDF_DEFAULT_FONT", "dejavu");
def("DOMPDF_UNICODE_ENABLED", true);

The html contains <meta http-equiv="Content-Type" content="text/html; 
charset=utf-8"/> and I have mb_ functions available in my installation

What is the expected output? What do you see instead?
Using the pdf.html script I should get Greek text in the header/footer, but 
instead I am getting ????

What version of dompdf are you using? What version of PHP? On what
operating system?
domPDF ver 0.6.0 beta3
Ubuntu server (lucid)
PHP 5.3.2-1

Please provide the HTML source code you want to convert, or any additional
information.

Original issue reported on code.google.com by soul...@gmail.com on 22 Mar 2012 at 11:08

Attachments:

GoogleCodeExporter commented 8 years ago
It appears the problem is that the DOMPDF_DEFAULT_FONT setting is ignored in 
favor of the default set in the Style class. You can work around the problem by 
adding a body styling to your CSS, e.g.:

  body { font-family: DejaVu Sans, sans-serif; }

If you want a quick fix for the issue you can modify 
dompdf/include/style.cls.php@238 to read as follows:

  $d["font_family"] = DOMPDF_DEFAULT_FONT;

(ref. 
http://code.google.com/p/dompdf/source/browse/tags/dompdf_0-6-0_beta3/dompdf/inc
lude/style.cls.php#238)

Also, please note that "dejavu" is not a valid font. The DejaVu font pack is a 
set of fonts that include the following: DejaVu Sans, DejaVu Sans Light, DejaVu 
Sans Condensed, DejaVu Sans Mono, DejaVu Serif, DejaVu Serif Condensed.

Original comment by eclecticgeek on 22 Mar 2012 at 10:34

GoogleCodeExporter commented 8 years ago
Using r481 as a reference for discussion.

A default font of "serif" is set in the Style class here:
http://code.google.com/p/dompdf/source/browse/trunk/dompdf/include/style.cls.php
?r=481#240

dompdf currently takes into account the DOMPDF_DEFAULT_FONT setting here:
http://code.google.com/p/dompdf/source/browse/trunk/dompdf/include/font_metrics.
cls.php?r=481#169

Since the default font set in CSS is a valid font the value of 
DOMPDF_DEFAULT_FONT will always be ignored unless the user specifies a bad 
font. We might consider switching where DOMPDF_DEFAULT_FONT is referenced so 
that the CSS default is set as follows:

  $d["font_family"] = (isset(DOMPDF_DEFAULT_FONT)?DOMPDF_DEFAULT_FONT:"serif");

And the FontMetrics class initializes to "serif" (a known, valid font) on line 
240.

Original comment by eclecticgeek on 22 Mar 2012 at 10:46

GoogleCodeExporter commented 8 years ago
I thought about the same thing for the default font, but I don't think the 
"isset" test is needed.

    $d["font_family"] = DOMPDF_DEFAULT_FONT;

should be enought IMO.

Original comment by fabien.menager on 25 Mar 2012 at 4:18

GoogleCodeExporter commented 8 years ago
You're right. No need to complicate the code.

Original comment by eclecticgeek on 26 Mar 2012 at 1:30

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r484.

Original comment by eclecticgeek on 28 Mar 2012 at 2:53

GoogleCodeExporter commented 8 years ago

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