summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2004-07-08 19:30:45 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-07-08 19:30:45 +0000
commit7fe9544383b46f8c68671d8b41ad3f55c76bb515 (patch)
tree2bcc7b0d289a11da069843f0bc13d7cc72d09aab
parent39833750298d6c102f05331f41fe6bd33c5ffb9a (diff)
downloadpango-7fe9544383b46f8c68671d8b41ad3f55c76bb515.tar.gz
Add pango_context_get_font_map()
Thu Jul 8 15:25:29 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-context.[ch]: Add pango_context_get_font_map() * pango/pango-fonts.c pango/pango-fontset.c pango/pango-context.c: Some s/PangoMetrics/PangoFontMetrics/ in docs. * pango/pango-context.c: Fix problem with unsetting the matrix for a context. * pango/pango-types.h: Switch to a much more efficient implementation of PANGO_SCALE.
-rw-r--r--pango/fonts.c2
-rw-r--r--pango/pango-context.c21
-rw-r--r--pango/pango-context.h1
-rw-r--r--pango/pango-fontset.c2
-rw-r--r--pango/pango-types.h10
5 files changed, 30 insertions, 6 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index 6535f7a9..5afe8bfd 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -1127,7 +1127,7 @@ pango_font_get_glyph_extents (PangoFont *font,
* be provided to indicate that the metrics should be retrieved that
* correspond to the script(s) used by that language.
*
- * Returns: a #PangoMetrics object. The caller must call pango_font_metrics_unref()
+ * Returns: a #PangoFontMetrics object. The caller must call pango_font_metrics_unref()
* when finished using the object.
**/
PangoFontMetrics *
diff --git a/pango/pango-context.c b/pango/pango-context.c
index 5f0ec379..7565103e 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -178,6 +178,8 @@ pango_context_set_matrix (PangoContext *context,
pango_matrix_free (context->matrix);
if (matrix)
context->matrix = pango_matrix_copy (matrix);
+ else
+ context->matrix = NULL;
}
/**
@@ -226,6 +228,23 @@ pango_context_set_font_map (PangoContext *context,
}
/**
+ * pango_context_get_font_map:
+ * @context: a #PangoContext
+ *
+ * Gets the #PangoFontmap used to look up fonts for this context.
+ *
+ * Return value: the font map for the #PangoContext. This value
+ * is owned by Pango and should not be unreferenced.
+ **/
+PangoFontMap *
+pango_context_get_font_map (PangoContext *context)
+{
+ g_return_val_if_fail (PANGO_IS_CONTEXT (context), NULL);
+
+ return context->font_map;
+}
+
+/**
* pango_context_list_families:
* @context: a #PangoContext
* @families: location to store a pointer to an array of PangoFontFamily *.
@@ -1231,7 +1250,7 @@ pango_itemize (PangoContext *context,
* be a composite of the metrics for the fonts loaded for the
* individual families.
*
- * Returns: a #PangoMetrics object. The caller must call pango_font_metrics_unref()
+ * Returns: a #PangoFontMetrics object. The caller must call pango_font_metrics_unref()
* when finished using the object.
**/
PangoFontMetrics *
diff --git a/pango/pango-context.h b/pango/pango-context.h
index 6a6d28c8..a5ae7c74 100644
--- a/pango/pango-context.h
+++ b/pango/pango-context.h
@@ -54,6 +54,7 @@ PangoContext *pango_context_new (void);
void pango_context_set_font_map (PangoContext *context,
PangoFontMap *font_map);
#endif /* PANGO_ENABLE_BACKEND */
+PangoFontMap *pango_context_get_font_map (PangoContext *context);
void pango_context_list_families (PangoContext *context,
PangoFontFamily ***families,
diff --git a/pango/pango-fontset.c b/pango/pango-fontset.c
index d4aaf351..f02344a1 100644
--- a/pango/pango-fontset.c
+++ b/pango/pango-fontset.c
@@ -67,7 +67,7 @@ pango_fontset_get_font (PangoFontset *fontset,
*
* Get overall metric information for the fonts in the fontset.
*
- * Returns: a #PangoMetrics object. The caller must call pango_font_metrics_unref()
+ * Returns: a #PangoFontMetrics object. The caller must call pango_font_metrics_unref()
* when finished using the object.
**/
PangoFontMetrics *
diff --git a/pango/pango-types.h b/pango/pango-types.h
index e2168866..e7c64f7f 100644
--- a/pango/pango-types.h
+++ b/pango/pango-types.h
@@ -111,9 +111,13 @@ void pango_matrix_concat (PangoMatrix *matrix,
PangoMatrix *new_matrix);
#define PANGO_SCALE 1024
-#define PANGO_PIXELS(d) (((d) >= 0) ? \
- ((d) + PANGO_SCALE / 2) / PANGO_SCALE : \
- ((d) - PANGO_SCALE / 2) / PANGO_SCALE)
+#define PANGO_PIXELS(d) (((int)(d) + 512) >> 10)
+/* The above expression is just slightly wrong for floating point d;
+ * We'd expect -512.5 => -1 but instead we get 0. That's unlikely
+ * to matter for practical use and the expression is much more
+ * compact and faster than alternatives that work exactly for both
+ * integers and floating point.
+ */
/* Macros to translate from extents rectangles to ascent/descent/lbearing/rbearing
*/