Browse Source

LibGfx: Fix affine transformations in TrueType composite glyphs

This fixes an issue where, when looping over the components of a
composite glyph, we used to mutate the affine transformation of the
glyph itself when computing the transformations of its components.

(AffineTransform::multiply() is non-const).
Itamar 2 years ago
parent
commit
7165dbce5c
1 changed files with 3 additions and 2 deletions
  1. 3 2
      Userland/Libraries/LibGfx/Font/TrueType/Glyf.h

+ 3 - 2
Userland/Libraries/LibGfx/Font/TrueType/Glyf.h

@@ -105,7 +105,7 @@ public:
         RefPtr<Gfx::Bitmap> rasterize_simple(i16 ascender, i16 descender, float x_scale, float y_scale) const;
         RefPtr<Gfx::Bitmap> rasterize_simple(i16 ascender, i16 descender, float x_scale, float y_scale) const;
 
 
         template<typename GlyphCb>
         template<typename GlyphCb>
-        void rasterize_composite_loop(Rasterizer& rasterizer, Gfx::AffineTransform& transform, GlyphCb glyph_callback) const
+        void rasterize_composite_loop(Rasterizer& rasterizer, Gfx::AffineTransform const& transform, GlyphCb glyph_callback) const
         {
         {
             ComponentIterator component_iterator(m_slice);
             ComponentIterator component_iterator(m_slice);
 
 
@@ -115,7 +115,8 @@ public:
                     break;
                     break;
                 }
                 }
                 auto item = opt_item.value();
                 auto item = opt_item.value();
-                auto affine_here = transform.multiply(item.affine);
+                Gfx::AffineTransform affine_here { transform };
+                affine_here.multiply(item.affine);
                 Glyph glyph = glyph_callback(item.glyph_id);
                 Glyph glyph = glyph_callback(item.glyph_id);
 
 
                 if (glyph.m_type == Type::Simple) {
                 if (glyph.m_type == Type::Simple) {