mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Properly track the Text node's text frame via the attribute system to fix misalignment (#4097)
* Compensate for upstream row-0 transform absorption in viewport-space 'TransformSet' * Add 'editor:text_frame' row attribute so the Text tool's drag cage tracks multi-row text * "Separate Glyph Elements" -> "Separate Glyphs" * Improve artboard migration robustness from older documents * Code review * Make the tools visualize the text frame based on attribute not upstream node
This commit is contained in:
@@ -92,7 +92,23 @@ impl TextContext {
|
||||
return Table::new_from_element(Vector::default());
|
||||
};
|
||||
|
||||
let mut path_builder = PathBuilder::new(per_glyph_items, layout.scale() as f64);
|
||||
let text_frame_size = DVec2::new(
|
||||
typesetting.max_width.unwrap_or_else(|| layout.full_width() as f64),
|
||||
typesetting.max_height.unwrap_or_else(|| layout.height() as f64),
|
||||
);
|
||||
|
||||
// First glyph offset (pre-height-filter) so the empty placeholder item in `per_glyph_items`
|
||||
// mode keeps the same item 0's transform, preventing `local_transforms` from jumping mid-drag
|
||||
let first_glyph_offset = layout
|
||||
.lines()
|
||||
.flat_map(|line| line.items())
|
||||
.find_map(|item| match item {
|
||||
PositionedLayoutItem::GlyphRun(run) => run.glyphs().next().map(|glyph| DVec2::new((run.offset() + glyph.x) as f64, (run.baseline() - glyph.y) as f64)),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut path_builder = PathBuilder::new(per_glyph_items, layout.scale() as f64, text_frame_size, first_glyph_offset);
|
||||
|
||||
for line in layout.lines() {
|
||||
for item in line.items() {
|
||||
|
||||
Reference in New Issue
Block a user