Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Commitd9bc2db
committed
Improve usability of dviread.Text by third parties.
dviread.Text specifies individual glyphs in parsed dvi files; this isused by the pdf and svg backends (via textpath, for svg) to parse theresult of usetex-compiled strings and embed the right glyphs at theright places in the output file (as a reminder, agg currenly uses dvipngto rasterize the dvi file, and the ps backend relies on pstricks).Unfortunately, if third-party backends (e.g. mplcairo) want to do usethe same strategy as pdf/svg, then they need to jump through a few hoops(e.g. understand PsfontsMap and find_tex_font) and use some private APIs(_parse_enc), as explained below. Try to improve the situation, byadding some methods on the Text class (which may later allow deprecatingPsfontsMap and find_tex_font as public API).First, the actual font to be used is speficied via the `.font`attribute, which itself has a `.texname` which itself must be used asa key into `PsfontsMap(find_tex_font("pdftex.map"))` to get the actualfont path (and some other info). Instead, just provide a `.font_path`property. pdftex.map can also require that the font be "slanted" or"extended" (that's some of the "other info), lift that as well to`.font_effects`. The `.font` attribute has a `.size`; also we can liftup to `.font_size`. Altogether, this will allow making `.font` private(later) -- except for the fact that Text is a namedtuple so deprecatingfields is rather annoying.The trickiest part is actually specifying what glyph to select from thefont. dvi just gives us an integer, whose interpretation depends againon pdftex.map. If pdftex.map specifies "no encoding" for the font, thenthe integer is the "native glyph index" of the font, and should bepassed as-is to FreeType's FT_Load_Char (after selecting the nativecharmap). If pdftex.map does specify an encoding, then that's a filethat needs to be separately loaded, parsed (with _parse_enc), andultimately converts the index into a glyph name (which can be passed toFreeType's FT_Load_Glyph). Altogether, from the PoV of the end user,the "glyph specification" is thus either an int (a native charmap index)or a str (a glyph name); thus, provide `.glyph_spec` which is that API.As an example of using that API, see the changes to textpath.py.1 parent3a994d2 commitd9bc2db
3 files changed
+91
-56
lines changedLines changed: 61 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
61 |
| - | |
62 | 61 |
| |
63 | 62 |
| |
64 | 63 |
| |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
65 | 125 |
| |
66 | 126 |
| |
67 | 127 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
131 | 131 |
| |
132 | 132 |
| |
133 | 133 |
| |
134 |
| - | |
| 134 | + | |
135 | 135 |
| |
136 | 136 |
| |
137 | 137 |
| |
|
Lines changed: 29 additions & 54 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 |
| - | |
3 | 2 |
| |
4 | 3 |
| |
5 | 4 |
| |
| |||
243 | 242 |
| |
244 | 243 |
| |
245 | 244 |
| |
246 |
| - | |
247 |
| - | |
248 |
| - | |
249 |
| - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
250 | 248 |
| |
| 249 | + | |
251 | 250 |
| |
252 | 251 |
| |
253 |
| - | |
254 |
| - | |
255 |
| - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
256 | 255 |
| |
257 |
| - | |
258 |
| - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
259 | 261 |
| |
260 | 262 |
| |
261 | 263 |
| |
262 |
| - | |
263 |
| - | |
264 |
| - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
265 | 267 |
| |
266 | 268 |
| |
267 | 269 |
| |
| |||
277 | 279 |
| |
278 | 280 |
| |
279 | 281 |
| |
280 |
| - | |
281 |
| - | |
282 |
| - | |
283 |
| - | |
284 |
| - | |
285 |
| - | |
286 |
| - | |
287 |
| - | |
288 |
| - | |
289 |
| - | |
290 |
| - | |
291 |
| - | |
292 |
| - | |
293 |
| - | |
294 |
| - | |
295 |
| - | |
296 |
| - | |
297 |
| - | |
298 |
| - | |
299 |
| - | |
300 |
| - | |
301 |
| - | |
302 |
| - | |
303 |
| - | |
304 |
| - | |
305 |
| - | |
306 |
| - | |
307 |
| - | |
308 |
| - | |
309 |
| - | |
310 |
| - | |
311 |
| - | |
312 |
| - | |
313 |
| - | |
314 |
| - | |
315 |
| - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
316 | 293 |
| |
317 |
| - | |
318 |
| - | |
319 |
| - | |
320 |
| - | |
321 |
| - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
322 | 297 |
| |
323 | 298 |
| |
324 | 299 |
| |
|
0 commit comments
Comments
(0)