Closed tecosaur closed 4 years ago
Just off the top of my head --
copy()
it.Thanks. I'll see how it goes and get back to you if I have any more questions (if you don't mind).
Sorry for leaving this open for so long without doing anything. Unfortunately I've been having some issues getting this to work.
Is there any chance you'd be willing to help by looking at what I've done and giving me your thoughts? I'm a bit lost.
The changes I have made can be seen at https://github.com/tecosaur/Ligaturizer and the current outpt is as follows:
fontforge -lang=py -script build.py 2>&1 \
| fgrep -v 'This contextual rule applies no lookups.' \
| fgrep -v 'Bad device table'
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
Based on sources from 16:11 UTC 1-May-2018-ML-D.
Based on source from git with hash:
The following table(s) in the font have been ignored by FontForge
Ignoring 'DSIG' digital signature table
This font contains both a 'kern' table and a 'GPOS' table.
The 'kern' table will only be read if there is no 'kern' feature in 'GPOS'.
Use-my-metrics flag set on at least two components in glyph 685
The glyph named Omega is mapped to U+03A9.
But its name indicates it should be mapped to U+2126.
Ligaturizing font IBMPlexSans-Regular.otf (IBM Plex Sans) as 'Liga IBM Plex Sans'
...using ligatures from fonts/dejaVu/DejaVuSans.ttf
...saving to 'fonts/output/LigaIBMPlexSans.otf' (Liga IBM Plex Sans)
To be clear, a file is generated, it just doesn't perform any replacements. In this case \in
is not replaced by "∈" U+2208
(8712
in base 10, see https://github.com/tecosaur/Ligaturizer/commit/5b48cd237e26bafd2ef85cd5308f8783147027df for the ligature addition and https://github.com/tecosaur/Ligaturizer/commit/fcf73b3574976deeceb06dcea55cc229466f1e0c for me trying to make it use unicode codepoints)
I improved the logging a bit
And now I get this
Which is interesting as the character I mentioned (U+2208) definately exists in the font
So I'm guessing one of the issues may be that the character needs to be copied over first
Simply copying the character glyph doesn't seem to work :disappointed:
I also tried changing to a character I knew was in the font, still no luck...
Perhaps it an issue with copying characters? I'll see what codepoint it's using
EDIT: Yep. It's using 97
which is fine, but for some reason apparently that codepoint is out of range!?
Ok, I needed to add a trailing comma. Now the ligatures are being added ... but I have some new weirdness to deal with
Fixed, that, latest issue is a corrupted font file being produced, here's my log:
```
fontforge -lang=py -script build.py 2>&1 \
| fgrep -v 'This contextual rule applies no lookups.' \
| fgrep -v 'Bad device table'
Copyright (c) 2000-2014 by George Williams. See AUTHORS for Contributors.
License GPLv3+: GNU GPL version 3 or later
Got a subset of the symbols working :smiley:
Sorry for the pile of notifications I've just given you.
If you still have any patience, there are a few things that I can't work out how to get to work.
At least one anchor point was lost when pasting from one font to another because no matching anchor class could be found in the new font.
are showing upI imagine that (3) would be the easiest to fix, and if you can help with (4) it's really annoying.
@ToxicFrog if you can help with that list of 4 issues in any way I'd be hugely appreciative :smiley:.
Whoops, sorry, I haven't been keeping up on my GH notifications.
No idea on (1) or (2).
(3) is tricky. If it can be done, it would probably be done by messing with the left_side_bearing
, right_side_bearing
, and width
of the ligature in correct_ligature_width
. LSB and RSB are the left and right margins of the glyph in its bounding box, and width
is the total horizontal width of the bounding box (the "advance").
Ligatures are characterized by large negative left bearings and normal advances and right bearings, meaning that the drawing of the ligature extends to the left "outside" the bounding box (which is what you want, since that covers all the characters that were replaced, not just the last one). So it's possible that by setting both bearings to negative values (thus yielding a negative advance as well), typing the ligature would cause its constituent characters to "condense" into the ligature, and the cursor to jump backwards.
That said, the documentation implies that setting a negative total advance is disallowed, or at least avoided; I don't know if it would actually work. Caveat scriptor.
(4) I have no idea on. What are you commenting out, parts of the ligature table? And what does "doesn't work" mean here -- it crashes? Fails to generate the output font? Generates it fine, but the ligatures don't work, or some of them don't? I wonder if there's some internal limit on the number of ligatures you can have, although it seems unlikely you'd be hitting it.
Hi @ToxicFrog ,
I'm trying to extend a font in such a similar way to that which you have done here that I was hoping you might be willing to give me one or two pointers, ideally on modifications that could be made to your code to make it do what I want :smiley:.
What I want to do is add ligatures, not for coding but for LaTeX. There seem to be two main differences between what I want to do and what you've done.
Would you be willing to give me an idea of what I'd need to modify from your script to make this possible?
thanks,
tecosaur
Addendum: Regarding using the unicode string → character name I imagine unicodedata.name could be useful