fix: resolve locked namespace binding in civilytics_load_fonts() and default theme to transparent background #19
Merged
jared
merged 3 commits from 2026-08-03 10:46:41 -04:00
kodor/fix-18-fonts-and-theme into master
No Reviewers
Labels
Clear labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
kodor
kodor/feature-proposal
kodor/fix
kodor/needs-review
kodor/triaged
question
wontfix
kodor
kodor/feature-proposal
kodor/fix
kodor/needs-review
kodor/triaged
Something isn't working
Improvements or additions to documentation
This issue or pull request already exists
New feature or request
Good for newcomers
Extra attention is needed
This doesn't seem right
Kodor should process this issue
Kodor has written a feature proposal
Kodor should implement a fix (assigned to Kodor)
Kodor's work or failure needs Jared's review
Kodor has already triaged this issue (skip)
Further information is requested
This will not be worked on
needs
human
Cannot move without a person -- a decision, a check an agent cannot make, something outside the repo
origin
client
Came from a client ask
origin
obligation
Created by a change elsewhere
origin
review
Came from human review
origin
roborev
Promoted from a roborev finding
type
chore
Maintenance with no behaviour change
type
debt
Owed work -- docs, tests, cleanup a change obligated
type
decision
Needs a decision before work can proceed
type
defect
Something is wrong
type
feature
New capability
ws
helpers
Analysis and workflow helpers
ws
logo
Logo and branded output composition
ws
packaging
Package infrastructure and release
ws
quarto
Quarto themes and publishing templates
ws
theme
Themes, palettes, and fonts
Assign a task to kodor
Kodor thinks this needs a feature.
Kodor should fix this
Kodor thinks the user is ready to review this.
Kodor is done with this issue.
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Civilytics/civilyticsR#19
Reference in New Issue
Block a user
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.