diff --git a/src/hb-aat-var-hvgl-table.cc b/src/hb-aat-var-hvgl-table.cc index 4f09d1d19..18bdac313 100644 --- a/src/hb-aat-var-hvgl-table.cc +++ b/src/hb-aat-var-hvgl-table.cc @@ -422,7 +422,12 @@ PartComposite::apply_to_transforms (hb_array_t> transform if (master_rotation_count && *master_rotation_indices == row) { - transform.rotate ((double) *master_rotation_deltas, true); + // Since transform is identity by default, we can just replace it with + // rotation. This saves a multiplication. + if (true) + transform = hb_transform_t::rotation ((double) *master_rotation_deltas); + else + transform.rotate ((double) *master_rotation_deltas, true); master_rotation_count--; master_rotation_indices++; master_rotation_deltas++; diff --git a/src/hb-geometry.hh b/src/hb-geometry.hh index cc774bab1..d484b0218 100644 --- a/src/hb-geometry.hh +++ b/src/hb-geometry.hh @@ -203,17 +203,21 @@ struct hb_transform_t yy *= scaleY; } - void rotate (Float rotation, bool before=false) + static hb_transform_t rotation (Float rotation) { - if (rotation == 0) - return; - // https://github.com/fonttools/fonttools/blob/f66ee05f71c8b57b5f519ee975e95edcd1466e14/Lib/fontTools/misc/transform.py#L240 Float c; Float s; hb_sincos (rotation, s, c); - auto other = hb_transform_t{c, s, -s, c, 0, 0}; - transform (other, before); + return {c, s, -s, c, 0, 0}; + } + + void rotate (Float radians, bool before=false) + { + if (radians == 0) + return; + + transform (rotation (radians), before); } void skew (Float skewX, Float skewY)