summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2005-07-25 12:29:23 +0000
committerOwen Taylor <otaylor@redhat.com>2005-07-25 12:29:23 +0000
commit85b74d82164e7908842d42bb1b11e8cf8c876b82 (patch)
tree34ef2bcd1ff2a0f42278172b990290a328159236 /src
parentfcd8867a47ce77163def423a37bb517870f6cc35 (diff)
src/cairo.[ch] src/cairo-gstate-private.h src/cairo-gstate.c src/cairoint.c: Add cairo_{get,set}_font_options().
Add cairo-xlib-private.h Update reviewed by: cworth
Diffstat (limited to 'src')
-rw-r--r--src/cairo-font-options.c2
-rw-r--r--src/cairo-gstate-private.h1
-rw-r--r--src/cairo-gstate.c22
-rw-r--r--src/cairo.c43
-rw-r--r--src/cairo.h8
-rw-r--r--src/cairoint.h8
6 files changed, 83 insertions, 1 deletions
diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c
index b4535b7c..d7f2529d 100644
--- a/src/cairo-font-options.c
+++ b/src/cairo-font-options.c
@@ -174,7 +174,7 @@ cairo_font_options_merge (cairo_font_options_t *options,
}
/**
- * cairo_font_options_equual:
+ * cairo_font_options_equal:
* @options: a #cairo_font_options_t
* @other: another #cairo_font_options_t
*
diff --git a/src/cairo-gstate-private.h b/src/cairo-gstate-private.h
index 7e2c8597..0d4d499f 100644
--- a/src/cairo-gstate-private.h
+++ b/src/cairo-gstate-private.h
@@ -97,6 +97,7 @@ struct _cairo_gstate {
cairo_font_face_t *font_face;
cairo_scaled_font_t *scaled_font; /* Specific to the current CTM */
cairo_matrix_t font_matrix;
+ cairo_font_options_t font_options;
cairo_clip_t clip;
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 86223d84..e99f9f40 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -121,6 +121,8 @@ _cairo_gstate_init (cairo_gstate_t *gstate,
cairo_matrix_init_scale (&gstate->font_matrix,
CAIRO_GSTATE_DEFAULT_FONT_SIZE,
CAIRO_GSTATE_DEFAULT_FONT_SIZE);
+
+ _cairo_font_options_init_default (&gstate->font_options);
gstate->clip.mode = _cairo_surface_get_clip_mode (target);
gstate->clip.region = NULL;
@@ -1866,6 +1868,24 @@ _cairo_gstate_get_font_matrix (cairo_gstate_t *gstate,
}
cairo_status_t
+_cairo_gstate_set_font_options (cairo_gstate_t *gstate,
+ const cairo_font_options_t *options)
+{
+ _cairo_gstate_unset_font (gstate);
+
+ gstate->font_options = *options;
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+void
+_cairo_gstate_get_font_options (cairo_gstate_t *gstate,
+ cairo_font_options_t *options)
+{
+ *options = gstate->font_options;
+}
+
+cairo_status_t
_cairo_gstate_get_font_face (cairo_gstate_t *gstate,
cairo_font_face_t **font_face)
{
@@ -1984,6 +2004,8 @@ _cairo_gstate_ensure_font (cairo_gstate_t *gstate)
return status;
cairo_surface_get_font_options (gstate->target, &options);
+ cairo_font_options_merge (&options, &gstate->font_options);
+
gstate->scaled_font = cairo_scaled_font_create (gstate->font_face,
&gstate->font_matrix,
&gstate->ctm,
diff --git a/src/cairo.c b/src/cairo.c
index 56da06ea..8d865e01 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -1793,6 +1793,49 @@ cairo_get_font_matrix (cairo_t *cr, cairo_matrix_t *matrix)
}
/**
+ * cairo_set_font_options:
+ * @cr: a #cairo_t
+ * @options: font options to use
+ *
+ * Sets a set of custom font rendering options for the #cairo_t.
+ * Rendering options are derived by merging these options with the
+ * options derived from underlying surface; if the value in @options
+ * has a default value (like %CAIRO_ANTIALIAS_DEFAULT), then the value
+ * from the surface is used.
+ **/
+void
+cairo_set_font_options (cairo_t *cr,
+ const cairo_font_options_t *options)
+{
+ if (cr->status) {
+ _cairo_error (cr, cr->status);
+ return;
+ }
+
+ cr->status = _cairo_gstate_set_font_options (cr->gstate, options);
+ if (cr->status)
+ _cairo_error (cr, cr->status);
+}
+
+/**
+ * cairo_get_font_options:
+ * @cr: a #cairo_t
+ * @options: a #cairo_font_options_t object into which to store
+ * the retrieved options. All existing values are overwritten
+ *
+ * Retrieves font rendering options set via #cairo_set_font_options.
+ * Note that the returned options do not include any options derived
+ * from the underlying surface; they are literally the options
+ * passed to cairo_set_font_options().
+ **/
+void
+cairo_get_font_options (cairo_t *cr,
+ cairo_font_options_t *options)
+{
+ _cairo_gstate_get_font_options (cr->gstate, options);
+}
+
+/**
* cairo_text_extents:
* @cr: a #cairo_t
* @utf8: a string of text, encoded in utf-8
diff --git a/src/cairo.h b/src/cairo.h
index c701208e..bf398c5f 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -821,6 +821,14 @@ cairo_get_font_matrix (cairo_t *cr,
cairo_matrix_t *matrix);
void
+cairo_set_font_options (cairo_t *cr,
+ const cairo_font_options_t *options);
+
+void
+cairo_get_font_options (cairo_t *cr,
+ cairo_font_options_t *options);
+
+void
cairo_show_text (cairo_t *cr, const char *utf8);
void
diff --git a/src/cairoint.h b/src/cairoint.h
index 32f99beb..a7ff7318 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1207,6 +1207,14 @@ cairo_private cairo_status_t
_cairo_gstate_set_font_matrix (cairo_gstate_t *gstate,
const cairo_matrix_t *matrix);
+void
+_cairo_gstate_get_font_options (cairo_gstate_t *gstate,
+ cairo_font_options_t *options);
+
+cairo_private cairo_status_t
+_cairo_gstate_set_font_options (cairo_gstate_t *gstate,
+ const cairo_font_options_t *options);
+
cairo_private cairo_status_t
_cairo_gstate_get_font_face (cairo_gstate_t *gstate,
cairo_font_face_t **font_face);