@@ -2176,43 +2176,46 @@ def draw_text_woven(chunks):
2176
2176
- math .sin (a ), math .cos (a ),
2177
2177
x , y , Op .concat_matrix )
2178
2178
2179
- # Output all the 1-byte characters in a BT/ET group, then
2180
- # output all the 2-byte characters.
2181
- for mode in (1 , 2 ):
2182
- newx = oldx = 0
2183
- # Output a 1-byte character chunk
2184
- if mode == 1 :
2185
- self .file .output (Op .begin_text ,
2186
- self .file .fontName (prop ),
2187
- fontsize ,
2188
- Op .selectfont )
2189
-
2190
- for chunk_type , chunk in chunks :
2191
- if mode == 1 and chunk_type == 1 :
2192
- self ._setup_textpos (newx , 0 , 0 , oldx , 0 , 0 )
2193
- self .file .output (self .encode_string (chunk , fonttype ),
2194
- Op .show )
2195
- oldx = newx
2196
-
2197
- for char_idx , newx in _text_layout .layout (
2198
- chunk , font , x0 = newx , kern_mode = KERNING_UNFITTED ):
2199
-
2200
- if mode == 2 and chunk_type == 2 :
2201
- glyph_name = font .get_glyph_name (char_idx )
2202
- self .file .output (Op .gsave )
2203
- self .file .output (0.001 * fontsize , 0 ,
2204
- 0 , 0.001 * fontsize ,
2205
- newx , 0 , Op .concat_matrix )
2206
- name = self .file ._get_xobject_symbol_name (
2207
- font .fname , glyph_name )
2208
- self .file .output (Name (name ), Op .use_xobject )
2209
- self .file .output (Op .grestore )
2210
- newx += (
2211
- font .load_glyph (char_idx , flags = LOAD_NO_HINTING )
2212
- .linearHoriAdvance / 65536 )
2213
-
2214
- if mode == 1 :
2215
- self .file .output (Op .end_text )
2179
+ # Output all the 1-byte characters in a BT/ET group.
2180
+ self .file .output (Op .begin_text ,
2181
+ self .file .fontName (prop ),
2182
+ fontsize ,
2183
+ Op .selectfont )
2184
+ newx = oldx = 0
2185
+ for chunk_type , chunk in chunks :
2186
+ if chunk_type == 1 :
2187
+ self ._setup_textpos (newx , 0 , 0 , oldx , 0 , 0 )
2188
+ self .file .output (self .encode_string (chunk , fonttype ),
2189
+ Op .show )
2190
+ oldx = newx
2191
+ # Update newx to include the advance from this chunk,
2192
+ # regardless of its mode...
2193
+ for char_idx , char_x in _text_layout .layout (
2194
+ chunk , font , x0 = newx , kern_mode = KERNING_UNFITTED ):
2195
+ pass
2196
+ newx = char_x + ( # ... including the last character's advance
2197
+ font .load_glyph (char_idx , flags = LOAD_NO_HINTING )
2198
+ .linearHoriAdvance / 65536 )
2199
+ self .file .output (Op .end_text )
2200
+
2201
+ # Then output all the 2-byte characters.
2202
+ newx = 0
2203
+ for chunk_type , chunk in chunks :
2204
+ for char_idx , char_x in _text_layout .layout (
2205
+ chunk , font , x0 = newx , kern_mode = KERNING_UNFITTED ):
2206
+ if chunk_type == 2 :
2207
+ glyph_name = font .get_glyph_name (char_idx )
2208
+ self .file .output (Op .gsave )
2209
+ self .file .output (0.001 * fontsize , 0 ,
2210
+ 0 , 0.001 * fontsize ,
2211
+ char_x , 0 , Op .concat_matrix )
2212
+ name = self .file ._get_xobject_symbol_name (
2213
+ font .fname , glyph_name )
2214
+ self .file .output (Name (name ), Op .use_xobject )
2215
+ self .file .output (Op .grestore )
2216
+ newx = char_x + ( # ... including the last character's advance
2217
+ font .load_glyph (char_idx , flags = LOAD_NO_HINTING )
2218
+ .linearHoriAdvance / 65536 )
2216
2219
2217
2220
self .file .output (Op .grestore )
2218
2221
0 commit comments