| 536 | |
| 537 | # PDFType1Font |
| 538 | class 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 |
| 569 | class PDFTrueTypeFont(PDFType1Font): |
no outgoing calls
no test coverage detected
searching dependent graphs…