Forum


Replies: 1   Views: 226
Customizewordcontent to change japanese font
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by jeremie  · 11-05-2020 - 14:37

I'm using customizeWordContent to change fonts. Its works fine for latin characters, but I doesn't for Japanese characters.

For example, I have a Word document containing two text lines.

The first line is in Japanese. The second line is in English. Document uses "MS Mincho" font for both lines.

Then I run function customizeWordContent to change font to "Yu Gothic":

foreach (array('document', 'header', 'footer', 'footnote', 'endnote') as $target)
        foreach (array('paragraph', 'run', 'list', 'style') as $type)
                $docx->customizeWordContent(['target' => $target, 'type' => $type, 'contains' => '',], ['font' => 'Yu Gothic']);

The resulting document has fonts "MS Mincho" for the first line (the line in Japanese) and "Yu Gothic" for the second line (the line in English). So it appears that it didn't work for the Japanese line.

I tried everything (many different fonts, many different configurations) but I couldn't make it work for the Japanese line.

What should I do?

Posted by admin  · 11-05-2020 - 15:00

Hello,

The current version of customizeWordContent replaces w:ascii, w:hAnsi and w:cs attributes, and the current beta branch also replaces w:eastAsia, this may be the problem. Please send the DOCX to contact[at]phpdocx.com so we can check it. Also please send us if you are using the classic or namespaces package and we'll send you the updated class, it's a minor change.

Regards.