Skip to content

Commit

Permalink
[Proxy] [Core] [FL] Font, Glyph [Update]:
Browse files Browse the repository at this point in the history
- Set Stems
  • Loading branch information
kateliev committed Oct 2, 2024
1 parent 10eaea4 commit 7c936e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
7 changes: 5 additions & 2 deletions Lib/typerig/proxy/fl/objects/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from typerig.proxy.fl.objects.glyph import pGlyph, eGlyph

# - Init ---------------------------------
__version__ = '0.28.9'
__version__ = '0.29.0'

# - Keep compatibility for basestring checks
try:
Expand Down Expand Up @@ -438,8 +438,11 @@ def update(self):
self.updateObject(self.fl, verbose=False)

# - Hinting --------------------------------------------------------
def setStem(self, stem_value, stem_name='', stem_is_horizontal=False, stem_type_TT=False):
def setStem(self, stem_value, stem_name='', stem_is_horizontal=False, stem_type_TT=False, layer=None):
new_stem = fl6.flStem(stem_value, stem_name)

if layer is not None:
self.fl.setMaster(layer)

if stem_type_TT:
if stem_is_horizontal:
Expand Down
33 changes: 22 additions & 11 deletions Scripts/TypeRig GUI/Panel/Glyph.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import fontgate as fgt

from typerig.proxy.fl.objects.font import pFont
from typerig.proxy.fl.objects.glyph import pGlyph
from typerig.proxy.fl.objects.glyph import eGlyph

from PythonQt import QtCore

Expand All @@ -31,7 +31,7 @@
pLayers = None
pMode = 0
pUndo = True
app_name, app_version = 'TypeRig | Glyph', '1.10'
app_name, app_version = 'TypeRig | Glyph', '1.11'

number_token = '#'

Expand Down Expand Up @@ -149,19 +149,30 @@ def glyph_setBasics(self, mode):


def setStem(self, horizontal=False):
# - Init
font = pFont()
active_glyph = pGlyph()
selection = active_glyph.selectedNodes(None, True)

if horizontal:
stem_width = int(abs(selection[0].y - selection[-1].y))
else:
stem_width = int(abs(selection[0].x - selection[-1].x))
active_glyph = eGlyph()

# - Prepare selection
selection = {layer_name:active_glyph.selectedNodes(layer_name, True) for layer_name in active_glyph._prepareLayers(pLayers)}
set_standard_stems = []

stem_name = '{}.{}:{}'.format(['V','H'][horizontal], active_glyph.name, stem_width)
# - Set name and metadata
stem_name = '{}.{}'.format(['V','H'][horizontal], active_glyph.name)
stem_type = self.cmb_select_stem.currentIndex

font.setStem(stem_width, stem_name, horizontal, stem_type)
# - Prepare stems
for layer_name, layer_selection in selection.items():
if horizontal:
stem_width = int(abs(layer_selection[0].y - layer_selection[-1].y))
else:
stem_width = int(abs(layer_selection[0].x - layer_selection[-1].x))

set_standard_stems.append((stem_width, stem_name, horizontal, stem_type, layer_name))

# - Set stems
for stem_data in set_standard_stems:
font.setStem(*stem_data)

# - Finish operation
global pUndo
Expand Down

0 comments on commit 7c936e2

Please sign in to comment.