Cannot display ¥ with TCPDF, but other kanji are ok

I use TCPDF to create PDF files containing Japanese characters. Using the TrueType font of ArialUni , most characters are displayed correctly, except that the yen symbol is displayed as a square field instead of ¥.

Here is a snippet of the resulting PDF file using ArialUni:

using ArialUni

So I tried a different font. Here is a section of the resulting PDF using GT200001 :

using GT200001

And here is the same section using Helvetica:

using helvetica

Here is the same section using GNU FreeSans :

using FreeSans

I would like the second line to display as "(渋 谷 猿, ¥ 8,000)"

I am not surprised that Helvetica and Freesans cannot correctly represent kanji, but I cannot understand why the other two fonts can display hieroglyphs, but not the yen symbol, which is much more common.

The web server that creates the PDF files is LAMP running on Ubuntu. I am viewing PDF files on OS X using Chrome (using viewing it in a browser). I also tried loading PDF files using Firefox and displaying in Preview. I get almost the same results: ArialUni and GT200001 do not display the yen symbol, while Helvetica and Freesans do not display the kanji (but display the yen symbol).

I know that I can use different fonts for different lines / cells of a PDF, but the kanji and yen symbol are on the same line.

How can I get the kanji and yen character on the same line using TCPDF?

At the top of my PDF, I load the font using TCPDF addTTFfont ();

$this->font = $this->addTTFfont(K_PATH_FONTS.'arialuni.ttf', 'TrueTypeUnicode', '', 32); 

Here is the code that I use to write a PDF section.

  $pdf->SetFont('arialuni','',10); $pdf->MultiCell(105, $remarks_height, $remarks, 'B', 'L', false, 0, '', '', true, 1, false, true, $remarks_height, 'T'); 
+4
source share
3 answers

In this wikipedia article, you can read more about this character.

Basically, there are two different ways of writing this Japanese kanji, as it happens with some other characters. From the accepted answer, “I used ¥, not ¥,” we can see that he used the “Occidental” or Unicode ¥ character when he really wanted to use the double-wide character ¥.

+5
source

Oh my god, I get it.

I used ¥, not ¥. Sorry for the confusion!

+3
source

What I noticed with TCPDF is all about fonts. I tried to use it for 15 completely different languages ​​with a different writing style, and the only font I use is Arial UNICODE MS.

TCPDF has a function that converts this font into friendly TCPDF files, which are arialuni.ctg.z (70k), arialuni.php (447k) and arialuni.z (14M).

functions, http://www.tcpdf.org/fonts.php

 $fontname = $pdf->addTTFfont('/path-to-font/ARIALUNICODE.TTF', 'TrueTypeUnicode', '', 32); 
+2
source

Source: https://habr.com/ru/post/1435450/


All Articles