linebender / norad

Rust crate for working with Unified Font Object files
Apache License 2.0
43 stars 12 forks source link

Implement transformation for glyph contents when kurbo available #110

Open madig opened 3 years ago

madig commented 3 years ago

I'd like to be able to do kurbo::Affine * Contour or some such, found at least two instances where that would come in handy. Maybe something for returning a transformed copy and for transforming in place?

cmyr commented 3 years ago

mm. I was also today running into decomposition, so I do think it makes sense to have a to_kurbo method on Contour, behind the kurbo feature. Does it make more sense to use the norad affine type in your case? I'm not sure, just thinking aloud...

madig commented 3 years ago

Then all the affine transformations would need to be impl'd on norad's affine type, no? I thought we should reuse kurbo for that.

simoncozens commented 3 years ago

Can we also have a to_kurbo method (or even better some kind of Into trait) on AffineTransform for components? Currently I'm doing this:

    let transform = [
        component.transform.x_scale as f64,
        component.transform.xy_scale as f64,
        component.transform.y_scale as f64,
        component.transform.yx_scale as f64,
        component.transform.x_offset as f64,
        component.transform.y_offset as f64,
    ];
    Affine::new(transform)
cmyr commented 3 years ago

@simoncozens we've got this already: https://github.com/linebender/norad/blob/master/src/glyph/mod.rs#L556

simoncozens commented 3 years ago

Hah, great. Not sure why I couldn’t see it on docs.rs - maybe it doesn’t pick up stuff behind features.

cmyr commented 3 years ago

Yes, I think that's true.