Пример #1
0
 def __init__(self, name, glyph_map, compress=False):
     Stream.__init__(self, compress)
     current_map = OrderedDict()
     maps = []
     for glyph_id in sorted(glyph_map):
         if len(current_map) > 99:
             maps.append(current_map)
             current_map = OrderedDict()
         val = []
         for c in glyph_map[glyph_id]:
             c = ord(c)
             val.append(to_hex_string(c))
         glyph_id = '<%s>'%to_hex_string(glyph_id)
         current_map[glyph_id] = '<%s>'%''.join(val)
     if current_map:
         maps.append(current_map)
     mapping = []
     for m in maps:
         meat = '\n'.join('%s %s'%(k, v) for k, v in iteritems(m))
         mapping.append('%d beginbfchar\n%s\nendbfchar'%(len(m), meat))
     try:
         name = name.encode('ascii').decode('ascii')
     except Exception:
         name = uuid4()
     self.write(self.skeleton.format(name=name, mapping='\n'.join(mapping)))
Пример #2
0
 def __init__(self, name, glyph_map, compress=False):
     Stream.__init__(self, compress)
     current_map = OrderedDict()
     maps = []
     for glyph_id in sorted(glyph_map):
         if len(current_map) > 99:
             maps.append(current_map)
             current_map = OrderedDict()
         val = []
         for c in glyph_map[glyph_id]:
             c = ord(c)
             val.append(to_hex_string(c))
         glyph_id = '<%s>'%to_hex_string(glyph_id)
         current_map[glyph_id] = '<%s>'%''.join(val)
     if current_map:
         maps.append(current_map)
     mapping = []
     for m in maps:
         meat = '\n'.join('%s %s'%(k, v) for k, v in iteritems(m))
         mapping.append('%d beginbfchar\n%s\nendbfchar'%(len(m), meat))
     try:
         name = name.encode('ascii').decode('ascii')
     except Exception:
         name = uuid4()
     self.write(self.skeleton.format(name=name, mapping='\n'.join(mapping)))
Пример #3
0
 def __init__(self, cache_key, matrix, w=8, h=8, paint_type=2, compress=False):
     Stream.__init__(self, compress=compress)
     self.paint_type = paint_type
     self.w, self.h = w, h
     self.matrix = (matrix.m11(), matrix.m12(), matrix.m21(), matrix.m22(),
                    matrix.dx(), matrix.dy())
     self.resources = Dictionary()
     self.cache_key = (self.__class__.__name__, cache_key, self.matrix)
Пример #4
0
 def __init__(self, data, w, h, depth, mask, soft_mask, dct):
     Stream.__init__(self)
     self.width, self.height, self.depth = w, h, depth
     self.mask, self.soft_mask = mask, soft_mask
     if dct:
         self.filters.append(Name('DCTDecode'))
     else:
         self.compress = True
     self.write(data)
Пример #5
0
 def __init__(self, data, w, h, depth, mask, soft_mask, dct):
     Stream.__init__(self)
     self.width, self.height, self.depth = w, h, depth
     self.mask, self.soft_mask = mask, soft_mask
     if dct:
         self.filters.append(Name('DCTDecode'))
     else:
         self.compress = True
     self.write(data)
Пример #6
0
 def __init__(self, is_otf, compress=False):
     Stream.__init__(self, compress=compress)
     self.is_otf = is_otf
Пример #7
0
 def __init__(self, mi):
     Stream.__init__(self)
     from calibre.ebooks.metadata.xmp import metadata_to_xmp_packet
     self.write(metadata_to_xmp_packet(mi))
Пример #8
0
 def __init__(self, is_otf, compress=False):
     Stream.__init__(self, compress=compress)
     self.is_otf = is_otf
Пример #9
0
 def __init__(self, mi):
     Stream.__init__(self)
     from calibre.ebooks.metadata.xmp import metadata_to_xmp_packet
     self.write(metadata_to_xmp_packet(mi))