-
-
Notifications
You must be signed in to change notification settings - Fork 991
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
Add support for subpixel rendering on Linux #1604
base: master
Are you sure you want to change the base?
Add support for subpixel rendering on Linux #1604
Conversation
9d67ca0
to
ba6af6e
Compare
Very impressive for your first contribution to kitty! |
I think it would be better to rename |
How do you ensure that kitty uses the correct color on the correct side? In my FreeBSD VM the left side of the characters in kitty is blue while the right side is red. In other programs in my VM and outside of my VM the left side is red while the right side is blue. Doing sub-pixel anti-aliasing wrong in this way will make the font look worse than using no sub-pixel anti-aliasing. Which side needs to have which color might depend on the monitor though, idk. |
Yes, I think it should be use_subpixel_rendering. As for BGR vs RGB IIRC that comes from the fontconfig configuration on Linux. |
@Luflosi when rendering using |
I started working on adding support for |
I investigated some more and it turns out that kitty correctly uses RGB in my FreeBSD VM. I made a mistake when thinking about which colors should be on which side, sorry for that. |
@nightuser I would not bother with LCD_V if I were you. Its a lot of work and is very rare in actual hardware. I think the only time it is used is if the monitor is rotated. |
@kovidgoyal well, I find out that some additional work needed for regular LCD, as there are some places in the code where we use that bitmap is grayscale. Also, I have a lot of acquaintances who use their monitors in the vertical orientation, myself included. |
If it is important to you feel free to implement support for vertical, I |
Hi! Sorry, I was a bit busy with my life. By the way, I implemented the support for vertical alignment and fixed some places, where it was implicitly assumed that the rendering is grayscale. I tested it with four possible combinations (RGB/BGR and horizontal/vertical), and it renders correctly. |
No worries, it is going to be some time before I can find the time to |
What would it take to add support for macOS? |
There would need ot be some way to get CoreText to render multi-channel bitmaps. Since Apple has officially decided to remove sub-pixel rendering, this seems unlikely to be possible. |
I didn't use transparent background, so I forgot to test it. From what I
see, it should be something easy to fix. I'll look into it later.
…On Fri, May 24, 2019, 14:36 miseran ***@***.***> wrote:
I gave this patch a try, but it doesn't seem to work correctly with
transparency yet. Around each character, there is a solid rectangle. (On
Xorg with compton, using Intel graphics.)
[image: transparency]
<https://user-images.githubusercontent.com/6820152/58324086-1eacaa00-7e26-11e9-840f-c01f769c04f5.png>
Really looking forward to this patch though, since most of my displays are
low DPI.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1604?email_source=notifications&email_token=AAN6F6D3K2ZBGHHRDMCRSLLPW7HKVA5CNFSM4HL5WQL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWFAW5I#issuecomment-495586165>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAN6F6CIEOPI6PRCIQRYJCTPW7HKVANCNFSM4HL5WQLQ>
.
|
@kovidgoyal but is it possible to use Freetype on macOS (an optional switch maybe). |
People on macs complain a lot if text rendering is different from |
Turns out, it's nearly impossible to implement transparency accurately, at least without rewriting much of the rendering (see https://stackoverflow.com/questions/33507617/blending-text-rendered-by-freetype-in-color-and-alpha , for example). @kovidgoyal could you help me with this short block of code: https://github.com/nightuser/kitty/blob/freetype_subpixel_rendering/kitty/cell_fragment.glsl#L64 (lines 64-69), please? I'm not fluent in OpenGL at all, so I am probably doing something wrong there. @miseran I added experimental support for transparency. Could you test it out? |
63038ef
to
d397b8c
Compare
I rebased my branch against current master because I personally use this patch as a daily driver. |
On Sun, May 26, 2019 at 12:06:49PM -0700, nightuser wrote:
@kovidgoyal could you help me with this short block of code: https://github.com/nightuser/kitty/blob/freetype_subpixel_rendering/kitty/cell_fragment.glsl#L71 , please? I'm not fluent in OpenGL at all, so I am probably doing something wrong there.
Sure, I am happy to help, what is your question? I dont know exactly
what you are trying to do there, so hard for me to say if you are right
or wrong.
|
@kovidgoyal Freetype provides alpha channel per color for each pixel separately. I'm blending the foreground and the background using
|
See the comment at the start of the main() function under #ifdef
TRANSPARENT for why bg_alpha is doubled.
As for scaled_mask, I will look at it a littl elater, when I have some
peace and quiet.
|
Regarding scaled mask. I dont quite understand the problem. The only |
@kovidgoyal the problem arises because at the end we combine bg and fg textures one above the other. So, if these transparent pixels are rendered in bg color (even if it's semi-transparent), we will draw two semi-transparent backgrounds in some places, which results in more-opaque color. In opaque case, it's okay, as an opaque image over opaque looks fine. |
@kovidgoyal It seems that it can probably be done with correct |
73708a1
to
6c1bb9b
Compare
@nightuser is this PR ready for review? |
@kovidgoyal I still need to test it against the latest changes. I'll do it probably today or tomorrow and then it'll hopefully be ready to be reviewed. |
@nightuser Obviously take all the time you need, but you are still interested in this right? |
@rien333 I don't have much time at the moment. Everything works fine modulo transparent backgrounds, and I didn't come up with a good solution for it. Since the Autumn semester started and I'm a teacher assistant, I'm teaching some classes and it takes time, obviously. If you want to contribute and help me with a transparent background, you're more than welcome. If you're just interested in the feature, you'll probably have to wait for a bit. |
All right, interesting to know that the transparency issue what is keeping this in the pipeline. Probably don't have time either, but we'll see. Good luck with your teaching duties. |
Hey @nightuser, is this still something you are pursuing ? I'm very interested in this feature. Thanks in advance ! |
Hi @sarnikowski. Not really, I don't use kitty currently. I might help if anyone wants to work on the feature. I hope I'll look into it in the future, but I have more important things to do right now. |
Hello, as far as I can tell the only problem with this PR is when transparency is enabled, please correct me if I am wrong! In this case, would it be possible to merge this PR, off by default, with a comment in the docs that it doesn't work with transparency and that it impacts performance? I consider subpixel rendering to be essential on a large 1080p monitor, which I have, and everything else that I use has subpixel rendering. Without it there is a noticeable difference that makes the experience worse. I personally don't use transparency and I consider that to be more of a stylistic choice, not a usability one. I think that most people with 1080p monitors and lower would like this feature and a lot of people probably do not use transparency for their terminals. I think Kitty is the best terminal feature and performance wise, but I currently cannot use it simply because it does not have subpixel rendering. If this was merged, it would be great for the most likely vast majority of users that do not have 1440p or 4k monitors. Thanks for the great terminal and hopefully this can get merged! |
+1 on this |
Alacritty supports subpixel rendering, and it has a similar bug. Imho this issue isn't so problematic that it should prohibit the feature from being included. |
Can't the on/off come from the fontconfig configuration also, at least the default? |
644357a
to
65c7ecb
Compare
f5a18f5
to
2bb42e6
Compare
why that PR wasn't merged yet? |
dc27691
to
63df210
Compare
Adds optional support for subpixel rendering when using freetype. This behavior is disabled by default and can be enabled in the configuration file.