forked from 1b-agent/opencadstudio-upstream
options: fonts and plot styles can live in a chosen folder
Options > Files lets the fonts and plot style folders move elsewhere, such as a share a whole team uses (Change... / Default). Fonts are then looked up and downloaded there, and plot style tables listed and saved there; the choice is kept in the profile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
e9a2b9d196
commit
686fb71780
8 files changed
+147
-15
No files matched your search
+16
-1
@@ -18,11 +18,26 @@ const REPO_API_URL: &str = "https://api.github.com/repos/HakanSeven12/OpenCADStu
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
const MAX_FONT_BYTES: u64 = 16 * 1024 * 1024;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
static FONTS_FOLDER: std::sync::RwLock<Option<PathBuf>> = std::sync::RwLock::new(None);
|
||||
|
||||
/// A folder chosen in Options to hold the fonts instead of the default one,
|
||||
/// such as a share on the office network.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn fonts_folder() -> Option<PathBuf> {
|
||||
FONTS_FOLDER.read().unwrap_or_else(|e| e.into_inner()).clone()
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn set_fonts_folder(folder: Option<PathBuf>) {
|
||||
*FONTS_FOLDER.write().unwrap_or_else(|e| e.into_inner()) = folder;
|
||||
}
|
||||
|
||||
/// Local store for fonts downloaded from the community repository. Text
|
||||
/// resolution searches here after the drawing folder.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn fonts_dir() -> Option<PathBuf> {
|
||||
crate::config::config_dir().map(|dir| dir.join("fonts"))
|
||||
fonts_folder().or_else(|| crate::config::config_dir().map(|dir| dir.join("fonts")))
|
||||
}
|
||||
|
||||
/// Web builds have no filesystem to cache fonts into.
|
||||
|
||||
@@ -34,8 +34,26 @@ const STANDARD_PLOT_STYLES: &[&str] = &[
|
||||
SCREENING_25_PLOT_STYLE,
|
||||
];
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
static PLOT_STYLES_FOLDER: std::sync::RwLock<Option<PathBuf>> = std::sync::RwLock::new(None);
|
||||
|
||||
/// A folder chosen in Options to hold the plot style tables instead of the
|
||||
/// default one, such as a share on the office network.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn plot_styles_folder() -> Option<PathBuf> {
|
||||
PLOT_STYLES_FOLDER.read().unwrap_or_else(|e| e.into_inner()).clone()
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn set_plot_styles_folder(folder: Option<PathBuf>) {
|
||||
*PLOT_STYLES_FOLDER.write().unwrap_or_else(|e| e.into_inner()) = folder;
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn plot_styles_dir() -> Result<PathBuf, String> {
|
||||
if let Some(folder) = plot_styles_folder() {
|
||||
return Ok(folder);
|
||||
}
|
||||
crate::config::config_dir()
|
||||
.map(|path| path.join("plotstyles"))
|
||||
.ok_or_else(|| "Plot styles folder could not be resolved".to_string())
|
||||
|
||||
Reference in new issue
Block a user