Merge pull request #768 from gianlucafiore/fix/annotative-text-units

Fix annotative text scaling for drawing units
This commit is contained in:
gianlucafiore 2026-08-14 15:39:26 -03:00 committed by GitHub
commit 577530d2e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 2 deletions

View file

@ -705,7 +705,7 @@ impl super::OpenCADStudio {
// it keeps the layout's shape, wrapping and alignment identical.
mt.insertion_point = Vector3::new(0.0, 0.0, 0.0);
let entity = EntityType::MText(mt.clone());
let anno = self.tabs[i].scene.annotation_scale;
let anno = 1.0;
let bg = self.tabs[i].scene.bg_color;
let wires: Vec<WireModel> = tessellate::tessellate(
&self.tabs[i].scene.document,

View file

@ -1147,6 +1147,10 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
// CANNOSCALEVALUE (paper/drawing factor). Convert its inverse into
// drawing units as well: metric annotation sizes are paper millimetres
// and imperial annotation sizes are paper inches.
// Current model-space annotation scale comes from the drawing's
// CANNOSCALEVALUE (paper/drawing factor). Convert its paper unit into
// the drawing's INSUNITS as well, so e.g. a metre drawing uses
// 0.001 model units for 1 mm of paper at 1:1.
let cannoscale_value = self.tabs[i].scene.document.header.annotation_scale_value;
let unit_factor = self.tabs[i].scene.annotation_scale_unit_factor();

View file

@ -670,7 +670,19 @@ pub fn effective_annotation_scale_for(
if !context_annotative && (text_like || !style_annotative) {
return 1.0;
}
// Annotative TEXT/MTEXT store their paper text height as the base value.
// `fallback` is the absolute paper-to-model multiplier for the active
// annotation scale and already includes the drawing's INSUNITS conversion.
//
// Example for a metre drawing with 2 mm paper text:
// 1:1 -> 2 * 0.001 = 0.002 m
// 1:100 -> 2 * 0.100 = 0.200 m
//
// Using active/native here would only produce 1 / 100 and would lose the
// millimetre-to-metre conversion entirely.
if matches!(entity, EntityType::Text(_) | EntityType::MText(_)) {
return fallback;
}
if matches!(
entity,
EntityType::Dimension(_)