@@ -89,7 +89,16 @@ def load_glyphs(self, code_points):
89
89
current_info = {}
90
90
current_y = 0
91
91
rounded_x = 1
92
- total_remaining = len (code_points )
92
+ if isinstance (code_points , int ):
93
+ remaining = set ()
94
+ remaining .add (code_points )
95
+ else :
96
+ remaining = set (code_points )
97
+ for code_point in remaining :
98
+ if code_point in self ._glyphs and self ._glyphs [code_point ]:
99
+ remaining .remove (code_point )
100
+ if not remaining :
101
+ return
93
102
94
103
x , _ , _ , _ = self .get_bounding_box ()
95
104
@@ -113,6 +122,7 @@ def load_glyphs(self, code_points):
113
122
if desired_character :
114
123
bounds = current_info ["bounds" ]
115
124
shift = current_info ["shift" ]
125
+ gc .collect ()
116
126
self ._glyphs [code_point ] = Glyph (current_info ["bitmap" ],
117
127
0 ,
118
128
bounds [0 ],
@@ -121,8 +131,8 @@ def load_glyphs(self, code_points):
121
131
bounds [3 ],
122
132
shift [0 ],
123
133
shift [1 ])
124
- gc . collect ( )
125
- if total_remaining == 0 :
134
+ remaining . remove ( code_point )
135
+ if not remaining :
126
136
return
127
137
desired_character = False
128
138
elif line .startswith (b"BBX" ):
@@ -146,11 +156,9 @@ def load_glyphs(self, code_points):
146
156
elif line .startswith (b"ENCODING" ):
147
157
_ , code_point = line .split ()
148
158
code_point = int (code_point )
149
- if code_point == code_points or code_point in code_points :
150
- total_remaining -= 1
151
- if code_point not in self ._glyphs or not self ._glyphs [code_point ]:
152
- desired_character = True
153
- current_info = {"bitmap" : None , "bounds" : None , "shift" : None }
159
+ if code_point in remaining :
160
+ desired_character = True
161
+ current_info = {"bitmap" : None , "bounds" : None , "shift" : None }
154
162
elif line .startswith (b"DWIDTH" ):
155
163
if desired_character :
156
164
_ , shift_x , shift_y = line .split ()
0 commit comments