Getting custom box drawing characters to line up perfectly #7680
-
I am trying to essentially create custom "box drawing" characters for a terminal-based branch viewer. The issue I'm running into is that characters don't line up perfectly. Essentially, I can never get the box drawing characters to "touch". There is always a small amount of space between them, either vertically or horizontally or both. For instance, this character is the closest I've gotten to filling one whole character space, but there are slight gaps between the characters horizontally and vertically: Of course, this is only one font size. On other font sizes, they line up vertically, but not horizontally, or vise-versa: I assume this is because of rounding true font sizes to pixel sizes. But it's not clear to me:
I am aware that most terminals generate their own box drawing characters, Kitty included, because this is a hard problem, but that's why I'm asking for help. At this point, until I know the answers to the above questions, I can't even get close. I am also aware this is not a Kitty-specific problem. But Kitty has the best font rendering I have tried. My goal right now is just to get it right in one font size in one terminal. If there is a more "font creating and rendering" specific forum I could ask this same question, I'm happy to move it there. Here's the font in case it helps: The box character is "", or unicode character 0xf640 My config is as follows:
For now I will keep researcing, testing, and digging into the the source code to solve this issue. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
IME, you cannot. Fonts rendering simply isnt designed for this, there is all sorts of fitting, hinting, etc. that goes on that means trying to line up complex shapes correctly at all sizes, hinting settings is a lost cause. This is why kitty generates box drawing character programmatically. It was among the first terminals to do so, nowadays all modern terminals follow it. Your best bet would be simply to get your characters included in something like NERD fonts and then hopefully terminals will eventually pick them up as additional box drawing characters. kitty for instance draws a number of characters from powerline and nerd font programmatically. You can try contributing code to box_drawing.py to draw your characters, since it will be python code it will be easy to follow for other terminal emulators if and when they decide to add them. |
Beta Was this translation helpful? Give feedback.
-
Sure, just be careful when assigning the private use unicode code
points. Don't trample on ones used by other popular iconsets.
A good start is to avoid everything used by NERD fonts, but also look at
Fira Code, powerline, etc.
|
Beta Was this translation helpful? Give feedback.
IME, you cannot. Fonts rendering simply isnt designed for this, there is all sorts of fitting, hinting, etc. that goes on that means trying to line up complex shapes correctly at all sizes, hinting settings is a lost cause.
This is why kitty generates box drawing character programmatically. It was among the first terminals to do so, nowadays all modern terminals follow it.
Your best bet would be simply to get your characters included in something like NERD fonts and then hopefully terminals will eventually pick them up as additional box drawing characters. kitty for instance draws a number of characters from powerline and nerd font programmatically. You can try contributing code to box_dr…