def __init__(self, fh, length): PackedFormat.__init__(self, fh) self.char_map = {} self.glyph_map = {} mapping = read_list_uint16(fh, self.entry_count) for n in range(self.entry_count): self.char_map[n] = mapping[n] self.glyph_map.setdefault(mapping[n], []).append(n)
def __init__(self, fh=None, length=None): start = fh.tell() - 4 PackedFormat.__init__(self, fh) if fh is None: return self.ranges = [] end_codes = read_list_uint16(fh, self.seg_count + 1) if end_codes[self.seg_count] != 0: print("INVALID pad byte....") return start_codes = read_list_uint16(fh, self.seg_count) iddelta = read_list_int16(fh, self.seg_count) offset_start = fh.tell() id_offset = read_list_uint16(fh, self.seg_count) ids_length = int((length - (fh.tell() - start)) / 2) self.glyph_ids = read_list_uint16(fh, ids_length) for n in range(self.seg_count): self.ranges.append( self.CMAPRange(start_codes[n], end_codes[n], iddelta[n], id_offset[n], self.seg_count - n))
def __init__(self, fh=None, num=0, data=None): self.glyph = num self.components = [] self.required = set() PackedFormat.__init__(self, fh=fh, data=data) # If the glyph is a compound glyph, ie it's made up of parts of other glyphs, # then we need to ensure we have all the component glyphs listed. if self.contours < 0: while True: (flags, next_glyph) = read_list_uint16(fh, 2) self.required.add(next_glyph) fh.read(calcsize(glyf_skip_format(flags))) if not glyph_more_components(flags): break
def __init__(self, fh=None, length=0): self.count = 0 if fh: start_pos = fh.tell() PackedFormat.__init__(self, fh) self.tables = {} self.map_table = None if self.count == 0: return for n in range(self.count): tbl = TTFcmapTable(fh) self.tables[(tbl.platform_id, tbl.encoding_id)] = tbl pos = fh.tell() fh.seek(start_pos + tbl.offset) tbl.format, length = read_list_uint16(fh, 2) if tbl.format == 4: tbl.map_data = TTF_cmap4(fh, length) elif tbl.format == 6: tbl.map_data = TTF_cmap6(fh, length) fh.seek(pos) # Choose the mapping we are going to use, initially on preferences and # then just fallback to first available map. for p in self.PREFS: if p in self.tables and self.tables[p].has_map_data: self.map_table = self.tables[p].map_data break if self.map_table is None: for t in self.tables.values(): if t.has_map_data: self.map_table = t.map_data break
def _read_list_uint16(self, n): return read_list_uint16(self.file_handle, n)