Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GD with JIS-mapped Japanese Font Support #4206

Closed
anonymous-matomo-user opened this issue Oct 8, 2013 · 6 comments
Closed

GD with JIS-mapped Japanese Font Support #4206

anonymous-matomo-user opened this issue Oct 8, 2013 · 6 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@anonymous-matomo-user
Copy link

Description

If you compile PHP with option "--enable-gd-jis-conv" and "JIS-mapped Japanese font support" in GD is enabled, characters that are embedded in the graph image by the function imagettftext() are unintelligible sequence of characters.

Reproduce

URL to reproduce such bug:

  • create a scheduled reports, pick few reports, select SHOW graph in all reports, "show historical top 5"
  • in Japanese language
  • download; index.php?module=API&action=index&idSite=1&period=week&date=2013-11-05&updated=2&token_auth=XXXXXXX&method=PDFReports.generateReport&idReport=1&outputType=3&language=ja

Error:

Warning: imagettfbbox(): any2eucjp(): invalid code in input string in /var/www/html/piwik/libs/pChart2.1.3/class/pImage.class.php on line 211

Backtrace -->

#0 Piwik_ErrorHandler(...) called at [:]
#1 imagettfbbox(...) called at [/var/www/html/piwik/libs/pChart2.1.3/class/pImage.class.php:211]
#2 pImage->getTextBox(...) called at [/var/www/html/piwik/libs/pChart2.1.3/class/pDraw.class.php:988]
#3 pDraw->drawText(...) called at [/var/www/html/piwik/plugins/ImageGraph/StaticGraph.php:290]
#4 Piwik_ImageGraph_StaticGraph->getTextWidthHeight(...) called at [/var/www/html/piwik/plugins/ImageGraph/StaticGraph.php:305]
#5 Piwik_ImageGraph_StaticGraph->getMaximumTextWidthHeight(...) called at [/var/www/html/piwik/plugins/ImageGraph/StaticGraph/GridGraph.php:382]
#6 Piwik_ImageGraph_StaticGraph_GridGraph->getGridBottomMargin(...) called at [/var/www/html/piwik/plugins/ImageGraph/StaticGraph/GridGraph.php:401]
#7 Piwik_ImageGraph_StaticGraph_GridGraph->getGraphBottom(...) called at [/var/www/html/piwik/plugins/ImageGraph/StaticGraph/GridGraph.php:84]
#8 Piwik_ImageGraph_StaticGraph_GridGraph->initGridChart(...) called at [/var/www/html/piwik/plugins/ImageGraph/StaticGraph/Evolution.php:28]
#9 Piwik_ImageGraph_StaticGraph_Evolution->renderGraph(...) called at [/var/www/html/piwik/plugins/ImageGraph/API.php:477]
#10 Piwik_ImageGraph_API->get(...) called at [:]
#11 call_user_func_array(...) called at [/var/www/html/piwik/core/API/Proxy.php:188]
#12 Piwik_API_Proxy->call(...) called at [/var/www/html/piwik/core/API/Request.php:145]
#13 Piwik_API_Request->process(...) called at [/var/www/html/piwik/core/ReportRenderer.php:238]
#14 Piwik_ReportRenderer::getStaticGraph(...) called at [/var/www/html/piwik/core/ReportRenderer/Pdf.php:411]
#15 Piwik_ReportRenderer_Pdf->paintGraph(...) called at [/var/www/html/piwik/core/ReportRenderer/Pdf.php:301]
#16 Piwik_ReportRenderer_Pdf->renderReport(...) called at [:]
#17 array_walk(...) called at [/var/www/html/piwik/plugins/PDFReports/API.php:425]
#18 Piwik_PDFReports_API->generateReport(...) called at [:]
#19 call_user_func_array(...) called at [/var/www/html/piwik/core/API/Proxy.php:188]
#20 Piwik_API_Proxy->call(...) called at [/var/www/html/piwik/core/API/Request.php:145]
#21 Piwik_API_Request->process(...) called at [/var/www/html/piwik/plugins/API/Controller.php:25]
#22 Piwik_API_Controller->index(...) called at [:]
#23 call_user_func_array(...) called at [/var/www/html/piwik/core/FrontController.php:125]
#24 Piwik_FrontController->dispatch(...) called at [/var/www/html/piwik/index.php:47]

Proposed solution

Add the process of converting to SJIS from UTF-8 as follows.

 if ($gdinfo['JIS-mapped Japanese Font Support']) {
 $string = mb_convert_encoding($string, "SJIS", "UTF-8");
 }

Keywords: graph chart

@mattab
Copy link
Member

mattab commented Oct 14, 2013

thanks for report!

have you tested this code in Piwik (which file)?

When you compile PHP with --enable-gd-jis-conv, do you also need the unifont.ttf as explained in this FAQ or is this font not required?
http://piwik.org/faq/how-to-install/#faq_142

@anonymous-matomo-user
Copy link
Author

No, this is a conceputual code.
I found this function is used in the pChart library, so I think adding the source to the library itself would be undesirable.

When you compile PHP with --enable-gd-jis-conv, do you also need the unifont.ttf as explained in this FAQ or is this font not required?

I'll try and report here.

@anonymous-matomo-user
Copy link
Author

I am sorry. In my misunderstanding, this was a phenomenon in the mobile app actually.
Please remove once this ticket.

@mattab
Copy link
Member

mattab commented Nov 5, 2013

There is this other line with this error:
Warning: imagettftext(): any2eucjp(): invalid code in input string in /var/www/html/piwik/libs/pChart2.1.3/class/pDraw.class.php on line 1023

@tsteur
Copy link
Member

tsteur commented Nov 13, 2013

In 516c13d: fixes #4206 it is now possible to render the graphs, fix is verified on the mentioned Piwik instance

@tsteur
Copy link
Member

tsteur commented Nov 13, 2013

In 69b30cd: refs #4206 mention fix in readme

@anonymous-matomo-user anonymous-matomo-user added this to the 2.0 - Piwik 2.0 milestone Jul 8, 2014
sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
… verified on the mentioned Piwik instance
sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

3 participants