summaryrefslogtreecommitdiff
path: root/pango/pango-context.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2004-05-28 22:53:24 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-05-28 22:53:24 +0000
commit31e0850c421fcc777c452121eb5c68fcf2ce3cda (patch)
tree3ff00cfd6e238df998bcf3c1b95fc059582ab1ce /pango/pango-context.c
parent3ef5e7edc246615f45accafca5d83739b14ca66b (diff)
downloadpango-31e0850c421fcc777c452121eb5c68fcf2ce3cda.tar.gz
Add PangoMatrix type for affine transforms.
Fri May 28 11:39:39 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-types.h pango/pango-utils.c: Add PangoMatrix type for affine transforms. * configure.in pango.pc.in pango/Makefile.am: Add a -lm dependency for PangoMatrix operations. * pango/pango-context.[ch]: Add pango_context_set/get_matrix(). * pango/pangoft2-render.c pango/pangoft2-private.h: Add code for drawing antialiased transformed rectangles and squiggly error underlines. * pango/pangoft2.[ch]: Add pango_ft2_render_transformed(), pango_ft2_render_layout_subpixel(), pango_ft2_render_layout_line_subpixel(), implement transformed rendering. * pango/pangofc-font.c: Pass any transformation matrix on to fontconfig when creating the pattern for a PangoFcFont.
Diffstat (limited to 'pango/pango-context.c')
-rw-r--r--pango/pango-context.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/pango/pango-context.c b/pango/pango-context.c
index 316245dd..9ebde1e1 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -37,6 +37,8 @@ struct _PangoContext
PangoDirection base_dir;
PangoFontDescription *font_desc;
+ PangoMatrix *matrix;
+
PangoFontMap *font_map;
};
@@ -117,6 +119,8 @@ pango_context_finalize (GObject *object)
g_object_unref (context->font_map);
pango_font_description_free (context->font_desc);
+ if (context->matrix)
+ pango_matrix_free (context->matrix);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -152,6 +156,51 @@ pango_context_new (void)
}
/**
+ * pango_context_set_matrix:
+ * @context: a #PangoContext
+ * @matrix: a #PangoMatrix, or %NULL to unset any existing matrix.
+ * (No matrix set is the same as setting the identity matrix.)
+ *
+ * Sets the transformation matrix that will be applied when rendering
+ * with this context. Note that reported metrics are in the user space
+ * coordinates before the application of the matrix, not device-space
+ * coordiantes after the application of the matrix. So, they don't scale
+ * with the matrix, though they may change slightly for different
+ * matrices, depending on how the text is fit to the pixel grid.
+ **/
+void
+pango_context_set_matrix (PangoContext *context,
+ PangoMatrix *matrix)
+{
+ g_return_if_fail (PANGO_IS_CONTEXT (context));
+
+ if (context->matrix)
+ pango_matrix_free (context->matrix);
+ if (matrix)
+ context->matrix = pango_matrix_copy (matrix);
+}
+
+/**
+ * pango_context_get_matrix:
+ * @context: a #PangoContext
+ *
+ * Gets the transformation matrix that will be applied when
+ * rendering with this context. See pango_context_set_matrix().
+ *
+ * Returns: the matrix, or %NULL if no matrix has been set
+ * (which is the same as the identity matrix). The returned
+ * matrix is owned by Pango and must not be modified or
+ * freed.
+ **/
+PangoMatrix *
+pango_context_get_matrix (PangoContext *context)
+{
+ g_return_val_if_fail (PANGO_IS_CONTEXT (context), NULL);
+
+ return context->matrix;
+}
+
+/**
* pango_context_set_font_map:
* @context: a #PangoContext
* @font_map: the #PangoFontMap to set.