forked from 1b-agent/opencadstudio-upstream
Merge pull request #1309 from ghost/embed-print-fonts
This commit is contained in:
commit
03f4e7cb86
29 files changed
+1833
-68
No files matched your search
@@ -4,9 +4,11 @@
|
||||
// Default save format: DWG (AC1032 / R2018+).
|
||||
|
||||
pub mod file_association;
|
||||
pub mod font_repo;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub mod edit_lock;
|
||||
pub mod obj;
|
||||
pub mod ole_embed;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub mod single_instance;
|
||||
pub mod pdf_export;
|
||||
@@ -1555,6 +1557,23 @@ pub async fn pick_image_file() -> Result<(PathBuf, u32, u32), String> {
|
||||
Ok((path, w, h))
|
||||
}
|
||||
|
||||
/// Pick an image file and prepare it for embedding (IMAGEEMBED). The bytes
|
||||
/// are read before returning so the OLE2FRAME payload is ready to place.
|
||||
pub async fn pick_embedded_image_file() -> Result<ole_embed::EmbeddedImage, String> {
|
||||
let handle = crate::sys::file_dialog()
|
||||
.set_title(crate::t!("Select Image File").as_ref())
|
||||
.add_filter(crate::t!("Images").as_ref(), &["png", "jpg", "jpeg", "bmp", "tiff", "tif"])
|
||||
.add_filter(crate::t!("PNG").as_ref(), &["png"])
|
||||
.add_filter(crate::t!("JPEG").as_ref(), &["jpg", "jpeg"])
|
||||
.add_filter(crate::t!("All Files").as_ref(), &["*"])
|
||||
.pick_file()
|
||||
.await
|
||||
.ok_or_else(|| "Cancelled".to_string())?;
|
||||
let name = handle.file_name();
|
||||
let bytes = handle.read().await;
|
||||
ole_embed::EmbeddedImage::from_bytes(name, bytes)
|
||||
}
|
||||
|
||||
/// Save `doc` to `path` with the given DXF version, overriding `doc.version`.
|
||||
/// Format is auto-detected from the extension (dwg / dxf).
|
||||
pub fn save_as_version(
|
||||
|
||||
Reference in new issue
Block a user