[pango/pango2: 131/195] attributes: Centralize classification
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 131/195] attributes: Centralize classification
- Date: Mon, 6 Jun 2022 04:14:44 +0000 (UTC)
commit 88441ad5f907ceb6e399cbc82a8dd9c093fd942b
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 25 20:52:58 2022 -0500
attributes: Centralize classification
Make the 'affects itemization' etc classification
available in one place, so we can use it elsewhere.
pango/pango-attributes-private.h | 5 ++++
pango/pango-attributes.c | 59 +++++++++++++++++++++++++++++++++++++++
pango/pango-line-breaker.c | 60 ++--------------------------------------
3 files changed, 66 insertions(+), 58 deletions(-)
---
diff --git a/pango/pango-attributes-private.h b/pango/pango-attributes-private.h
index 4c427695..7d311082 100644
--- a/pango/pango-attributes-private.h
+++ b/pango/pango-attributes-private.h
@@ -50,4 +50,9 @@ gboolean pango_attr_iterator_advance (PangoAttrIterator *iterator,
int index);
+gboolean pango_attribute_affects_itemization (PangoAttribute *attr,
+ gpointer data);
+gboolean pango_attribute_affects_break_or_shape (PangoAttribute *attr,
+ gpointer data);
+
#endif
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 179bd3dc..9b8dcb8f 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -523,6 +523,65 @@ pango_attr_shape_equal (const PangoAttribute *attr1,
shape_attr1->data == shape_attr2->data);
}
/* }}} */
+/* }}} */
+/* {{{ Private API */
+
+gboolean
+pango_attribute_affects_itemization (PangoAttribute *attr,
+ gpointer data)
+{
+ switch ((int)attr->klass->type)
+ {
+ /* These affect font selection */
+ case PANGO_ATTR_LANGUAGE:
+ case PANGO_ATTR_FAMILY:
+ case PANGO_ATTR_STYLE:
+ case PANGO_ATTR_WEIGHT:
+ case PANGO_ATTR_VARIANT:
+ case PANGO_ATTR_STRETCH:
+ case PANGO_ATTR_SIZE:
+ case PANGO_ATTR_FONT_DESC:
+ case PANGO_ATTR_SCALE:
+ case PANGO_ATTR_FALLBACK:
+ case PANGO_ATTR_ABSOLUTE_SIZE:
+ case PANGO_ATTR_GRAVITY:
+ case PANGO_ATTR_GRAVITY_HINT:
+ case PANGO_ATTR_FONT_SCALE:
+ /* These need to be constant across runs */
+ case PANGO_ATTR_LETTER_SPACING:
+ case PANGO_ATTR_SHAPE:
+ case PANGO_ATTR_RISE:
+ case PANGO_ATTR_BASELINE_SHIFT:
+ case PANGO_ATTR_LINE_HEIGHT:
+ case PANGO_ATTR_ABSOLUTE_LINE_HEIGHT:
+ case PANGO_ATTR_TEXT_TRANSFORM:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+gboolean
+pango_attribute_affects_break_or_shape (PangoAttribute *attr,
+ gpointer data)
+{
+ switch ((int)attr->klass->type)
+ {
+ /* Affects breaks */
+ case PANGO_ATTR_ALLOW_BREAKS:
+ case PANGO_ATTR_WORD:
+ case PANGO_ATTR_SENTENCE:
+ case PANGO_ATTR_PARAGRAPH:
+ /* Affects shaping */
+ case PANGO_ATTR_INSERT_HYPHENS:
+ case PANGO_ATTR_FONT_FEATURES:
+ case PANGO_ATTR_SHOW:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
/* }}} */
/* {{{ Public API */
diff --git a/pango/pango-line-breaker.c b/pango/pango-line-breaker.c
index df68fe9f..66ceaa52 100644
--- a/pango/pango-line-breaker.c
+++ b/pango/pango-line-breaker.c
@@ -148,62 +148,6 @@ item_is_paragraph_separator (PangoLineBreaker *self,
return ch == '\r' || ch == '\n' || ch == 0x2029;
}
-static gboolean
-affects_itemization (PangoAttribute *attr,
- gpointer data)
-{
- switch ((int)attr->klass->type)
- {
- /* These affect font selection */
- case PANGO_ATTR_LANGUAGE:
- case PANGO_ATTR_FAMILY:
- case PANGO_ATTR_STYLE:
- case PANGO_ATTR_WEIGHT:
- case PANGO_ATTR_VARIANT:
- case PANGO_ATTR_STRETCH:
- case PANGO_ATTR_SIZE:
- case PANGO_ATTR_FONT_DESC:
- case PANGO_ATTR_SCALE:
- case PANGO_ATTR_FALLBACK:
- case PANGO_ATTR_ABSOLUTE_SIZE:
- case PANGO_ATTR_GRAVITY:
- case PANGO_ATTR_GRAVITY_HINT:
- case PANGO_ATTR_FONT_SCALE:
- /* These need to be constant across runs */
- case PANGO_ATTR_LETTER_SPACING:
- case PANGO_ATTR_SHAPE:
- case PANGO_ATTR_RISE:
- case PANGO_ATTR_BASELINE_SHIFT:
- case PANGO_ATTR_LINE_HEIGHT:
- case PANGO_ATTR_ABSOLUTE_LINE_HEIGHT:
- case PANGO_ATTR_TEXT_TRANSFORM:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-static gboolean
-affects_break_or_shape (PangoAttribute *attr,
- gpointer data)
-{
- switch ((int)attr->klass->type)
- {
- /* Affects breaks */
- case PANGO_ATTR_ALLOW_BREAKS:
- case PANGO_ATTR_WORD:
- case PANGO_ATTR_SENTENCE:
- case PANGO_ATTR_PARAGRAPH:
- /* Affects shaping */
- case PANGO_ATTR_INSERT_HYPHENS:
- case PANGO_ATTR_FONT_FEATURES:
- case PANGO_ATTR_SHOW:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
static void
apply_attributes_to_items (GList *items,
PangoAttrList *attrs)
@@ -286,8 +230,8 @@ ensure_items (PangoLineBreaker *self)
self->render_attrs = pango_attr_list_copy (self->data->attrs);
if (self->render_attrs)
{
- shape_attrs = pango_attr_list_filter (self->render_attrs, affects_break_or_shape, NULL);
- itemize_attrs = pango_attr_list_filter (self->render_attrs, affects_itemization, NULL);
+ shape_attrs = pango_attr_list_filter (self->render_attrs, pango_attribute_affects_break_or_shape,
NULL);
+ itemize_attrs = pango_attr_list_filter (self->render_attrs, pango_attribute_affects_itemization, NULL);
}
self->items = pango_itemize_with_font (self->context,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]