#18 - locked namespace binding error in civilytics_load_fonts()
Problem: The function used <<- to write to a package-level variable (.cv_fonts_loaded), which R locks when the namespace seals at load time. This caused an error on every call: cannot change value of locked binding for .cv_fonts_loaded.
Fix: Replaced the plain variable with a mutable environment (.cv_state) whose contents remain writable even though the binding itself is locked. This follows the standard R idiom for mutable package state (see Advanced R: Environments as containers).
Additional: Added a force = FALSE argument so subsequent calls within the same session are no-ops (the guard flag now actually works).
#7 - Default theme_civilytics() to transparent background
Problem: The cream paper background (#FAF7F2) was the default, forcing downstream consumers to override it for transparent figures.
Fix: Flipped paper_bg default from TRUE to FALSE. Cream is now an explicit opt-in via theme_civilytics(paper_bg = TRUE).
Breaking change note: Existing code relying on the cream default will now get transparent backgrounds. Add paper_bg = TRUE to restore the previous behavior.
R/theme.R - Default flip, updated docs and examples
Testing
Changes follow standard R patterns. Manual testing requires an R session with the civilytics package installed.
## Summary
Fixes two issues in the civilyticsR package:
### #18 - locked namespace binding error in civilytics_load_fonts()
Problem: The function used <<\- to write to a package-level variable (.cv_fonts_loaded), which R locks when the namespace seals at load time. This caused an error on every call: cannot change value of locked binding for .cv_fonts_loaded.
Fix: Replaced the plain variable with a mutable environment (.cv_state) whose contents remain writable even though the binding itself is locked. This follows the standard R idiom for mutable package state (see Advanced R: Environments as containers).
Additional: Added a force = FALSE argument so subsequent calls within the same session are no-ops (the guard flag now actually works).
### #7 - Default theme_civilytics() to transparent background
Problem: The cream paper background (#FAF7F2) was the default, forcing downstream consumers to override it for transparent figures.
Fix: Flipped paper_bg default from TRUE to FALSE. Cream is now an explicit opt-in via theme_civilytics(paper_bg = TRUE).
Breaking change note: Existing code relying on the cream default will now get transparent backgrounds. Add paper_bg = TRUE to restore the previous behavior.
## Files changed
- R/fonts.R - Environment-based state, guard check, updated roxygen
- R/theme.R - Default flip, updated docs and examples
## Testing
Changes follow standard R patterns. Manual testing requires an R session with the civilytics package installed.
- Replace .cv_fonts_loaded <<- TRUE with environment-based state
(.cv_state) to avoid 'locked namespace binding' error (#18)
- Add force=FALSE argument for idempotent font loading with guard check
- Flip theme_civilytics() paper_bg default to FALSE (transparent) (#7)
- Update roxygen docs and examples for both changes
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Fixes two issues in the civilyticsR package:
#18 - locked namespace binding error in civilytics_load_fonts()
Problem: The function used <<- to write to a package-level variable (.cv_fonts_loaded), which R locks when the namespace seals at load time. This caused an error on every call: cannot change value of locked binding for .cv_fonts_loaded.
Fix: Replaced the plain variable with a mutable environment (.cv_state) whose contents remain writable even though the binding itself is locked. This follows the standard R idiom for mutable package state (see Advanced R: Environments as containers).
Additional: Added a force = FALSE argument so subsequent calls within the same session are no-ops (the guard flag now actually works).
#7 - Default theme_civilytics() to transparent background
Problem: The cream paper background (#FAF7F2) was the default, forcing downstream consumers to override it for transparent figures.
Fix: Flipped paper_bg default from TRUE to FALSE. Cream is now an explicit opt-in via theme_civilytics(paper_bg = TRUE).
Breaking change note: Existing code relying on the cream default will now get transparent backgrounds. Add paper_bg = TRUE to restore the previous behavior.
Files changed
Testing
Changes follow standard R patterns. Manual testing requires an R session with the civilytics package installed.