-
-
Notifications
You must be signed in to change notification settings - Fork 992
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
Extension Kitty graphics protocol to support fonts #2259
Comments
I'm not sure what the problem is?? The cell metrics are anyway set by |
I'm not sure it's very useful if metrics are not changeable, so I guess I am proposing to let applications change main window font as well. Game developers need to know the metrics, at least within a certain threshold. Problem is, fonts can vary too much; from thin fonts like Sudo to wide ones like Press Start 2P. |
The easiest way to do this is to enforce—
You might not be willing to do that though. I'm not convinced yet that it's impossible to make it per-window. It'll just take some work, which I'll try to do if it's needed. |
I dont get the use case for changing the entire window font in a game?? As I |
Why do the cells have to be square for this? You can use two cells to get a square sprite. Your sprite font would then need to split up each sprite into two or alternately simply use a space after the code point (for PUA characters followed by spaces, kitty will auto-create a ligature of the character+spaces) so you can have square PUA glyphs. |
If I use two cells, then if the user has a square (or squarish) font, it will look very strange. |
I doubt there are squarish fonts, and an application always knows the |
Oh and you can see that in action with kitty +icat --print-window-size |
@msokalski Unfortunately, with the current implementation, symbol fonts, even if they are all the glyphs on a line, do not have their own metrics (cell shape). That's:
So this must be dealt with one way or another. Needing to cram all glyphs into the cell shape of the master cell is an implementation hurdle that's difficult to cross. |
Note that I don't think we should make this line based. That's way too difficult and will lead to bugs. We just ought to offer a metrics command, so applications can change the cell shape of the entire window to meet their needs. |
There is already a mechanism to change cell shapes, simply use a PUA |
What if you want a cell shape of a width not expressable as width*n, where n∈ℕ*? For example, suppose a user is using a cell ratio of 1.5:1, h:w. So, 2w makes our cell 1.5:2. 3w makes our cell 1.5:3. There's no way to get 1.5:1.5, 1.5 is not a possible n: we cannot therefore make a perfect square. w is unlikely to be > h, but it can happen also. A true metrics command would say, "a cell is now h by w", with the understanding that these values represent not pixels but rather something like CSS, a pixel times a certain device-specific multiplier to support HiDPI. |
This is a terminal we are talking about, if you really want pixel Trying to render perfect graphics by indirection through a font is |
If I can find a way to make it per-window without affecting performance...? Still no? I'm willing to spend some time refactoring if that's what it takes. 😋 As someone who works on fonts, I think metrics are a vital part of a font, even a monospaced one, and am not sure I want to contribute a way to set outlines without metrics... I think our API should be like this: Font slotsWhen loading a font there should be a flag, let's call it Really, instead of flags, it's better to think of them as slots. So you have a So, applications can use the API to put a font in any of the slots, and to add/remove This would allow an application wanting square fonts to load into Then it can load into I am willing to contribute example code of course if we get this past the drawing board. All C stuff (for now …)
|
I wont object to per window without affecting performance, but you will I really dont think that level of effort is worth it, but if you want to |
I just realized something: this will fix a problem I noticed before, that if I have two windows open in the same process, resizing one resizes the other, even though I hadn't intended to do that. Presumably there are a lot of small bugs like that that will be solved as well I'm not promising to succeed, only to try :-) |
On Tue, Jan 07, 2020 at 06:17:10PM -0800, Fredrick Brennan wrote:
I just realized something: this will fix a problem I noticed before, that if I have two windows open in the same process, resizing one resizes the other, even though I hadn't intended to do that.
Resizing the fonts in a window only changes fonts in other windows in
the top level OS Window, not all top level windows in the same process.
Unless you use the default font size shortcuts which do it for all
windows. See change_font_size in
https://sw.kovidgoyal.net/kitty/conf.html
Presumably there are a lot of small bugs like that that will be solved as well
There are no font size related bugs that I am aware of, beyond the
limitation that you must use the same fonts size for all windows in a
single top level OS Window.
|
Oh, are you calling tabs windows?? |
There are three things:
When you change the font size for any kitty window all kitty windows in However, windows in other OS Windows in the same process will not be |
kitty has no GUI library capable of drawing GUI controls and is never
I really dont think this amount of work/disruption is worth it just to |
(I work on FontForge, which has its own GUI toolkit, which I have also worked on. Actually, just incidentally, my most recent commit to FontForge dealt with drawing a tab bar, and tabs, and close button, and handling drawing of all that, and making it so tabs could be reordered et cetera. I wasn't recommending we start linking to Qt, the OpenGL API is more than enough.) I don't really understand why that much has to change, though. We can just pretend that there is an overall cell size...basically, we change the font for all kitty windows in an OS window, but we keep a record of which fonts map to which tab, so when the user changes it, it still looks seemless, like each tab has its own fonts, when in reality we're switching them out every time |
On Tue, Jan 07, 2020 at 07:55:12PM -0800, Fredrick Brennan wrote:
(I work on FontForge, which has its own GUI toolkit, which I have also worked on. Actually, just incidentally, my most recent commit to FontForge dealt with drawing a tab bar, and tabs, and close button, and handling drawing of all that, and making it so tabs could be reordered et cetera. I wasn't recommending we start linking to Qt, the OpenGL API is more than enough.)
I don't really understand why that much has to change, though. We can just pretend that there is an overall cell size...basically, we change the font for all kitty windows in an OS window, but we keep a record of which fonts map to which tab, so when the user changes it, it still looks seemless, like each tab has its own fonts, when in reality we're switching them out every time
Again, the tab bar is not the issue. The windows are.
|
Yeah, but the windows can't be seen until the user clicks the tab bar, so if we just switch up the fonts it doesn't matter—right? |
On Tue, Jan 07, 2020 at 08:19:44PM -0800, Fredrick Brennan wrote:
Yeah, but the windows can't be seen until the user clicks the tab bar, so if we just switch up the fonts it doesn't matter—right?
You can have more than one window visible per tab see the screenshot
here: https://sw.kovidgoyal.net/kitty/
or run
kitty -o enabled_layouts=tall
and press ctrl+shift+enter a few times
And see https://sw.kovidgoyal.net/kitty/#tabs-and-windows
for details.
|
Oh, hmm, okay that's a big problem :-\ You're right it would be a lot of work. Let's put a pin in this for now; my time can be better spent other ways, as I'm sure yours can be as well. :-) |
Actually I think I am going to close this, as changing main font is not realistic IMO. I am willing to merge a protocol that allows applications to add entries to symbol_map but that's about the limit of what I think is doable in a reasonable way. |
Please reopen this given the scourge of nerd fonts. https://gist.github.com/ctrlcctrlv/4ae789dabaea774548da5f00a6bf16e9 |
I agree Nerd fonts are pretty awful, I dont use them myself (only a few separators for powerline, drawn natively by kitty), but that doesnt really change my opinion on this issue. Having per window fonts is still too much work. |
I don't think so. We already require fontconfig, and I know how to do it. |
(We wouldn't have per-window fonts fullstop, we'd have per-window fallback fonts in my new conception of this idea.) |
I'm confused then. Are you saying you dont care about metrics anymore. If so, as I said, when I closed this issue I am happy to consider a protocol that allows applications to specify additions to symbol_map. |
Oh, right, I forgot that. Yes, no longer care about metrics. I'd rather get rid of nerd fonts. |
(I mean, I still care, but not more than I care about deprecating nerd fonts lol.) |
This will have to be a graphics extension, right? Send a font along with a |
It doesnt have anything to do with graphics. You have several
There are several design considerations: a) do we allow only one such mapping to be active per window. If not b) Do we bother with side channel transmission (filesystem/shared c) do we have a way to activate/deactive the mappings? For example, d) Other things that dont come to mind right now :) This will require careful thought/design so I suggest you opena |
Will do. Thanks Kovid :) And yes I only said it was graphics protocol related because the way I want to do it it will be in the code. No reason to write another way to transfer data from terminal application to users, can just use graphics proto |
This issue continues discussion in #2145—
As I see it, we have two problems to figure out:
We've basically worked out the font itself. It will be SFNT, only some certain PUA codepoints.
The metrics though are an open question. If we just change up the symbol_map, it won't look same on all terminals. Thoughts @kovidgoyal ?
The text was updated successfully, but these errors were encountered: