def _convert_slot(self): """ Start converting slot """ chars_sets = str(self.txtBrowser_chars.toPlainText()) if chars_sets: gtime = time.time() # converting to ngl font name = self.lineEdit_fontName.text() self.NGL_Font = NFontConverter.convertQFont( chars_sets, name, self.font) ch_list = self.NGL_Font.get_chars_list() gtime = time.time() - gtime self.lbl_gen_time.setText( 'converted at: %.2f sec | estimate code size: ~%0.3fk' % (gtime, self.NGL_Font.code_size_calc() / 1000)) self.lbl_gen_time.update() else: QMessageBox.critical( self, 'ERROR', """ Nothing to convert! Add singles char or characters set to textbox first""")
def _reGenerateFont(self): # regenerate 'code' and 'offset' fo chars offset = 0 for ch in self.ngl_font.get_chars_list(): ch['code'], _offset = NFontConverter.font_bmpCode(ch['bitmap']) ch['offset'] = offset offset += _offset # generate code for font, return result font self.ngl_font.code = NFontCodeGen.font(self.ngl_font) return self.ngl_font
def _reGenerateFont(self): # regenerate 'code' and 'offset' fo chars offset = 0 for ch in self.ngl_font.get_chars_list(): ch['code'], _offset = NFontConverter.font_bmpCode(ch['bitmap']) ch['offset'] = offset offset += _offset # generate code for font, return result font self.ngl_font.code = NFontCodeGen.font( self.ngl_font ) return self.ngl_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 _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 parseFile(self, fontfile): if fontfile: with open(fontfile, 'r') as f: code = f.read() _description = self._getFontDescription(code) _name = self._parseName(_description).replace('Info', '') _start_char, _end_char = self._parseStartEndChars(_description) _pchars = self._parseChars(code) # crate NGL Font ngl_font = NGL_Font(_name) # add chars bitmaps to font offset = 0 for pch in _pchars: _, ch_offset = NFontConverter.font_bmpCode(pch['bitmap']) ngl_font.add_char(pch['char'], None, offset, pch['bitmap']) offset += ch_offset return ngl_font
def parseFile(self, fontfile): if fontfile: with open(fontfile, 'r') as f: code = f.read() _description = self._getFontDescription( code ) _name = self._parseName( _description ).replace('Info', '') _start_char, _end_char = self._parseStartEndChars( _description ) _pchars = self._parseChars( code ) # crate NGL Font ngl_font = NGL_Font( _name ) # add chars bitmaps to font offset = 0 for pch in _pchars: _, ch_offset = NFontConverter.font_bmpCode( pch['bitmap'] ) ngl_font.add_char( pch['char'], None, offset, pch['bitmap'] ) offset += ch_offset return ngl_font