Vote #76011
完了Wiki PDF Export: <pre> not rendered with monospaced font
0%
説明
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!
journals
I think the problem is in "this line":http://www.redmine.org/projects/redmine/repository/revisions/13944/entry/trunk/lib/redmine/export/pdf.rb#L45. "set_default_monospaced_font" should not be set to the default content-font (a non monospaced font). Removing this line works for me.
--------------------------------------------------------------------------------
Marcel Müller wrote:
> Removing this line works for me.
But, Cyrillic is broken.
!fonts.png!
--------------------------------------------------------------------------------
I have created issue.
https://github.com/naitoh/rbpdf/issues/11
--------------------------------------------------------------------------------
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.)
h2. 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||
--------------------------------------------------------------------------------
Thanks for the patch. Works fine for me.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
I have committed from r14907 to r14911 without this change.
<pre><code class="diff">
=== (+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
</code></pre>
I cannot see difference with and without this change on attachment:Arabic.txt.
Is this change needed?
--------------------------------------------------------------------------------
Toshi MARUYAMA wrote:
> I cannot see difference with and without this change on attachment:Arabic.txt.
On Arabic locale.
--------------------------------------------------------------------------------
> I cannot see difference with and without this change on attachment: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.
--------------------------------------------------------------------------------
But monospace italic is in HTML source.
Does not PDF support @"code"@ and @%{font-style: italic; font-family: monospace}word%@?
<pre>
%{font-style: italic; font-family: monospace}italic monospace%
_italic_
@monospace@
<pre>
pre
</pre>
</pre>
!html.png!
!pdf.png!
--------------------------------------------------------------------------------
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.
<pre>
style.delete!('I') if l(:general_pdf_fontname) == 'DejaVuSans' && current_language.to_s.casecmp("vi") != 0
</pre>
--------------------------------------------------------------------------------
I can see DejaVuSansMono italic has problem in Vietnamese, but I cannot see in Arabic.
Where is source?
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
Toshi MARUYAMA wrote:
> r14950 stabilizes behaviour changes.
But r14950 breaks Arabic italic pdf rendering again.
(I mistook r14951 comment.)
--------------------------------------------------------------------------------
I try with this change on r14951, English locale is OK, but Arabic locale is NG.
I think SetFont() has stability bug.
<pre>
%{font-style: italic; font-family: DejaVuSansMono}Tiếng Việt%
%{font-style: italic; font-family: DejaVuSansMono}عربي%
</pre>
<pre><code class="diff">
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.
</code></pre>
!ar-en.png!
--------------------------------------------------------------------------------
I'm closing this for 3.2 release. If there any problems pending, please open another issue.
--------------------------------------------------------------------------------
r14950 is wrong.
<pre><code class="ruby">
style.delete!('I') if family.to_s.casecmp('DejaVuSans') != 0
</code></pre>
should be
<pre><code class="ruby">
style.delete!('I') if family.to_s.casecmp('DejaVuSans') == 0
</code></pre>
--------------------------------------------------------------------------------
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 version:3.2.0.
--------------------------------------------------------------------------------
Toshi MARUYAMA wrote:
> 3.2-stable r14962 has completed.
Sorry, I have committed very minor 3.2-stable r14964.
Please release version:3.2.0.
--------------------------------------------------------------------------------
Thanks.
--------------------------------------------------------------------------------