I recently switched to emacs23.1.1 and the unicode support is great. I use the default DejaVuSansMono font in emacs, but when I try to do a ps-print-buffer or ps-spool-buffer, it uses the Courier font. Thus the result is disappointing because Courier does not support a lot of unicode characters.
I tried to set ps-font-family to "Monospace" or "DejaVuSansMono" which is the default font on my DE (gnome 2.28). But I get the warning "don't have data to scale font Monospace. Known fonts family are (Courier..." The list of known fonts is pretty short and I don't think that any of them supports the whole unicode range.
I am a bit clueless about that scaling issue. (this is not an problem related to the printer or system, gedit prints without problem with that font). How can I make emacs use the Monospace font for printing ?
> I recently switched to emacs23.1.1 and the unicode support is great. > I use the default DejaVuSansMono font in emacs, but when I try to do > a ps-print-buffer or ps-spool-buffer, it uses the Courier font. > Thus the result is disappointing because Courier does not support > a lot of unicode characters.
In Unicode forget ps-print-<whatever>! PostScript only handles encodings of 256 elements (and with some difficulty also CJK fonts with thousands of code points). What you need is a conversion from text to Unicode encoded HTML which then can easily be handled by your OS or desktop.
Htmlize.el by Hrvoje Nikšić: http://fly.srk.fer.hr/~hniksic/emacs/ htmlize.el. A sample of its capabilities can be seen here: http:// fly.srk.fer.hr/~hniksic/emacs/htmlize.el.html – missing some CJK and other non-Latin content. Lennart Borgman's htmlize-view.el helps a bit to handle printing (http://piprim.tuxfamily.org/home/pi/emacs.d/ site-lisp/htmlize-view.el).
So using DejaVu in the buffer will produce HTML output using the same fonts which then can be converted to PDF for the purpose of printing, still using DejaVu.
-- Greetings
Pete
Give a man a fish, and you've fed him for a day. Teach him to fish, and you've depleted the lake.
Thanks for your reply. Instead of converting to html, I think I will just open the file in the browser and print from there. DejaVu is also used as the default monospace in my browser.
I am a bit surprised by your comment on postscript not supporting unicode. I successfully print unicode/DejaVu text files from gedit. Redirecting the output to a virtual printer, I get a well behaved postscript file that displays the DejaVu fonts without problem. From what I have seen, the unicode characters appearing in the text file are redefined in the postscript. I don't know what part of the gnome desktop generates the postscript though.
Is there some plan (or obstruction) to implement that feature in emacs with ps-print ? That is, being able to print a buffer with the (unicode, ttf) font actually displayed in the buffer instead of the bdf default Courier ? Or maybe I can put it on the wishlist.
> Thanks for your reply. > Instead of converting to html, I think I will just open the file in > the > browser and print from there. DejaVu is also used as the default > monospace > in my browser.
That's exactly what htmlize.el and htmlize-view.el do: they prepare an Unicode encoded buffer easily as HTML which is then "sent" to an external HTML viewer (a so-called "browser") which can use the OS' desktop mechanisms to print that Unicode contents as PDF Unicode.
> I am a bit surprised by your comment on postscript not supporting > unicode.
PostScript is 8 bit! It might be elder then you. PostScript fonts can larger, maybe contain 1,000 glyphs. These are accessed by an encoding, which is 8 bit. TeX, a bit elder then PS, is essentially 7 bit. The trick of a "virtual font, " something like a "fontset" in GNU Emacs, allows it to access two 7-bit encoded fonts as if it were one 8-bit font. Similarly by using a whole stack of encodings TeX is able to access some percent of Unicode. Particular mechanisms in TeX and in PostScript allow to print in CJK.
BTW, I am not that sure that your GNOME desktop creates PostScript files! (It would necessitate CID fonts.) You can easily check this by disabling the printer queue. Then any print output is queued in but not sent to the printer. So you have (almost) infinite time to locate the queue's content and check the files' type – possibly with super- user privileges. And I am sure you'll find PDF...
-- Greetings
Pete
Encryption, n.: A powerful algorithmic encoding technique employed in the creation of computer manuals.
Peter Dyballa <Peter_Dyba...@Web.DE> writes: > Am 11.11.2009 um 17:12 schrieb harven: > BTW, I am not that sure that your GNOME desktop creates PostScript > files! (It would necessitate CID fonts.) You can easily check this by > disabling the printer queue. Then any print output is queued in but > not sent to the printer. So you have (almost) infinite time to locate > the queue's content and check the files' type – possibly with super- > user privileges. And I am sure you'll find PDF...
I just tried your suggestion. From the virtual printer, I can choose ps or pdf for the output. When I choose ps, I get a file starting with
From the cairographics webpage, I see that the fonts are always subsetted and embedded. Later in the file, I find
Encoding 1 /uni222C put Encoding 2 /uni006D put Encoding 3 /uni006F put ... /sfnts [ <00010000000a008000030020636d61700043f0c90000080c0000005863767420e997070c00 00 0864000002306670676d5b026bdf00000a94000000ac676c79663d08b488000000ac0000076 0
which corresponds to the unicode characters I typed. Finally, when I open the file on a computer which does not have the DejaVu fonts, the "postscript" correctly displays the text with the DejaVu fonts. So what do you think ? I may be fooled by the headers, I don't know much about postscript.
BTW, Am I wrong, or emacs23 now depends on cairo for 2D display ?
> Finally, when I open > the file on a computer which does not have the DejaVu fonts, the > "postscript" > correctly displays the text with the DejaVu fonts. So what do you > think ?
Cairo obviously has expanded PostScript use remarkably. It is embedding the TT font (large number of glyphs), as it should, and it seems to create one or more arbitrary encodings to encode just the characters used. Clever! (Could you send me privately this PS file? You don't need to print anything, lprm will remove anything from the queue.)
> BTW, Am I wrong, or emacs23 now depends on cairo for 2D display ?
I cannot explain a thing on this issue, but I can tell that Cairo is part of GNOME/GTK – and nowhere in GNU Emacs code some Cairo function is used. So it's some part of GTK which needs Cairo functions.
-- Greetings
Pete
Life is the only flaw in an otherwise perfect nonexistence – Schopenhauer