mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-02 06:07:06 -06:00
Snap to Glyph: the x-height guide stays on the glyphs' x-height
Character Rotation turned a glyph's baseline shift and scaling with the glyph, and the Skew path effect slants a glyph's height away from the path's normal, so the x-height guide moved off the glyphs. Each positioned glyph now carries the transform that removes its Character Rotation (PositionedGlyph::unturned), and the guide goes through the glyph's x-height point placed without it, measured across the baseline. Snap to Glyph also takes Smart Guides being on in the tools, as View › Snap to Glyph already does in the engine.
This commit is contained in:
@@ -216,6 +216,12 @@ impl Ctx<'_> {
|
||||
Affine::rotate(-g.rotation.to_radians()) * Affine::translate((g.dx - lead, g.dy - g.bshift)) * Affine::scale_non_uniform(g.sx, g.sy)
|
||||
}
|
||||
};
|
||||
let unturned = if g.inline.is_none() && g.rotation != 0.0 && g.sx != 0.0 && g.sy != 0.0 {
|
||||
let placed = Affine::translate((g.dx - lead, g.dy - g.bshift)) * Affine::scale_non_uniform(g.sx, g.sy);
|
||||
placed.inverse() * Affine::rotate(g.rotation.to_radians()) * placed
|
||||
} else {
|
||||
Affine::IDENTITY
|
||||
};
|
||||
let mut m = pre * local;
|
||||
if self.vertical && self.on_path {
|
||||
// Vertical path type keeps the baseline path and turns each glyph across it.
|
||||
@@ -271,6 +277,7 @@ impl Ctx<'_> {
|
||||
image,
|
||||
colour,
|
||||
bend: None,
|
||||
unturned,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -367,5 +367,6 @@ fn ruby_glyph(g: &PositionedGlyph, m: Affine, run: usize, byte: usize, line: usi
|
||||
image: None,
|
||||
colour: None,
|
||||
bend: None,
|
||||
unturned: Affine::IDENTITY,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +136,9 @@ pub struct PositionedGlyph {
|
||||
/// the path ([`GlyphBend`]) so it meets its neighbours, and `xf` is only the straight glyph
|
||||
/// nearest it (for the caret, hit testing and tools). `None`: the glyph is drawn through `xf`.
|
||||
pub bend: Option<GlyphBend>,
|
||||
/// Font units → font units: `xf * unturned` places the glyph as it would be placed without
|
||||
/// its Character Rotation. The identity for a glyph without one.
|
||||
pub unturned: Affine,
|
||||
}
|
||||
|
||||
/// How a glyph on a path is bent along it: a point of its pen space (x along its advance from its
|
||||
|
||||
@@ -163,6 +163,7 @@ fn lines_of_clusters(lines: &[&[(usize, usize, f64)]], rtl: bool) -> TextLayout
|
||||
image: None,
|
||||
colour: None,
|
||||
bend: None,
|
||||
unturned: Affine::IDENTITY,
|
||||
});
|
||||
x += advance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user