I'm trying to develop a Kivy desktop app which needs to display trees in labels.
The tree is just a string that looks something like this:
" ┌ 3 \n │\n 1 ┤ ┌ 2 \n └─────────────── 4 ┤\n └ 5 "
This works perfectly when operating inside the terminal, and the tree is aligned correctly as below.
However, when putting this string inside a Kivy label, it does not align correctly (see below).
I'm thinking there is an issue with the dimensions of the text not being the same as they are in the terminal. However, I have had no luck adjusting the properties of the label, the text size, the font or anything else. The problem always seems to persist.
The default font would not even display the tree branches. I set the font_name to "DejaVuSans.ttf", which at least renders the branches, but they are still not aligned.
I'm at my wit's end and no searches are returning any relevant information. Any help with fixing this annoying issue would be greatly appreciated.
Also, if there is a cleverer way to display trees in a Kivy app that would bypass this issue entirely, that would be even better!
If you use the FreeMono
font and adjust the label text to:
" ┌ 3 \n │\n 1 ┤ ┌ 2 \n └─────────────── 4 ┤\n └ 5 "
it seems to work.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments