You are not logged in.
Hi, i set up my printer(1005w) connect with WiFi.
printer is working, and i can print same text correctly
with WPS-office package, but when i send emacs buffer content
directly with `(print-buffer)`, all Chinese character replace
with a Square.
Thank you.
Last edited by zw963 (2020-09-14 07:49:49)
Offline
Offline
Sorry, i checked, but not found any useful info from above link.
Following is some supplement, do you consider if another one issue?
1. I use Wayland, not Xorg.
2. I guess emacs use lpr command for print, because when i run code like
$: cat 'text_file' |lpr
get same print result.
3. all content show correct when open with emacs, it just not correct if print with
lpr. (my emacs use a font which load from ~/.fonts, not system location), maybe this
cause that?
Following is a screenshot for print result (print to a pdf file)
https://i.imgur.com/R9j0Fpl.png
Thank you.
Offline
What is your test_file encoding? CJK txt files often use different encoding then ASCII/UTF-8. Try first transcode your file:
$ file text_file
$text_file: ISO-8859 text
$ iconv -sc -f GB2312 -t UTF-8 text_file -o result.txt
Last edited by solskog (2020-09-12 11:31:24)
Offline
(my emacs use a font which load from ~/.fonts, not system location), maybe this cause that?
Yes. Cups doesn't run as your user.
Try installing eg. https://www.archlinux.org/packages/extr … fonts-cjk/
The "normal" problem would have been that you're using a pcf bitmap font to resolve cjk from - which is no longer supported by pango.
@solskog, 湯 interpreted as iso-8859 would be "湯", not a single empty glyph.
Last edited by seth (2020-09-12 13:23:04)
Offline
湯 interpreted as iso-8859 would be "湯", not a single empty glyph.
Yes, but it depends on your editors font settings. I set encoding=utf8 and fileencodings=utf8,gb2312 in Vim to get correct encoding. but in another editor eg: Vis Editor with default settings I get empty glyph.
And I am suspect that even if OP had correct fonts installed in system and correct encoding/settings for Emacs but the CUPS lpr encoding/settings were not justified for CJK.
Last edited by solskog (2020-09-12 19:38:13)
Offline
If you have utf-8 codepoints in a file interpreted as gb2312 you'll (likely) get (some) errors, what could lead to the glyph being skipped or displayed as some error or whatnot (though an accurate™ error should reflect more boxes per glyph to account for the byte count, I guess)
This should™ only happen for external files, though, since your primary encoding is still utf-8
Offline
What is your test_file encoding? CJK txt files often use different encoding then ASCII/UTF-8. Try first transcode your file:
Acutally, i only use UTF-8 coding.
╰─ $ file 2.txt
2.txt: UTF-8 Unicode text
╰─ $ \cat 2.txt
0x03000003 0 lggram 只要看这一篇,车险全搞懂(值得收藏) - 知乎 - Nightly
0x03000097 0 lggram Frequently Asked Questions · Sorbet - Nightly
Try installing eg. https://www.archlinux.org/packages/extr … fonts-cjk/
The "normal" problem would have been that you're using a pcf bitmap font to resolve cjk from - which is no longer supported by pango.
Yes, i try install noto-fonts-cjk, but no luck, it still not working.
In fact, i want to clarify this, because i guess it maybe a lpr issue.(not a emacs issue?)
because i can reproduce this issue with following command
╰─ $ cat 2.txt |lpr
Because i set pdf as default printer, With above command, i can get a pdf content like this
But i find out a solution use paps package. (though, i even don't know what this package stand for,
and, if this just a workaround, not really fix my issue)
╰─ $ 127 pacman -S paps
resolving dependencies...
looking for conflicting packages...
Packages (1) paps-0.7.1-2
...
╰─ $ cat 2.txt |paps|lpr
Now i get a new pdf, with Chinese character get print correctly.
So, is this really a setup fonts into ~/.fonts issue? i don't know, but,
i can confirm, this is not a gb2312 encoding issue anyway.
Thank you.
----------------------------------------------------
UPDATED:
I fixed my question with a bash wrapper script.
╰─ $ \cat new_lpr
#!/bin/bash
paps|lpr
And, set emacs to use this new lpr command
(setq lpr-command "new_lpr")
Emacs "printer-buffer" command is working now, i guess it print out a new paper
which use same fonts as emacs itself used.
Last edited by zw963 (2020-09-14 04:53:18)
Offline
seth wrote
The "normal" problem would have been that you're using a pcf bitmap font to resolve cjk from - which is no longer supported by pango.
community/paps 0.7.1-2
Converts Unicode text to postscript and pdf using pango
Great that you solved it!
Last edited by solskog (2020-09-14 05:42:14)
Offline
The issue is actually that emacs just shells out the text to lpr instead of generating postscript or pdf internally and the texttopdf filter, while linking fontconfig, can apparently not deal w/ it.
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.
Offline