Project

General

Profile

Actions

Defect #19017

closed

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

Added by Marcel Müller almost 10 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Toshi MARUYAMA
Category:
PDF export
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

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:


Files

PdfExportHtmlVsPdf.png (5.8 KB) PdfExportHtmlVsPdf.png Marcel Müller, 2015-02-03 23:40
fonts.png (76 KB) fonts.png Toshi MARUYAMA, 2015-03-03 15:24
rbpdf-1.19.0_ monospaced_font.pdf (128 KB) rbpdf-1.19.0_ monospaced_font.pdf Jun NAITOH, 2015-11-21 04:59
pdf_monospaced_font_r14882.patch (23.6 KB) pdf_monospaced_font_r14882.patch Jun NAITOH, 2015-11-21 06:43
Arabic.txt (95 Bytes) Arabic.txt Toshi MARUYAMA, 2015-12-04 08:21
pdf.png (8.71 KB) pdf.png Toshi MARUYAMA, 2015-12-05 11:44
html.png (76.5 KB) html.png Toshi MARUYAMA, 2015-12-05 11:51
ar-en.png (17.5 KB) ar-en.png Toshi MARUYAMA, 2015-12-06 08:44
Actions #1

Updated by Marcel Müller almost 10 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.

Actions #2

Updated by Toshi MARUYAMA almost 10 years ago

Marcel Müller wrote:

Removing this line works for me.

But, Cyrillic is broken.

Actions #3

Updated by Toshi MARUYAMA almost 10 years ago

Actions #4

Updated by Jun NAITOH about 9 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
Actions #5

Updated by Go MAEDA about 9 years ago

  • Target version set to 3.2.0

Thanks for the patch. Works fine for me.

Actions #6

Updated by Toshi MARUYAMA about 9 years ago

  • Assignee set to Toshi MARUYAMA
Actions #7

Updated by Toshi MARUYAMA almost 9 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?

Actions #8

Updated by Toshi MARUYAMA almost 9 years ago

Toshi MARUYAMA wrote:

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

On Arabic locale.

Actions #9

Updated by Jun NAITOH almost 9 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.

Actions #10

Updated by Toshi MARUYAMA almost 9 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>


Actions #11

Updated by Jun NAITOH almost 9 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

Actions #12

Updated by Toshi MARUYAMA almost 9 years ago

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

Actions #13

Updated by Toshi MARUYAMA almost 9 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.

Actions #14

Updated by Toshi MARUYAMA almost 9 years ago

Toshi MARUYAMA wrote:

r14950 stabilizes behaviour changes.

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

Actions #15

Updated by Toshi MARUYAMA almost 9 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.

Actions #16

Updated by Jean-Philippe Lang almost 9 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.

Actions #17

Updated by Toshi MARUYAMA almost 9 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
Actions #18

Updated by Toshi MARUYAMA almost 9 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.

Actions #19

Updated by Toshi MARUYAMA almost 9 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.

Actions #20

Updated by Jean-Philippe Lang almost 9 years ago

Thanks.

Actions

Also available in: Atom PDF