| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1c881a3 commit c4e54cf
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + *fontfile* parameter of ``PdfFile.createType1Descriptor`` | ||
| 2 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 3 | + This parameter is deprecated; all relevant pieces of information are now | ||
| 4 | + directly extracted from the *t1font* argument. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -579,6 +579,16 @@ def _parse(self): | |||
| 579 | 579 | extras = ('(?i)([ -](regular|plain|italic|oblique|(semi)?bold|' | |
| 580 | 580 | '(ultra)?light|extra|condensed))+$') | |
| 581 | 581 | prop['FamilyName'] = re.sub(extras, '', prop['FullName']) | |
| 582 | + | ||
| 583 | + # Parse FontBBox | ||
| 584 | + toks = [*_tokenize(prop['FontBBox'].encode('ascii'), True)] | ||
| 585 | + if ([tok.kind for tok in toks] | ||
| 586 | + != ['delimiter', 'number', 'number', 'number', 'number', 'delimiter'] | ||
| 587 | + or toks[-1].raw != toks[0].opposite()): | ||
| 588 | + raise RuntimeError( | ||
| 589 | + f"FontBBox should be a size-4 array, was {prop['FontBBox']}") | ||
| 590 | + prop['FontBBox'] = [tok.value() for tok in toks[1:-1]] | ||
| 591 | + | ||
| 582 | 592 | # Decrypt the encrypted parts | |
| 583 | 593 | ndiscard = prop.get('lenIV', 4) | |
| 584 | 594 | cs = prop['CharStrings'] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1034,14 +1034,15 @@ def _embedTeXFont(self, fontinfo): | |||
| 1034 | 1034 | fontinfo.effects.get('extend', 1.0)) | |
| 1035 | 1035 | fontdesc = self._type1Descriptors.get((fontinfo.fontfile, effects)) | |
| 1036 | 1036 | if fontdesc is None: | |
| 1037 | - fontdesc = self.createType1Descriptor(t1font, fontinfo.fontfile) | ||
| 1037 | + fontdesc = self.createType1Descriptor(t1font) | ||
| 1038 | 1038 | self._type1Descriptors[(fontinfo.fontfile, effects)] = fontdesc | |
| 1039 | 1039 | fontdict['FontDescriptor'] = fontdesc | |
| 1040 | 1040 | ||
| 1041 | 1041 | self.writeObject(fontdictObject, fontdict) | |
| 1042 | 1042 | return fontdictObject | |
| 1043 | 1043 | ||
| 1044 | - def createType1Descriptor(self, t1font, fontfile): | ||
| 1044 | + @_api.delete_parameter("3.11", "fontfile") | ||
| 1045 | + def createType1Descriptor(self, t1font, fontfile=None): | ||
| 1045 | 1046 | # Create and write the font descriptor and the font file | |
| 1046 | 1047 | # of a Type-1 font | |
| 1047 | 1048 | fontdescObject = self.reserveObject('font descriptor') | |
@@ -1076,24 +1077,22 @@ def createType1Descriptor(self, t1font, fontfile): | |||
| 1076 | 1077 | if 0: | |
| 1077 | 1078 | flags |= 1 << 18 | |
| 1078 | 1079 | ||
| 1079 | - ft2font = get_font(fontfile) | ||
| 1080 | - | ||
| 1081 | 1080 | descriptor = { | |
| 1082 | 1081 | 'Type': Name('FontDescriptor'), | |
| 1083 | 1082 | 'FontName': Name(t1font.prop['FontName']), | |
| 1084 | 1083 | 'Flags': flags, | |
| 1085 | - 'FontBBox': ft2font.bbox, | ||
| 1084 | + 'FontBBox': t1font.prop['FontBBox'], | ||
| 1086 | 1085 | 'ItalicAngle': italic_angle, | |
| 1087 | - 'Ascent': ft2font.ascender, | ||
| 1088 | - 'Descent': ft2font.descender, | ||
| 1086 | + 'Ascent': t1font.prop['FontBBox'][3], | ||
| 1087 | + 'Descent': t1font.prop['FontBBox'][1], | ||
| 1089 | 1088 | 'CapHeight': 1000, # TODO: find this out | |
| 1090 | 1089 | 'XHeight': 500, # TODO: this one too | |
| 1091 | 1090 | 'FontFile': fontfileObject, | |
| 1092 | 1091 | 'FontFamily': t1font.prop['FamilyName'], | |
| 1093 | 1092 | 'StemV': 50, # TODO | |
| 1094 | 1093 | # (see also revision 3874; but not all TeX distros have AFM files!) | |
| 1095 | 1094 | # 'FontWeight': a number where 400 = Regular, 700 = Bold | |
| 1096 | - } | ||
| 1095 | + } | ||
| 1097 | 1096 | ||
| 1098 | 1097 | self.writeObject(fontdescObject, descriptor) | |
| 1099 | 1098 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments