Skip to content

Commit

Permalink
Improved file opening; other small revisions.
Browse files Browse the repository at this point in the history
  • Loading branch information
psb1558 committed Jan 4, 2025
1 parent d41d3aa commit 2661afe
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
10 changes: 1 addition & 9 deletions src/ygt/freetypeFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,6 @@ def _get_bitmap_metrics(self):
r["advance"] = round(self.glyph_slot.advance.x / 64)
return r

#def glyph_bit(self, x, y):
# pitch = abs(self.glyph_slot.bitmap.pitch)
# row = self.glyph_slot.bitmap.buffer[pitch * y::]
# cValue = row[x >> 3]
# return cValue & (128 >> (x & 7)) != 0

def monomap_to_array(self, bitmap):
data = [0] * (bitmap.rows * bitmap.width)
for y in range(bitmap.rows):
Expand Down Expand Up @@ -342,10 +336,8 @@ def _draw_char_mono(
gdata["advance"] = self.advance = gdata["width"] + 4
else:
starting_xpos = xpos = (x + gdata["bitmap_left"]) + x_offset
qp = QPen(QColor("black"))
qp = QPen(QColor("white") if dark_theme else QColor("black"))
qp.setWidth(1)
on_pixel = QColor("white") if dark_theme else QColor("black")
qp.setColor(QColor(on_pixel))
painter.setPen(qp)
bytestepper = 0
for r in range(gdata["rows"]):
Expand Down
2 changes: 0 additions & 2 deletions src/ygt/harfbuzzFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,6 @@ def __init__(self, top_window, hb_font):
self.feature_list = []
for s in self.hb_font._sub_features:
self.feature_list.append(harfbuzzFont.expanded_feature_name(s))
#for s in self.hb_font._pos_features:
# self.feature_list.append(harfbuzzFont.expanded_feature_name(s))
self.feature_list = sorted(self.feature_list)
if len(self.feature_list):
self.feature_box = QComboBox()
Expand Down
33 changes: 21 additions & 12 deletions src/ygt/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1315,20 +1315,31 @@ def open_recent(self) -> None:
@pyqtSlot()
def open_file(self) -> None:
f: FileNameVar = QFileDialog.getOpenFileName(
self, "Open TrueType font or YAML file", "", "Files (*.ttf *.ufo *.yaml)"
self, "Open TrueType font, UFO, or YAML file", "", "Files (*.ttf *.ufo *.yaml)"
)
result = 1
try:
os.chdir(os.path.split(f[0])[0])
result = self._open(f)
# We get an empty string if user clicked "Cancel." In that case, do nothing.
# If file does not exist, display error message and then do nothing.
if len(f[0]) > 0:
if os.path.exists(f[0]):
os.chdir(os.path.split(f[0])[0])
result = self._open(f)
else:
emsg = "file " + f[0] + " does not exist."
result = 0
self.error_manager.new_message({"msg": emsg, "mode": "dialog"})
else:
result = 0
except FileNotFoundError:
emsg = "Can't find file '" + str(f) + "'."
# emsg = "Can't find file '" + str(f[0]) + "'."
if type(f) is tuple:
emsg += f[0]
fn = f[0]
elif type(f) is str:
emsg += f
fn = f
else:
emsg += str(f)
fn = str(f)
emsg = "Can't find file '" + fn + "'."
self.error_manager.new_message({"msg": emsg, "mode": "console"})
if result == 1:
self.set_preferences()
Expand Down Expand Up @@ -1615,15 +1626,13 @@ def set_status_validity_msg(self, t: str) -> None:
@pyqtSlot()
def show_about_dialog(self) -> None:
msg = QMessageBox(self)
msg.setStyleSheet("QLabel{min-width: 350px;}")
msg.setWindowTitle("About YGT")
msg.setText("YGT " + ygt_version)
detailed_text = "TrueType Hint Editor.\n"
detailed_text += "Copyright © 2024 by Peter S. Baker.\n"
msg.setText("YGT TrueType Hint Editor v. " + ygt_version)
detailed_text = "Copyright © 2024 by Peter S. Baker.\n"
detailed_text += "Apache License, version 2.0. \n\n"
detailed_text += "For further information, visit https://github.com/psb1558/ygt."
msg.setDetailedText(detailed_text)
# Will need to mess with size hints and policies to do this.
# msg.resize(round(msg.width() * 2), round(msg.height() * 2))
msg.setStandardButtons(QMessageBox.StandardButton.NoButton)
msg.exec()

Expand Down
6 changes: 6 additions & 0 deletions src/ygt/ygStems.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,9 @@ def get_color(self) -> str:
result = "whitedist"
return result


# class horizontalSegmentList:
# def __init__(self, c: List[ygPoint]):
# self.pt_list = []
# found_points = []
# for p in c:

0 comments on commit 2661afe

Please sign in to comment.