mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-19 09:51:48 +02:00
font-patcher: Copy selection instead of continuously regenerating
[why] This is a TODO item. Well, two in fact. The symbolFont's selection is used for two things - the main loop to iterate over all glyphs to insert - to select the one glyph that is actually copied over Because the main loop uses iterators on the selection. The iterator is not 'stable' but invalidates if the selection is changed. The current code therefor restores the old selection before the loop jumps to the head again. This design is not very robust. [how] We need the selection to copy the symbol glyph. But we can rewrite the loop that it does not need the selection at every iteration, but that the selection is copied into a list, and we loop over that list - which is independent on a later selection state. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
db026dd5c9
commit
a19800195a
1 changed files with 4 additions and 11 deletions
15
font-patcher
15
font-patcher
|
@ -669,15 +669,14 @@ class font_patcher:
|
||||||
symbolFont.selection.select((str("ranges"), str("unicode")), symbolFontStart, symbolFontEnd)
|
symbolFont.selection.select((str("ranges"), str("unicode")), symbolFontStart, symbolFontEnd)
|
||||||
self.sourceFont.selection.select((str("ranges"), str("unicode")), sourceFontStart, sourceFontEnd)
|
self.sourceFont.selection.select((str("ranges"), str("unicode")), sourceFontStart, sourceFontEnd)
|
||||||
|
|
||||||
# Get number of selected non-empty glyphs @TODO FIXME
|
# Get number of selected non-empty glyphs
|
||||||
for index, sym_glyph in enumerate(symbolFont.selection.byGlyphs):
|
symbolFontSelection = list(symbolFont.selection.byGlyphs)
|
||||||
glyphSetLength += 1
|
glyphSetLength = len(symbolFontSelection)
|
||||||
# end for
|
|
||||||
|
|
||||||
if self.args.quiet is False:
|
if self.args.quiet is False:
|
||||||
sys.stdout.write("Adding " + str(max(1, glyphSetLength)) + " Glyphs from " + setName + " Set \n")
|
sys.stdout.write("Adding " + str(max(1, glyphSetLength)) + " Glyphs from " + setName + " Set \n")
|
||||||
|
|
||||||
for index, sym_glyph in enumerate(symbolFont.selection.byGlyphs):
|
for index, sym_glyph in enumerate(symbolFontSelection):
|
||||||
index = max(1, index)
|
index = max(1, index)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -822,12 +821,6 @@ class font_patcher:
|
||||||
# does not overlap the bearings (edges)
|
# does not overlap the bearings (edges)
|
||||||
self.remove_glyph_neg_bearings(self.sourceFont[currentSourceFontGlyph])
|
self.remove_glyph_neg_bearings(self.sourceFont[currentSourceFontGlyph])
|
||||||
|
|
||||||
# reset selection so iteration works properly @TODO fix? rookie misunderstanding?
|
|
||||||
# This is likely needed because the selection was changed when the glyph was copy/pasted
|
|
||||||
if symbolFontStart == 0:
|
|
||||||
symbolFont.selection.all()
|
|
||||||
else:
|
|
||||||
symbolFont.selection.select((str("ranges"), str("unicode")), symbolFontStart, symbolFontEnd)
|
|
||||||
# end for
|
# end for
|
||||||
|
|
||||||
if self.args.quiet is False or self.args.progressbars:
|
if self.args.quiet is False or self.args.progressbars:
|
||||||
|
|
Loading…
Reference in a new issue