Defect #4787

Gannt to PNG - CJK (Chinese, Japanese and Korean) characters appear as ?

Added by Jeffrey Jones over 7 years ago. Updated about 3 years ago.

Status:ClosedStart date:2010-02-10
Priority:NormalDue date:
Assignee:Toshi MARUYAMA% Done:

100%

Category:Gantt
Target version:2.2.0
Resolution:Fixed Affected version:

Description

When exporting a gantt chart to png format all Japanese (hiragana,katakana and kanji) characters are replaced with ? characters.

This is using RMagick 2.12.2 and the libmagick9-dev provided with Ubuntu 9.10.

Being able to export to PNG would relieve some of the problems we are facing with the inability to export to PDF (As discussed in issue #61 )

(Also would it be useful to add an "Exporters" category? I am not sure what to file this under)

gantt_korean.png - Gannt Korean export broken. (23.3 KB) Namho Kim, 2012-01-25 05:59

png_rmagick_font_r8745.patch Magnifier (2.01 KB) Jun NAITOH, 2012-02-01 16:30

rmagick_font.png (23.8 KB) Jun NAITOH, 2012-02-01 16:30

user-pref.png (33.9 KB) Toshi MARUYAMA, 2012-02-02 03:17

user-pref-r8745.patch Magnifier (3.03 KB) Toshi MARUYAMA, 2012-02-02 03:17

redmine-gantt_kr.png (50.1 KB) Namho Kim, 2012-02-09 04:00

png_rmagick_font_path_r8987.patch Magnifier (1.07 KB) Jun NAITOH, 2012-02-25 04:32

png_rmagick_font_path_r10851.patch Magnifier (1.3 KB) Toshi MARUYAMA, 2012-11-19 13:36


Related issues

Related to Redmine - Defect #6505: PDF export broken with Japanese (Gannt and Issue Tracking) Closed 2010-09-27
Related to Redmine - Defect #61: Broken character encoding in pdf export Closed
Related to Redmine - Patch #3231: patch for broken character problem on png-exported gantt ... Closed 2009-04-23
Related to Redmine - Feature #69: Textilized description in PDF Closed
Related to Redmine - Feature #5638: Use Bundler (Gemfile) for gem management Closed 2010-06-02
Related to Redmine - Defect #13781: CJK(Chinese/Japanese/Korean) characters are not shown in ... Closed
Duplicated by Redmine - Defect #6506: Gantt chart export to PDF/PNG works incorrectly in zh-tw ... Closed 2010-09-27

Associated revisions

Revision 10890
Added by Toshi MARUYAMA almost 5 years ago

add configuration of RMagcik font for CJK (Chinese, Japanese and Korean) (#4787)

Contributed by Jun NAITOH.

Revision 10892
Added by Toshi MARUYAMA almost 5 years ago

fix comment of RMagcik font configuration (#4787)

History

#1 Updated by Jeffrey Jones over 7 years ago

  • % Done changed from 0 to 10

Looks like this is a font issue.

I edited /lib/redmine/helpers/gantt.rb and hacked in the following

gc = Magick::Draw.new
gc.font = "/usr/share/fonts/truetype/msttcorefonts/gothic.ttf" # New Line - Explicitly declare font
# Subjects

This is an ugly hard-coded hack that points to a font that I know for sure is UTF-8 Japanese character compatible and it works.

So the question now is how to make this something that can be merged into redmine itself and works on all platforms.

Maybe we could make an administration option that allows us to select the fonts we desire for our exports? (When using PDF/PNG?)

#2 Updated by Ki Won Kim over 7 years ago

Symptoms are the same, and I was modified gantt.rb by your hacked code.
thanks a lot.

Jeffrey Jones wrote:

When exporting a gantt chart to png format all Japanese (hiragana,katakana and kanji) characters are replaced with ? characters.

This is using RMagick 2.12.2 and the libmagick9-dev provided with Ubuntu 9.10.

Being able to export to PNG would relieve some of the problems we are facing with the inability to export to PDF (As discussed in issue #61 )

(Also would it be useful to add an "Exporters" category? I am not sure what to file this under)

#3 Updated by Mischa The Evil almost 7 years ago

  • Category set to Gantt

#4 Updated by Toshi MARUYAMA over 6 years ago

  • Subject changed from Gannt to PNG - Japanese characters appear as ? to Gannt to PNG - CJK (Chinese, Japanese and Korean) characters appear as ?

#5 Updated by Namho Kim over 5 years ago

That's right. For example Gannt include Korean like belows.

#6 Updated by Namho Kim over 5 years ago

That's right. For example Gannt include Korean like belows.

Gannt Korean export broken.

#7 Updated by Jun NAITOH over 5 years ago

This issue is font setting problem.

I wrote selectable RMagcik font patch.
This patch add RMagick font selector of Display tab in Setting.

If you want to show Japanese, so please select Japanese Font.

I tested on RMagick 2.13.1 on CentOS 6, RMagick 2.12.0 on Windows XP.

#8 Updated by Toshi MARUYAMA over 5 years ago

  • Assignee set to Toshi MARUYAMA

#9 Updated by Etienne Massip over 5 years ago

Please don't make this a new setting, just force the police font to what would fit well if possible?

#10 Updated by Toshi MARUYAMA over 5 years ago

  • Assignee deleted (Toshi MARUYAMA)

#11 Updated by Toshi MARUYAMA over 5 years ago

This is a patch using user preference.

#12 Updated by Etienne Massip over 5 years ago

I can't see why a font would be a user preference?? This should be automatic, who wants to select a specific font to export a chart? I just want to click and get my Gantt chart exported as a image as it it rendered in browser, period.

Please don't add too much complexity.

#13 Updated by Toshi MARUYAMA over 5 years ago

Etienne Massip wrote:

This should be automatic

There is no standard font in Japanese.

  • Windows: MS Mincho, MS Gothic
  • MacOS: HIRAGINO
  • Linux: Nothing

Unicode has Unified problem.
http://en.wikipedia.org/wiki/CJK_Unified_Ideographs

So, CJK font cannot be defined automatically.

#14 Updated by Toshi MARUYAMA over 5 years ago

On Redmine 1.3, CJK PDF fonts are hard-coded.
source:tags/1.3.0/lib/redmine/export/pdf.rb#L52

Redmine 1.3 uses non embedded fonts for CJK PDF.
So, PDF reader uses alternate fonts if there is no fonts on client.

But, rmagick processes on server.
So, we cannot hard-coded and defined fonts at locale files (config/locales/ja.yml).

#15 Updated by Etienne Massip over 5 years ago

Can't you add a setting to embed fonts into exported file?

#16 Updated by Toshi MARUYAMA over 5 years ago

Etienne Massip wrote:

Can't you add a setting to embed fonts into exported file?

It is difficult that user/administrator finds fonts name on server.
On Note-12 user-pref.png, font name is "IPAGothic-Regular".

#17 Updated by Namho Kim over 5 years ago

Korean is OK, using the above patch.

#18 Updated by Jun NAITOH over 5 years ago

Toshi MARUYAMA wrote:

This is a patch using user preference.

I'm checked. I think this patch is better than my patch.

#19 Updated by Jun NAITOH over 5 years ago

Etienne Massip wrote:

Please don't add too much complexity.

OK. I tried another approach.
This patch add a configurable path of RMagick in configuration.yml.

#20 Updated by Go MAEDA almost 5 years ago

Current PNG output is of no use in CJK. Font name must be set to address the problem but we cannot know what font is installed in a system because standard CJK font is different by operating system.

NAITOH's patch (png_rmagick_font_path_r8987.patch) seems smart approach to deal with the problem because there's no ui change.

It wishes strongly that the patch is merged to trunk to make Redmine more useful.

#21 Updated by Toshi MARUYAMA almost 5 years ago

This is a patch of note-19 png_rmagick_font_path_r8987.patch rebased to trunk r10851.
You can apply it to 2.1-stable r10848 (2.1.3).

#22 Updated by Toshi MARUYAMA almost 5 years ago

  • Status changed from New to Closed
  • Assignee set to Toshi MARUYAMA
  • Target version set to 2.2.0
  • % Done changed from 10 to 100
  • Resolution set to Fixed

I have added comment to note-21 patch and committed in trunk r10890 and r10892.

#23 Updated by Daniel Felix about 3 years ago

Etienne Massip wrote:

Please don't make this a new setting, just force the police font to what would fit well if possible?

Well I would agree to that point. Our users won't be able to easily determine the right font on languages they don't even know.

#24 Updated by Toshi MARUYAMA about 3 years ago

  • Related to Defect #13781: CJK(Chinese/Japanese/Korean) characters are not shown in PDF on non CJK locales added

Also available in: Atom PDF