MCPcopy
hub / github.com/rsms/inter / loadLocalNamesDB

Function loadLocalNamesDB

misc/tools/restore-diacritics-kerning.py:171–203  ·  view source on GitHub ↗
(agl, diacriticComps)

Source from the content-addressed store, hash-verified

169
170
171def loadLocalNamesDB(agl, diacriticComps): # { 2126: ['Omega', ...], ...}
172 uc2names = None
173
174 for fontPath in srcFontPaths:
175 font = OpenFont(fontPath)
176 if uc2names is None:
177 uc2names = font.getCharacterMapping() # { 2126: ['Omega', ...], ...}
178 else:
179 for uc, names in font.getCharacterMapping().iteritems():
180 names2 = uc2names.get(uc, [])
181 for name in names:
182 if name not in names2:
183 names2.append(name)
184 uc2names[uc] = names2
185
186 # agl { 2126: 'Omega', ...} -> { 'Omega': [2126, ...], ...}
187 aglName2Ucs = {}
188 for uc, name in agl.iteritems():
189 aglName2Ucs.setdefault(name, []).append(uc)
190
191 for glyphName, comp in diacriticComps.iteritems():
192 for uc in aglName2Ucs.get(glyphName, []):
193 names = uc2names.get(uc, [])
194 if glyphName not in names:
195 names.append(glyphName)
196 uc2names[uc] = names
197
198 name2ucs = {}
199 for uc, names in uc2names.iteritems():
200 for name in names:
201 name2ucs.setdefault(name, set()).add(uc)
202
203 return uc2names, name2ucs
204
205
206def _canonicalGlyphName(name, localName2ucs, localUc2Names, altName2ucs):

Callers 1

mainFunction · 0.70

Calls 2

addMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…