diff options
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-layout-private.h | 2 | ||||
-rw-r--r-- | pango/pango-layout.c | 60 | ||||
-rw-r--r-- | pango/pango-layout.h | 5 | ||||
-rw-r--r-- | pango/pango.def | 1 |
4 files changed, 66 insertions, 2 deletions
diff --git a/pango/pango-layout-private.h b/pango/pango-layout-private.h index c3def007..6751ae60 100644 --- a/pango/pango-layout-private.h +++ b/pango/pango-layout-private.h @@ -44,6 +44,8 @@ struct _PangoLayout int indent; /* amount by which first line should be shorter */ int spacing; /* spacing between lines */ + int unknown_glyphs_count; /* number of unknown glyphs */ + guint justify : 1; guint alignment : 2; diff --git a/pango/pango-layout.c b/pango/pango-layout.c index c95e9e20..e6e4d8cf 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -197,6 +197,7 @@ pango_layout_init (PangoLayout *layout) layout->lines = NULL; layout->tab_width = -1; + layout->unknown_glyphs_count = -1; layout->wrap = PANGO_WRAP_WORD; layout->is_wrapped = FALSE; @@ -307,8 +308,10 @@ pango_layout_copy (PangoLayout *src) layout->tabs = pango_tab_array_copy (src->tabs); layout->wrap = src->wrap; layout->ellipsize = src->ellipsize; + + layout->unknown_glyphs_count = -1; - /* is_wrapped, is_ellipsized, log_attrs, lines + /* unknown_glyphs_count, is_wrapped, is_ellipsized, log_attrs, lines * fields are updated by check_lines */ return layout; @@ -1059,6 +1062,59 @@ pango_layout_set_markup_with_accel (PangoLayout *layout, } /** + * pango_layout_get_unknown_glyphs_count: + * @layout: a #PangoLayout + * + * Counts the number unknown glyphs in @layout. That is, zero if + * glyphs for all characters in the layout text were found, or more + * than zero otherwise. + * + * Return value: The number of unknown glyphs in @layout. + * + * Since: 1.16 + */ +int +pango_layout_get_unknown_glyphs_count (PangoLayout *layout) +{ + PangoLayoutLine *line; + PangoLayoutRun *run; + GSList *lines_list; + GSList *runs_list; + int i, count = 0; + + g_return_val_if_fail (PANGO_IS_LAYOUT (layout), 0); + + pango_layout_check_lines (layout); + + if (layout->unknown_glyphs_count >= 0) + return layout->unknown_glyphs_count; + + lines_list = layout->lines; + while (lines_list) + { + line = lines_list->data; + runs_list = line->runs; + + while (runs_list) + { + run = runs_list->data; + + for (i = 0; i < run->glyphs->num_glyphs; i++) + { + if (run->glyphs->glyphs[i].glyph & PANGO_GLYPH_UNKNOWN_FLAG) + count++; + } + + runs_list = runs_list->next; + } + lines_list = lines_list->next; + } + + layout->unknown_glyphs_count = count; + return count; +} + +/** * pango_layout_context_changed: * @layout: a #PangoLayout * @@ -2538,6 +2594,8 @@ pango_layout_clear_lines (PangoLayout *layout) g_free (layout->log_attrs); layout->log_attrs = NULL; } + + layout->unknown_glyphs_count = -1; layout->logical_rect_cached = FALSE; layout->ink_rect_cached = FALSE; layout->is_ellipsized = FALSE; diff --git a/pango/pango-layout.h b/pango/pango-layout.h index a1d24ea5..47b4394f 100644 --- a/pango/pango-layout.h +++ b/pango/pango-layout.h @@ -156,7 +156,9 @@ void pango_layout_set_ellipsize (PangoLayout *layout, PangoEllipsizeMode pango_layout_get_ellipsize (PangoLayout *layout); gboolean pango_layout_is_ellipsized (PangoLayout *layout); -void pango_layout_context_changed (PangoLayout *layout); +int pango_layout_get_unknown_glyphs_count (PangoLayout *layout); + +void pango_layout_context_changed (PangoLayout *layout); void pango_layout_get_log_attrs (PangoLayout *layout, PangoLogAttr **attrs, @@ -207,6 +209,7 @@ PangoLayoutLine *pango_layout_get_line_readonly (PangoLayout *layout, GSList * pango_layout_get_lines (PangoLayout *layout); GSList * pango_layout_get_lines_readonly (PangoLayout *layout); + #define PANGO_TYPE_LAYOUT_LINE (pango_layout_line_get_type ()) GType pango_layout_line_get_type (void) G_GNUC_CONST; diff --git a/pango/pango.def b/pango/pango.def index e0380441..da6b0784 100644 --- a/pango/pango.def +++ b/pango/pango.def @@ -234,6 +234,7 @@ EXPORTS pango_layout_get_tabs pango_layout_get_text pango_layout_get_type + pango_layout_get_unknown_glyphs_count pango_layout_get_width pango_layout_get_wrap pango_layout_index_to_line_x |