summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-01-16 20:03:40 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-01-16 20:03:40 +0000
commite6b83e4264b4ad2ab73a3239d902b4064c75634d (patch)
treed17827e323d1df9a5cd580293e7b5e86d77b25ae
parent29263f589d82036fd50742061834a5de81e4aff3 (diff)
downloadpango-e6b83e4264b4ad2ab73a3239d902b4064c75634d.tar.gz
Bug 328585 – Need to know if a layout has unknown glyphs Patch from
2007-01-16 Behdad Esfahbod <behdad@gnome.org> Bug 328585 – Need to know if a layout has unknown glyphs Patch from LingNing Zhang * pango/pango-layout-private.h: * pango/pango-layout.c (pango_layout_init), (pango_layout_copy), (pango_layout_get_unknown_glyphs_count), (pango_layout_clear_lines): * pango/pango-layout.h: New public function: pango_layout_get_unknown_glyphs_count() * pango/pango.def: * docs/tmpl/layout.sgml: * docs/pango-sections.txt: Update. svn path=/trunk/; revision=2162
-rw-r--r--ChangeLog19
-rw-r--r--docs/pango-sections.txt1
-rw-r--r--docs/tmpl/layout.sgml9
-rw-r--r--pango/pango-layout-private.h2
-rw-r--r--pango/pango-layout.c60
-rw-r--r--pango/pango-layout.h5
-rw-r--r--pango/pango.def1
7 files changed, 95 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 1c1ba017..d037e8b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
2007-01-16 Behdad Esfahbod <behdad@gnome.org>
+ Bug 328585 – Need to know if a layout has unknown glyphs
+ Patch from LingNing Zhang
+
+ * pango/pango-layout-private.h:
+ * pango/pango-layout.c (pango_layout_init), (pango_layout_copy),
+ (pango_layout_get_unknown_glyphs_count),
+ (pango_layout_clear_lines):
+ * pango/pango-layout.h:
+ New public function:
+
+ pango_layout_get_unknown_glyphs_count()
+
+ * pango/pango.def:
+ * docs/tmpl/layout.sgml:
+ * docs/pango-sections.txt:
+ Update.
+
+2007-01-16 Behdad Esfahbod <behdad@gnome.org>
+
Part of Bug 326693 – PangoLayouts should be query-able about their
effective properties (width / wrapped / ellipsized / etc)
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index 541dadce..fc47f612 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -469,6 +469,7 @@ pango_layout_get_single_paragraph_mode
PangoAlignment
PANGO_TYPE_ALIGNMENT
+pango_layout_get_unknown_glyphs_count
pango_layout_get_log_attrs
pango_layout_index_to_pos
diff --git a/docs/tmpl/layout.sgml b/docs/tmpl/layout.sgml
index 32b89c03..524cbbce 100644
--- a/docs/tmpl/layout.sgml
+++ b/docs/tmpl/layout.sgml
@@ -424,6 +424,15 @@ The #GObject type for #PangoAlignment.
+<!-- ##### FUNCTION pango_layout_get_unknown_glyphs_count ##### -->
+<para>
+
+</para>
+
+@layout:
+@Returns:
+
+
<!-- ##### FUNCTION pango_layout_get_log_attrs ##### -->
<para>
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