diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 21 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 21 | ||||
-rw-r--r-- | docs/pango-sections.txt | 3 | ||||
-rw-r--r-- | docs/pango_markup.sgml | 17 | ||||
-rw-r--r-- | docs/tmpl/text-attributes.sgml | 24 | ||||
-rw-r--r-- | docs/tmpl/win32-fonts.sgml | 13 | ||||
-rw-r--r-- | pango/pango-attributes.c | 54 | ||||
-rw-r--r-- | pango/pango-attributes.h | 16 | ||||
-rw-r--r-- | pango/pango-markup.c | 48 | ||||
-rw-r--r-- | pango/pango-renderer.c | 169 |
11 files changed, 323 insertions, 84 deletions
@@ -1,3 +1,24 @@ +Tue Nov 23 10:23:43 2004 Owen Taylor <otaylor@redhat.com> + + * pango/pango-attributes.[ch]: Add underline_color + and strikethrough_color attribute types. (#147616, Morten + Welinder) + + * pango/pango-markup.c docs/pango_markup.sgml: Add + corresponding 'underline_color' and + 'strikethrough_color' attributes for <span>. + + * pango/pango-renderer.c (pango_renderer_default_prepare_run): + Implement underline and strikethrough colors. + + * pango/pango-renderer.c: Fix some bigs with updating + underlines/strikethrough state. + + * pango/pango-renderer.c (get_total_matrix): Fix a const + warning. + + * docs/pango-sections.txt: Update + Mon Nov 22 15:53:37 2004 Manish Singh <yosh@gimp.org> * modules/thai/Makefile.am: Remove stray 'x' character. diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index f4f18f26..e0ccdc7a 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,24 @@ +Tue Nov 23 10:23:43 2004 Owen Taylor <otaylor@redhat.com> + + * pango/pango-attributes.[ch]: Add underline_color + and strikethrough_color attribute types. (#147616, Morten + Welinder) + + * pango/pango-markup.c docs/pango_markup.sgml: Add + corresponding 'underline_color' and + 'strikethrough_color' attributes for <span>. + + * pango/pango-renderer.c (pango_renderer_default_prepare_run): + Implement underline and strikethrough colors. + + * pango/pango-renderer.c: Fix some bigs with updating + underlines/strikethrough state. + + * pango/pango-renderer.c (get_total_matrix): Fix a const + warning. + + * docs/pango-sections.txt: Update + Mon Nov 22 15:53:37 2004 Manish Singh <yosh@gimp.org> * modules/thai/Makefile.am: Remove stray 'x' character. diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index f4f18f26..e0ccdc7a 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,24 @@ +Tue Nov 23 10:23:43 2004 Owen Taylor <otaylor@redhat.com> + + * pango/pango-attributes.[ch]: Add underline_color + and strikethrough_color attribute types. (#147616, Morten + Welinder) + + * pango/pango-markup.c docs/pango_markup.sgml: Add + corresponding 'underline_color' and + 'strikethrough_color' attributes for <span>. + + * pango/pango-renderer.c (pango_renderer_default_prepare_run): + Implement underline and strikethrough colors. + + * pango/pango-renderer.c: Fix some bigs with updating + underlines/strikethrough state. + + * pango/pango-renderer.c (get_total_matrix): Fix a const + warning. + + * docs/pango-sections.txt: Update + Mon Nov 22 15:53:37 2004 Manish Singh <yosh@gimp.org> * modules/thai/Makefile.am: Remove stray 'x' character. diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt index 939952c2..10600e3c 100644 --- a/docs/pango-sections.txt +++ b/docs/pango-sections.txt @@ -303,7 +303,9 @@ pango_attr_font_desc_new pango_attr_foreground_new pango_attr_background_new pango_attr_strikethrough_new +pango_attr_strikethrough_color_new pango_attr_underline_new +pango_attr_underline_color_new PangoUnderline PANGO_TYPE_UNDERLINE pango_attr_shape_new @@ -656,6 +658,7 @@ pango_x_font_cache_unload PANGO_RENDER_TYPE_WIN32 pango_win32_get_context pango_win32_render +pango_win32_render_transformed pango_win32_render_layout_line pango_win32_render_layout pango_win32_get_unknown_glyph diff --git a/docs/pango_markup.sgml b/docs/pango_markup.sgml index 4a55356e..7bd81ac3 100644 --- a/docs/pango_markup.sgml +++ b/docs/pango_markup.sgml @@ -69,7 +69,7 @@ Synonym for font_family <varlistentry><term>size</term> <listitem><para> -Font size in 1024ths of a point, one of the absolute sizes +Font size in 1024ths of a point, or one of the absolute sizes 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', or one of the relative sizes 'smaller' or 'larger'. If you want to specify a absolute size, it's usually easier @@ -127,6 +127,14 @@ One of 'single', 'double', 'low', 'none' </para></listitem> </varlistentry> +<varlistentry><term>underline_col +or</term> +<listitem><para> +The color of underlines; an RGB color specification such as '#00FF00' +or a color name such as 'red' +</para></listitem> +</varlistentry> + <varlistentry><term>rise</term> <listitem><para> Vertical displacement, in 10000ths of an em. Can be negative for @@ -140,6 +148,13 @@ subscript, positive for superscript. </para></listitem> </varlistentry> +<varlistentry><term>strikethrough_color</term> +<listitem><para> +The color of strikethrough lines; an RGB color specification such as +'#00FF00' or a color name such as 'red' +</para></listitem> +</varlistentry> + <varlistentry><term>fallback</term> <listitem><para> 'true' or 'false' whether to enable fallback. If disabled, then characters diff --git a/docs/tmpl/text-attributes.sgml b/docs/tmpl/text-attributes.sgml index 5aee1e0a..d4f5d467 100644 --- a/docs/tmpl/text-attributes.sgml +++ b/docs/tmpl/text-attributes.sgml @@ -45,6 +45,8 @@ attribute is listed in parentheses after the description. @PANGO_ATTR_SCALE: font size scale factor (#PangoAttrScale) @PANGO_ATTR_FALLBACK: whether fallback is enabled (#PangoAttrInt) @PANGO_ATTR_LETTER_SPACING: +@PANGO_ATTR_UNDERLINE_COLOR: +@PANGO_ATTR_STRIKETHROUGH_COLOR: <!-- ##### MACRO PANGO_TYPE_ATTR_TYPE ##### --> <para> @@ -301,6 +303,17 @@ impose shape restrictions. @Returns: +<!-- ##### FUNCTION pango_attr_strikethrough_color_new ##### --> +<para> + +</para> + +@red: +@green: +@blue: +@Returns: + + <!-- ##### FUNCTION pango_attr_underline_new ##### --> <para> @@ -310,6 +323,17 @@ impose shape restrictions. @Returns: +<!-- ##### FUNCTION pango_attr_underline_color_new ##### --> +<para> + +</para> + +@red: +@green: +@blue: +@Returns: + + <!-- ##### ENUM PangoUnderline ##### --> <para> the #PangoUnderline enumeration is used to specify diff --git a/docs/tmpl/win32-fonts.sgml b/docs/tmpl/win32-fonts.sgml index 5f997876..863b8500 100644 --- a/docs/tmpl/win32-fonts.sgml +++ b/docs/tmpl/win32-fonts.sgml @@ -42,6 +42,19 @@ g_quark_from_string()) is used to identify the renderer in pango_find_map(). @y: +<!-- ##### FUNCTION pango_win32_render_transformed ##### --> +<para> + +</para> + +@hdc: +@matrix: +@font: +@glyphs: +@x: +@y: + + <!-- ##### FUNCTION pango_win32_render_layout_line ##### --> <para> diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index 276f7acd..f4b9b5e2 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -578,6 +578,33 @@ pango_attr_underline_new (PangoUnderline underline) } /** + * pango_attr_underline_color_new: + * @red: the red value (ranging from 0 to 65535) + * @green: the green value + * @blue: the blue value + * + * Create a new underline color attribute. This attribute + * modifies the color of underlines. If not set, underlines + * will use the foreground color. + * + * Return value: the new #PangoAttribute. + **/ +PangoAttribute * +pango_attr_underline_color_new (guint16 red, + guint16 green, + guint16 blue) +{ + static const PangoAttrClass klass = { + PANGO_ATTR_UNDERLINE_COLOR, + pango_attr_color_copy, + pango_attr_color_destroy, + pango_attr_color_equal + }; + + return pango_attr_color_new (&klass, red, green, blue); +} + +/** * pango_attr_strikethrough_new: * @strikethrough: %TRUE if the text should be struck-through. * @@ -599,6 +626,33 @@ pango_attr_strikethrough_new (gboolean strikethrough) } /** + * pango_attr_strikethrough_color_new: + * @red: the red value (ranging from 0 to 65535) + * @green: the green value + * @blue: the blue value + * + * Create a new strikethrough color attribute. This attribute + * modifies the color of strikethrough lines. If not set, strikethrough + * lines will use the foreground color. + * + * Return value: the new #PangoAttribute. + **/ +PangoAttribute * +pango_attr_strikethrough_color_new (guint16 red, + guint16 green, + guint16 blue) +{ + static const PangoAttrClass klass = { + PANGO_ATTR_STRIKETHROUGH_COLOR, + pango_attr_color_copy, + pango_attr_color_destroy, + pango_attr_color_equal + }; + + return pango_attr_color_new (&klass, red, green, blue); +} + +/** * pango_attr_rise_new: * @rise: the amount that the text should be displaced vertically, * in Pango units. Positive values displace the text upwards. diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h index 643d15e8..69b63187 100644 --- a/pango/pango-attributes.h +++ b/pango/pango-attributes.h @@ -82,7 +82,9 @@ typedef enum PANGO_ATTR_SHAPE, /* PangoAttrShape */ PANGO_ATTR_SCALE, /* PangoAttrFloat */ PANGO_ATTR_FALLBACK, /* PangoAttrInt */ - PANGO_ATTR_LETTER_SPACING /* PangoAttrInt */ + PANGO_ATTR_LETTER_SPACING, /* PangoAttrInt */ + PANGO_ATTR_UNDERLINE_COLOR, /* PangoAttrColor */ + PANGO_ATTR_STRIKETHROUGH_COLOR /* PangoAttrColor */ } PangoAttrType; typedef enum { @@ -182,8 +184,16 @@ PangoAttribute *pango_attr_weight_new (PangoWeight weight PangoAttribute *pango_attr_variant_new (PangoVariant variant); PangoAttribute *pango_attr_stretch_new (PangoStretch stretch); PangoAttribute *pango_attr_font_desc_new (const PangoFontDescription *desc); -PangoAttribute *pango_attr_underline_new (PangoUnderline underline); -PangoAttribute *pango_attr_strikethrough_new (gboolean strikethrough); + +PangoAttribute *pango_attr_underline_new (PangoUnderline underline); +PangoAttribute *pango_attr_underline_color_new (guint16 red, + guint16 green, + guint16 blue); +PangoAttribute *pango_attr_strikethrough_new (gboolean strikethrough); +PangoAttribute *pango_attr_strikethrough_color_new (guint16 red, + guint16 green, + guint16 blue); + PangoAttribute *pango_attr_rise_new (int rise); PangoAttribute *pango_attr_scale_new (double scale_factor); PangoAttribute *pango_attr_fallback_new (gboolean enable_fallback); diff --git a/pango/pango-markup.c b/pango/pango-markup.c index 3b45cc73..5f68b8cd 100644 --- a/pango/pango-markup.c +++ b/pango/pango-markup.c @@ -855,7 +855,9 @@ span_parse_func (MarkupData *md, const char *foreground = NULL; const char *background = NULL; const char *underline = NULL; + const char *underline_color = NULL; const char *strikethrough = NULL; + const char *strikethrough_color = NULL; const char *rise = NULL; const char *letter_spacing = NULL; const char *lang = NULL; @@ -919,11 +921,21 @@ span_parse_func (MarkupData *md, CHECK_DUPLICATE (underline); underline = values[i]; } + else if (strcmp (names[i], "underline_color") == 0) + { + CHECK_DUPLICATE (underline_color); + underline_color = values[i]; + } else if (strcmp (names[i], "strikethrough") == 0) { CHECK_DUPLICATE (strikethrough); strikethrough = values[i]; } + else if (strcmp (names[i], "strikethrough_color") == 0) + { + CHECK_DUPLICATE (strikethrough_color); + strikethrough_color = values[i]; + } else if (strcmp (names[i], "rise") == 0) { CHECK_DUPLICATE (rise); @@ -1177,6 +1189,24 @@ span_parse_func (MarkupData *md, add_attribute (tag, pango_attr_underline_new (ul)); } + if (underline_color) + { + PangoColor color; + + if (!pango_color_parse (&color, underline_color)) + { + g_set_error (error, + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + _("Could not parse underline_color color specification " + "'%s' on line %d"), + underline_color, line_number); + goto error; + } + + add_attribute (tag, pango_attr_underline_color_new (color.red, color.green, color.blue)); + } + if (strikethrough) { if (strcmp (strikethrough, "true") == 0) @@ -1196,6 +1226,24 @@ span_parse_func (MarkupData *md, } } + if (strikethrough_color) + { + PangoColor color; + + if (!pango_color_parse (&color, strikethrough_color)) + { + g_set_error (error, + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + _("Could not parse strikethrough_color color specification " + "'%s' on line %d"), + strikethrough_color, line_number); + goto error; + } + + add_attribute (tag, pango_attr_strikethrough_color_new (color.red, color.green, color.blue)); + } + if (fallback) { if (strcmp (fallback, "true") == 0) diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c index bc2d462c..2f0ae3a5 100644 --- a/pango/pango-renderer.c +++ b/pango/pango-renderer.c @@ -273,10 +273,10 @@ handle_line_state_change (PangoRenderer *renderer, state->strikethrough) { PangoRectangle *rect = &state->strikethrough_rect; - + rect->width = state->logical_rect_end - rect->x; - draw_underline (renderer, state); - state->underline = renderer->underline; + draw_strikethrough (renderer, state); + state->strikethrough = renderer->strikethrough; rect->x = state->logical_rect_end; rect->width = 0; } @@ -285,102 +285,88 @@ handle_line_state_change (PangoRenderer *renderer, static void add_underline (PangoRenderer *renderer, LineState *state, - PangoFontMetrics *metrics, /* NULL if no underline */ + PangoFontMetrics *metrics, int base_x, int base_y, PangoRectangle *ink_rect, PangoRectangle *logical_rect) { - if (renderer->underline == PANGO_UNDERLINE_NONE) + PangoRectangle *current_rect = &state->underline_rect; + PangoRectangle new_rect; + + int underline_thickness = pango_font_metrics_get_underline_thickness (metrics); + int underline_position = pango_font_metrics_get_underline_position (metrics); + + new_rect.x = base_x + ink_rect->x; + new_rect.width = ink_rect->width; + new_rect.height = underline_thickness; + + switch (renderer->underline) { - draw_underline (renderer, state); + case PANGO_UNDERLINE_NONE: + g_assert_not_reached (); + break; + case PANGO_UNDERLINE_SINGLE: + case PANGO_UNDERLINE_DOUBLE: + case PANGO_UNDERLINE_ERROR: + new_rect.y = base_y - underline_position; + break; + case PANGO_UNDERLINE_LOW: + new_rect.y = base_y + ink_rect->y + ink_rect->height + underline_thickness; + break; + } + + if (renderer->underline == state->underline && + new_rect.y == current_rect->y && + new_rect.height == current_rect->height) + { + current_rect->y = new_rect.y; + current_rect->width = new_rect.x + new_rect.width - current_rect->x; + current_rect->height = new_rect.height; } else { - PangoRectangle *current_rect = &state->underline_rect; - PangoRectangle new_rect; - - int underline_thickness = pango_font_metrics_get_underline_thickness (metrics); - int underline_position = pango_font_metrics_get_underline_position (metrics); - - new_rect.x = base_x + ink_rect->x; - new_rect.width = ink_rect->width; - new_rect.height = underline_thickness; + draw_underline (renderer, state); - switch (renderer->underline) - { - case PANGO_UNDERLINE_NONE: - g_assert_not_reached (); - break; - case PANGO_UNDERLINE_SINGLE: - case PANGO_UNDERLINE_DOUBLE: - case PANGO_UNDERLINE_ERROR: - new_rect.y = base_y - underline_position; - break; - case PANGO_UNDERLINE_LOW: - new_rect.y = base_y + ink_rect->y + ink_rect->height + underline_thickness; - break; - } - - if (renderer->underline == state->underline && - new_rect.y == current_rect->y && - new_rect.height == current_rect->height) - { - current_rect->y = new_rect.y; - current_rect->width = new_rect.x + new_rect.width - current_rect->x; - current_rect->height = new_rect.height; - } - else - { - draw_underline (renderer, state); - - *current_rect = new_rect; - state->underline = renderer->underline; - } + *current_rect = new_rect; + state->underline = renderer->underline; } } static void add_strikethrough (PangoRenderer *renderer, LineState *state, - PangoFontMetrics *metrics, /* NULL if no strikethrough */ + PangoFontMetrics *metrics, int base_x, int base_y, PangoRectangle *ink_rect, PangoRectangle *logical_rect) { - if (!renderer->strikethrough) + PangoRectangle *current_rect = &state->strikethrough_rect; + PangoRectangle new_rect; + + int strikethrough_thickness = pango_font_metrics_get_strikethrough_thickness (metrics); + int strikethrough_position = pango_font_metrics_get_strikethrough_position (metrics); + + new_rect.x = base_x + ink_rect->x; + new_rect.width = ink_rect->width; + new_rect.y = base_y - strikethrough_position; + new_rect.height = strikethrough_thickness; + + if (state->strikethrough && + new_rect.y == current_rect->y && + new_rect.height == current_rect->height) { - draw_strikethrough (renderer, state); + current_rect->y = new_rect.y; + current_rect->width = new_rect.x + new_rect.width - current_rect->x; + current_rect->height = new_rect.height; } else { - PangoRectangle *current_rect = &state->strikethrough_rect; - PangoRectangle new_rect; - - int strikethrough_thickness = pango_font_metrics_get_strikethrough_thickness (metrics); - int strikethrough_position = pango_font_metrics_get_strikethrough_position (metrics); - - new_rect.x = base_x + ink_rect->x; - new_rect.width = ink_rect->width; - new_rect.y = base_y - strikethrough_position; - new_rect.height = strikethrough_thickness; + draw_strikethrough (renderer, state); - if (state->strikethrough && - new_rect.y == current_rect->y && - new_rect.height == current_rect->height) - { - current_rect->y = new_rect.y; - current_rect->width = new_rect.x + new_rect.width - current_rect->x; - current_rect->height = new_rect.height; - } - else - { - draw_strikethrough (renderer, state); - - *current_rect = new_rect; - state->strikethrough = TRUE; - } + *current_rect = new_rect; + state->strikethrough = TRUE; } } @@ -563,6 +549,13 @@ pango_renderer_draw_layout_line (PangoRenderer *renderer, pango_font_metrics_unref (metrics); } + if (renderer->underline == PANGO_UNDERLINE_NONE && + state.underline != PANGO_UNDERLINE_NONE) + draw_underline (renderer, &state); + + if (!renderer->strikethrough && state.strikethrough) + draw_strikethrough (renderer, &state); + x_off += logical_rect.width; } @@ -837,11 +830,11 @@ pango_renderer_draw_error_underline (PangoRenderer *renderer, #define HEIGHT_SQUARES 2.5 static void -get_total_matrix (PangoMatrix *total, - PangoMatrix *global, - int x, - int y, - int square) +get_total_matrix (PangoMatrix *total, + const PangoMatrix *global, + int x, + int y, + int square) { PangoMatrix local; gdouble scale = 0.5 * square; @@ -1148,6 +1141,8 @@ pango_renderer_default_prepare_run (PangoRenderer *renderer, { PangoColor *fg_color = NULL; PangoColor *bg_color = NULL; + PangoColor *underline_color = NULL; + PangoColor *strikethrough_color = NULL; GSList *l; renderer->underline = PANGO_UNDERLINE_NONE; @@ -1175,15 +1170,29 @@ pango_renderer_default_prepare_run (PangoRenderer *renderer, bg_color = &((PangoAttrColor *)attr)->color; break; + case PANGO_ATTR_UNDERLINE_COLOR: + underline_color = &((PangoAttrColor *)attr)->color; + break; + + case PANGO_ATTR_STRIKETHROUGH_COLOR: + strikethrough_color = &((PangoAttrColor *)attr)->color; + break; + default: break; } } + if (!underline_color) + underline_color = fg_color; + + if (!strikethrough_color) + strikethrough_color = fg_color; + pango_renderer_set_color (renderer, PANGO_RENDER_PART_FOREGROUND, fg_color); pango_renderer_set_color (renderer, PANGO_RENDER_PART_UNDERLINE, fg_color); - pango_renderer_set_color (renderer, PANGO_RENDER_PART_STRIKETHROUGH, fg_color); - pango_renderer_set_color (renderer, PANGO_RENDER_PART_BACKGROUND, bg_color); + pango_renderer_set_color (renderer, PANGO_RENDER_PART_UNDERLINE, underline_color); + pango_renderer_set_color (renderer, PANGO_RENDER_PART_STRIKETHROUGH, strikethrough_color); } /** |