the-lambda-church / dmlenu

a clone of dmenu written in OCaml.
MIT License
46 stars 5 forks source link

Reimplement the drawing code using Cairo+Pango #15

Closed Armael closed 4 years ago

Armael commented 4 years ago

The motivation for this PR is to be able to handle modern fonts (other than X11 bitmap fonts), and generally move towards more modern toolkits that hopefully make it easier to handle things like HiDPI and wayland in the future. In particular, we now have nice support for emojis!

sun

The PR essentially reimplements the drawing backend of dlmenu to use: 1) some X-specific C code to setup the window 2) backend-agnostic drawing code using Cairo 3) modern text-rendering using Pango.

The Cairo/Pango code is written in OCaml, using the nice cairo2/cairo2-pango bindings. The code is a bit more subtle than it was before because we now handle nicely the fact that the geometry of a piece of text is not always the same depending on the characters inside (e.g. Chinese ideograms typically require a few more vertical pixels). So we take care of first computing the overall geometry of the various UI elements, and only after start to draw them.

I'm afraid that the individual commits do not make much sense, they could/should be squashed.

trefis commented 4 years ago

I tried it, I liked it.