Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing issue with Hindi Unicode on Windows and Ubuntu both

I am working with Hindi Text on pdf. Though Hindi text is generating but its showing as misplaced matras. Suppose I have word like 'ज़िन्दगी' but its showing as

enter image description here

If I copy this text and paste on Libre Office Writer then it prints correct. I have tried nearly two fonts with tcpdf. Arial Unicode MS as well as Lohit_hi

$tcpdf->SetFont('arialuni', 'B', 15, 'false');
$html = nl2br($result['Song']['hindi']);
$tcpdf->writeHTMLCell(0, 20, 20, 25, $html);

Why its showing character but misplaced their position.

like image 255
Sankalp Avatar asked Sep 01 '13 16:09

Sankalp


People also ask

Why Hindi fonts are not showing up in Word?

Hindi Content Not displayed in MS Word etc application. Solution: Install Hindi Unicode Font like Mangal, Arial Unicode MS, Aparajita etc. If you are using Windows XP or older windows OS, then you have to install Hindi Language pack also. After that you will see Hindi content and text in any application.

Which Hindi font is used in Unicode?

Example of Hindi Unicode font is - Mangal font, Akshar, Aparajita etc.

How can I change Hindi font in Windows 10?

Right click Windows Key and click on“Control Panel”. Under the Control Panel, click on“Clock, Language, and Region”. Select language option and click on Add a language button. Select Hindi and click on Add.


2 Answers

If I copy and paste 'ज़िन्दगी' into microsoft word, by default, it shows like this:

enter image description here

It's actually the exact same string of unicode characters (that is, a िन followed by a virama, followed by a द), but it's just rendered in different ways, depending on the font. Unicode fonts have complex logic for deciding when to substitute a certain string of characters for a different glyph, and the font being used by your PDF doesn't support the particular substitution you want.

You just have to find a font that does support that substitution, and make sure that your PDF is using that font. (It might be the case that your current setFont call isn't working correctly, or the font you specify isn't available at the time you set it, so it uses the system's default font for hindi characters, which doesn't support the substitution you're referring to).

like image 153
joshua.paling Avatar answered Sep 30 '22 16:09

joshua.paling


Why aren't you using writeHTML() instead of writeHTMLCell() ? Your problem correlates obviously with the cell. Looks a like the line height is wrong or even there is the CSS attribute for background repeat is set (should be background-repeat:none; ). writeHTML() would prevent this.

like image 25
Hexodus Avatar answered Sep 30 '22 16:09

Hexodus