Skip to content

Commit

Permalink
No longer observe distinction of black, white, gray distance.
Browse files Browse the repository at this point in the history
  • Loading branch information
psb1558 committed Jan 17, 2025
1 parent 21f1b34 commit 519d3e6
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 100 deletions.
62 changes: 35 additions & 27 deletions src/ygt/makeCVDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def __init__(

self.general_tab_layout = QVBoxLayout()
self.cv_type_widget = cvTypeWidget(self.cv_source)
self.cv_color_widget = cvColorWidget(self.cv_source)
#self.cv_color_widget = cvColorWidget(self.cv_source)
self.cv_axis_widget = cvAxisWidget(self.cv_source)
self.cv_val_widget = cvValueWidget(self.cv_source)
self.cv_name_widget = cvNameWidget(self.cv_source, owner=self.owner)
Expand Down Expand Up @@ -593,9 +593,9 @@ def __init__(
self.gen_widgets[-1].addWidget(QLabel("suffix"))
self.gen_widgets[-1].addWidget(self.cv_suffix_widget)

self.gen_widgets.append(QHBoxLayout())
self.gen_widgets[-1].addWidget(QLabel("distance type"))
self.gen_widgets[-1].addWidget(self.cv_color_widget)
# self.gen_widgets.append(QHBoxLayout())
# self.gen_widgets[-1].addWidget(QLabel("distance type"))
# self.gen_widgets[-1].addWidget(self.cv_color_widget)

# Set up link tab

Expand Down Expand Up @@ -699,7 +699,7 @@ def refresh(self, cv_source: cvSource) -> None:
self.cv_name_widget.refresh(self.cv_source)
self.cv_type_widget.refresh(self.cv_source)
self.cv_axis_widget.refresh(self.cv_source)
self.cv_color_widget.refresh(self.cv_source)
#self.cv_color_widget.refresh(self.cv_source)
self.cv_val_widget.refresh(self.cv_source)
self.cv_cat_widget.refresh(self.cv_source)
self.cv_suffix_widget.refresh(self.cv_source)
Expand All @@ -715,7 +715,7 @@ def fixup(self) -> None:
self.cv_name_widget.fixup()
self.cv_type_widget.fixup()
self.cv_axis_widget.fixup()
self.cv_color_widget.fixup()
#self.cv_color_widget.fixup()
self.cv_val_widget.fixup()
self.cv_cat_widget.fixup()
self.cv_suffix_widget.fixup()
Expand Down Expand Up @@ -780,20 +780,25 @@ def __init__(self, yg_font: ygFont) -> None:
self.anchor_layout.addWidget(self.anchor_checkbox)
self.layout_obj.addLayout(self.anchor_layout)

self.blackdist_layout = QHBoxLayout()
self.blackdist_checkbox = QCheckBox("Black distance")
self.blackdist_layout.addWidget(self.blackdist_checkbox)
self.layout_obj.addLayout(self.blackdist_layout)
self.stem_layout = QHBoxLayout()
self.stem_checkbox = QCheckBox("Stem")
self.stem_layout.addWidget(self.stem_checkbox)
self.layout_obj.addLayout(self.stem_layout)

# self.blackdist_layout = QHBoxLayout()
# self.blackdist_checkbox = QCheckBox("Black distance")
# self.blackdist_layout.addWidget(self.blackdist_checkbox)
# self.layout_obj.addLayout(self.blackdist_layout)

self.whitedist_layout = QHBoxLayout()
self.whitedist_checkbox = QCheckBox("White distance")
self.whitedist_layout.addWidget(self.whitedist_checkbox)
self.layout_obj.addLayout(self.whitedist_layout)
# self.whitedist_layout = QHBoxLayout()
# self.whitedist_checkbox = QCheckBox("White distance")
# self.whitedist_layout.addWidget(self.whitedist_checkbox)
# self.layout_obj.addLayout(self.whitedist_layout)

self.graydist_layout = QHBoxLayout()
self.graydist_checkbox = QCheckBox("Gray distance")
self.graydist_layout.addWidget(self.graydist_checkbox)
self.layout_obj.addLayout(self.graydist_layout)
# self.graydist_layout = QHBoxLayout()
# self.graydist_checkbox = QCheckBox("Gray distance")
# self.graydist_layout.addWidget(self.graydist_checkbox)
# self.layout_obj.addLayout(self.graydist_layout)

self.shift_layout = QHBoxLayout()
self.shift_checkbox = QCheckBox("Shift")
Expand All @@ -813,9 +818,10 @@ def __init__(self, yg_font: ygFont) -> None:
self.refresh()

self.anchor_checkbox.stateChanged.connect(self.button_state_changed)
self.blackdist_checkbox.stateChanged.connect(self.button_state_changed)
self.whitedist_checkbox.stateChanged.connect(self.button_state_changed)
self.graydist_checkbox.stateChanged.connect(self.button_state_changed)
self.stem_checkbox.stateChanged.connect(self.button_state_changed)
# self.blackdist_checkbox.stateChanged.connect(self.button_state_changed)
# self.whitedist_checkbox.stateChanged.connect(self.button_state_changed)
# self.graydist_checkbox.stateChanged.connect(self.button_state_changed)
self.shift_checkbox.stateChanged.connect(self.button_state_changed)
self.align_checkbox.stateChanged.connect(self.button_state_changed)
self.interpolate_checkbox.stateChanged.connect(self.button_state_changed)
Expand All @@ -828,9 +834,10 @@ def button_state_changed(self) -> None:
return
r = {}
r["anchor"] = self.anchor_checkbox.isChecked()
r["blackdist"] = self.blackdist_checkbox.isChecked()
r["whitedist"] = self.whitedist_checkbox.isChecked()
r["graydist"] = self.graydist_checkbox.isChecked()
r["stem"] = self.stem_checkbox.isChecked()
# r["blackdist"] = self.blackdist_checkbox.isChecked()
# r["whitedist"] = self.whitedist_checkbox.isChecked()
# r["graydist"] = self.graydist_checkbox.isChecked()
r["shift"] = self.shift_checkbox.isChecked()
r["align"] = self.align_checkbox.isChecked()
r["interpolate"] = self.interpolate_checkbox.isChecked()
Expand All @@ -842,9 +849,10 @@ def fixup(self) -> None:
def refresh(self) -> None:
self.ignore_signal = True
self.anchor_checkbox.setChecked(self.defaults.rounding_state("anchor"))
self.blackdist_checkbox.setChecked(self.defaults.rounding_state("blackdist"))
self.whitedist_checkbox.setChecked(self.defaults.rounding_state("whitedist"))
self.graydist_checkbox.setChecked(self.defaults.rounding_state("graydist"))
self.stem_checkbox.setChecked(self.defaults.rounding_state("stem"))
# self.blackdist_checkbox.setChecked(self.defaults.rounding_state("blackdist"))
# self.whitedist_checkbox.setChecked(self.defaults.rounding_state("whitedist"))
# self.graydist_checkbox.setChecked(self.defaults.rounding_state("graydist"))
self.shift_checkbox.setChecked(self.defaults.rounding_state("shift"))
self.align_checkbox.setChecked(self.defaults.rounding_state("align"))
self.interpolate_checkbox.setChecked(
Expand Down
2 changes: 1 addition & 1 deletion src/ygt/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# FileNameVar = TypeVar("FileNameVar", str, tuple[str, Any])
FileNameVar = Union[str, tuple[str, Any]]
# FileNameVar = Any
ygt_version = "0.2.6"
ygt_version = "0.2.7"


class ygPreviewFontMaker(QThread):
Expand Down
127 changes: 66 additions & 61 deletions src/ygt/ygHintEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@
"shift": HINT_SHIFT_COLOR,
"interpolate": HINT_INTERPOLATE_COLOR,
"stem": HINT_STEM_COLOR,
"whitedist": HINT_STEM_COLOR,
"blackdist": HINT_STEM_COLOR,
"graydist": HINT_STEM_COLOR,
# "whitedist": HINT_STEM_COLOR,
# "blackdist": HINT_STEM_COLOR,
# "graydist": HINT_STEM_COLOR,
"move": HINT_STEM_COLOR,
"macro": HINT_FUNC_COLOR,
"function": HINT_FUNC_COLOR,
Expand All @@ -162,9 +162,9 @@
"shift": HINT_SHIFT_DARK,
"interpolate": HINT_INTERPOLATE_DARK,
"stem": HINT_STEM_DARK,
"whitedist": HINT_STEM_DARK,
"blackdist": HINT_STEM_DARK,
"graydist": HINT_STEM_DARK,
# "whitedist": HINT_STEM_DARK,
# "blackdist": HINT_STEM_DARK,
# "graydist": HINT_STEM_DARK,
"move": HINT_STEM_DARK,
"macro": HINT_FUNC_DARK,
"function": HINT_FUNC_DARK,
Expand All @@ -178,9 +178,9 @@
"shift": HINT_SHIFT_SELECT_COLOR,
"interpolate": HINT_INTERPOLATE_SELECT_COLOR,
"stem": HINT_STEM_SELECT_COLOR,
"whitedist": HINT_STEM_SELECT_COLOR,
"blackdist": HINT_STEM_SELECT_COLOR,
"graydist": HINT_STEM_SELECT_COLOR,
# "whitedist": HINT_STEM_SELECT_COLOR,
# "blackdist": HINT_STEM_SELECT_COLOR,
# "graydist": HINT_STEM_SELECT_COLOR,
"move": HINT_STEM_SELECT_COLOR,
"macro": HINT_FUNC_SELECT_COLOR,
"function": HINT_FUNC_SELECT_COLOR,
Expand All @@ -192,9 +192,9 @@
"shift": HINT_SHIFT_SELECT_DARK,
"interpolate": HINT_INTERPOLATE_SELECT_DARK,
"stem": HINT_STEM_SELECT_DARK,
"whitedist": HINT_STEM_SELECT_DARK,
"blackdist": HINT_STEM_SELECT_DARK,
"graydist": HINT_STEM_SELECT_DARK,
# "whitedist": HINT_STEM_SELECT_DARK,
# "blackdist": HINT_STEM_SELECT_DARK,
# "graydist": HINT_STEM_SELECT_DARK,
"move": HINT_STEM_SELECT_DARK,
"macro": HINT_FUNC_SELECT_DARK,
"function": HINT_FUNC_SELECT_DARK,
Expand Down Expand Up @@ -839,10 +839,10 @@ def _prepare_graphics(self, **kwargs) -> None:
pen.setColor(SELECTED_HINT_COLOR[hint_type])
else:
pen.setColor(HINT_COLOR[hint_type])
if hint_type == "whitedist":
pen.setDashPattern([2, 2])
if hint_type == "graydist":
pen.setDashPattern([4, 2])
# if hint_type == "whitedist":
# pen.setDashPattern([2, 2])
# if hint_type == "graydist":
# pen.setDashPattern([4, 2])
self.setPen(pen)

def find_mid_point(self, pt1: QPointF, pt2: QPointF) -> QPointF:
Expand Down Expand Up @@ -2487,15 +2487,17 @@ def make_hint_from_selection(
self.sig_new_hint.emit(new_yg_hint)
if hint_type_num in [1, 3]:
if pplen >= 2:
try:
if hint_type_num == 3:
hint_type = stemFinder(
self._model_point(pp[0]),
self._model_point(pp[1]),
self.yg_glyph,
).get_color()
except Exception as e:
print(e)
# try:
# if hint_type_num == 3:
# hint_type = stemFinder(
# self._model_point(pp[0]),
# self._model_point(pp[1]),
# self.yg_glyph,
# ).get_color()
# except Exception as e:
# print(e)
if hint_type_num == 3:
hint_type = "stem"
ref_name = ""
target_names = []
for ppp in pp:
Expand Down Expand Up @@ -2551,6 +2553,7 @@ def make_hint_from_selection(
h = {"ptid": tgt, "ref": touched_names, "rel": hint_type} # type: ignore
new_yg_hint = ygHint(self.yg_glyph, h)
else:
# Are we handling a case here that will never happen?
newlist = []
for p in pp:
newlist.append(self._model_point(p))
Expand Down Expand Up @@ -2727,7 +2730,7 @@ def contextMenuEvent(self, event) -> None:
cv_anchor_action_list = []
cv_stem_action_list = []
point_param_list = []
black_space = white_space = gray_space = None
#black_space = white_space = gray_space = None

cmenu.addSeparator()

Expand Down Expand Up @@ -2821,34 +2824,35 @@ def contextMenuEvent(self, event) -> None:

hint_color_menu = cmenu.addMenu("Set distance type...")

no_color_menu = hint == None or ntype != 3

black_space = QAction("Black", self, checkable=True) # type: ignore
if hint != None:
if hint.yg_hint.hint_type in ["stem", "blackdist"]:
black_space.setChecked(True)
hint_color_menu.addAction(black_space)
if no_color_menu:
black_space.setEnabled(False)
black_space.setVisible(False)

white_space = QAction("White", self, checkable=True) # type: ignore
if hint != None:
if hint.yg_hint.hint_type == "whitedist":
white_space.setChecked(True)
hint_color_menu.addAction(white_space)
if no_color_menu:
white_space.setEnabled(False)
white_space.setVisible(False)

gray_space = QAction("Gray", self, checkable=True) # type: ignore
if hint != None:
if hint.yg_hint.hint_type == "graydist":
gray_space.setChecked(True)
hint_color_menu.addAction(gray_space)
if no_color_menu:
gray_space.setEnabled(False)
gray_space.setVisible(False)
#no_color_menu = hint == None or ntype != 3
no_color_menu = True

# black_space = QAction("Black", self, checkable=True) # type: ignore
# if hint != None:
# if hint.yg_hint.hint_type in ["stem", "blackdist"]:
# black_space.setChecked(True)
# hint_color_menu.addAction(black_space)
# if no_color_menu:
# black_space.setEnabled(False)
# black_space.setVisible(False)

# white_space = QAction("White", self, checkable=True) # type: ignore
# if hint != None:
# if hint.yg_hint.hint_type == "whitedist":
# white_space.setChecked(True)
# hint_color_menu.addAction(white_space)
# if no_color_menu:
# white_space.setEnabled(False)
# white_space.setVisible(False)

# gray_space = QAction("Gray", self, checkable=True) # type: ignore
# if hint != None:
# if hint.yg_hint.hint_type == "graydist":
# gray_space.setChecked(True)
# hint_color_menu.addAction(gray_space)
# if no_color_menu:
# gray_space.setEnabled(False)
# gray_space.setVisible(False)

if no_color_menu:
a = hint_color_menu.menuAction()
Expand Down Expand Up @@ -3022,12 +3026,12 @@ def contextMenuEvent(self, event) -> None:
self.yg_glyph.send_error_message(
{"msg": self.cv_error_msg, "mode": "console"}
)
if hint and ntype == 3 and (action == black_space):
self.sig_change_hint_color.emit({"hint": hint, "color": "blackdist"})
if hint and ntype == 3 and (action == white_space):
self.sig_change_hint_color.emit({"hint": hint, "color": "whitedist"})
if hint and ntype == 3 and (action == gray_space):
self.sig_change_hint_color.emit({"hint": hint, "color": "graydist"})
# if hint and ntype == 3 and (action == black_space):
# self.sig_change_hint_color.emit({"hint": hint, "color": "blackdist"})
# if hint and ntype == 3 and (action == white_space):
# self.sig_change_hint_color.emit({"hint": hint, "color": "whitedist"})
# if hint and ntype == 3 and (action == gray_space):
# self.sig_change_hint_color.emit({"hint": hint, "color": "graydist"})
if hint and ntype == 4 and (action == add_params):
self.sig_edit_macfunc_params.emit(hint)
if action in macro_actions:
Expand Down Expand Up @@ -3220,7 +3224,8 @@ def make_hint_from_selection(self) -> None:
"Align (L)": "align",
"Shift (H)": "shift",
"Interpolate (I)": "interpolate",
"Stem (T)": "graydist",
#"Stem (T)": "graydist",
"Stem (T)": "stem",
}
with_ctrl = (
QApplication.keyboardModifiers() & Qt.KeyboardModifier.ControlModifier
Expand Down
15 changes: 11 additions & 4 deletions src/ygt/ygModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from PyQt6.QtGui import QUndoCommand, QUndoStack, QAction
from fontTools import ttLib, ufoLib # type: ignore
import yaml
from yaml import Dumper
from yaml import Dumper, parse
import os
import pathlib
import uuid
Expand All @@ -29,15 +29,19 @@
import defcon # type: ignore
from ufo2ft import compileTTF # type: ignore

obsolete_hint_types = [
"blackdist", "whitedist", "graydist"
]

hint_type_nums = {
"anchor": 0,
"align": 1,
"shift": 1,
"interpolate": 2,
"stem": 3,
"whitedist": 3,
"blackdist": 3,
"graydist": 3,
# "whitedist": 3,
# "blackdist": 3,
# "graydist": 3,
"move": 3,
"macro": 4,
"function": 4,
Expand Down Expand Up @@ -2731,6 +2735,9 @@ def _yaml_hint_type(self, n) -> str:
if "macro" in n:
return "macro"
if "rel" in n:
#if n["rel"] == "blackdist" or n["rel"] == "whitedist" or n["rel"] == "graydist":
if n["rel"] in obsolete_hint_types:
n["rel"] = "stem"
return n["rel"]
return "anchor"

Expand Down
Loading

0 comments on commit 519d3e6

Please sign in to comment.