[vim/vim] Add hardcopy print backend using Pango + Cairo (PR #20648)

8 views
Skip to first unread message

Foxe Chen

unread,
Jun 27, 2026, 1:17:35 AMJun 27
to vim/vim, Subscribed

Add a print backend for the hardcopy feature that uses Pango and Cairo for rendering text. The benefit of this is that unicode is properly supported and probably other stuff, as now Pango handles all the dirty work. Postscript is outputted using the cairo postscript backend, so there shouldn't be anything missing compared to the existing postscript code.

This feature is enabled by default for Vim compiled with GTK GUI (in both terminal and GUI), because GTK requires Pango and Cairo anways. However it is disabled by default when not compiled with GTK GUI, instead it must be enabled with --enable-print-pango, because I'm not sure if adding two dependencies (that are pretty big) would be very welcomed.

Additionally, replace the existing GTK4 native print dialog code to instead use this, and now use GtkPrintDialog (GTK 4.14+) to get print settings via a graphical dialog like Windows. TODO

Left: Pango + Cairo backend, Right: existing postscript code
image.png (view on web)


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/20648

Commit Summary

File Changes

(14 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20648@github.com>

Christian Brabandt

unread,
Jul 26, 2026, 11:01:34 AM (yesterday) Jul 26
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#20648)

thanks


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20648/c5084032598@github.com>

Christian Brabandt

unread,
Jul 26, 2026, 11:12:50 AM (yesterday) Jul 26
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#20648)

I tried this out with digraphs.txt and print to pdf and postscript (because it contains many multibyte characters). Unfortunately, the created files are zero bytes long and I see the following warnings printed:
image.png (view on web)
so it doesn't seem to work yet


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20648/c5084074208@github.com>

Foxe Chen

unread,
Jul 26, 2026, 11:53:04 AM (yesterday) Jul 26
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#20648)

I tried this out with digraphs.txt and print to pdf and postscript (because it contains many multibyte characters). Unfortunately, the created files are zero bytes long and I see the following warnings printed: image so it doesn't seem to work yet

Whoops, that was a mistake I did in a recent commit, it should be fixed now


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20648/c5084222130@github.com>

Foxe Chen

unread,
Jul 26, 2026, 1:49:03 PM (yesterday) Jul 26
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#20648)

The GTK4 print dialog using xdg desktop portal, looking at GTK source code. However it seems that when selecting "Print to file" option, and choosing another format other than pdf (ps, svg), it still creates a pdf file? I tried running the GTK demo example that uses GtkPrintDialog, and it seems to have the same issue too, so I think this is a GTK bug.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20648/c5084664784@github.com>

Christian Brabandt

unread,
5:22 PM (6 hours ago) 5:22 PM
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#20648)

Hm, still not working. It hangs now when creating the pdf (or postscript) file:

Printing page 1 (0%)

strace shows this (and hangs on the last read(), does not progress):

ppoll([{fd=4, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN|POLLPRI}, {fd=16, events=POLLIN|POLLPRI}], 4, {tv_sec=0, tv_nsec=0}, NULL, 8) = 1 ([{fd=16, revents=POLLIN}], left {tv_sec=0, tv_nsec=0})
ppoll([{fd=4, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN|POLLPRI}, {fd=16, events=POLLIN|POLLPRI}], 4, {tv_sec=0, tv_nsec=0}, NULL, 8) = 1 ([{fd=16, revents=POLLIN}], left {tv_sec=0, tv_nsec=0})
write(4, "\1\0\0\0\0\0\0\0", 8)         = 8
read(16, "%PDF-1.7\n%\265\355\256\373\n4 0 obj\n<< /Lengt"..., 1024) = 1024
read(16, "\316.\277/\277\236\210\351\4\3415\20\2630\37\224qB;\254B@\26\222k\324\202_\2552r\273"..., 1024) = 1024
read(16, "*3\21\254\26j\337\306\240\202 \6K\257\257\273\273\374rY\3357$q\24U\336is_Cd"..., 1024) = 438
read(16

Claude thinks this is a deadlock, same process reading and writing the pipe:

130 66741 chrisbra@debian-arm64 /mnt/home/chrisbra/code/vim-upstream/src (git)-[pr-20648]- % ls -l /proc/2965653/fd
total 0
[...]
lr-x------ 1 chrisbra chrisbra 64 Jul 27 21:15 16 -> 'pipe:[4716128]'
l-wx------ 1 chrisbra chrisbra 64 Jul 27 21:15 17 -> 'pipe:[4716128]'
[...]

I can only hard-kill it (kill -9)


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20648/c5096955157@github.com>

Foxe Chen

unread,
5:40 PM (6 hours ago) 5:40 PM
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#20648)

Hm, still not working. It hangs now when creating the pdf (or postscript) file:

Printing page 1 (0%)

strace shows this (and hangs on the last read(), does not progress):

ppoll([{fd=4, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN|POLLPRI}, {fd=16, events=POLLIN|POLLPRI}], 4, {tv_sec=0, tv_nsec=0}, NULL, 8) = 1 ([{fd=16, revents=POLLIN}], left {tv_sec=0, tv_nsec=0})
ppoll([{fd=4, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN|POLLPRI}, {fd=16, events=POLLIN|POLLPRI}], 4, {tv_sec=0, tv_nsec=0}, NULL, 8) = 1 ([{fd=16, revents=POLLIN}], left {tv_sec=0, tv_nsec=0})
write(4, "\1\0\0\0\0\0\0\0", 8)         = 8
read(16, "%PDF-1.7\n%\265\355\256\373\n4 0 obj\n<< /Lengt"..., 1024) = 1024
read(16, "\316.\277/\277\236\210\351\4\3415\20\2630\37\224qB;\254B@\26\222k\324\202_\2552r\273"..., 1024) = 1024
read(16, "*3\21\254\26j\337\306\240\202 \6K\257\257\273\273\374rY\3357$q\24U\336is_Cd"..., 1024) = 438
read(16

Claude thinks this is a deadlock, same process reading and writing the pipe:

130 66741 chrisbra@debian-arm64 /mnt/home/chrisbra/code/vim-upstream/src (git)-[pr-20648]- % ls -l /proc/2965653/fd
total 0
[...]
lr-x------ 1 chrisbra chrisbra 64 Jul 27 21:15 16 -> 'pipe:[4716128]'
l-wx------ 1 chrisbra chrisbra 64 Jul 27 21:15 17 -> 'pipe:[4716128]'
[...]

I can only hard-kill it (kill -9)

Are you using the GTK4 dialog or running the hardcopy command directly? I cannot reproduce


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20648/c5097114316@github.com>

Reply all
Reply to author
Forward
0 new messages