Defect #19017

Wiki PDF Export: <pre> not rendered with monospaced font

Added by Marcel Müller over 3 years ago. Updated over 2 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Toshi MARUYAMA% Done:

0%

Category:PDF export
Target version:3.2.0
Resolution: Affected version:2.6.1

Description

In redmine < pre > tags are rendered with a monospaced font. When exporting a wiki with a < pre > element, this element is not rendered with a monospaced font, loosing the intended "formatting".

Simple example:

PdfExportHtmlVsPdf.png (5.8 KB) Marcel Müller, 2015-02-03 23:40

fonts.png (76 KB) Toshi MARUYAMA, 2015-03-03 15:24

rbpdf-1.19.0_ monospaced_font.pdf (128 KB) Jun NAITOH, 2015-11-21 04:59

pdf_monospaced_font_r14882.patch Magnifier (23.6 KB) Jun NAITOH, 2015-11-21 06:43

Arabic.txt Magnifier (95 Bytes) Toshi MARUYAMA, 2015-12-04 08:21

pdf.png (8.71 KB) Toshi MARUYAMA, 2015-12-05 11:44

html.png (76.5 KB) Toshi MARUYAMA, 2015-12-05 11:51

ar-en.png (17.5 KB) Toshi MARUYAMA, 2015-12-06 08:44

Associated revisions

Revision 14907
Added by Toshi MARUYAMA over 2 years ago

