def convertQFont(chars_sets, name, font): NFontConverter.font = font # font.setHintingPreference( QFont.PreferNoHinting ) # font.setStyleHint( QFont.SansSerif ) font.setStyleStrategy(QFont.NoAntialias | QFont.PreferQuality) # create NGL_Font and generate all chars code nfont = NGL_Font(name, font) offset = 0 for char in chars_sets: ch_bmp = NFontConverter.font_charBmp(font, char) ch_code, ch_offset = NFontConverter.font_bmpCode(ch_bmp) nfont.add_char(char, ch_code, offset, ch_bmp) offset += ch_offset # generate code text out nfont.code = NFontCodeGen.font(nfont) return nfont
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