Beispiel #1
0
    def load_extra(line):
        nonlocal ver1_unicodes
        words = line.split()

        if len(words) < 2:
            raise Exception('invalid format')

        uni = fnutil.parse_hex('unicode', words[0])

        if uni == 0xFFFE:
            raise Exception('FFFE is not a character')

        if next((char for char in font.chars if char.code == uni), None):
            if uni > fnutil.UNICODE_BMP_MAX:
                ver1_unicodes = False

            if uni not in tables:
                tables[uni] = []

            table = tables[uni]

            for word in words[1:]:
                dup = fnutil.parse_hex('extra code', word)

                if dup == 0xFFFF:
                    raise Exception('FFFF is not a character')

                if dup > fnutil.UNICODE_BMP_MAX:
                    ver1_unicodes = False

                if not dup in table or 0xFFFE in table:
                    tables[uni].append(dup)

            if version == 1 and not ver1_unicodes:
                raise Exception('-1 requires unicodes <= %X' %
                                fnutil.UNICODE_BMP_MAX)
Beispiel #2
0
 def parse(self, name, value, params):
     if name == '-d':
         params.dir_hint = fnutil.parse_dec('DIR-HINT', value, -2, 2)
     elif name == '-e':
         params.em_size = fnutil.parse_dec('EM-SIZE', value, EM_SIZE_MIN,
                                           EM_SIZE_MAX)
     elif name == '-g':
         params.line_gap = fnutil.parse_dec('LINE-GAP', value, 0,
                                            EM_SIZE_MAX << 1)
     elif name == '-l':
         params.low_ppem = fnutil.parse_dec('LOW-PPEM', value, 1,
                                            bdf.DPARSE_LIMIT)
     elif name == '-E':
         params.encoding = value
     elif name == '-W':
         params.w_lang_id = fnutil.parse_hex('WLANG-ID', value, 0, 0x7FFF)
     elif name == '-X':
         params.x_max_extent = False
     elif name == '-L':
         params.single_loca = True
     elif name == '-P':
         params.post_names = True
     else:
         self.fallback(name, params)
 def load_code(line):
     new_codes.append(fnutil.parse_hex('unicode', line))