[cairo-commit] 4 commits - src/cairo-font-options.c src/cairo-gl-surface.c src/cairo-image-surface.c src/cairoint.h src/cairo-pdf-surface.c src/cairo-ps-surface.c src/cairo-scaled-font.c src/cairo-surface.c src/cairo-svg-surface.c src/cairo-types-private.h src/cairo-vg-surface.c src/cairo-win32-printing-surface.c src/cairo-xcb-surface.c src/cairo-xlib-screen.c
Andrea Canciani
ranma42 at kemper.freedesktop.org
Fri Oct 22 00:07:13 PDT 2010
src/cairo-font-options.c | 49 +++++++++++++++++++++++++++++++++++--
src/cairo-gl-surface.c | 1
src/cairo-image-surface.c | 1
src/cairo-pdf-surface.c | 1
src/cairo-ps-surface.c | 1
src/cairo-scaled-font.c | 11 ++++++--
src/cairo-surface.c | 3 +-
src/cairo-svg-surface.c | 1
src/cairo-types-private.h | 7 +++++
src/cairo-vg-surface.c | 1
src/cairo-win32-printing-surface.c | 1
src/cairo-xcb-surface.c | 1
src/cairo-xlib-screen.c | 1
src/cairoint.h | 7 +++++
14 files changed, 81 insertions(+), 5 deletions(-)
New commits:
commit cee1dadc66107e1cc6bcac7718e0b67969141876
Author: Uli Schlachter <psychon at znc.in>
Date: Thu Oct 21 22:14:57 2010 +0200
Other backends: Set round_glyph_positions to OFF
This sets CAIRO_ROUND_GLYPH_POS_OFF in all surface backends that didn't use
CAIRO_ROUND_GLYPH_POS_ON.
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index d8de9b9..11d68f3 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -3609,6 +3609,7 @@ _cairo_pdf_surface_get_font_options (void *abstract_surface,
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GRAY);
+ _cairo_font_options_set_round_glyph_positions (options, CAIRO_ROUND_GLYPH_POS_OFF);
}
static cairo_pdf_resource_t
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 4e8aa0a..71d8398 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -3490,6 +3490,7 @@ _cairo_ps_surface_get_font_options (void *abstract_surface,
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GRAY);
+ _cairo_font_options_set_round_glyph_positions (options, CAIRO_ROUND_GLYPH_POS_OFF);
}
static cairo_int_status_t
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index fb612fa..9628166 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -2574,6 +2574,7 @@ _cairo_svg_surface_get_font_options (void *abstract_surface,
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GRAY);
+ _cairo_font_options_set_round_glyph_positions (options, CAIRO_ROUND_GLYPH_POS_OFF);
}
static const cairo_surface_backend_t cairo_svg_surface_backend = {
diff --git a/src/cairo-vg-surface.c b/src/cairo-vg-surface.c
index acc3f80..a35c517 100644
--- a/src/cairo-vg-surface.c
+++ b/src/cairo-vg-surface.c
@@ -1301,6 +1301,7 @@ _vg_surface_get_font_options (void *abstract_surface,
_cairo_font_options_init_default (options);
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
+ _cairo_font_options_set_round_glyph_positions (options, CAIRO_ROUND_GLYPH_POS_OFF);
}
static cairo_int_status_t
commit d24e9881de7b392cfce1d82c9861553ece558aaf
Author: Uli Schlachter <psychon at znc.in>
Date: Thu Oct 21 14:03:38 2010 +0200
raster backends: Set round_glpyh_positions to ON
This fixes "text-rotate" in the test suite for the image backend and
"overlapping-glyphs" for the xcb backend.
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c
index e53506c..278e642 100644
--- a/src/cairo-gl-surface.c
+++ b/src/cairo-gl-surface.c
@@ -1368,6 +1368,7 @@ _cairo_gl_surface_get_font_options (void *abstract_surface,
_cairo_font_options_init_default (options);
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
+ _cairo_font_options_set_round_glyph_positions (options, CAIRO_ROUND_GLYPH_POS_ON);
}
static cairo_status_t
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 5b2c063..2d769ea 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -4088,6 +4088,7 @@ _cairo_image_surface_get_font_options (void *abstract_surface,
_cairo_font_options_init_default (options);
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
+ _cairo_font_options_set_round_glyph_positions (options, CAIRO_ROUND_GLYPH_POS_ON);
}
/* legacy interface kept for compatibility until surface-fallback is removed */
diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c
index 497be25..1e8bd26 100644
--- a/src/cairo-win32-printing-surface.c
+++ b/src/cairo-win32-printing-surface.c
@@ -1157,6 +1157,7 @@ _cairo_win32_printing_surface_get_font_options (void *abstract_
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
cairo_font_options_set_antialias (options, CAIRO_ANTIALIAS_GRAY);
+ _cairo_font_options_set_round_glyph_positions (options, CAIRO_ROUND_GLYPH_POS_ON);
}
static cairo_int_status_t
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 656e589..80fc19c 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -604,6 +604,7 @@ _cairo_xcb_surface_get_font_options (void *abstract_surface,
{
/* XXX copy from xlib */
_cairo_font_options_init_default (options);
+ _cairo_font_options_set_round_glyph_positions (options, CAIRO_ROUND_GLYPH_POS_ON);
}
static cairo_status_t
diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c
index 801dc3d..a0c3df8 100644
--- a/src/cairo-xlib-screen.c
+++ b/src/cairo-xlib-screen.c
@@ -447,6 +447,7 @@ _cairo_xlib_screen_get_font_options (cairo_xlib_screen_t *info)
{
if (! info->has_font_options) {
_cairo_font_options_init_default (&info->font_options);
+ _cairo_font_options_set_round_glyph_positions (&info->font_options, CAIRO_ROUND_GLYPH_POS_ON);
if (info->screen != NULL) {
cairo_xlib_display_t *display;
commit b514863a0ee8e6c4f0a994f6f5e7db18ce290e79
Author: Uli Schlachter <psychon at znc.in>
Date: Thu Oct 21 13:59:25 2010 +0200
Actually implement round_glpyh_positions
The previous commit only added this option and made sure it gets set, but it
didn't actually have any effect. This commit now implements this option.
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index b40e4d4..12d8cea 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -2071,6 +2071,7 @@ _cairo_scaled_font_glyph_device_extents (cairo_scaled_font_t *scaled_font,
cairo_box_t box = { { INT_MAX, INT_MAX }, { INT_MIN, INT_MIN }};
cairo_scaled_glyph_t *glyph_cache[64];
cairo_bool_t overlap = overlap_out ? FALSE : TRUE;
+ cairo_round_glyph_positions_t round_glyph_positions = _cairo_font_options_get_round_glyph_positions (&scaled_font->options);
int i;
if (unlikely (scaled_font->status))
@@ -2099,11 +2100,17 @@ _cairo_scaled_font_glyph_device_extents (cairo_scaled_font_t *scaled_font,
glyph_cache[cache_index] = scaled_glyph;
}
- x = _cairo_fixed_from_double (glyphs[i].x);
+ if (round_glyph_positions == CAIRO_ROUND_GLYPH_POS_ON)
+ x = _cairo_fixed_from_double (_cairo_lround (glyphs[i].x));
+ else
+ x = _cairo_fixed_from_double (glyphs[i].x);
x1 = x + scaled_glyph->bbox.p1.x;
x2 = x + scaled_glyph->bbox.p2.x;
- y = _cairo_fixed_from_double (glyphs[i].y);
+ if (round_glyph_positions == CAIRO_ROUND_GLYPH_POS_ON)
+ y = _cairo_fixed_from_double (_cairo_lround (glyphs[i].y));
+ else
+ y = _cairo_fixed_from_double (glyphs[i].y);
y1 = y + scaled_glyph->bbox.p1.y;
y2 = y + scaled_glyph->bbox.p2.y;
commit 6bfe71124b56b496056b77b3b51eef4d656ccf54
Author: Uli Schlachter <psychon at znc.in>
Date: Thu Oct 21 13:52:33 2010 +0200
font options: Add private round_glpyh_positions field
Signed-off-by: Uli Schlachter <psychon at znc.in>
diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c
index b472a30..5d59fb0 100644
--- a/src/cairo-font-options.c
+++ b/src/cairo-font-options.c
@@ -54,7 +54,8 @@ static const cairo_font_options_t _cairo_font_options_nil = {
CAIRO_SUBPIXEL_ORDER_DEFAULT,
CAIRO_LCD_FILTER_DEFAULT,
CAIRO_HINT_STYLE_DEFAULT,
- CAIRO_HINT_METRICS_DEFAULT
+ CAIRO_HINT_METRICS_DEFAULT,
+ CAIRO_ROUND_GLYPH_POS_DEFAULT
};
/**
@@ -71,6 +72,7 @@ _cairo_font_options_init_default (cairo_font_options_t *options)
options->lcd_filter = CAIRO_LCD_FILTER_DEFAULT;
options->hint_style = CAIRO_HINT_STYLE_DEFAULT;
options->hint_metrics = CAIRO_HINT_METRICS_DEFAULT;
+ options->round_glyph_positions = CAIRO_ROUND_GLYPH_POS_DEFAULT;
}
void
@@ -82,6 +84,7 @@ _cairo_font_options_init_copy (cairo_font_options_t *options,
options->lcd_filter = other->lcd_filter;
options->hint_style = other->hint_style;
options->hint_metrics = other->hint_metrics;
+ options->round_glyph_positions = other->round_glyph_positions;
}
/**
@@ -211,6 +214,8 @@ cairo_font_options_merge (cairo_font_options_t *options,
options->hint_style = other->hint_style;
if (other->hint_metrics != CAIRO_HINT_METRICS_DEFAULT)
options->hint_metrics = other->hint_metrics;
+ if (other->round_glyph_positions != CAIRO_ROUND_GLYPH_POS_DEFAULT)
+ options->round_glyph_positions = other->round_glyph_positions;
}
slim_hidden_def (cairo_font_options_merge);
@@ -241,7 +246,8 @@ cairo_font_options_equal (const cairo_font_options_t *options,
options->subpixel_order == other->subpixel_order &&
options->lcd_filter == other->lcd_filter &&
options->hint_style == other->hint_style &&
- options->hint_metrics == other->hint_metrics);
+ options->hint_metrics == other->hint_metrics &&
+ options->round_glyph_positions == other->round_glyph_positions);
}
slim_hidden_def (cairo_font_options_equal);
@@ -390,6 +396,45 @@ _cairo_font_options_get_lcd_filter (const cairo_font_options_t *options)
}
/**
+ * _cairo_font_options_set_round_glyph_positions:
+ * @options: a #cairo_font_options_t
+ * @round: the new rounding value
+ *
+ * Sets the rounding options for the font options object. If rounding is set, a
+ * glyph's position will be rounded to integer values.
+ *
+ * Since: 1.12
+ **/
+void
+_cairo_font_options_set_round_glyph_positions (cairo_font_options_t *options,
+ cairo_round_glyph_positions_t round)
+{
+ if (cairo_font_options_status (options))
+ return;
+
+ options->round_glyph_positions = round;
+}
+
+/**
+ * _cairo_font_options_get_round_glyph_positions:
+ * @options: a #cairo_font_options_t
+ *
+ * Gets the glyph position rounding option for the font options object.
+ *
+ * Return value: The round glyph posistions flag for the font options object.
+ *
+ * Since: 1.12
+ **/
+cairo_round_glyph_positions_t
+_cairo_font_options_get_round_glyph_positions (const cairo_font_options_t *options)
+{
+ if (cairo_font_options_status ((cairo_font_options_t *) options))
+ return CAIRO_ROUND_GLYPH_POS_DEFAULT;
+
+ return options->round_glyph_positions;
+}
+
+/**
* cairo_font_options_set_hint_style:
* @options: a #cairo_font_options_t
* @hint_style: the new hint style
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index ba70a2e..2293991 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -123,7 +123,8 @@ const cairo_surface_t name = { \
CAIRO_SUBPIXEL_ORDER_DEFAULT, /* subpixel_order */ \
CAIRO_LCD_FILTER_DEFAULT, /* lcd_filter */ \
CAIRO_HINT_STYLE_DEFAULT, /* hint_style */ \
- CAIRO_HINT_METRICS_DEFAULT /* hint_metrics */ \
+ CAIRO_HINT_METRICS_DEFAULT, /* hint_metrics */ \
+ CAIRO_ROUND_GLYPH_POS_DEFAULT /* round_glyph_positions */ \
} /* font_options */ \
}
diff --git a/src/cairo-types-private.h b/src/cairo-types-private.h
index ac3fda8..93b035d 100644
--- a/src/cairo-types-private.h
+++ b/src/cairo-types-private.h
@@ -161,12 +161,19 @@ typedef enum _cairo_lcd_filter {
CAIRO_LCD_FILTER_FIR5
} cairo_lcd_filter_t;
+typedef enum _cairo_round_glyph_positions {
+ CAIRO_ROUND_GLYPH_POS_DEFAULT,
+ CAIRO_ROUND_GLYPH_POS_ON,
+ CAIRO_ROUND_GLYPH_POS_OFF
+} cairo_round_glyph_positions_t;
+
struct _cairo_font_options {
cairo_antialias_t antialias;
cairo_subpixel_order_t subpixel_order;
cairo_lcd_filter_t lcd_filter;
cairo_hint_style_t hint_style;
cairo_hint_metrics_t hint_metrics;
+ cairo_round_glyph_positions_t round_glyph_positions;
};
/* XXX: Right now, the _cairo_color structure puts unpremultiplied
diff --git a/src/cairoint.h b/src/cairoint.h
index e3582ec..346fc51 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1088,6 +1088,13 @@ _cairo_font_options_set_lcd_filter (cairo_font_options_t *options,
cairo_private cairo_lcd_filter_t
_cairo_font_options_get_lcd_filter (const cairo_font_options_t *options);
+cairo_private void
+_cairo_font_options_set_round_glyph_positions (cairo_font_options_t *options,
+ cairo_round_glyph_positions_t round);
+
+cairo_private cairo_round_glyph_positions_t
+_cairo_font_options_get_round_glyph_positions (const cairo_font_options_t *options);
+
/* cairo-hull.c */
cairo_private cairo_status_t
_cairo_hull_compute (cairo_pen_vertex_t *vertices, int *num_vertices);
More information about the cairo-commit
mailing list