summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Module/FanChartModule.php7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/Module/FanChartModule.php b/app/Module/FanChartModule.php
index bcf60d20b7..82d6e6d099 100644
--- a/app/Module/FanChartModule.php
+++ b/app/Module/FanChartModule.php
@@ -552,6 +552,13 @@ class FanChartModule extends AbstractModule implements ModuleChartInterface, Req
*/
protected function textWidthInPixels(string $text): int
{
+ // If PHP is compiled with --enable-gd-jis-conv, then the function
+ // imagettftext() is modified to expect EUC-JP encoding instead of UTF-8.
+ // Attempt to detect and convert...
+ if (gd_info()['JIS-mapped Japanese Font Support'] ?? false) {
+ $text = mb_convert_encoding($text, 'EUC-JP', 'UTF-8');
+ }
+
$bounding_box = imagettfbbox(self::TEXT_SIZE_POINTS, 0, self::FONT, $text);
return $bounding_box[4] - $bounding_box[0];