MCPcopy Index your code
hub / github.com/clips/pattern / PDFType1Font

Class PDFType1Font

pattern/web/pdf/pdffont.py:538–566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

536
537# PDFType1Font
538class PDFType1Font(PDFSimpleFont):
539
540 def __init__(self, rsrcmgr, spec):
541 try:
542 self.basefont = literal_name(spec['BaseFont'])
543 except KeyError:
544 if STRICT:
545 raise PDFFontError('BaseFont is missing')
546 self.basefont = 'unknown'
547 try:
548 (descriptor, widths) = FontMetricsDB.get_metrics(self.basefont)
549 except KeyError:
550 descriptor = dict_value(spec.get('FontDescriptor', {}))
551 firstchar = int_value(spec.get('FirstChar', 0))
552 lastchar = int_value(spec.get('LastChar', 255))
553 widths = list_value(spec.get('Widths', [0]*256))
554 widths = dict( (i+firstchar,w) for (i,w) in enumerate(widths) )
555 PDFSimpleFont.__init__(self, descriptor, widths, spec)
556 if 'Encoding' not in spec and 'FontFile' in descriptor:
557 # try to recover the missing encoding info from the font file.
558 self.fontfile = stream_value(descriptor.get('FontFile'))
559 length1 = int_value(self.fontfile['Length1'])
560 data = self.fontfile.get_data()[:length1]
561 parser = Type1FontHeaderParser(StringIO(data))
562 self.cid2unicode = parser.get_encoding()
563 return
564
565 def __repr__(self):
566 return '<PDFType1Font: basefont=%r>' % self.basefont
567
568# PDFTrueTypeFont
569class PDFTrueTypeFont(PDFType1Font):

Callers 1

get_fontMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…