forked from 1b-agent/opencadstudio-upstream
feat: embed images (OLE2FRAME), print pipeline fixes, plot prefs, community fonts
- IMAGEEMBED: pack raster images into OLE2FRAME entities so a .dwg is self-contained; 'Embed Image' entry in the XREF attach menu; control/MCP op embed_image for external tools; dxf_name for OLE2FRAME queries. - Scene: populate_images_from_document now rebuilds OLE2FRAME and PDF underlay models too (they used to vanish after any XREF op). - Printing: add PRINTER_ENUM_NETWORK pass when listing printers; GDI spooler fallback (hayro raster at 300 DPI + StretchDIBits) for hosts whose PDF handler registers no print verb; DEVMODE orientation with a 90-degree raster rotation fallback for v4 drivers; fix the fit-scale precedence bug that printed blank pages. - PDF export dialogs on Windows use the async file dialog so the native overwrite confirmation no longer deadlocks the UI thread. - Plot dialog: persist the chosen printer (saved on selection) and the picked plot window across sessions; page setups with no device no longer reset the output device. - Community fonts: detect unresolvable .shx references on open and offer a download from the repository's fonts/ folder (contribution guide in fonts/README.md); custom font source URL setting for intranet font servers; downloaded fonts resolve from the per-user fonts directory.
This commit is contained in:
1 parent
1450fdeedf
commit
28efbffd57
27 files changed
+1767
-66
No files matched your search
+111
-3
@@ -951,6 +951,93 @@ impl OpenCADStudio {
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::ImageEmbedPick => {
|
||||
Task::perform(crate::io::pick_embedded_image_file(), Message::ImageEmbedPickResult)
|
||||
}
|
||||
|
||||
Message::ImageEmbedPickResult(Ok(image)) => {
|
||||
use crate::command::CadCommand;
|
||||
use crate::modules::draw::draw::raster_image::ImageCommand;
|
||||
self.command_line.push_output(crate::tf!(
|
||||
"IMAGEEMBED \"{name}\": {w}×{h} px (embedded)",
|
||||
name = image.name.as_str(),
|
||||
w = image.pixel_width,
|
||||
h = image.pixel_height,
|
||||
).as_ref());
|
||||
let cmd = ImageCommand::new_embedded(image);
|
||||
let i = self.active_tab;
|
||||
self.command_line.push_info(&cmd.prompt());
|
||||
self.tabs[i].active_cmd = Some(Box::new(cmd));
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::ImageEmbedPickResult(Err(e)) => {
|
||||
if e != "Cancelled" {
|
||||
self.command_line
|
||||
.push_error(crate::tf!("IMAGEEMBED: {e}").as_ref());
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::MissingFontsSourceChanged(url) => {
|
||||
self.font_source_input = url;
|
||||
Task::none()
|
||||
}
|
||||
Message::MissingFontsDownload => {
|
||||
// Remember the source across sessions — and across drawings.
|
||||
let source = self.font_source_input.trim().to_string();
|
||||
if self.font_source_url != source {
|
||||
self.font_source_url = source.clone();
|
||||
self.save_config();
|
||||
}
|
||||
let fonts = self.missing_fonts.take().unwrap_or_default();
|
||||
Task::perform(
|
||||
async move {
|
||||
let source = crate::io::font_repo::FontSource::from_url(&source);
|
||||
crate::io::font_repo::download_fonts(&fonts, &source)
|
||||
},
|
||||
Message::MissingFontsResult,
|
||||
)
|
||||
}
|
||||
Message::MissingFontsDismiss => {
|
||||
self.missing_fonts = None;
|
||||
self.close_active_modal();
|
||||
Task::none()
|
||||
}
|
||||
Message::MissingFontsResult(result) => {
|
||||
self.missing_fonts = None;
|
||||
self.close_active_modal();
|
||||
match result {
|
||||
Ok(pairs) if pairs.is_empty() => {
|
||||
self.command_line.push_error(crate::t!(
|
||||
"None of the missing fonts are in the community repository yet. Contribute them at github.com/huaninstratech/OpenCADStudio/tree/main/fonts."
|
||||
).as_ref());
|
||||
}
|
||||
Ok(pairs) => {
|
||||
for (name, path) in &pairs {
|
||||
self.command_line.push_output(crate::tf!(
|
||||
"FONT Downloaded {name} → {path}",
|
||||
path = path.display()
|
||||
).as_ref());
|
||||
}
|
||||
// The downloaded files change glyph resolution for the
|
||||
// whole drawing — reload it through the standard open
|
||||
// pipeline so every wire is rebuilt with the real fonts.
|
||||
let i = self.active_tab;
|
||||
if let Some(path) = self.tabs[i].current_path.clone() {
|
||||
return Task::done(Message::OpenExternal(path));
|
||||
}
|
||||
self.command_line.push_info(crate::t!(
|
||||
"Save and reopen the drawing to apply the new fonts."
|
||||
).as_ref());
|
||||
}
|
||||
Err(e) => {
|
||||
self.command_line.push_error(crate::tf!("Font download failed: {e}").as_ref());
|
||||
}
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
Message::PdfAttachPick => Task::perform(
|
||||
async {
|
||||
let handle = crate::sys::file_dialog()
|
||||
@@ -8281,7 +8368,7 @@ impl OpenCADStudio {
|
||||
.and_then(|path| path.file_stem())
|
||||
.map(|name| format!("{}_layouts", name.to_string_lossy()))
|
||||
.unwrap_or_else(|| "drawing_layouts".into());
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(all(not(target_arch = "wasm32"), not(target_os = "windows")))]
|
||||
{
|
||||
let Some(window_id) = self.main_window else {
|
||||
return Task::done(Message::PrintAllPdfPath(None));
|
||||
@@ -8291,6 +8378,13 @@ impl OpenCADStudio {
|
||||
})
|
||||
.map(Message::PrintAllPdfPath)
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
Task::perform(
|
||||
crate::io::pdf_export::pick_pdf_path_async(stem),
|
||||
Message::PrintAllPdfPath,
|
||||
)
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
let _ = stem;
|
||||
@@ -8326,7 +8420,7 @@ impl OpenCADStudio {
|
||||
.and_then(|p: &std::path::Path| p.file_stem())
|
||||
.map(|s: &std::ffi::OsStr| s.to_string_lossy().into_owned())
|
||||
.unwrap_or_else(|| "drawing".into());
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(all(not(target_arch = "wasm32"), not(target_os = "windows")))]
|
||||
{
|
||||
let Some(window_id) = self.main_window else {
|
||||
return Task::done(Message::PlotExportPath(None));
|
||||
@@ -8336,6 +8430,13 @@ impl OpenCADStudio {
|
||||
})
|
||||
.map(Message::PlotExportPath)
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
Task::perform(
|
||||
crate::io::pdf_export::pick_pdf_path_async(stem),
|
||||
Message::PlotExportPath,
|
||||
)
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
Task::perform(
|
||||
@@ -8363,7 +8464,7 @@ impl OpenCADStudio {
|
||||
.and_then(|p: &std::path::Path| p.file_stem())
|
||||
.map(|s: &std::ffi::OsStr| s.to_string_lossy().into_owned())
|
||||
.unwrap_or_else(|| "drawing".into());
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[cfg(all(not(target_arch = "wasm32"), not(target_os = "windows")))]
|
||||
{
|
||||
let Some(window_id) = self.main_window else {
|
||||
return Task::done(Message::PlotWindowExportPath(None));
|
||||
@@ -8373,6 +8474,13 @@ impl OpenCADStudio {
|
||||
})
|
||||
.map(Message::PlotWindowExportPath)
|
||||
}
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
Task::perform(
|
||||
crate::io::pdf_export::pick_pdf_path_async(stem),
|
||||
Message::PlotWindowExportPath,
|
||||
)
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
Task::perform(
|
||||
|
||||
Reference in new issue
Block a user