diff --git a/src/ygt/freetypeFont.py b/src/ygt/freetypeFont.py index a41b892..e8a3102 100644 --- a/src/ygt/freetypeFont.py +++ b/src/ygt/freetypeFont.py @@ -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): @@ -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"]): diff --git a/src/ygt/harfbuzzFont.py b/src/ygt/harfbuzzFont.py index 871c310..7ca5ecb 100644 --- a/src/ygt/harfbuzzFont.py +++ b/src/ygt/harfbuzzFont.py @@ -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() diff --git a/src/ygt/window.py b/src/ygt/window.py index 015effa..6ad84b5 100755 --- a/src/ygt/window.py +++ b/src/ygt/window.py @@ -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() @@ -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() diff --git a/src/ygt/ygStems.py b/src/ygt/ygStems.py index aafd25b..33c23f0 100644 --- a/src/ygt/ygStems.py +++ b/src/ygt/ygStems.py @@ -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: \ No newline at end of file