MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / createType1Descriptor

Method createType1Descriptor

lib/matplotlib/backends/backend_pdf.py:1030–1098  ·  view source on GitHub ↗
(self, t1font, fontfile=None)

Source from the content-addressed store, hash-verified

1028
1029 @_api.delete_parameter("3.11", "fontfile")
1030 def createType1Descriptor(self, t1font, fontfile=None):
1031 # Create and write the font descriptor and the font file
1032 # of a Type-1 font
1033 fontdescObject = self.reserveObject('font descriptor')
1034 fontfileObject = self.reserveObject('font file')
1035
1036 italic_angle = t1font.prop['ItalicAngle']
1037 fixed_pitch = t1font.prop['isFixedPitch']
1038
1039 flags = 0
1040 # fixed width
1041 if fixed_pitch:
1042 flags |= 1 << 0
1043 # TODO: serif
1044 if 0:
1045 flags |= 1 << 1
1046 # TODO: symbolic (most TeX fonts are)
1047 if 1:
1048 flags |= 1 << 2
1049 # non-symbolic
1050 else:
1051 flags |= 1 << 5
1052 # italic
1053 if italic_angle:
1054 flags |= 1 << 6
1055 # TODO: all caps
1056 if 0:
1057 flags |= 1 << 16
1058 # TODO: small caps
1059 if 0:
1060 flags |= 1 << 17
1061 # TODO: force bold
1062 if 0:
1063 flags |= 1 << 18
1064
1065 encoding = t1font.prop['Encoding']
1066 charset = ''.join(
1067 sorted(
1068 f'/{c}' for c in encoding.values()
1069 if c != '.notdef'
1070 )
1071 )
1072
1073 descriptor = {
1074 'Type': Name('FontDescriptor'),
1075 'FontName': Name(t1font.prop['FontName']),
1076 'Flags': flags,
1077 'FontBBox': t1font.prop['FontBBox'],
1078 'ItalicAngle': italic_angle,
1079 'Ascent': t1font.prop['FontBBox'][3],
1080 'Descent': t1font.prop['FontBBox'][1],
1081 'CapHeight': 1000, # TODO: find this out
1082 'XHeight': 500, # TODO: this one too
1083 'FontFile': fontfileObject,
1084 'FontFamily': t1font.prop['FamilyName'],
1085 'StemV': 50, # TODO
1086 'CharSet': charset,
1087 # (see also revision 3874; but not all TeX distros have AFM files!)

Callers 1

_embedTeXFontMethod · 0.95

Calls 6

reserveObjectMethod · 0.95
writeObjectMethod · 0.95
outputStreamMethod · 0.95
NameClass · 0.85
joinMethod · 0.80
valuesMethod · 0.80

Tested by

no test coverage detected