Skip to content
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

mac: box drawing rounded corners are not rounded #2240

Closed
ahmedelgabri opened this issue Jan 1, 2020 · 14 comments
Closed

mac: box drawing rounded corners are not rounded #2240

ahmedelgabri opened this issue Jan 1, 2020 · 14 comments

Comments

@ahmedelgabri
Copy link

Left: kitty 0.15.1, right: iterm2 Build 3.3.7

For example:

Font is PragmataPro

Screenshot 2020-01-01 at 17 21 07

Same with other fonts (they all work in iterm)

FiraCode
Screenshot 2020-01-01 at 17 28 16

Iosevka
Screenshot 2020-01-01 at 17 29 07

@kovidgoyal
Copy link
Owner

Yes, I have never bothered implementing drawing of rounded corners. I
dont care enough, if you do patches are welcome, relevant code is in
box_drawing.py

@rodrigore
Copy link

rodrigore commented Jan 30, 2020

It would be cool to render border, for example you can make the floating window on neovim with rounded borders like this https://github.com/Blacksuan19/init.nvim/blob/d4577a9e522861edda0996589279c226dadcc415/init.vim#L334

@ahmedelgabri did you hack some solution?

@ahmedelgabri
Copy link
Author

@ahmedelgabri did you hack some solution?

No, I didn't have time to do it yet. Feel free to pick it up if you want.

@ctrlcctrlv
Copy link
Contributor

I think it's possible to disable Kitty's box drawing code and use the glyphs in the font. Does that work for you?

@rodrigore
Copy link

rodrigore commented Jan 30, 2020

I think it's possible to disable Kitty's box drawing code and use the glyphs in the font. Does that work for you?

Not sure what is the option to disable box drawing, can you give me a hand?

@ctrlcctrlv
Copy link
Contributor

Try this:

diff --git a/kitty/fonts/box_drawing.py b/kitty/fonts/box_drawing.py
index d03f5bec..ecb6236b 100644
--- a/kitty/fonts/box_drawing.py
+++ b/kitty/fonts/box_drawing.py
@@ -707,6 +707,7 @@ def test_drawing(sz=48, family='monospace'):
             return concat_cells(width, height, False, cells)
 
         def render_chr(ch):
+            return space
             if ch in box_chars:
                 cell = bytearray(len(space))
                 render_box_char(ch, cell, width, height)

Of course, it will require you to compile kitty.

@ctrlcctrlv
Copy link
Contributor

(If my idea works for you, I'll make a PR to make it an official option.)

@ctrlcctrlv
Copy link
Contributor

ctrlcctrlv commented Jan 31, 2020

I'm sorry, my previous patch is bad. Please try this one, I'm sure it works on my system this time. My eyesight is bad, and I thought I saw a difference before, but there was none.

2020-01-31-090757_3043x1942_scrot

Not at all beautiful, but possible.

diff --git a/kitty/fonts.c b/kitty/fonts.c
index 0c6d1f43..02a7186a 100644
--- a/kitty/fonts.c
+++ b/kitty/fonts.c
@@ -581,15 +581,6 @@ START_ALLOW_CASE_RANGE
         case ' ':
         case '\t':
             return BLANK_FONT;
-        case 0x2500 ... 0x2573:
-        case 0x2574 ... 0x259f:
-        case 0xe0b0 ... 0xe0b4:
-        case 0xe0b6:
-        case 0xe0b8: // 
-        case 0xe0ba: //   
-        case 0xe0bc: // 
-        case 0xe0be: //   
-            return BOX_FONT;
         default:
             ans = in_symbol_maps(fg, cpu_cell->ch);
             if (ans > -1) return ans;

(Compile with CFLAGS -Wno-all)

@kovidgoyal
Copy link
Owner

I'm afraid using fonts for box drawing characters is a no-go. They wont
line up properly at different font sizes. You are welcome to use the
patch yourself, but I am not going to accept it as an option in kitty.

@ctrlcctrlv
Copy link
Contributor

Oh OK, I understand. Yes, as my screenshot shows, it looks very ugly. I think it might be possible to make a font that understands how Kitty renders which would work, but at that point, we should just add whatever is needed to box_drawing.py instead.

@kovidgoyal
Copy link
Owner

Drawing the curve is relatively easy it should be doable using a cubic
bezier. The hard part is drawing an anti-aliased curve that looks good
at different sizes, line thicknesses. Currently the box_drawing.py code
contains code for drawing filled curves like a filled D shape which are
easier. But curved lines somewhat harder.

@kovidgoyal
Copy link
Owner

And I just added support for antialiasing using super sampling which should make this easier.

@rodrigore
Copy link

Hey @kovidgoyal, how can I test?
Should I clone the last version and should be ok or I have to do something?
Thanks

@kovidgoyal
Copy link
Owner

You need to add @supersampled() to any function whose result you want
anti-aliased. The functions first three arguments must be the buffer,
width and height.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants