Subject: muttprint: some non-ASCII characters are silently missing from the generated .ps file

From: Vincent Lefevre <[email-masked]>
Date: Tue, 10 Oct 2017 13:43:53 +0200

Package: muttprint
Version: 0.73-8
Severity: important

When I used muttprint (with print to file, for checking) on a mail
with δ and ε characters, these characters were silently missing
from the generated .ps file.

With debug output, I can see errors:

! Undefined control sequence.
\u-default-949 #1->\textepsilon 

! Undefined control sequence.
\u-default-948 #1->\textdelta 

-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'stable-updates'), (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.13.0-1-amd64 (SMP w/12 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=POSIX (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages muttprint depends on:
ii  libtext-iconv-perl         1.7-5+b6
ii  perl                       5.26.0-8
ii  texlive-fonts-recommended  2017.20171004-1
ii  texlive-latex-extra        2017.20171004-1
ii  texlive-latex-recommended  2017.20171004-1

Versions of packages muttprint recommends:
ii  emacs24-lucid [mail-reader]  24.5+1-11+local2
ii  emacs25 [mail-reader]        25.2+1-6
ii  evolution [mail-reader]      3.26.1-1
ii  libtimedate-perl             2.3000-2
ii  mailutils [mail-reader]      1:3.2-1
ii  mutt [mail-reader]           1.8.3+neomutt20170609-2+b1

Versions of packages muttprint suggests:
pn  compface                         <none>
ii  dialog                           1.3-20160828-2
ii  emacs24-lucid [news-reader]      24.5+1-11+local2
ii  emacs25 [news-reader]            25.2+1-6
ii  imagemagick                      8:6.9.7.4+dfsg-16
ii  imagemagick-6.q16 [imagemagick]  8:6.9.7.4+dfsg-16
ii  lynx [news-reader]               2.8.9dev16-1
ii  muttprint-manual                 0.73-8
pn  ospics                           <none>
ii  psutils                          1.17.dfsg-4
ii  texlive-fonts-extra              2017.20171004-1
ii  tin [news-reader]                1:2.4.1-1

-- no debconf information

---

From: Vincent Lefevre <[email-masked]>
Date: Tue, 10 Oct 2017 15:55:36 +0200

> from the generated .ps file.

I think that the easiest solution would be to use xelatex and
a font that the required characters (DejaVu Sans Mono seems one
of the most complete fonts).

I've attached a patch that does this (mainly for testing), but
I haven't tried in non-UTF8 locales (I suppose that the input
should be converted to UTF8 or \XeTeXinputencoding should be
used) and the font is hardcoded in the patch.

-- 
Vincent Lefèvre <[email-masked]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
--- a/muttprint	2017-06-19 21:12:50.000000000 +0200
+++ b/muttprint	2017-10-10 15:02:58.212793432 +0200
@@ -177,7 +177,7 @@
 my %Header;									# Header ...
 my @PrintedMailheaders;						# Mailheader so wie er gedruckt wird (LaTeX-Code)
 my $childPid;								# PID des Kinds
-my $DVIopts;								# Optionen fuer DVI - Aufruf
+my $PDFopts;								# Optionen fuer PDF - Aufruf
 my @Command;								# Kommando zum Drucken; fuer Druck in Datei
 my $Laenge = "0";							# zum Ermitteln der laengsten Zeile
 my $MaxLaenge = "0";						# die laengste Zeile
@@ -583,13 +583,13 @@
 
 #
 # running latex twice because of the "page ... of ..."
-system("latex -interaction=nonstopmode mail.tex >> $errorRedirection 2>&1");
-system("latex -interaction=nonstopmode mail.tex >> $errorRedirection 2>&1");
+system("xelatex -interaction=nonstopmode mail.tex >> $errorRedirection 2>&1");
+system("xelatex -interaction=nonstopmode mail.tex >> $errorRedirection 2>&1");
 
 #
 # no check of the exit code because we do this here
-unless (-e $Temp{dvi}) {
-	fatalError "Latex didn't work. There's no DVI file. If you ".
+unless (-e $Temp{pdf}) {
+	fatalError "Latex didn't work. There's no PDF file. If you ".
 		"write a bugreport, please include a mail where printing fails.";
 }
 
@@ -599,8 +599,8 @@
 
 #
 # generating the postscript file in every case
-system("dvips -t $paperformat -o $Temp{ps} $Temp{dvi} >> $errorRedirection 2>&1")
-	and fatalError "Error while running dvips:\n$!";
+system("pdftops $Temp{pdf} $Temp{ps} >> $errorRedirection 2>&1")
+	and fatalError "Error while running pdftops:\n$!";

 # now we find out the number of pages the document has
@@ -1167,7 +1167,7 @@
 	$Temp{content} 	= "$Temp{dir}/content";
 	$Temp{latex} 		= "$Temp{dir}/mail.tex";
 	$Temp{logf} 		= "$logf";
-	$Temp{dvi} 			= "$Temp{dir}/mail.dvi";
+	$Temp{pdf} 			= "$Temp{dir}/mail.pdf";
 	$Temp{ps} 			= "$Temp{dir}/mail.ps";
 	$Temp{psnew} 		= "$Temp{dir}/mail-new.ps";
 	$Temp{ps1} 			= "$Temp{dir}/mail1.ps";
@@ -1386,10 +1386,11 @@
 
 output \*LATEX, "
 \\documentclass[compat2,$Config{FONTSIZE}]{article}
-$fontencString
 \\renewcommand{\\tt}{\\rm}
 \\usepackage[$babellanguage]{babel}
-\\usepackage[$inputcharset]{inputenc}
+\\usepackage{fontspec}
+\\setmainfont{DejaVu Sans}
+\\setmonofont{DejaVu Sans Mono}
 \\usepackage{$LatexPackages}
 \\usepackage[${paperformat}paper,left=$Config{LEFTMARGIN}mm,right=$Config{RIGHTMARGIN}mm,%
 	top=$Config{TOPMARGIN}mm,bottom=$Config{BOTTOMMARGIN}mm,headsep=5mm]{geometry}