Open kris10ansn opened 3 years ago
@kris10ansn Did you find a solution to this problem?
I did not unfortunately
I think that it might be possible to do this, in theory.
Glyph width is characterized by three values: left bearing (how much the pen advances before it starts drawing the glyph), advance (how wide the actual glyph is), and right bearing (how much the pen advances afterwards). Ligatures are nominally drawn overtop the last glyph in the ligature (as you can see in your example); wide ligatures overdraw the earlier columns by using a very wide negative left bearing and positive advance.
Fira's <!--
, for example, has a left bearing of about¹ -3em and advance of +4em, so to draw the ligature, it starts at the last -
, backtracks three columns to the <
, then draws the 4em-wide glyph, leaving the pen sitting just after the last -
.
For your λ
, I think if you subtracted 5em from the left bearing and left the other metrics intact, you would get a lambda ligature that backtracks 5 columns from the start of the last a
and then advances only one column in drawing the glyph, getting the effect you want. I can't guarantee it won't confuse the editor though!
Did you inject the ligature by hand, or did you patch ligaturizer? If the latter, I'd be glad to incorporate it as an "inject arbitrary ligatures" feature, and it might be possible to include bearing correction in that.
¹ in practice there's fractional ems there so the letter spacing looks nice, but I'm rounding here for simplicity's sake
Hey. I'm not very familiar with this codebase. I just wanted to make some ligatures that allowed me to use greek letters in my code. I added this to the ligatures array:
{ 'chars': ['l', 'a', 'm', 'b', 'd', 'a'], 'firacode_ligature_name': 'lambda', }
Is there an easy way to modify the ligature width, or do I have to dive into the code? How so in that case?
There is not currently any easy way of doing this. It would probably have be done by adding options that control that feature to the table of ligatures, and then respecting those options, if present, in correct_ligature_width; correct_character_width has an example of left and right bearing adjustment, albeit for a different purpose.
This does seem like an interesting feature to have, but I can't make any promises as to when I'll have time to poke at it.
I made a ligature that changes
['l', 'a', 'm', 'b', 'd', 'a']
into the actual lambda characterλ
, and it worked fine. The only problem is that the singleλ
character takes up the space of the entire"lambda"
word and just looks kinda weird. Is it possible to change the width of a single ligature?I'm using VS Code (VSCodium to be precise) if that makes any difference.
Showcase:![image](https://user-images.githubusercontent.com/40371637/108086977-3ce51f80-7077-11eb-8c9b-f0bf7718efef.png)