mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-03 06:51:50 -06:00
Rename PrintCraft to PdfCraft (#174)
The app, crates, binaries, bundle id, packaging, icons, screenshots and docs are now PdfCraft / pdfcraft (repo storytold/pdfcraft). On first launch the desktop app moves the PrintCraft settings and crash-recovery folders to the new name, and both apps read settings saved under the old storage key, so upgrades keep recent files, preferences and unsaved work. The signing test fixtures keep their PrintCraft subject names (they are binary). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
1c78ff479c
commit
d3db99818f
@@ -1,4 +1,4 @@
|
||||
//! Appearance streams (§12.5.5) for the comment types PrintCraft creates, execution plan M5.2.
|
||||
//! Appearance streams (§12.5.5) for the comment types PdfCraft creates, execution plan M5.2.
|
||||
//!
|
||||
//! [`build`] draws a normal appearance (`/AP /N`) from the annotation dictionary alone, so the
|
||||
//! same code serves new comments and restyled ones. Drawings are in page space with
|
||||
@@ -6,13 +6,13 @@
|
||||
//! It returns `None` for anything it cannot draw faithfully (cloudy borders, unknown line
|
||||
//! endings, indirect geometry), so callers never replace an appearance with a worse one.
|
||||
//!
|
||||
//! The note icons are PrintCraft's own drawings (AGENTS.md §1). Text boxes use the standard
|
||||
//! The note icons are PdfCraft's own drawings (AGENTS.md §1). Text boxes use the standard
|
||||
//! Helvetica font with WinAnsi encoding; line breaking uses [`text_width`], an approximation of
|
||||
//! Helvetica's proportions by character class (no font program or metrics file is bundled).
|
||||
|
||||
use printcraft_cos::{Dict, Object, PdfString, Stream};
|
||||
pub use printcraft_fonts::{helvetica_width as text_width, wrap};
|
||||
use printcraft_fonts::{literal, win_ansi};
|
||||
use pdfcraft_cos::{Dict, Object, PdfString, Stream};
|
||||
pub use pdfcraft_fonts::{helvetica_width as text_width, wrap};
|
||||
use pdfcraft_fonts::{literal, win_ansi};
|
||||
|
||||
use crate::{NOTE_SIZE, Rgb, n};
|
||||
|
||||
@@ -435,7 +435,7 @@ pub fn build(d: &Dict) -> Option<Stream> {
|
||||
res.set(b"XObject".to_vec(), Object::Dict(xo));
|
||||
return Some(form(rect, c.as_bytes(), res));
|
||||
}
|
||||
// Only PrintCraft's own Fill & Sign marks are drawn here.
|
||||
// Only PdfCraft's own Fill & Sign marks are drawn here.
|
||||
let name = d.name(b"Name")?;
|
||||
let col = stroke.unwrap_or([0.0; 3]);
|
||||
let [x0, y0, x1, y1] = rect;
|
||||
@@ -482,7 +482,7 @@ pub fn build(d: &Dict) -> Option<Stream> {
|
||||
n(y0 + h / 2.0)
|
||||
)),
|
||||
other => {
|
||||
// Only stamps PrintCraft made: others keep their own artwork.
|
||||
// Only stamps PdfCraft made: others keep their own artwork.
|
||||
if !matches!(d.get(b"PCStamp"), Some(Object::Bool(true))) {
|
||||
return None;
|
||||
}
|
||||
@@ -727,9 +727,9 @@ fn ellipse(x0: f64, y0: f64, x1: f64, y1: f64) -> String {
|
||||
s
|
||||
}
|
||||
|
||||
/// PrintCraft's note icons, drawn in a 20 × 20 box: a speech bubble for `/Comment`, a page
|
||||
/// PdfCraft's note icons, drawn in a 20 × 20 box: a speech bubble for `/Comment`, a page
|
||||
/// with a folded corner for everything else, both filled with the note colour.
|
||||
/// File attachment icons in a 20 × 20 box: PrintCraft's own drawings.
|
||||
/// File attachment icons in a 20 × 20 box: PdfCraft's own drawings.
|
||||
fn attach_icon(name: &str, col: Rgb) -> String {
|
||||
let mut s = format!("{}{}1.2 w 1 j 1 J\n", rg(col), rg_stroke(col));
|
||||
match name {
|
||||
|
||||
+11
-11
@@ -1,4 +1,4 @@
|
||||
//! printcraft-annot — comments (annotations), ISO 32000-2 §12.5, execution plan M5.1–M5.3.
|
||||
//! pdfcraft-annot — comments (annotations), ISO 32000-2 §12.5, execution plan M5.1–M5.3.
|
||||
//!
|
||||
//! Builders for the comment types Acrobat's commenting tools create (sticky note, highlight,
|
||||
//! underline, strikethrough, squiggly, rectangle, oval, line/arrow, freehand ink, text box),
|
||||
@@ -6,15 +6,15 @@
|
||||
//! change its text, recolour, move, resize and delete.
|
||||
//!
|
||||
//! Addressing: a comment is `(page, index)`, its position in the page's `/Annots` array, which
|
||||
//! is what `printcraft_render::Annotation::index` reports. Inline annotation dictionaries are
|
||||
//! is what `pdfcraft_render::Annotation::index` reports. Inline annotation dictionaries are
|
||||
//! promoted to indirect objects when they are edited (replies need a reference to point at).
|
||||
//!
|
||||
//! Every edit mutates a `printcraft_cos::Document` (copy-on-write); callers snapshot it first
|
||||
//! Every edit mutates a `pdfcraft_cos::Document` (copy-on-write); callers snapshot it first
|
||||
//! for undo. Keys we do not understand are left alone.
|
||||
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
|
||||
use printcraft_cos::{Dict, Document, ObjRef, Object, PdfString};
|
||||
use pdfcraft_cos::{Dict, Document, ObjRef, Object, PdfString};
|
||||
|
||||
pub mod appearance;
|
||||
pub mod links;
|
||||
@@ -35,7 +35,7 @@ pub enum AnnotError {
|
||||
#[error("{0} comments can't be restyled yet (their appearance can't be regenerated)")]
|
||||
Unsupported(String),
|
||||
#[error("{0}")]
|
||||
Cos(#[from] printcraft_cos::CosError),
|
||||
Cos(#[from] pdfcraft_cos::CosError),
|
||||
}
|
||||
|
||||
pub type Rgb = [f64; 3];
|
||||
@@ -101,7 +101,7 @@ pub enum FillMark {
|
||||
}
|
||||
|
||||
impl FillMark {
|
||||
/// The `/Name` of the stamp PrintCraft draws for it.
|
||||
/// The `/Name` of the stamp PdfCraft draws for it.
|
||||
pub fn name(self) -> &'static str {
|
||||
match self {
|
||||
FillMark::Check => "PCCheck",
|
||||
@@ -121,7 +121,7 @@ impl FillMark {
|
||||
}
|
||||
}
|
||||
|
||||
/// The stamps of Acrobat's stamp palette (drawn in PrintCraft's own style).
|
||||
/// The stamps of Acrobat's stamp palette (drawn in PdfCraft's own style).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum StampKind {
|
||||
// Standard business.
|
||||
@@ -921,7 +921,7 @@ pub fn add_annotation(doc: &mut Document, new: &NewAnnotation, meta: &Meta) -> R
|
||||
Shape::Stamp { stamp, by, .. } => {
|
||||
d.set(b"C".to_vec(), rgb(style.color));
|
||||
d.set(b"Name".to_vec(), Object::name(stamp.name()));
|
||||
// Marks the stamp as drawn by PrintCraft: other stamps with standard names keep
|
||||
// Marks the stamp as drawn by PdfCraft: other stamps with standard names keep
|
||||
// their own artwork.
|
||||
d.set(b"PCStamp".to_vec(), Object::Bool(true));
|
||||
if let Some(b) = by {
|
||||
@@ -987,7 +987,7 @@ pub fn add_annotation(doc: &mut Document, new: &NewAnnotation, meta: &Meta) -> R
|
||||
let mut ef = Dict::new();
|
||||
ef.set(b"Type".to_vec(), Object::name("EmbeddedFile"));
|
||||
ef.set(b"Params".to_vec(), Object::Dict(params));
|
||||
let ef = doc.add(Object::Stream(printcraft_cos::Stream::flate(ef, data)));
|
||||
let ef = doc.add(Object::Stream(pdfcraft_cos::Stream::flate(ef, data)));
|
||||
let mut efd = Dict::new();
|
||||
efd.set(b"F".to_vec(), Object::Ref(ef));
|
||||
efd.set(b"UF".to_vec(), Object::Ref(ef));
|
||||
@@ -1255,7 +1255,7 @@ fn reply(
|
||||
fd.set(b"Type".to_vec(), Object::name("XObject"));
|
||||
fd.set(b"Subtype".to_vec(), Object::name("Form"));
|
||||
fd.set(b"BBox".to_vec(), num_array(&[0.0, 0.0, 0.0, 0.0]));
|
||||
let ap = doc.add(Object::Stream(printcraft_cos::Stream::from_raw(fd, Vec::new())));
|
||||
let ap = doc.add(Object::Stream(pdfcraft_cos::Stream::from_raw(fd, Vec::new())));
|
||||
let mut apd = Dict::new();
|
||||
apd.set(b"N".to_vec(), Object::Ref(ap));
|
||||
d.set(b"AP".to_vec(), Object::Dict(apd));
|
||||
@@ -1460,7 +1460,7 @@ pub fn set_style(
|
||||
// ── reading ─────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// One comment as the viewer lists it (the same fields and rules as
|
||||
/// `printcraft_render::Annotation`), read straight from the object graph. The engine uses it to
|
||||
/// `pdfcraft_render::Annotation`), read straight from the object graph. The engine uses it to
|
||||
/// refresh the comment list after a comment edit without re-inspecting the whole document.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Summary {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Links (ISO 32000-2 §12.5.6.5): create, edit and remove link annotations with Acrobat's Link
|
||||
//! Properties (appearance and a go-to-page or open-a-web-page action).
|
||||
|
||||
use printcraft_cos::{Dict, Document, ObjRef, Object, PdfString};
|
||||
use pdfcraft_cos::{Dict, Document, ObjRef, Object, PdfString};
|
||||
|
||||
use crate::{AnnotError, annots, page_ref, page_refs, set_annots};
|
||||
|
||||
@@ -11,7 +11,7 @@ pub enum LinkAction {
|
||||
/// A page of this document (0-based), shown fitting the window (`/Fit`).
|
||||
Page(usize),
|
||||
Uri(String),
|
||||
/// Something PrintCraft doesn't edit yet (named destination, JavaScript…): kept as is.
|
||||
/// Something PdfCraft doesn't edit yet (named destination, JavaScript…): kept as is.
|
||||
Other(String),
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use printcraft_cos::{Document, ObjRef, Object, SaveOptions, write_incremental};
|
||||
use pdfcraft_cos::{Document, ObjRef, Object, SaveOptions, write_incremental};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user