RogerTheDragon
RogerTheDragon

Reputation: 267

Emacs: printing a UTF-8 buffer

In Emacs, everything seems to work quite well regarding UTF-8. The problem is, I sometimes want to print out an email containing Unicode characters (I use mu4e as my MUA).

I'll typically have something like the following in a mu4e:view buffer:

    From: A Person
    To: Me
    Subject: Notes on Chapter 9
    Date: Tue 22 Sep 2015 13:46:44 CEST
    Maildir: /mymaildir/INBOX
    User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

      • “for open platforms” -> “for \textit{open platforms}, as defined in
        [123].  Such platforms include frobbing devices and home-assistant
        foobars.”

The problem is, when I do M-x ps-print-buffer, the physical output on paper looks like this:

    ...

      ? ?for open platforms? -> ?for \textit{open platforms}, as defined in
        [123].  Such platforms include frobbing devices and home-assistant
        foobars.?

Does anybody know how I can print so that it looks the same as on my screen? After some Startpaging/DuckDuckGoing I haven't managed to find any pointers.

Upvotes: 5

Views: 1332

Answers (2)

djcb
djcb

Reputation: 399

An alternative way in mu4e would be to use view-in-browser ('a V' in the view), and then print it from there.

Or, if you have msg2pdf (optional part of mu), you convert it to pdf ('a v' in the view), then open the resulting pdf in some viewer than can print.

(below function may be handy for that)

(defun xdg-open () "Open current file with xdg-open." (interactive) (when (buffer-file-name) (shell-command (format "xdg-open %s" (shell-quote-argument (buffer-file-name))))))

Upvotes: 0

shakurov
shakurov

Reputation: 2518

There's a simple solution that may or may not yeild satisfactory results. Emacs knows how to work with GNU Intlfonts, which allow non-ASCII characters to be printed.

Intlfonts are bitmap fonts and not the prettiest ones outthere. They may work well for ASCII texts with only occasional non-ASCII characters in them (quotes, bullets and such), but for texts using non-latin alphabets the result is not a pleasure to look at (the text is presented correctly, just not beautifully).

To try it out, install the fonts first. The way to do that depends on the operating system and its distribution; example for Ubuntu:

sudo apt-get install emacs-intl-fonts

Then tweak the following Emacs settings:

(setq ps-multibyte-buffer :bdf-font-except-latin)
(setq bdf-directory-list "/usr/share/emacs/fonts/bdf")

The first variable instructs Emacs to use Intlfonts for non-latin characters. The second variable specifies location of fonts (be sure to set it right, otherwise Emacs will ignore the setup silently).

Although some sources (e.g. M-x describe-variable ps-mule-font-info-database and these pages) suggest that it is possible to configure ps-print to print non-ASCII characters in ways other than using Intlfonts, I've failed to find proper configuration. Please let me know if you find one.

BTW, calling lpr-buffer directly seems to print international characters just fine.

Upvotes: 2

Related Questions