pdf: use "family" parameter instead of l(:general_pdf_fontname) at SetFont method (#19017)

Contributed by Jun NAITOH.

Revision 14908
Added by Toshi MARUYAMA over 2 years ago

pdf: upgrade rbpdf to 1.19.0 (#19017)

Contributed by Jun NAITOH.

Revision 14909
Added by Toshi MARUYAMA over 2 years ago

pdf: add general_pdf_monospaced_fontname to locales (#19017)

Contributed by Jun NAITOH.

Revision 14910
Added by Toshi MARUYAMA over 2 years ago

pdf: use l(:general_pdf_monospaced_fontname) (#19017)

Contributed by Jun NAITOH.

Revision 14911
Added by Toshi MARUYAMA over 2 years ago

revert r14907 (#19017)

r14907 breaks Arabic italic pdf rendering.

Revision 14912
Added by Toshi MARUYAMA over 2 years ago

Merged r14908, r14909 and r14910 from trunk to 3.2-stable (#19017)

Revision 14950
Added by Toshi MARUYAMA over 2 years ago

pdf: use "family" parameter instead of l(:general_pdf_fontname) at SetFont method (#19017)

Contributed by Jun NAITOH.

Revision 14951
Added by Toshi MARUYAMA over 2 years ago

revert r14950 (#19017)

r14907 breaks Arabic italic pdf rendering.

Revision 14959
Added by Toshi MARUYAMA over 2 years ago

pdf: use "family" parameter instead of l(:general_pdf_fontname) at SetFont method (#19017)

Contributed by Jun NAITOH.

Revision 14960
Added by Toshi MARUYAMA over 2 years ago

pdf: remove italic from DejaVuSansMono (#19017)

DejaVuSansMono Italic Arabic font has problem.

Contributed by Jun NAITOH.

Revision 14961
Added by Toshi MARUYAMA over 2 years ago

Merged r14959 from trunk to 3.2-stable (#19017)

pdf: use "family" parameter instead of l(:general_pdf_fontname) at SetFont method.

Contributed by Jun NAITOH.

Revision 14962
Added by Toshi MARUYAMA over 2 years ago

Merged r14960 from trunk to 3.2-stable (#19017)

pdf: remove italic from DejaVuSansMono.

DejaVuSansMono Italic Arabic font has problem.

Contributed by Jun NAITOH.

Revision 14963
Added by Toshi MARUYAMA over 2 years ago

pdf: use all lower cases for DejaVuSansMono (#19017)

Revision 14964
Added by Toshi MARUYAMA over 2 years ago

Merged r14963 from trunk to 3.2-stable (#19017)

pdf: use all lower cases for DejaVuSansMono.

History

#1 Updated by Marcel Müller over 3 years ago

I think the problem is in this line. "set_default_monospaced_font" should not be set to the default content-font (a non monospaced font). Removing this line works for me.

#2 Updated by Toshi MARUYAMA over 3 years ago

Marcel Müller wrote:

Removing this line works for me.

But, Cyrillic is broken.

#4 Updated by Jun NAITOH over 2 years ago

This is font problem.

rbpdf 1.19.0 was added DejaVu SansMono font,
and Supported for font subsetting. (for reduce the size of documents using large unicode font files.)

Please use monospaced font. (see attached patch and sample pdf.)

language font list

config/locales Proportional font Monospaced font notes
ar.yml DejaVuSans DejaVuSansMono DejaVuSansMono Italic Arabic font has problem.
az.yml freesans freemono
bg.yml freesans freemono
bs.yml freesans freemono
ca.yml freesans freemono
cs.yml freesans freemono
da.yml freesans freemono
de.yml freesans freemono
el.yml freesans freemono
en-GB.yml freesans freemono
en.yml freesans freemono
es-PA.yml freesans freemono
es.yml freesans freemono
et.yml freesans freemono
eu.yml freesans freemono
fa.yml DejaVuSans DejaVuSans DejaVuSansMono Persian font has problem.
fi.yml freesans freemono
fr.yml freesans freemono
gl.yml freesans freemono
he.yml freesans freemono
hr.yml freesans freemono
hu.yml freesans freemono
id.yml freesans freemono
it.yml freesans freemono
ja.yml kozminproregular kozminproregular
ko.yml hysmyeongjostdmedium hysmyeongjostdmedium
lt.yml freesans freemono
lv.yml freesans freemono
mk.yml freesans freemono
mn.yml freesans freemono
nl.yml freesans freemono
no.yml freesans freemono
pl.yml freesans freemono
pt-BR.yml freesans freemono
pt.yml freesans freemono
ro.yml freesans freemono
ru.yml freesans freemono
sk.yml freesans freemono
sl.yml freesans freemono
sq.yml freesans freemono
sr-YU.yml freesans freemono
sr.yml freesans freemono
sv.yml freesans freemono
th.yml freeserif freeserif freesans and freemono Thai fonts have problem.
tr.yml freesans freemono
uk.yml freesans freemono
vi.yml DejaVuSans DejaVuSans DejaVuSansMono Vietnamese font has problem.
zh-TW.yml msungstdlight msungstdlight
zh.yml stsongstdlight stsongstdlight

#5 Updated by Go MAEDA over 2 years ago

  • Target version set to 3.2.0

Thanks for the patch. Works fine for me.

#6 Updated by Toshi MARUYAMA over 2 years ago

  • Assignee set to Toshi MARUYAMA

#7 Updated by Toshi MARUYAMA over 2 years ago

I have committed from r14907 to r14911 without this change.

=== (+3,-1) lib/redmine/export/pdf.rb ===
@@ -55,6 +55,8 @@
           style.delete!('B') if l(:general_pdf_fontname) == 'freeserif'
           # DejaVuSans Italic Arabic and Persian font has problem.
           style.delete!('I') if l(:general_pdf_fontname) == 'DejaVuSans' && current_language.to_s.casecmp("vi") != 0
+          # DejaVuSansMono Italic Arabic font has problem.
+          style.delete!('I') if l(:general_pdf_fontname) == 'DejaVuSansMono'
           super(family, style, size, fontfile)
         end
         alias_method :set_font, :SetFont

I cannot see difference with and without this change on Arabic.txt.
Is this change needed?

#8 Updated by Toshi MARUYAMA over 2 years ago

Toshi MARUYAMA wrote:

I cannot see difference with and without this change on Arabic.txt.

On Arabic locale.

#9 Updated by Jun NAITOH over 2 years ago

I cannot see difference with and without this change on Arabic.txt.
Is this change needed?

I checked it once again. so, this change is unnecessary, Sorry.

Because Redmine 3.2(r14911) used a monospaced font in the pre tag, but a style(bold/italic) wasn't applied in the pre tag.

#10 Updated by Toshi MARUYAMA over 2 years ago

But monospace italic is in HTML source.
Does not PDF support "code" and %{font-style: italic; font-family: monospace}word%?

%{font-style: italic; font-family: monospace}italic monospace%
_italic_
@monospace@

<pre>
pre
</pre>


#11 Updated by Jun NAITOH over 2 years ago

Toshi MARUYAMA wrote:

But monospace italic is in HTML source.
Does not PDF support "code" and %{font-style: italic; font-family: monospace}word%?

PDF don't support "code" and %{font-family: monospace}word%
but, PDF support %{font-style: italic; font-family: DejaVuSansMono}word%

If use %{font-style: italic; font-family: DejaVuSansMono}word%, it's no problem by following setting on Arabic locale.

           style.delete!('I') if l(:general_pdf_fontname) == 'DejaVuSans' && current_language.to_s.casecmp("vi") != 0

#12 Updated by Toshi MARUYAMA over 2 years ago

I can see DejaVuSansMono italic has problem in Vietnamese, but I cannot see in Arabic.
Where is source?

#13 Updated by Toshi MARUYAMA over 2 years ago

Toshi MARUYAMA wrote:

I can see DejaVuSansMono italic has problem in Vietnamese, but I cannot see in Arabic.

This behaviour changes frequently. "family" parameter of SetFont() sometimes comes all lower-cases.
source:trunk/lib/redmine/export/pdf.rb@14949#L53
r14950 stabilizes behaviour changes.

#14 Updated by Toshi MARUYAMA over 2 years ago

Toshi MARUYAMA wrote:

r14950 stabilizes behaviour changes.

But r14950 breaks Arabic italic pdf rendering again.
(I mistook r14951 comment.)

#15 Updated by Toshi MARUYAMA over 2 years ago

I try with this change on r14951, English locale is OK, but Arabic locale is NG.
I think SetFont() has stability bug.

%{font-style: italic; font-family: DejaVuSansMono}Tiếng Việt%
%{font-style: italic; font-family: DejaVuSansMono}عربي%

diff --git a/config/locales/ar.yml b/config/locales/ar.yml
--- a/config/locales/ar.yml
+++ b/config/locales/ar.yml
@@ -140,8 +140,8 @@
   general_csv_separator: ','
   general_csv_decimal_separator: '.'
   general_csv_encoding: ISO-8859-1
-  general_pdf_fontname: DejaVuSans
-  general_pdf_monospaced_fontname: DejaVuSansMono
+  general_pdf_fontname: freesans
+  general_pdf_monospaced_fontname: freemono
   general_first_day_of_week: '7'

   notice_account_updated: لقد تم تجديد الحساب بنجاح.
diff --git a/config/locales/en.yml b/config/locales/en.yml
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -141,8 +141,8 @@
   general_csv_separator: ','
   general_csv_decimal_separator: '.'
   general_csv_encoding: ISO-8859-1
-  general_pdf_fontname: freesans
-  general_pdf_monospaced_fontname: freemono
+  general_pdf_fontname: DejaVuSans
+  general_pdf_monospaced_fontname: DejaVuSansMono
   general_first_day_of_week: '7'

   notice_account_updated: Account was successfully updated.

#16 Updated by Jean-Philippe Lang over 2 years ago

  • Status changed from New to Closed

I'm closing this for 3.2 release. If there any problems pending, please open another issue.

#17 Updated by Toshi MARUYAMA over 2 years ago

r14950 is wrong.

style.delete!('I') if family.to_s.casecmp('DejaVuSans') != 0

should be

style.delete!('I') if family.to_s.casecmp('DejaVuSans') == 0

#18 Updated by Toshi MARUYAMA over 2 years ago

Jean-Philippe Lang wrote:

I'm closing this for 3.2 release. If there any problems pending, please open another issue.

3.2-stable r14962 has completed.
Please release 3.2.0.

#19 Updated by Toshi MARUYAMA over 2 years ago

Toshi MARUYAMA wrote:

3.2-stable r14962 has completed.

Sorry, I have committed very minor 3.2-stable r14964.
Please release 3.2.0.

#20 Updated by Jean-Philippe Lang over 2 years ago

Thanks.

Also available in: Atom PDF