Merge pull request #1884 from marcoarnulfo/fix/text-scale-font-size

Info panel: scaled type shows its scaled size, as the Character panel does
This commit is contained in:
BFlat
2026-10-16 02:14:55 +07:00
committed by GitHub
+18 -1
View File
@@ -78,7 +78,10 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
&& let vectorcraft_doc::NodeKind::Text(tx) = &n.kind
{
widgets::divider(ui);
let st = tx.first_style();
let raw = tx.first_style();
// The size in document points, as the Character panel shows it (#1034); a collapsed
// transform has none, so the stored size stands.
let st = tx.effective_char_style(&raw).unwrap_or(raw);
mono(ui, format!("{} {}", st.font_family, st.font_style));
mono(
ui,
@@ -108,4 +111,18 @@ mod tests {
assert_eq!(color_values(&Color::cmyk(0.1, 0.0, 0.0, 0.5))[3].1, "50%");
assert_eq!(color_values(&Color::gray(0.25)).len(), 1);
}
/// #1882: scaled type shows its size in document points, as the Character panel does (#1034).
#[test]
fn scaled_type_shows_its_scaled_size() {
use super::super::tests_appearance::{app_with_rect, frame_events, run};
use serde_json::json;
let mut app = app_with_rect();
let id = run(&mut app, "text.create", json!({"x": 10, "y": 150, "text": "Hi", "size": 12}))["id"].clone();
run(&mut app, "select.set", json!({ "ids": [id] }));
run(&mut app, "object.scale", json!({"sx": 200}));
let texts = frame_events(&egui::Context::default(), &mut app, vec![], show);
let size = texts.iter().find(|(t, _)| t.starts_with("Size:")).map(|(t, _)| t.as_str());
assert_eq!(size, Some("Size: 24 pt Tracking: 0"), "{texts:?}");
}
}