-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shapes example #4
Conversation
When I first was trying to use I wanted one of the core aspects of this example to be demonstrating that the drawable is (for very basic use cases) the window itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the libery to fix typos and reword a comment.
I had some difficulties running the example on Ubuntu (see comments near font).
Note: As you can see, I was able to push commit directly to your master branch. This is because you gave me permission to edit your PR. It's better practice to start a PR from a branch, so the maintainer (if granted privileges) can only edit the branch (and not master directly).
examples/shapes/main.go
Outdated
fontname := "-gnu-unifont-*-*-*-*-16-*-*-*-*-*-*-*" | ||
err = xproto.OpenFontChecked(X, font, uint16(len(fontname)), fontname).Check() | ||
if err != nil { | ||
fmt.Println("Failed opening the font:", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got an:
Failed opening the font: BadName {NiceName: Name, Sequence: 8, BadValue: 67108870, MinorOpcode: 0, MajorOpcode: 45}
on Ubuntu MATE 20.10
What are we going to do about the missing font issue? The example font that is often used is simply However, I also want to demonstrate writing UTF8 characters (the ö), but I tried finding a font that would be preinstalled on many systems, looks like that didn't work out. It is possible to see the available fonts using However, I don't know how to determine which of these support unicode characters. |
Could you kindly try the font spec |
I just tried again, and now it's working for me too. I guess I just had something wrong during my first tries.
This simply selectes any font that is iso10646-1 encoded, which is basically the character encoding of Unicode. So any of these fonts should have at least a basic set of extended latin characters.
Sounds good! |
TLDR: How to create a window and draw / fill things using
xproto
:(the white border outside the black border is generated by my WM, should not be there for you)
A bit of backstory: I originally got into
xgb
because I was working on a go implementation of thexwd
(x window dump) file format and I needed to create small windows with randomly colored pixels, something like this:So I got into
xproto
and how to create images and such.I cloned this example originally from Alex Kesling's testing which is basically a Go copy of an example in the
xcb
documentation.I adapted some things to go nicer along the
create-window
example, added commentary and some more things (e. g. drawing text and filling a rectangle).