You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: ASCII backend generates PDF binary content instead of text output (#222)
## Summary
- Fix issue #220: ASCII backend was generating PDF binary content
instead of text output for .txt files
- Root cause: Backend switching logic hardcoded current backend
assumption instead of detecting actual type
- Solution: Use polymorphic type checking to properly detect current
backend type
## Test plan
- [x] Verified with scale_examples.f90: .txt files now contain proper
ASCII text visualization
- [x] File type detection confirms files are "ASCII text" not "PDF
document"
- [x] Sequential backend switching (ASCII->PDF->ASCII) works correctly
- [x] Output files are UTF-8 compatible for documentation tools
- [x] Box drawing characters and proper text formatting in ASCII output
## Details
The bug occurred when a figure switched backends multiple times (e.g.,
ASCII -> PDF -> ASCII). The `switch_backend_if_needed()` function was
hardcoding `current_backend = 'ascii'` instead of checking what backend
was actually allocated. This caused the function to skip backend
switching when it should have switched from PDF back to ASCII for .txt
files.
The fix uses `select type` to examine the polymorphic backend object and
correctly identify whether it's an `ascii_context`, `pdf_context`,
`png_context`, etc.
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments