mirror of
https://github.com/ToxicFrog/Ligaturizer.git
synced 2024-08-16 13:20:41 +03:00
Add support for copying individual characters as well
This commit is contained in:
parent
2c7bb65892
commit
768ba112ff
@ -39,7 +39,7 @@ they are available via brew (`brew install fontforge`).
|
||||
## Using the Script ##
|
||||
|
||||
1. Move/copy the font you want to ligaturize into `input-fonts/` (or somewhere else convenient).
|
||||
2. Edit `ligatures.py` to disable any ligatures you don't want.
|
||||
2. Edit `ligatures.py` to disable any ligatures you don't want, and/or enable any (non-ligature) characters you want from Fira Code in addition to the ligatures.
|
||||
3. Run the script: `$ fontforge -lang=py ligaturize.py <INPUT> <OUTPUT>`, e.g. `$ fontforge -lang=py ligaturize.py input-fonts/Cousine-Regular.ttf output-fonts/CousineLigaturized-Regular.ttf`
|
||||
|
||||
The font family and weight for the output font (as recorded in the file) will be automatically set based on the name; if the output is `CousineLigaturized-Regular.ttf`, the font family will be `CousineLigaturized` and the font weight will be `Regular`. If no weight is specified, `Regular` is the default.
|
||||
|
16
ligatures.py
16
ligatures.py
@ -1,4 +1,20 @@
|
||||
ligatures = [
|
||||
## These are all the punctuation characters used in Fira Code ligatures.
|
||||
## Uncomment this block to enable copying of these characters as well; it
|
||||
## will make punctuation blend in with the ligatures more cleanly, at the
|
||||
## cost of blending in with the rest of the font not as well.
|
||||
## You can also edit the 'chars' list to change exactly which characters
|
||||
## will be copied.
|
||||
# {
|
||||
# 'chars': [
|
||||
# 'ampersand', 'asciicircum', 'asciitilde', 'asterisk', 'at',
|
||||
# 'backslash', 'bar', 'braceleft', 'braceright', 'bracketleft', 'bracketright',
|
||||
# 'colon', 'dollar', 'equal', 'exclam', 'greater', 'hyphen',
|
||||
# 'less', 'numbersign', 'parenleft', 'percent', 'period', 'plus',
|
||||
# 'question', 'semicolon', 'slash', 'underscore',
|
||||
# ],
|
||||
# 'firacode_ligature_name': None,
|
||||
# },
|
||||
{ # <-
|
||||
'chars': ['less', 'hyphen'],
|
||||
'firacode_ligature_name': 'less_hyphen.liga',
|
||||
|
@ -87,6 +87,17 @@ class LigatureCreator(object):
|
||||
|
||||
|
||||
def add_ligature(self, input_chars, firacode_ligature_name):
|
||||
if firacode_ligature_name is None:
|
||||
# No ligature name -- we're just copying a bunch of individual characters.
|
||||
for char in input_chars:
|
||||
self.firacode.selection.none()
|
||||
self.firacode.selection.select(char)
|
||||
self.firacode.copy()
|
||||
self.font.selection.none()
|
||||
self.font.selection.select(char)
|
||||
self.font.paste()
|
||||
return
|
||||
|
||||
if not self.copy_ligature_from_source(firacode_ligature_name):
|
||||
print('Error reading ligature %s from %s -- skipping' % (
|
||||
firacode_ligature_name, self.firacode.fontname))
|
||||
|
Loading…
Reference in New Issue
Block a user