From: Carl Worth <cworth@cworth.org>
Date: Thu, 7 Nov 2013 21:22:00 +0000 (-0800)
Subject: Force an identity matrix when creating a pango layout
X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=970682d49861e98bdad635128b9db3cbee48ffec;p=acre

Force an identity matrix when creating a pango layout

I've been seeing strange effects in the font rendering when zooming in
dramatically. Inter-character and inter-word spacing was becoming
radically large or radically close to zero, (with overlapping
characters, etc.).

I assume the problem has something to do with numbers outside the
representable range of Pango's fixed-width implementation, (see "pango
units"). Simply setting an identity matrix before creating the layout
and selecting the font clears up all problems that I have seen so far.
---

diff --git a/acre.c b/acre.c
index fac0a20..8e7f1b1 100644
--- a/acre.c
+++ b/acre.c
@@ -368,11 +368,16 @@ _create_layout (acre_t *acre, const char *text)
     if (text == NULL)
 	    text = "";
 
+    cairo_save (acre->cr);
+    cairo_identity_matrix (acre->cr);
+
     layout = pango_cairo_create_layout (acre->cr);
     pango_layout_set_font_description (layout, acre->font);
     pango_layout_set_text (layout, text, -1);
     pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
 
+    cairo_restore (acre->cr);
+
     return layout;
 }