Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't display ¥ with TCPDF, but other kanji are okay

I'm using TCPDF to create PDFs that include Japanese characters. Using the TrueType font ArialUni, most characters are displayed correctly, except the yen symbol shows up as a square box instead of ¥.

Here's a snippet of the resulting PDF using ArialUni:

using ArialUni

So I tried another font. Here's the same section of the resulting PDF using GT200001:

using GT200001

And here's the same section using Helvetica:

using Helvetica

Here's the same section using GNU's FreeSans:

using FreeSans

I would like that second line to show up as "(渋谷猿, ¥8,000)"

I'm not surprised that Helvetica and Freesans cannot render the kanji correctly, but I cannot fathom why the other two fonts can render the kanji, but not the yen symbol, which is much more common.

The web server creating the PDFs is LAMP running Ubuntu. I'm viewing the PDFs on OS X with Chrome (using its in-browser view). I've also tried downloading the PDFs with Firefox and displaying in Preview. I get essentially the same results: ArialUni and GT200001 don't display the yen symbol, while Helvetica and Freesans don't display the kanji (but do display the yen symbol).

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

How can I get the kanji and yen symbol to display in a single line using TCPDF?

Near the top of my PDF code, I load the font using TCPDF's addTTFfont();

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

Here's the code I'm using to write the section of the PDF.

        $pdf->SetFont('arialuni','',10);
        $pdf->MultiCell(105, $remarks_height, $remarks, 'B', 'L', false, 0, '', '', true, 1, false, true,  $remarks_height, 'T');
like image 878
Thunder Rabbit Avatar asked Dec 27 '22 17:12

Thunder Rabbit


2 Answers

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

Basically, there are 2 different ways of writing this Japanese Kanji, as it happens with some other symbols. From accepted answer "I was using ¥, not ¥", we can see that he was using the 'occidental' or Unicode ¥ symbol, when he actually wanted to use the double-width character ¥.

like image 149
Francisco Presencia Avatar answered Jan 08 '23 14:01

Francisco Presencia


Oh dear, I figured it out.

I was using ¥, not ¥. Sorry for being confused!!

like image 32
Thunder Rabbit Avatar answered Jan 08 '23 15:01

Thunder Rabbit