mirror of
https://github.com/ToxicFrog/Ligaturizer.git
synced 2024-08-16 13:20:41 +03:00
Lookup letter glyphs by codepoint rather than name
Fonts usually let you look up the glyphs by name, but not always; all they are *required* to support is lookup by codepoint. This fixes em lookup and the www ligature on fonts that don't have nametables for letter glyphs. Fixes #16 and #21.
This commit is contained in:
parent
a37419e657
commit
f98f3523bb
@ -19,7 +19,7 @@ ligatures = [
|
||||
## These characters are also used by the ligatures, but are likely
|
||||
## to look more out of place when spliced into another font.
|
||||
# 'at', 'braceleft', 'braceright', 'bracketleft', 'bracketright',
|
||||
# 'dollar', 'parenleft', 'parenright', 'underscore',
|
||||
# 'dollar', 'parenleft', 'parenright', 'underscore', 'w'
|
||||
],
|
||||
'firacode_ligature_name': None,
|
||||
},
|
||||
|
@ -75,7 +75,7 @@ class LigatureCreator(object):
|
||||
|
||||
# Scale firacode to correct em height.
|
||||
self.firacode.em = self.font.em
|
||||
self.emwidth = self.font['m'].width
|
||||
self.emwidth = self.font[ord('m')].width
|
||||
|
||||
def copy_ligature_from_source(self, ligature_name):
|
||||
try:
|
||||
@ -184,6 +184,12 @@ class LigatureCreator(object):
|
||||
self.font.addLookup(lookup_name(i), 'gsub_single', (), ())
|
||||
self.font.addLookupSubtable(lookup_name(i), lookup_sub_name(i))
|
||||
|
||||
if char not in self.font:
|
||||
# We assume here that this is because char is a single letter
|
||||
# (e.g. 'w') rather than a character name, and the font we're
|
||||
# editing doesn't have glyphnames for letters.
|
||||
self.font[ord(char)].glyphname = char
|
||||
|
||||
if i < len(input_chars) - 1:
|
||||
self.font.createChar(-1, cr_name(i))
|
||||
self.font.selection.none()
|
||||
@ -194,7 +200,6 @@ class LigatureCreator(object):
|
||||
else:
|
||||
self.font[char].addPosSub(lookup_sub_name(i), ligature_name)
|
||||
|
||||
|
||||
calt_lookup_name = 'calt.{}'.format(self._lig_counter)
|
||||
self.font.addLookup(calt_lookup_name, 'gsub_contextchain', (),
|
||||
(('calt', (('DFLT', ('dflt',)),
|
||||
|
Loading…
Reference in New Issue
Block a user