summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/pango-sections.txt1
-rw-r--r--pango/pango-attributes.c76
-rw-r--r--pango/pango-attributes.h4
-rw-r--r--pango/pango-layout.c6
-rw-r--r--pango/pango-markup.c202
-rw-r--r--pango/pango-renderer.c13
-rw-r--r--tests/test-break.c6
7 files changed, 205 insertions, 103 deletions
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index e87b8750..4648816b 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -440,6 +440,7 @@ pango_attr_list_filter
pango_attr_list_update
PangoAttrFilterFunc
pango_attr_list_get_attributes
+pango_attr_list_equal
pango_attr_list_get_iterator
PangoAttrIterator
pango_attr_iterator_copy
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 2d2dd2a2..03a45de4 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1916,6 +1916,82 @@ pango_attr_list_get_attributes (PangoAttrList *list)
return g_slist_copy_deep (list->attributes, (GCopyFunc)pango_attribute_copy, NULL);
}
+/**
+ * pango_attr_list_equal:
+ * @list: a #PangoAttrList
+ * @other_list: the other #PangoAttrList
+ *
+ * Checks whether @list and @other_list contain the same attributes and
+ * whether those attributes apply to the same ranges. Beware that this
+ * will return wrong values if any list contains duplicates.
+ *
+ * Return value: %TRUE if the lists are equal, %FALSE if they aren't.
+ *
+ * Since: 1.46
+ */
+gboolean
+pango_attr_list_equal (PangoAttrList *list,
+ PangoAttrList *other_list)
+{
+ GSList *attrs, *other_attrs;
+ GSList *iter = NULL;
+ guint attrs_length = 0;
+ guint64 skip_bitmask = 0;
+
+ if (list == other_list)
+ return TRUE;
+
+ if (list == NULL || other_list == NULL)
+ return FALSE;
+
+ attrs = list->attributes;
+ other_attrs = other_list->attributes;
+
+ for (iter = attrs; iter != NULL; iter = iter->next)
+ {
+ PangoAttribute *attr = iter->data;
+ GSList *other_iter = NULL;
+ gboolean attr_equal = FALSE;
+ guint other_attr_index = 0;
+
+ attrs_length++;
+
+ for (other_iter = other_attrs;
+ other_iter != NULL;
+ other_iter = other_iter->next)
+ {
+ PangoAttribute *other_attr = other_iter->data;
+ guint64 other_attr_bitmask =
+ other_attr_index < 64 ? 1 << other_attr_index : 0;
+
+ if ((skip_bitmask & other_attr_bitmask) != 0)
+ {
+ other_attr_index++;
+ continue;
+ }
+
+ if (attr->start_index == other_attr->start_index &&
+ attr->end_index == other_attr->end_index &&
+ pango_attribute_equal (attr, other_attr))
+ {
+ skip_bitmask |= other_attr_bitmask;
+ attr_equal = TRUE;
+ break;
+ }
+
+ other_attr_index++;
+ }
+
+ if (!attr_equal)
+ return FALSE;
+ }
+
+ if (attrs_length != g_slist_length (other_attrs))
+ return FALSE;
+
+ return TRUE;
+}
+
G_DEFINE_BOXED_TYPE (PangoAttrIterator,
pango_attr_iterator,
pango_attr_iterator_copy,
diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h
index 09d1a69a..6f6622ab 100644
--- a/pango/pango-attributes.h
+++ b/pango/pango-attributes.h
@@ -633,6 +633,10 @@ PangoAttrList *pango_attr_list_filter (PangoAttrList *list,
PANGO_AVAILABLE_IN_1_44
GSList *pango_attr_list_get_attributes (PangoAttrList *list);
+PANGO_AVAILABLE_IN_1_46
+gboolean pango_attr_list_equal (PangoAttrList *list,
+ PangoAttrList *other_list);
+
PANGO_AVAILABLE_IN_1_44
GType pango_attr_iterator_get_type (void) G_GNUC_CONST;
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 44d59367..643f5623 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3061,6 +3061,10 @@ ensure_tab_width (PangoLayout *layout)
PangoAttrIterator *iter;
PangoFontDescription *font_desc = pango_font_description_copy_static (pango_context_get_font_description (layout->context));
PangoLanguage *language;
+ PangoShapeFlags shape_flags = PANGO_SHAPE_NONE;
+
+ if (pango_context_get_round_glyph_positions (layout->context))
+ shape_flags |= PANGO_SHAPE_ROUND_POSITIONS;
layout_attrs = pango_layout_get_effective_attributes (layout);
iter = pango_attr_list_get_iterator (layout_attrs);
@@ -3089,7 +3093,7 @@ ensure_tab_width (PangoLayout *layout)
pango_attr_list_unref (tmp_attrs);
item = items->data;
- pango_shape (" ", 8, &item->analysis, glyphs);
+ pango_shape_with_flags (" ", 8, " ", 8, &item->analysis, glyphs, shape_flags);
pango_item_free (item);
g_list_free (items);
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index cdea3a98..a67e10fd 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -56,165 +56,169 @@
* ]|
*
* Pango uses #GMarkup to parse this language, which means that XML
- * features such as numeric character entities such as &amp;#169; for
+ * features such as numeric character entities such as `&#169;` for
* © can be used too.
*
- * The root tag of a marked-up document is &lt;markup&gt;, but
- * pango_parse_markup()allows you to omit this tag, so you will most
- * likely never need to use it. The most general markup tag is &lt;span&gt;,
+ * The root tag of a marked-up document is `<markup>`, but
+ * pango_parse_markup() allows you to omit this tag, so you will most
+ * likely never need to use it. The most general markup tag is `<span>`,
* then there are some convenience tags.
*
- * &lt;span&gt; has the following attributes:
+ * ## Span attributes
*
- * font_desc
- * : A font description string, such as "Sans Italic 12".
+ * `<span>` has the following attributes:
+ *
+ * * `font_desc`:
+ * A font description string, such as "Sans Italic 12".
* See pango_font_description_from_string() for a description of the
* format of the string representation . Note that any other span
* attributes will override this description. So if you have "Sans Italic"
- * and also a style="normal" attribute, you will get Sans normal,
+ * and also a `style="normal"` attribute, you will get Sans normal,
* not italic.
*
- * font_family
- * : A font family name
+ * * `font_family`:
+ * A font family name
*
- * font_size, size
- * : 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
+ * * `font_size`, `size`:
+ * 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 to take advantage of the ability to specify a partial
- * font description using 'font'; you can use |font='12.5'|
- * rather than |size='12800'|.
+ * font description using `font`; you can use `font='12.5'`
+ * rather than `size='12800'`.
*
- * font_style
- * : One of 'normal', 'oblique', 'italic'
+ * * `font_style`:
+ * One of `normal`, `oblique`, `italic`
*
- * font_weight
- * : One of 'ultralight', 'light', 'normal', 'bold',
- * 'ultrabold', 'heavy', or a numeric weight
+ * * `font_weight`:
+ * One of `ultralight`, `light`, `normal`, `bold`,
+ * `ultrabold`, `heavy`, or a numeric weight
*
- * font_variant
- * : One of 'normal' or 'smallcaps'
+ * * `font_variant`:
+ * One of `normal` or `smallcaps`
*
- * font_stretch, stretch
- * : One of 'ultracondensed', 'extracondensed', 'condensed',
- * 'semicondensed', 'normal', 'semiexpanded', 'expanded',
- * 'extraexpanded', 'ultraexpanded'
+ * * `font_stretch`, `stretch`:
+ * One of `ultracondensed`, `extracondensed`, `condensed`,
+ * `semicondensed`, `normal`, `semiexpanded`, `expanded`,
+ * `extraexpanded`, `ultraexpanded`
*
- * font_features
- * : A comma separated list of OpenType font feature
+ * * `font_features`:
+ * A comma-separated list of OpenType font feature
* settings, in the same syntax as accepted by CSS. E.g:
- * |font_features='dlig=1, -kern, afrc on'|
+ * `font_features='dlig=1, -kern, afrc on'`
*
- * foreground, fgcolor
- * : An RGB color specification such as '#00FF00' or a color
- * name such as 'red'. Since 1.38, an RGBA color specification such
- * as '#00FF007F' will be interpreted as specifying both a foreground
+ * * `foreground`, `fgcolor`:
+ * An RGB color specification such as `#00FF00` or a color
+ * name such as `red`. Since 1.38, an RGBA color specification such
+ * as `#00FF007F` will be interpreted as specifying both a foreground
* color and foreground alpha.
*
- * background, bgcolor
- * : An RGB color specification such as '#00FF00' or a color
- * name such as'red'.
- * Since 1.38, an RGBA color specification such as '#00FF007F' will
+ * * `background`, `bgcolor`:
+ * An RGB color specification such as `#00FF00` or a color
+ * name such as `red`.
+ * Since 1.38, an RGBA color specification such as `#00FF007F` will
* be interpreted as specifying both a background color and
* background alpha.
*
- * alpha, fgalpha
- * : An alpha value for the foreground color, either a plain
- * integer between 1 and 65536 or a percentage value like '50%'.
+ * * `alpha`, `fgalpha`:
+ * An alpha value for the foreground color, either a plain
+ * integer between 1 and 65536 or a percentage value like `50%`.
*
- * background_alpha, bgalpha
- * : An alpha value for the background color, either a plain
- * integer between 1 and 65536 or a percentage value like '50%'.
+ * * `background_alpha`, `bgalpha`:
+ * An alpha value for the background color, either a plain
+ * integer between 1 and 65536 or a percentage value like `50%`.
*
- * underline
- * : One of 'none', 'single', 'double', 'low', 'error',
- * 'single-line', 'double-line' or 'error-line'.
+ * * `underline`:
+ * One of `none`, `single`, `double`, `low`, `error`,
+ * `single-line`, `double-line` or `error-line`.
*
- * underline_color
- * : The color of underlines; an RGB color
- * specification such as '#00FF00' or a color name such as 'red'
+ * * `underline_color`:
+ * The color of underlines; an RGB color
+ * specification such as `#00FF00` or a color name such as `red`
*
- * overline
- * : One of 'none' or 'single'
+ * * `overline`:
+ * One of `none` or `single`
*
- * overline_color
- * : The color of overlines; an RGB color
- * specification such as '#00FF00' or a color name such as 'red'
+ * * `overline_color`:
+ * The color of overlines; an RGB color
+ * specification such as `#00FF00` or a color name such as `red`
*
- * rise
- * : Vertical displacement, in Pango units. Can be negative for
+ * * `rise`:
+ * Vertical displacement, in Pango units. Can be negative for
* subscript, positive for superscript.
*
- * strikethrough
- * : 'true' or 'false' whether to strike through the text
+ * * `strikethrough`
+ * `true` or `false` whether to strike through the text
*
- * strikethrough_color
- * : The color of strikethrough lines; an RGB
- * color specification such as '#00FF00' or a color name such as 'red'
+ * * `strikethrough_color`:
+ * The color of strikethrough lines; an RGB
+ * color specification such as `#00FF00` or a color name such as `red`
*
- * fallback
- * : 'true' or 'false' whether to enable fallback. If
+ * * `fallback`:
+ * `true` or `false` whether to enable fallback. If
* disabled, then characters will only be used from the closest
* matching font on the system. No fallback will be done to other
* fonts on the system that might contain the characters in the text.
* Fallback is enabled by default. Most applications should not
* disable fallback.
*
- * allow_breaks
- * : 'true' or 'false' whether to allow line breaks or not. If
+ * * `allow_breaks`:
+ * `true` or `false` whether to allow line breaks or not. If
* not allowed, the range will be kept in a single run as far
* as possible. Breaks are allowed by default.
*
- * insert_hyphens
- * : 'true' or 'false' whether to insert hyphens when breaking
+ * * `insert_hyphens`:`
+ * `true` or `false` whether to insert hyphens when breaking
* lines in the middle of a word. Hyphens are inserted by default.
*
- * show
- * : A value determining how invisible characters are treated.
- * Possible values are 'spaces', 'line-breaks', 'ignorables'
- * or combinations, such as 'spaces|line-breaks'.
+ * * `show`:
+ * A value determining how invisible characters are treated.
+ * Possible values are `spaces`, `line-breaks`, `ignorables`
+ * or combinations, such as `spaces|line-breaks`.
+ *
+ * * `lang`:
+ * A language code, indicating the text language
*
- * lang
- * : A language code, indicating the text language
+ * * `letter_spacing`:
+ * Inter-letter spacing in 1024ths of a point.
*
- * letter_spacing
- * : Inter-letter spacing in 1024ths of a point.
+ * * `gravity`:
+ * One of `south`, `east`, `north`, `west`, `auto`.
*
- * gravity
- * : One of 'south', 'east', 'north', 'west', 'auto'.
+ * * `gravity_hint`:
+ * One of `natural`, `strong`, `line`.
*
- * gravity_hint
- * : One of 'natural', 'strong', 'line'.
+ * ## Convenience tags
*
* The following convenience tags are provided:
*
- * &lt;b&gt;
- * : Bold
+ * * `<b>`:
+ * Bold
*
- * &lt;big&gt;
- * : Makes font relatively larger, equivalent to &lt;span size="larger"&gt;
+ * * `<big>`:
+ * Makes font relatively larger, equivalent to `<span size="larger">`
*
- * &lt;i&gt;
- * : Italic
+ * * `<i>`:
+ * Italic
*
- * &lt;s&gt;
- * : Strikethrough
+ * * `<s>`:
+ * Strikethrough
*
- * &lt;sub&gt;
- * : Subscript
+ * * `<sub>`:
+ * Subscript
*
- * &lt;sup&gt;
- * : Superscript
+ * * `<sup>`:
+ * Superscript
*
- * &lt;small&gt;
- * : Makes font relatively smaller, equivalent to &lt;span size="smaller"&gt;
+ * * `<small>`:
+ * Makes font relatively smaller, equivalent to `<span size="smaller">`
*
- * &lt;tt&gt;
- * : Monospace
+ * * `<tt>`:
+ * Monospace
*
- * &lt;u&gt;
- * : Underline
+ * * `<u>`:
+ * Underline
*/
/* FIXME */
diff --git a/pango/pango-renderer.c b/pango/pango-renderer.c
index 539df34a..07f81a88 100644
--- a/pango/pango-renderer.c
+++ b/pango/pango-renderer.c
@@ -1096,15 +1096,22 @@ pango_renderer_default_draw_error_underline (PangoRenderer *renderer,
int width,
int height)
{
- int square = height / HEIGHT_SQUARES;
- int unit_width = (HEIGHT_SQUARES - 1) * square;
- int width_units = (width + unit_width / 2) / unit_width;
+ int square;
+ int unit_width;
+ int width_units;
const PangoMatrix identity = PANGO_MATRIX_INIT;
const PangoMatrix *matrix;
double dx, dx0, dy0;
PangoMatrix total;
int i;
+ if (width <= 0 || height <= 0)
+ return;
+
+ square = height / HEIGHT_SQUARES;
+ unit_width = (HEIGHT_SQUARES - 1) * square;
+ width_units = (width + unit_width / 2) / unit_width;
+
x += (width - width_units * unit_width) / 2;
if (renderer->matrix)
diff --git a/tests/test-break.c b/tests/test-break.c
index 49eaa653..aec36008 100644
--- a/tests/test-break.c
+++ b/tests/test-break.c
@@ -317,6 +317,12 @@ main (int argc, char *argv[])
if (!strstr (name, "break"))
continue;
+#ifndef HAVE_LIBTHAI
+ /* four.break involves Thai, so only test it when we have libthai */
+ if (strstr (name, "four.break"))
+ continue;
+#endif
+
path = g_strdup_printf ("/break/%s", name);
g_test_add_data_func_full (path, g_test_build_filename (G_TEST_DIST, "breaks", name, NULL),
test_break, g_free);