def _convertFont(self, font, verbose): """ Convert parsed QFont to NGL_Font object """ # charters set to converting char_range = range(ord(" "), ord("~")) chars_sets = "".join([chr(x) for x in char_range]) if verbose: inform("converting font %s, %spt, bold %s" % (font.family(), font.pointSize(), font.bold())) name = NGL_Font.formatName(font.family(), font.pointSize(), font.bold()) # convert and return return NFontConverter.convertQFont(chars_sets, name, font)
def _convertFont(self, font, verbose): """ Convert parsed QFont to NGL_Font object """ # charters set to converting char_range = range(ord(' '), ord('~')) chars_sets = ''.join([chr(x) for x in char_range]) if verbose: inform( 'converting font %s, %spt, bold %s' % (font.family(), font.pointSize(), font.bold())) name = NGL_Font.formatName(font.family(), font.pointSize(), font.bold()) # convert and return return NFontConverter.convertQFont(chars_sets, name, font)
def __init__(self, name, dataSlot=None, parent=None): """ Constructor """ super(NFontConverterWidget, self).__init__(parent) self.settings = QSettings('NeilLab', 'NGL Font') # load main ui window uifile = pkg_resources.resource_filename('ngl_utils.nfont', 'qtres/ngl_font.ui') self.uic = uic.loadUi(uifile, self) self.nfont_view = CodeView_Window(self) self.sysFont_dialog = QFontDialog(self) # def sysfont and font name self.font = QFont('Times', 8) self.NGL_Font = None fname = NGL_Font.formatName(self.font.family(), self.font.pointSize(), self.font.bold()) self.lineEdit_fontName.setText(fname) # generates chars set for combobox self._charstersRangesInit() # font edit widget self.edit_view = NFontEditWidget('__util__') # connect signals / slots self.tBtn_Font.clicked.connect(self._selectFont_slot) self.tBtn_AddChars.clicked.connect(self._add_chars_slot) self.tBtn_Convert.clicked.connect(self._convert_slot) self.tBtn_Save.clicked.connect(self._saveAs_slot) self.tBtn_ViewOut.clicked.connect(self._view_out_slot) self.tBtn_Edit.clicked.connect(self._edit_font_slot) if name == '__main__': self.tBtn_Close.setText('Close') self.tBtn_Close.clicked.connect(self._close_slot) else: self.tBtn_Close.setText('Add') self.tBtn_Close.clicked.connect(self._ok_slot) self.connectDataReadySlot(dataSlot) # set window to center and show self.frameGeometry().moveCenter( QDesktopWidget().availableGeometry().center())
def _ngl_font_name(self): if self.font: return NGL_Font.formatName(self.font.family(), self.font.pointSize(), self.font.bold()) else: return ""