Zend PDF loaded ttf with language support but still not rendering characters such as Russian or Polish

560 views Asked by At

Zend PDF standard fonts are generally equal to Latin1 character so to work with other languages an appropriate ttf font should be referenced, so that is what I am doing....

return Zend_Pdf_Font::fontWithPath($this->_getFontFileDir() . $fontFile)

The font is definitely being used but language specific characters are failing to be rendered: Russian - цдгчкфсшдгч or Polish - ńóźżćć

I've tried a number of fonts with the appropriate language support including for example DejaVuSans that comes with the dompdf library.

I'm also checking character encoding before sending to ->drawText(

        $addressItem = @iconv(mb_detect_encoding($addressItem), "UTF-8", addressItem);           

        $page->drawText(
            $addressItem,
            $this->_width,
            $this->_height,
            'UTF-8'
        );

Perhaps someone has used a font in this situation that has been seen to work with the failed characters above?

1

There are 1 answers

0
Alessandro On

It's just a matter of font, as I had the same problem for rendering Turkish and Polish texts: they were printing fine on screen (echoing them from PHP), but the PDF (with Zend_Pdf) was not rendered well, showing (or not showing at all) squares in place of several chars.. I had to import and try several external .ttf fonts before finding the one that worked: I used a plain Arial TTF font. I hope this helps!