Skip to content

Commit

Permalink
font options: Add private round_glpyh_positions field
Browse files Browse the repository at this point in the history
Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information
Uli Schlachter committed Oct 21, 2010
1 parent fae8805 commit 6bfe711
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 3 deletions.
49 changes: 47 additions & 2 deletions src/cairo-font-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

/**
Expand All @@ -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
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -389,6 +395,45 @@ _cairo_font_options_get_lcd_filter (const cairo_font_options_t *options)
return options->lcd_filter;
}

/**
* _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
Expand Down
3 changes: 2 additions & 1 deletion src/cairo-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */ \
}

Expand Down
7 changes: 7 additions & 0 deletions src/cairo-types-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/cairoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6bfe711

Please sign in to comment.