RazrFalcon / rustybuzz

A complete harfbuzz's shaping algorithm port to Rust
MIT License
498 stars 34 forks source link

Using `Face` with multiple font sizes #43

Closed mahkoh closed 10 months ago

mahkoh commented 2 years ago

I'm storing a Face in an Arc that is shared across multiple threads. When I need to perform shaping, I call Face::clone and set the font size on the cloned Face. This clone is not entirely free because Face contains a Vec.

I would like for shape to take an additional argument that contains all of the mutable properties of a Face so that Face can be treated as immutable after construction. E.g.

struct FaceConfig {
    pub pixels_per_em: Option<(u16, u16)>,
    pub points_per_em: Option<f32>,
}

pub fn shape(face: &Face, config: &FaceConfig, features: &[Feature], buffer: UnicodeBuffer) -> GlyphBuffer {
RazrFalcon commented 2 years ago

Yes, I guess it makes sense.

behdad commented 2 years ago
struct FaceConfig {
    pub pixels_per_em: Option<(u16, u16)>,
    pub points_per_em: Option<f32>,
}

We call them Font in HarfBuzz.