BurntSushi / xgb

The X Go Binding is a low-level API to communicate with the X server. It is modeled on XCB and supports many X extensions.
Other
489 stars 75 forks source link

Xft support #55

Closed aacebedo closed 3 years ago

aacebedo commented 3 years ago

Hi ! I need to draw some text on my windows using xgb. Drawing with X core fonts is working perfectly however as it has been deprecated for xft I was wondering how could I use it with xgb.

I didn't find any bindings for xft in go. Any ideas ?

Regards

BurntSushi commented 3 years ago

Look at how Wingo does it: https://github.com/BurntSushi/wingo/tree/master/text

aacebedo commented 3 years ago

Thanks for the answer. I was already digging in this direction from your example in xgbutil drawtext. However I am facing an issue with the XSurfaceSet method because I am trying to add some layer to currently existing windows and the depth of the root window is different from the depth of one of mine (terminal windows especially) This leads to a badmatch error.

In the XSurfaceSet method a pixmap is created with the depth of the root window, this pixmap is used in a changeWindowAttributesChecked call leading to the crash.

I'll continue with this approach and find a solution.

Keep you posted

aacebedo commented 3 years ago

So I've found two things and it is still related to the depth.

First, in the XDraw function of an image the depth is hard coded (24), as my window has a 32 bits depth I get a BadMatch error. When correcting this by injecting the correct issue, I still got a BadMatch error but this time in the call to the PutImageChecked function

According to tronche.net, the function returns this when the depth of the image is not the same as the depth of the drawable. My drawable is a Pixmap I created with a correct depth, my image is created by the call related to the font function you pointed to me. I am currently not able to find where the depth is given.