summaryrefslogtreecommitdiff
path: root/pango/pango-context.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2000-12-15 04:06:31 +0000
committerHavoc Pennington <hp@src.gnome.org>2000-12-15 04:06:31 +0000
commita8ea5ad3907b28d0361957a4f165cf31cc4fc2fc (patch)
tree8a234ddb539b81153dc9beeba4168d765c2d96e6 /pango/pango-context.c
parent04b813f8baea7bb0da71b132bfd1fbf90e730cfd (diff)
downloadpango-a8ea5ad3907b28d0361957a4f165cf31cc4fc2fc.tar.gz
Use a fallback shaper if no engine is found for a range, the fallback
2000-12-14 Havoc Pennington <hp@redhat.com> * pango/pango-context.c (add_engines): Use a fallback shaper if no engine is found for a range, the fallback shaper shapes to glyphs of 0. This is just to let other code depend on the invariant that there's a shape engine for all characters. * tests/all-unicode.txt: Huge file containing all Unicode characters, for robustness testing. Not in EXTRA_DIST for now, not sure we should torture people that way... * pango/fonts.c (pango_font_find_shaper): remove the assert that we found a shaper, and instead let things fall back to the fallback shaper
Diffstat (limited to 'pango/pango-context.c')
-rw-r--r--pango/pango-context.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/pango/pango-context.c b/pango/pango-context.c
index c8a7d5c1..fb1e71e9 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -657,6 +657,63 @@ pango_itemize (PangoContext *context,
return g_list_reverse (result);
}
+static void
+fallback_engine_shape (PangoFont *font,
+ const char *text,
+ gint length,
+ PangoAnalysis *analysis,
+ PangoGlyphString *glyphs)
+{
+ int n_chars;
+ int i;
+ char *p;
+
+ g_return_if_fail (font != NULL);
+ g_return_if_fail (text != NULL);
+ g_return_if_fail (length >= 0);
+ g_return_if_fail (analysis != NULL);
+
+ n_chars = g_utf8_strlen (text, length);
+ pango_glyph_string_set_size (glyphs, n_chars);
+
+ p = text;
+ for (i = 0; i < n_chars; i++)
+ {
+ glyphs->glyphs[i].glyph = 0;
+
+ glyphs->glyphs[i].geometry.x_offset = 0;
+ glyphs->glyphs[i].geometry.y_offset = 0;
+ glyphs->glyphs[i].geometry.width = 0;
+
+ glyphs->log_clusters[i] = p - text;
+
+ ++i;
+ p = g_utf8_next_char (p);
+ }
+}
+
+static PangoCoverage*
+fallback_engine_get_coverage (PangoFont *font,
+ const char *lang)
+{
+ PangoCoverage *result = pango_coverage_new ();
+
+ /* We return an empty coverage (this function won't get
+ * called, but if it is, empty coverage will keep
+ * it from being used).
+ */
+
+ return result;
+}
+
+static PangoEngineShape fallback_shaper = {
+ "FallbackScriptEngine",
+ PANGO_ENGINE_TYPE_SHAPE,
+ sizeof (PangoEngineShape),
+ fallback_engine_shape,
+ fallback_engine_get_coverage
+};
+
static PangoFont *
get_font (PangoFont **fonts,
PangoCoverage **coverages,
@@ -919,6 +976,9 @@ add_engines (PangoContext *context,
else
shape_engines[i] = NULL;
+ if (shape_engines[i] == NULL)
+ shape_engines[i] = &fallback_shaper;
+
extra_attr_lists[i] = extra_attrs;
}