diff options
author | Owen Taylor <otaylor@redhat.com> | 2003-09-23 23:11:59 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2003-09-23 23:11:59 +0000 |
commit | 0f36f55ee0e7c9bf224fabbaf31843b3868f213c (patch) | |
tree | a8446856f4dce9b792f5e2ca1c3f9d25bbc40b76 /pango/pango-fontset.c | |
parent | 8fa8e29cd61c802c6b100b3cca800784e3a9de20 (diff) | |
download | pango-0f36f55ee0e7c9bf224fabbaf31843b3868f213c.tar.gz |
Modules now declare a list of scripts that they cover instead of a list of
Tue Sep 23 18:03:57 2003 Owen Taylor <otaylor@redhat.com>
* pango/pango-engines.[ch] pango/pango-engines-private.h:
Modules now declare a list of scripts that they cover instead of a
list of code point ranges. Also, there is now a ->covers() virtual
function that allows a module to decide live whether the font
covers a particular codepoint; remove old get_coverage() method.
* pango/pango-fontset.[ch]: Add a foreach() function to
iterate over all the fonts in a fontset (with a true
return stopping iteration).
* pango/pango-context.c: Complete rewrite using script-run
information to improve language tags. Switch to an approach
where we handle one run at a time rather than computing
information for each character individually then later
breaking the result into runs.
* pango/pango-fontset.[ch]: Switch over to using
pango-impl-utils.h.
* modules/basic/basic-x.c pango/pangox-fontmap.c: Adapt to
the change from get_coverage => covers.
* pango/pango-modules.h pango/modules.c: Switch PangoMap
over to being based on script rather than being based
on codepoint. Remove the no longer needed pango_map_get_entry().
* pango/modules.c: Handle new script-based modules.
* pango/pango-fc-fontmap.c pango/pango-win32-fontmap.c
pango/pang-fontmap.[ch]: Add a shape_engine_type field
to PangoFontmapClass, pango_font_map_get_shape_engine_type();
this allows generic code to find a shaper for a particular
fontmap.
* pango/pango-script.[ch]: Add pango_script_get_sample_language(),
pango_language_includes_script(); functions for determining
the relationship between scripts and language.
* tools/gen-script-for-lang.c: Modify to spit out a
useful table.
* pango/pango-script-lang-table.h: Version of table
generated from current fontconfig data.
* pango/pangox.c: Remove complicated code to compute
coverages; no longer useful now that we just have
the basic shaper as a legacy thing.
* modules/*/*.c: Adapt to identifying shape engines
by language range.
* modules/thai/thai-fc.c modules/thai/thai-shaper.[ch]:
Remove now unused "has_glyph" function and XTIS support.
* modules/thai/thai-fc.c: Handle non-Thai characters
as well, since the Thai module now gets spaces,
punctuation, and so forth.
Diffstat (limited to 'pango/pango-fontset.c')
-rw-r--r-- | pango/pango-fontset.c | 110 |
1 files changed, 50 insertions, 60 deletions
diff --git a/pango/pango-fontset.c b/pango/pango-fontset.c index 7ba883d1..1f639376 100644 --- a/pango/pango-fontset.c +++ b/pango/pango-fontset.c @@ -26,45 +26,20 @@ #include "pango-types.h" #include "pango-font.h" #include "pango-fontset.h" +#include "pango-impl-utils.h" #include "pango-utils.h" -static void pango_fontset_class_init (PangoFontsetClass *class); static PangoFontMetrics *pango_fontset_real_get_metrics (PangoFontset *fontset); -GType -pango_fontset_get_type (void) -{ - static GType object_type = 0; - - if (!object_type) - { - static const GTypeInfo object_info = - { - sizeof (PangoFontsetClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) pango_fontset_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PangoFontset), - 0, /* n_preallocs */ - NULL /* init */ - }; - - object_type = g_type_register_static (G_TYPE_OBJECT, - "PangoFontset", - &object_info, 0); - } - - return object_type; -} - static void pango_fontset_class_init (PangoFontsetClass *class) { class->get_metrics = pango_fontset_real_get_metrics; } +PANGO_DEFINE_TYPE_ABSTRACT (PangoFontset, pango_fontset, + pango_fontset_class_init, NULL, G_TYPE_OBJECT); + /** * pango_fontset_get_font: * @fontset: a #PangoFontset @@ -81,7 +56,7 @@ pango_fontset_get_font (PangoFontset *fontset, guint wc) { - g_return_val_if_fail (fontset != NULL, NULL); + g_return_val_if_fail (PANGO_IS_FONTSET (fontset), NULL); return PANGO_FONTSET_GET_CLASS (fontset)->get_font (fontset, wc); } @@ -98,11 +73,30 @@ pango_fontset_get_font (PangoFontset *fontset, PangoFontMetrics * pango_fontset_get_metrics (PangoFontset *fontset) { - g_return_val_if_fail (fontset != NULL, NULL); + g_return_val_if_fail (PANGO_IS_FONTSET (fontset), NULL); return PANGO_FONTSET_GET_CLASS (fontset)->get_metrics (fontset); } +/** + * pango_fontset_foreach: + * @fontset: a #PangoFontset + * @func: Callback function + * @data: data to pass to the callback function + * + * Iterate through all the fonts in a fontset, calling @func for + * each one. If @func returns TRUE, that stops the iteration. + **/ +void +pango_fontset_foreach (PangoFontset *fontset, + PangoFontsetForeachFunc func, + gpointer data) +{ + g_return_if_fail (PANGO_IS_FONTSET (fontset)); + g_return_if_fail (func != NULL); + + PANGO_FONTSET_GET_CLASS (fontset)->foreach (fontset, func, data); +} static PangoFontMetrics * pango_fontset_real_get_metrics (PangoFontset *fontset) @@ -175,13 +169,15 @@ pango_fontset_real_get_metrics (PangoFontset *fontset) #define PANGO_IS_FONTSET_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_FONTSET_SIMPLE)) #define PANGO_FONTSET_SIMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_FONTSET_SIMPLE, PangoFontsetSimpleClass)) -static void pango_fontset_simple_class_init (PangoFontsetSimpleClass *class); static void pango_fontset_simple_finalize (GObject *object); static void pango_fontset_simple_init (PangoFontsetSimple *fontset); static PangoFontMetrics *pango_fontset_simple_get_metrics (PangoFontset *fontset); static PangoLanguage * pango_fontset_simple_get_language (PangoFontset *fontset); static PangoFont * pango_fontset_simple_get_font (PangoFontset *fontset, guint wc); +static void pango_fontset_simple_foreach (PangoFontset *fontset, + PangoFontsetForeachFunc func, + gpointer data); struct _PangoFontsetSimple { @@ -218,34 +214,6 @@ pango_fontset_simple_new (PangoLanguage *language) return fontset; } -GType -pango_fontset_simple_get_type (void) -{ - static GType object_type = 0; - - if (!object_type) - { - static const GTypeInfo object_info = - { - sizeof (PangoFontsetSimpleClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) pango_fontset_simple_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (PangoFontsetSimple), - 0, /* n_preallocs */ - (GInstanceInitFunc) pango_fontset_simple_init, - }; - - object_type = g_type_register_static (PANGO_TYPE_FONTSET, - "PangoFontsetSimple", - &object_info, 0); - } - - return object_type; -} - static void pango_fontset_simple_class_init (PangoFontsetSimpleClass *class) { @@ -258,6 +226,7 @@ pango_fontset_simple_class_init (PangoFontsetSimpleClass *class) fontset_class->get_font = pango_fontset_simple_get_font; fontset_class->get_metrics = pango_fontset_simple_get_metrics; fontset_class->get_language = pango_fontset_simple_get_language; + fontset_class->foreach = pango_fontset_simple_foreach; } static void @@ -268,6 +237,10 @@ pango_fontset_simple_init (PangoFontsetSimple *fontset) fontset->language = NULL; } +PANGO_DEFINE_TYPE (PangoFontsetSimple, pango_fontset_simple, + pango_fontset_simple_class_init, pango_fontset_simple_init, + PANGO_TYPE_FONTSET); + static void pango_fontset_simple_finalize (GObject *object) { @@ -379,3 +352,20 @@ pango_fontset_simple_get_font (PangoFontset *fontset, font = g_ptr_array_index(simple->fonts, result); return g_object_ref (font); } + +static void +pango_fontset_simple_foreach (PangoFontset *fontset, + PangoFontsetForeachFunc func, + gpointer data) +{ + PangoFontsetSimple *simple = PANGO_FONTSET_SIMPLE (fontset); + int i; + + for (i = 0; i < simple->fonts->len; i++) + { + if ((*func) (fontset, + g_ptr_array_index (simple->fonts, i), + data)) + return; + } +} |