mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 20:23:53 +00:00
Merge remote-tracking branch 'origin/main' into fix/ruler-double-click-guide
This commit is contained in:
@@ -425,7 +425,8 @@ impl Renderer {
|
||||
if !k.is_finite() || k <= 1e-12 {
|
||||
return;
|
||||
}
|
||||
// The art in its own coordinates, with its own resources.
|
||||
// The art in its own coordinates, with its own resources (its composite fonts included).
|
||||
let _lent = vectorcraft_text::FontDb::global().lend_composite_fonts(&e.doc.composite_fonts);
|
||||
let symbols = e.doc.symbol_boxes().quick();
|
||||
let visible = m.inverse().transform_rect_bbox(f.visible);
|
||||
let inner = Frame { doc: &e.doc, symbols: &symbols, view: f.view * m, visible, px: f.px / k, output: f.output * m, ..*f };
|
||||
|
||||
@@ -179,6 +179,34 @@ fn a_documents_own_composite_font_draws_without_being_registered() {
|
||||
assert_eq!(thumbnail(&composite, id), thumbnail(&plain, plain_id), "thumbnail");
|
||||
let placed = |d: &Document| crate::placed_document::render_inside(&mut Renderer::new(), d, &d.layers[0], 300, 150, view).map(|r| r.pixels);
|
||||
assert_eq!(placed(&composite), placed(&plain), "a placed document's art");
|
||||
// A page that places the document, drawn exactly (no bitmap of the placed art).
|
||||
let page = |d: &Document, id: NodeId, key: &str| {
|
||||
use vectorcraft_doc::{ImageBlob, LinkInfo, PlacedDocument};
|
||||
let blob = ImageBlob::new("application/json", key.as_bytes().to_vec());
|
||||
let p = PlacedDocument {
|
||||
link: LinkInfo::new("/art/type.vectorcraft"),
|
||||
key: key.into(),
|
||||
bounding: false,
|
||||
page_box: Default::default(),
|
||||
width: 300.0,
|
||||
height: 150.0,
|
||||
xf: Affine::IDENTITY,
|
||||
placement: Default::default(),
|
||||
};
|
||||
let art = d.node(id).unwrap().clone();
|
||||
vectorcraft_doc::placed_document::prime(&p, blob.bytes.clone(), (d.clone(), art, Rect::new(0.0, 0.0, 300.0, 150.0)));
|
||||
let mut page = Document::new(300.0, 150.0);
|
||||
page.images.insert(key.into(), blob);
|
||||
let n = Node::new(page.alloc_id(), NodeKind::PlacedDocument(Box::new(p)));
|
||||
let l = page.layers[0].id;
|
||||
page.insert(Some(l), 0, n).unwrap();
|
||||
Renderer::new().render(&page, 300, 150, view, &opts).pixels
|
||||
};
|
||||
assert_eq!(
|
||||
page(&composite, id, "fontchange-composite-placed"),
|
||||
page(&plain, plain_id, "fontchange-plain-placed"),
|
||||
"a placed document's art drawn exactly"
|
||||
);
|
||||
assert!(db.composite_font(NAME).is_none(), "given back after each render");
|
||||
}
|
||||
|
||||
|
||||
@@ -251,7 +251,8 @@ fn optional_number(d: &Dialog, key: &str) -> Result<Option<Value>, String> {
|
||||
"v_scale" => tl!("Vertical Scale"),
|
||||
"baseline_shift" => tl!("Baseline Shift"),
|
||||
"rotation" => tl!("Character Rotation"),
|
||||
"fill_tint" | "stroke_tint" => tl!("Tint"),
|
||||
"fill_tint" => tl!("Fill Tint"),
|
||||
"stroke_tint" => tl!("Stroke Tint"),
|
||||
"stroke_width" => tl!("Weight"),
|
||||
_ => return Err("unknown character style number field".into()),
|
||||
};
|
||||
@@ -1649,8 +1650,8 @@ mod tests {
|
||||
fn color_tint_and_weight_outside_their_limits_are_errors() {
|
||||
let linked = json!({"type": "solid", "color": {"model": "gray", "k": 0.5}, "swatch": "Ink"});
|
||||
for (key, value, message) in [
|
||||
("fill_tint", "150", "Tint must be a number from 0 to 100"),
|
||||
("stroke_tint", "-1", "Tint must be a number from 0 to 100"),
|
||||
("fill_tint", "150", "Fill Tint must be a number from 0 to 100"),
|
||||
("stroke_tint", "-1", "Stroke Tint must be a number from 0 to 100"),
|
||||
("stroke_width", "-1", "Weight must be a number from 0 to 4000000"),
|
||||
("stroke_width", "thick", "Weight must be a number"),
|
||||
] {
|
||||
|
||||
Reference in New Issue
Block a user