Commit 8e8cd3d
fix: ASCII backend generating PDF binary content instead of text output
Fixes issue #220 where .txt files generated PDF binary data instead of ASCII text.
Root cause: The switch_backend_if_needed() function was hardcoding
current_backend='ascii' instead of detecting the actual backend type.
When a figure switched from ASCII->PDF->ASCII, the backend remained PDF
but the switching logic incorrectly assumed it was ASCII, skipping the
necessary switch back to ASCII backend.
Solution: Use polymorphic type checking (select type) to properly detect
the current backend type by examining the allocated backend object.
Changes:
- Replace hardcoded backend assumption with runtime type detection
- Add proper imports for all backend context types
- Maintain existing PNG backend workaround for segfault prevention
Testing:
- Verified with scale_examples.f90: .txt files now contain ASCII text
- File type detection confirms files are "ASCII text" not "PDF document"
- Sequential backend switching (ASCII->PDF->ASCII) works correctly
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 141f245 commit 8e8cd3d
1 file changed
+25
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
282 | 287 | | |
283 | 288 | | |
284 | 289 | | |
285 | 290 | | |
286 | 291 | | |
287 | | - | |
288 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
289 | 312 | | |
290 | 313 | | |
291 | 314 | | |
| |||
0 commit comments