That's all I can ask for. :) (And it's anyway the drill I'm used to from my contributions to ROOT.) I'm willing to try and help fix any breakage, should we get any.
Manuel
apparently because the ASCII-to-glyph mapping won't quite work - I suspect that's due to PragmataPro having ligatures in that range, too. I solved this by inserting a space between characters that we hand to pango for shaping. Sane fonts will not have ligatures between a space and a printable character, this way we still get one glyph per ASCII character. I've attached the modified patch. This will work with normal fonts and ones with programming ligatures like Hasklig and PragmataPro; I've tested it with the gtk2 and gtk3 front ends.
Please let me know if it would be possible to include this, and if not, at least the patch is public now where people can find it if they want it.
Best regards,
Manuel
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@googlegroups.com.
On Monday, 8 August 2016 12:49:15 UTC+2, Kazunobu Kuriyama wrote:
> Sorry, but I still don't understand how you justify your patch that adds 0x20 to each of alphanumeric characters and send them to Pango.
In my opinion, the optimisation in and of itself is a bit of a hack. The trouble is that it does the wrong thing in case of ligatures, since you get fewer glyphs than ASCII characters, which breaks the 1-to-1 mapping. The spaces are added to prevent ligatures (since most fonts with ligatures do not define a ligature between a space and another character).
In some sense, this is still a hack, and what you would really want to do (if you want to keep the optimisation hack) is to shape one character one at a time, so are guaranteed to get one glyph per ascii character...
> Actually, what is your point to make every text data length double? That is 100% inefficient and totally ruins the existing optimization hack. Just as what you wrote in your patch yourself, that's a ugly hack, indeed.
It is, but bypassing the shaping to gain a bit of speed is ugly to start with, and adds quite a bit of code, data structures and complexity to vim's rendering routines. If I just disable that optimisation, vim doesn't have any issue with monospaced fonts, ligatures or otherwise.
It's an optimisation, and one that isn't quite right. My point is that my patch contains more of the correct solution than does the code that's currently there. I don't claim it's nice, or beautiful, or anything. The double-length array is only a cost in memory, some small multiple of 128 bytes (likely 4 times that), which I doubt will be a consideration if you're running gvim, and an integer multiply (by 2, so likely a left shift) in the code that renders glyphs in the code path that is used by the optimisation...
> If I wrote a patch for ligature support, I would remove the optimization hack and add some code to cursor movement over a ligature, selection mechanisms for visual mode and text objects when either of the region boundaries has a ligatures on it, line wrapping handling at a ligature (to name but a few) in order to decently accommodate ligatures in vim.
>
> What consideration is paid to those in your patch? I don't see any.
The trick is to activate the optimisation not for all ASCII characters (chars < 128), but only for [A-Z], [a-z], [0-9] and space. If a string to be displayed contains other characters, it'll pass through the full blown shaping and has its glyphs drawn, including ligatures.
> My question in the previous mail was whether or not PragmataPro was a monospace font family as binary data. Not that what you felt about it nor what the world saw about it. That was a purely technical question. Was it too hard for you to check your PragmataPro file(s) with an appropriate utility?
I tried to answer your question as best as I could, and I'm sorry if I didn't quite hit the mark. In fact, with your new question, I don't even know what "monospace font family as binary data" means, maybe you could clarify. Unless you can read TrueType/OpenType fonts in hexdumps, and glean meaning from it, this will tell you very little. It's not a bitmap font, if that's what you mean.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@googlegroups.com.
On Monday, 8 August 2016 15:39:02 UTC+2, Kazunobu Kuriyama wrote:
> If your windowing system is a recent X11 with fontconfig, do
>
> $ fc-scan <your favorite ligature font file>
>
>
> then you'll have something human readable.
>
>
> Take a look at an item called 'spacing.'
>
>
> If you have none or the number zero, then the font is proportional.
> If you have the number 90, then the font is dual.
> If you have the number 100, then the font is monospace.
> If you have the number 110, then the font is charcell
Thanks, this is getting us somewhere. :)
I've run a couple of checks with the commands you suggested, and I get the following results:
- DejaVu and PragmataPro Mono do indeed have the spacing attribute set to 100.
- Hasklig and PragmataPro do not, in fact they do not show a spacing attribute. (However, as I tried to explain in that previous post in my own frightfully limited way, they're effectively monospaced, and after glyph shaping where appropriate, things will line up with the character cell layout that the rendering code assumes, I think...)
So, apparently, there's monospaced fonts, and fonts that just happen to have individual glyphs an intger multiple of the same width. I freely admit that I did not know about this, and apologise if I have given offence in the process.
To my mind, the question the list now needs to decide is this: Do we want to support these "effectively monospaced" fonts like Hasklig, or not? (I think we should, but I'll abide by your decision, of course. :)
If the answer is yes, we can discuss which bits of the patch you'd like cleaned up, and I'll do my best to provide something that's acceptable. Sorry again for the "exchange of fire" earlier, I certainly didn't mean to hurt anyone's feelings.
Best regards,
Manuel
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
Okay, now I understand - thanks for the clarification. Well, current vim code (and my patch) bypasses pango's glyph shaping completely in some cases. Current vim code does this if the string only contains code points <= 127. My patch restricts the range somewhat, so that glyph shaping occurs in more cases as with vanilla vim code. As far as I can tell, strings containing code points of 128 and above are left alone with or without my patch, and pango deals with them the usual way by shaping, and then drawing the resulting glyphs...
Thanks,
Manuel
Hi Bram,
well, it seems I upset quite a bee's nest with this (much of which may be my own fault ;)...
Neither patch nor the current vim code will work when one ASCII character translates to more than one display cell.
But when you have a ligature between two characters, drawing a two-cell glyph might be considered an improvement by some. As to what happens when you change highlighting, or move the cursor across such a ligature: Currently, the redrawn character cell gets repainted with the "non-ligaturised" version of that single glyph, which results in the ligature partially reverting back to its component glyphs. Moving the cursor off, and a (partial) redraw like from pressing ^L causes the ligature glyph to reappear. It's not perfect, but it's consistent with the behaviour I've seen from e.g. putty and Konsole/qterminal (the latter two do their own metrics calculation, and get the spacing wrong if there's ligatures on the line - patched gvim doesn't do that, so I'm very happy with it ;). My assertion is that people using these programming fonts will be happy to see these ligatures assemble/disassemble as they edit across them.
Regarding your question about the range of ascii characters to which the tabulated cache is applied: Restricting this to subranges of [0,127] that I mentioned should get you most of the speed improvement that can be had from bypassing pango's shaping, and from what I understood, the space ' ' is especially important, since it's used to clear the screen.
But the restriction to those subranges also means that strings containing the popular "programming ligatures" like "<=", ">=", "!=", "->" etc. will be subject to pango's shaping, thus ligatures are displayed... In a way, we're selectively disabling the "shaping bypass" for less obvious character ranges where ligatures are more likely (and more likely to be missed by programmers).
I hope this clarifies things a bit.
Thanks for the interest,
Manuel
On Monday, 8 August 2016 22:27:11 UTC+2, Bram Moolenaar wrote:
> Manuel Schiller wrote:
>
> [...]
>
> > Concerning your request to send a patch that just fixes the assumption
> > about "one ascii character == one glyph": One could either get rid of
> > that speed optimisation code altogether (in which case all ligatures
> > will work), or rewrite most of that optimisation, doing one shaping
> > call into pango for each of (or some of) the characters with codes <
> > 128. The latter versoin would amount to some overhead for all those
> > calls, and reassembling the returned data structures in a suitable
> > way...
>
> I don't see how it can work with a font where it is not true that each
> ASCII character is one display cell. E.g., when highlighting or drawing
> the cursor. If you draw some combination of two ASCII characters with
> one double-wide glyph it's not possible to highlight half of it.
>
> It appears pango has no way to disable ligatures.
>
> So the table we create should work, putting in extra spaces to avoid the
> shaping to take place. But I don't see why we would be doing this only
> for alphanumeric characters, this should work for all ASCII characters.
>
>
Hi Bram,
well, it seems I upset quite a bee's nest with this (much of which may be my own fault ;)...
Neither patch nor the current vim code will work when one ASCII character translates to more than one display cell.
But when you have a ligature between two characters, drawing a two-cell glyph might be considered an improvement by some. As to what happens when you change highlighting, or move the cursor across such a ligature: Currently, the redrawn character cell gets repainted with the "non-ligaturised" version of that single glyph, which results in the ligature partially reverting back to its component glyphs. Moving the cursor off, and a (partial) redraw like from pressing ^L causes the ligature glyph to reappear. It's not perfect, but it's consistent with the behaviour I've seen from e.g. putty and Konsole/qterminal (the latter two do their own metrics calculation, and get the spacing wrong if there's ligatures on the line - patched gvim doesn't do that, so I'm very happy with it ;).
My assertion is that people using these programming fonts will be happy to see these ligatures assemble/disassemble as they edit across them.
Regarding your question about the range of ascii characters to which the tabulated cache is applied: Restricting this to subranges of [0,127] that I mentioned should get you most of the speed improvement that can be had from bypassing pango's shaping, and from what I understood, the space ' ' is especially important, since it's used to clear the screen.
But the restriction to those subranges also means that strings containing the popular "programming ligatures" like "<=", ">=", "!=", "->" etc. will be subject to pango's shaping, thus ligatures are displayed... In a way, we're selectively disabling the "shaping bypass" for less obvious character ranges where ligatures are more likely (and more likely to be missed by programmers).
I hope this clarifies things a bit.
Thanks for the interest,
Manuel
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@googlegroups.com.
> My assertion is that people using these programming fonts will be happy to see these ligatures assemble/disassemble as they edit across them.
>
> Once people view ligatures on Vim, they will ask us more for the purpose of editing them in a way each individual thinks better...
>
Yep, that's the sign of people doing a good job - people ask for more. :) In a sense, that's what I'm doing as well (I hope you see that as a compliment!).
Seriously, I don't mean to aggravate you or anybody else, or cloud your vacation in any way. Maybe we postpone this until you're back from vacation, and we've both had some time to think it over?
Kind regards, and enjoy your vacation,
Manuel
> Best,
> Kazunobu
>
>
>
>
> Regarding your question about the range of ascii characters to which the tabulated cache is applied: Restricting this to subranges of [0,127] that I mentioned should get you most of the speed improvement that can be had from bypassing pango's shaping, and from what I understood, the space ' ' is especially important, since it's used to clear the screen.
>
>
>
> But the restriction to those subranges also means that strings containing the popular "programming ligatures" like "<=", ">=", "!=", "->" etc. will be subject to pango's shaping, thus ligatures are displayed... In a way, we're selectively disabling the "shaping bypass" for less obvious character ranges where ligatures are more likely (and more likely to be missed by programmers).
>
>
>
> I hope this clarifies things a bit.
>
>
>
> Thanks for the interest,
>
>
>
> Manuel
>
>
>
>
>
> --
>
> --
>
> You received this message from the "vim_dev" maillist.
>
> Do not top-post! Type your reply below the text you are replying to.
>
> For more information, visit http://www.vim.org/maillist.php
>
>
>
> ---
>
> You received this message because you are subscribed to the Google Groups "vim_dev" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@googlegroups.com.
Dear Kazunobu,
On Tuesday, 9 August 2016 12:03:47 UTC+2, Kazunobu Kuriyama wrote:
> Hi Manual,
>
> [...]
> Well, the trouble is that I think you likely are qualified to review that patch, despite me being a newcomer who cannot really tell because I don't know who does what, and who is experienced in which field. But somehow, we seem to have gotten off on the wrong foot (which may be my fault, and if it is, I'm sorry), or you seem to feel really strongly that the code should only deal with true monospaced fonts. That's a bit of a pity because I think we're both trying to make vim a little bit better (even if it's in a frightfully limited way in my case). By the way, your vacation remark I find a bit insulting in this context.
>
>
> Apologies to you for that.
>
No need, I rather speak up when something is getting beyond my confort zone, but before I actually feel seriously insulted. And I guess I'm at the very least sharing the blame for the escalation... :) Sorry for that again, and for the noise!
>
> > My assertion is that people using these programming fonts will be happy to see these ligatures assemble/disassemble as they edit across them.
>
> >
>
> > Once people view ligatures on Vim, they will ask us more for the purpose of editing them in a way each individual thinks better...
>
> >
>
> Yep, that's the sign of people doing a good job - people ask for more. :) In a sense, that's what I'm doing as well (I hope you see that as a compliment!).
>
>
>
> Seriously, I don't mean to aggravate you or anybody else, or cloud your vacation in any way. Maybe we postpone this until you're back from vacation, and we've both had some time to think it over?
>
>
> That sounds good...but considering the fact that the ligature patch now looks gaining momentum for the first time in two years (as Bram shows an interest in it), I think your keeping working on it while I'm off could lead to a good, even better and faster, result. So I'd like to say to you, "Keep it up! Over my dead body!", though it's all up to you :)
>
Okay, fair enough. :) It might take some time though, since I'll be moving to a different country to start a new job in the coming month.
What direction would you like to see things heading? I'll most likely be no good at finding the ultimate patch that gets everything right because I'm not enough of an expert in the font rendering library field - it only dawned on me what was going wrong in that code recently.
If you'd want the ultimate ligature-clean solution, I anticipate one would need to revamp much of the gtk display code to update the right bits of the screen and keep the relation between glyph and characters, especially for the cursor drawing routines, so the right bit gets redrawn. That's a tall order, and I feel my C and gtk/pango skills are a bit too much in the range from non-existant to rusty for that. (My C++ is good, but that doesn't help here. ;) Moreovwe, we may want to use a patch along the lines I suggested to gain a bit of experience to learn about what's important in this business before we try and design the patch that solves all ligature issues... It may involve bug reports, and users asking for features, but that's very good feedback once we understand where the problem is, guiding us toward a better solution.
In the meantime, I may be able to clean up the glyph cache for ascii codes < 128, for example, by having a shaping call per character code, so we only need to store a single glyph in the cache, if you feel that would help. One could also think about making the ascii code range which passes through the glyph cache configurable, if you guys would prefer that over the static list like the one I took over from the original patch proposition.
Is there anything else I can do that you or others would feel is valuable to have? Feel free to keep the suggestions coming...
All the best,
Manuel
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@googlegroups.com.
Point taken.
> > Regarding your question about the range of ascii characters to which
> > the tabulated cache is applied: Restricting this to subranges of
> > [0,127] that I mentioned should get you most of the speed improvement
> > that can be had from bypassing pango's shaping, and from what I
> > understood, the space ' ' is especially important, since it's used to
> > clear the screen.
> >
> > But the restriction to those subranges also means that strings
> > containing the popular "programming ligatures" like "<=", ">=", "!=",
> > "->" etc. will be subject to pango's shaping, thus ligatures are
> > displayed... In a way, we're selectively disabling the "shaping
> > bypass" for less obvious character ranges where ligatures are more
> > likely (and more likely to be missed by programmers).
>
> What makes you think these are popular? Maybe it's because I have read
> ">=" as two characters all my programming life, but having it show up as
> anything but the sequence of two characters would look weird to me.
> Perhaps it would look nice in a book or other place where you only read
> code.
Well, preferences matter a lot to people, and I respect that (read on,
because I think there's a way how both of us can have our cake, and eat
it, too...).
In fact, I had a useful discussion by mail with Kazunobu earlier today, and
also did some thinking on the tram home tonight, and here's what I figured:
- I think I should have another go at the ascii (code < 128) character to
glyph cache in such a way that it forces one glyph per character, regardless
of what the font offers in terms of ligatures. That way, the corruption for
normal text for these effectively monospaced fonts with ligatures in that
range will stop (because we'd effectively disable ligatures in that range),
and we'll introduce none of the strange drawing issues with the cursor/redraw.
- Instead of having a hardcoded range of characters for which we bypass glyph
shaping (be it the entire range from 0 to 127, or just the subrange that
the patch proposed), we could have a bit map from characters 0-127 in 4
32 bit integers, where each bit specifies if the character is eligible
to bypass glyph shaping, or not. (We can discuss other data structures,
of course.)
If we make this user settable in some form, and set the default such that the
old behaviour (i.e. no ligatures, no redrawing problems) remains unless people
do something in their .vimrc, we could have correct, albeit non-fancy behaviour
by default, and have effectively monospace fonts work (without ligatures).
If users change the character range for which they bypass glyph shaping
because they want ligatures, they'll get some, or all of the ligatures, with
all the interesting behaviour that happens on redraw and cursor movement.
Thus, users would get a choice.
That way, we'd kind of have the best of both worlds with one or two relatively
simple patches that I would hope to be viable for most people, and that do the
right thing with no surprises or drawing glitches, unless people change the
default settings.
Once we have a bit of experience with that, maybe we can come up with a better
patch that supports ligatures in an even better way.
Would that be acceptable for you as an interim hack/solution, Bram?
> If we don't do this, then is there still any point in trying to support
> this font that isn't really mono spaced?
Hmm, given that a proportional font like Helvetica works (even if the result
isn't pretty), producing gibberish for these effectively monospaced fonts
with ligatures seems to violate the POLA (Principle Of Least Astonishment).
My prediction would be that not fixing it will just generate you a steady
stream of discussions through the coming years, and you'll have to explain
point to a statement each time that goes "no, we really mean monospaced
and monospaced only when it comes to supported fonts, with the proper flag
set and everything".
> I'm afraid any half solution will just lead to more bugs about details
> later. It might be better to just say that this font is not supported.
Well, that could still remain the official slogan, or we could dub it
"experimental" or something if you think it helps. But the question will
come back every now and then, I think...
Kind regards,
Manuel
Hi Stefan,
thanks for giving it a try, I appreciate it! Keep that feedback
coming (I'll keep reading mail), and we can hopefully make
ligatures in vim happen at some point. I'll keep updating patches
at the github repo I mentioned in my last mail.
Cheers,
Manuel
Best regards,
Tony.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@googlegroups.com.
I just tried Hasklig on Windows. It seems that ligatures partly works on
Windows.
After Vim 7.4.393, gvim.exe can use two types of rendering engine, the
traditional GDI engine and newer DirectWrite engine. GDI doesn't seem to
support ligatures at all, but DirectWrite supports ligature. However, when
you put the cursor on a ligature, it is shown as separate characters. If you
want to show the ligature again, you need to type <Ctrl-L>.
Screenshot attached. (I haven't try PragmataPro.)
Regards,
Ken Takata
After Vim 7.4.393, gvim.exe can use two types of rendering engine, the
traditional GDI engine and newer DirectWrite engine. GDI doesn't seem to
support ligatures at all, but DirectWrite supports ligature. However, when
you put the cursor on a ligature, it is shown as separate characters. If you
want to show the ligature again, you need to type <Ctrl-L>.
Screenshot attached. (I haven't try PragmataPro.)
Regards,
Ken Takata
On 2016-08-11, 15:40 GMT, Kazunobu Kuriyama wrote:
>> Screenshot attached. (I haven't try PragmataPro.)
>
> I don't either for an obvious reason..Isn't there a free version? :)
Would https://github.com/tonsky/FiraCode/ work?
Matěj
--
https://matej.ceplovi.cz/blog/, Jabber: mc...@ceplovi.cz
GPG Finger: 3C76 A027 CA45 AD70 98B5 BC1D 7920 5802 880B C9D8
..every Man has a Property in his own Person. This no Body has
any Right to but himself. The Labour of his Body, and the Work of
his Hands, we may say, are properly his. .... The great and chief
end therefore, of Mens uniting into Commonwealths, and putting
themselves under Government, is the Preservation of their
Property.
-- John Locke, "A Treatise Concerning Civil Government"
That said, I'm very happy for suggestions (or patches), and will try to have a draft ready soonish when suggestions do trickle in. :)
Does this help?
Cheers,
Manuel
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@googlegroups.com.