Text isn't centred
Here's a good example from something I'm working on:
The left margin, 1, is wider than the right. It's offset by 1chr, I think?
This is tricky because the terminal is cell based. If the total amount of margin is even, we can distribute it evenly on each side so that's good. If it's odd though we can either distribute an extra one on the left or right or we can distribute it evenly but then the text won't fit anymore and we need to push a word to the next line, and even then there's no guarantee you'll have an equal amount of margin on each side.
Understandable - does the kitty protocol help here?
On April 7, 2025, GitHub @.***> wrote:
This is tricky because the terminal is cell based. If the total amount of margin is even, we can distribute it evenly on each side so that's good. If it's odd though we can either distribute an extra one on the left or right or we can distribute it evenly but then the text won't fit anymore and we need to push a word to the next line, and even then there's no guarantee you'll have an equal amount of margin on each side.
— Reply to this email directly, view it on GitHub <https://github.com/mfontanini/presenterm/issues/539#issuecomment- 2783809690>, or unsubscribe <https://github.com/notifications/unsubscribe- auth/AAA33MLKOTOBIR2HWN5FZRL2YKMI5AVCNFSM6AAAAAB2T2QEZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBTHAYDSNRZGA>. You are receiving this because you authored the thread.Message ID: @.***>
mfontanini left a comment (mfontanini/presenterm#539) <https://github.com/mfontanini/presenterm/issues/539#issuecomment- 2783809690>
This is tricky because the terminal is cell based. If the total amount of margin is even, we can distribute it evenly on each side so that's good. If it's odd though we can either distribute an extra one on the left or right or we can distribute it evenly but then the text won't fit anymore and we need to push a word to the next line, and even then there's no guarantee you'll have an equal amount of margin on each side. — Reply to this email directly, view it on GitHub <https://github.com/mfontanini/presenterm/issues/539#issuecomment- 2783809690>, or unsubscribe <https://github.com/notifications/unsubscribe- auth/AAA33MLKOTOBIR2HWN5FZRL2YKMI5AVCNFSM6AAAAAB2T2QEZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOOBTHAYDSNRZGA>. You are receiving this because you authored the thread.Message ID: @.***>
Good point! Yeah I think printing a space with a size of 0.5 on each side should do it. This will require changing a few things but it should work fine, albeit only on kitty but that's okay.
sweet! kitty is freakin' amazing. ghostty also supports kitty, which I'm excited about
BTW, headings also seem to be pushed one extra chr to the right, which feels like a separate problem?
Ghostty supports the kitty graphics protocol, I don't imagine they support the kitty font size one yet as it just came out.
I'll have a look at the offset problem soon, I'm AFK for a few days
oh! those are different, I see! That's wonderful, and would REALLY help my OCD looking at these offbyone titles 😆 let me know if I you want a pair/test at any point! Thank you again!
Alright, I'm back home and I'm looking at using fractional sizes via the kitty protocol but it won't fix the issue. Per the spec:
The fractional scale does not affect the number of cells the text occupies, instead, it just adjusts the rendered font size within those cells.
So writing a 1/2 size space won't move all the text in that row by half a cell. This makes sense and I was wondering how it dealt with it otherwise, since the terminal stops being cell based and becomes a chain of characters otherwise.
So sorry but I don't know how to fix this. There's N columns, M is taken by the text and P = (N - M) is padding. If P is odd I have no choice but to put the extra space either on the left or right or the text.
Makes sense, thanks so much for doing the research, I've opened a slightly different issue about the offbyone issue specifically with centering headings: #541
Closing this because unfortunately there's nothing that can be done as this is a limitation of the terminal environment.