Skip to content

Commit

Permalink
fix behaviour in current version of Glyphs
Browse files Browse the repository at this point in the history
  • Loading branch information
justanotherfoundry committed Nov 12, 2023
1 parent d6244ed commit 588c0ff
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
33 changes: 16 additions & 17 deletions Edit Next Glyph.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@
if font:
tab = font.currentTab
if tab:
initialCursor = tab.textCursor
while 1:
tab.textCursor = (tab.textCursor + 1) % len(tab.layers)
# in case there are no real glyphs in the tab, we need to prevent an infinite loop
if tab.textCursor == initialCursor:
break
try:
if font.selectedLayers[0].parent.name:
break
except:
# this happens when the cursor reaches a line break
pass
layer = font.selectedLayers[0]
if tab.viewPort.origin.x + tab.viewPort.size.width < tab.bounds.origin.x + tab.bounds.size.width:
vp = tab.viewPort
vp.origin.x = tab.selectedLayerOrigin.x + 0.5 * ( layer.width * tab.scale - vp.size.width )
tab.viewPort = vp
view = tab.graphicView()
selectedLayerRange = view.selectedLayerRange()
# note: if several glyphs are selected then this will move the whole selection.
# not sure whether this is useful but at least it is not an unexpected behaviour.
if selectedLayerRange.location == len( tab.layers ) - 1:
# the current glyph is the very last. let’s move to the very first:
selectedLayerRange.location = 0
else:
# move one glyph right:
selectedLayerRange.location += 1
view.setSelectedLayerRange_(selectedLayerRange)
# re-center glyph:
vp = tab.viewPort
vp.origin.x = tab.selectedLayerOrigin.x + 0.5 * ( layer.width * tab.scale - vp.size.width )
tab.viewPort = vp
# TODO: in case the new glyph is on a different line, also adjust y
38 changes: 19 additions & 19 deletions Edit Previous Glyph.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
"""

font = Glyphs.font
initialCursor = font.currentTab.textCursor
while 1:
font.currentTab.textCursor = (font.currentTab.textCursor - 1) % len(font.currentTab.layers)
# in case there are no real glyphs in the tab, we need to prevent an infinite loop
if font.currentTab.textCursor == initialCursor:
break
try:
if Glyphs.font.selectedLayers[0].parent.name:
break
except:
# this happens when the cursor reaches a line break
pass

layer = Glyphs.font.selectedLayers[0]
tab = Glyphs.font.currentTab
if tab.viewPort.origin.x > tab.bounds.origin.x:
vp = tab.viewPort
vp.origin.x = tab.selectedLayerOrigin.x + 0.5 * ( layer.width * tab.scale - vp.size.width )
tab.viewPort = vp
if font:
tab = font.currentTab
if tab:
view = tab.graphicView()
selectedLayerRange = view.selectedLayerRange()
# note: if several glyphs are selected then this will move the whole selection.
# not sure whether this is useful but at least it is not an unexpected behaviour.
if selectedLayerRange.location == 0:
# the current glyph is the very first. let’s move to the very last:
selectedLayerRange.location = len( tab.layers ) - 1
else:
# move one glyph left:
selectedLayerRange.location -= 1
view.setSelectedLayerRange_(selectedLayerRange)
# re-center glyph:
vp = tab.viewPort
vp.origin.x = tab.selectedLayerOrigin.x + 0.5 * ( layer.width * tab.scale - vp.size.width )
tab.viewPort = vp
# TODO: in case the new glyph is on a different line, also adjust y

0 comments on commit 588c0ff

Please sign in to comment.