summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2003-08-03 21:57:35 +0000
committerOwen Taylor <otaylor@src.gnome.org>2003-08-03 21:57:35 +0000
commit2584212cd0976f5f95d9381e829917e7d2a10d28 (patch)
tree5773e9f6802f8316c5c7463aa55677babe67343c /modules
parent95a8d1788e884b7d8d29d4171a1adc51c61e880e (diff)
downloadpango-2584212cd0976f5f95d9381e829917e7d2a10d28.tar.gz
Make PangoEngine{,Lang,Shape} GObjects, and use a GTypeModule-based
Sat Aug 2 23:19:16 2003 Owen Taylor <otaylor@redhat.com> * pango/pango-engine.[ch] modules/*/*-{fc,win32,x}.c pango/modules.c pango/break.c pango/pango-context.c pango/pango-layout.c pango/pango-modules.h pango/querymodules.c pango/shape.c: Make PangoEngine{,Lang,Shape} GObjects, and use a GTypeModule-based module-loading system closely based on the one used for GtkIMContext and GtkThemeEngine. * pango/pango-impl-utils.h: OK, I'm tired of typing in get_type() functions. * pango/pango-script.[ch] pango/pango-script-table.h tests/testscript.c tools/gen-script-table.pl: Add port of script-range code from ICU in preparation for future use. (#91542) * tools/gen-script-for-lang.c: Utility program to determine the script for each fontconfig .orth file. * docs/tmpl/{scripts.sgml,pango-engine-lang.sgml, pango-engine-shape.sgml} docs/pango-sections.txt docs/pango-docs.sgml: Redo to go along with the above changes. * configure.in: chmod +x tests/runtests.sh
Diffstat (limited to 'modules')
-rw-r--r--modules/arabic/arabic-fc.c51
-rw-r--r--modules/basic/basic-fc.c51
-rw-r--r--modules/basic/basic-win32.c75
-rw-r--r--modules/basic/basic-x.c53
-rw-r--r--modules/hangul/hangul-fc.c62
-rw-r--r--modules/hebrew/hebrew-fc.c59
-rw-r--r--modules/indic/indic-fc.c66
-rw-r--r--modules/thai/thai-fc.c49
-rw-r--r--modules/thai/thai-shaper.c3
-rw-r--r--modules/thai/thai-shaper.h3
10 files changed, 206 insertions, 266 deletions
diff --git a/modules/arabic/arabic-fc.c b/modules/arabic/arabic-fc.c
index 80c9ae81..fd425d2e 100644
--- a/modules/arabic/arabic-fc.c
+++ b/modules/arabic/arabic-fc.c
@@ -26,8 +26,12 @@
#include "pango-engine.h"
#include "pango-utils.h"
-
#include "pangofc-font.h"
+
+/* No extra fields needed */
+typedef PangoEngineShape ArabicEngineFc;
+typedef PangoEngineShapeClass ArabicEngineFcClass ;
+
#define SCRIPT_ENGINE_NAME "ArabicScriptEngineFc"
#define RENDER_TYPE PANGO_RENDER_TYPE_FC
@@ -129,7 +133,8 @@ set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGl
}
static void
-arabic_engine_shape (PangoFont *font,
+arabic_engine_shape (PangoEngineShape *engine,
+ PangoFont *font,
const char *text,
gint length,
PangoAnalysis *analysis,
@@ -294,31 +299,26 @@ arabic_engine_shape (PangoFont *font,
pango_fc_font_unlock_face (fc_font);
}
-static PangoCoverage *
-arabic_engine_get_coverage (PangoFont *font,
- PangoLanguage *lang)
+static void
+arabic_engine_fc_class_init (PangoEngineShapeClass *class)
{
- return pango_font_get_coverage (font, lang);
+ class->script_shape = arabic_engine_shape;
}
-static PangoEngine *
-arabic_engine_fc_new ()
-{
- PangoEngineShape *result;
-
- result = g_new (PangoEngineShape, 1);
+PANGO_ENGINE_SHAPE_DEFINE_TYPE (ArabicEngineFc, arabic_engine_fc,
+ arabic_engine_fc_class_init, NULL);
- result->engine.id = SCRIPT_ENGINE_NAME;
- result->engine.type = PANGO_ENGINE_TYPE_SHAPE;
- result->engine.length = sizeof (result);
- result->script_shape = arabic_engine_shape;
- result->get_coverage = arabic_engine_get_coverage;
+void
+PANGO_MODULE_ENTRY(init) (GTypeModule *module)
+{
+ arabic_engine_fc_register_type (module);
+}
- return (PangoEngine *)result;
+void
+PANGO_MODULE_ENTRY(exit) (void)
+{
}
-/* List the engines contained within this module
- */
void
PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
int *n_engines)
@@ -327,18 +327,11 @@ PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
*n_engines = G_N_ELEMENTS (script_engines);
}
-/* Load a particular engine given the ID for the engine
- */
PangoEngine *
-PANGO_MODULE_ENTRY(load) (const char *id)
+PANGO_MODULE_ENTRY(create) (const char *id)
{
if (!strcmp (id, SCRIPT_ENGINE_NAME))
- return arabic_engine_fc_new ();
+ return g_object_new (arabic_engine_fc_type, NULL);
else
return NULL;
}
-
-void
-PANGO_MODULE_ENTRY(unload) (PangoEngine *engine)
-{
-}
diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c
index 7af2d3af..6de50e8c 100644
--- a/modules/basic/basic-fc.c
+++ b/modules/basic/basic-fc.c
@@ -25,10 +25,14 @@
#include <glib/gprintf.h>
#include "pango-engine.h"
#include "pango-utils.h"
+#include "pangofc-font.h"
#include "basic-common.h"
-#include "pangofc-font.h"
+/* No extra fields needed */
+typedef PangoEngineShape BasicEngineFc;
+typedef PangoEngineShapeClass BasicEngineFcClass;
+
#define SCRIPT_ENGINE_NAME "BasicScriptEngineFc"
#define RENDER_TYPE PANGO_RENDER_TYPE_FC
@@ -115,7 +119,8 @@ set_glyph (PangoFont *font,
}
static void
-basic_engine_shape (PangoFont *font,
+basic_engine_shape (PangoEngineShape *engine,
+ PangoFont *font,
const char *text,
gint length,
PangoAnalysis *analysis,
@@ -222,31 +227,26 @@ basic_engine_shape (PangoFont *font,
pango_fc_font_unlock_face (fc_font);
}
-static PangoCoverage *
-basic_engine_get_coverage (PangoFont *font,
- PangoLanguage *lang)
+static void
+basic_engine_fc_class_init (PangoEngineShapeClass *class)
{
- return pango_font_get_coverage (font, lang);
+ class->script_shape = basic_engine_shape;
}
-static PangoEngine *
-basic_engine_fc_new ()
-{
- PangoEngineShape *result;
-
- result = g_new (PangoEngineShape, 1);
+PANGO_ENGINE_SHAPE_DEFINE_TYPE (BasicEngineFc, basic_engine_fc,
+ basic_engine_fc_class_init, NULL);
- result->engine.id = SCRIPT_ENGINE_NAME;
- result->engine.type = PANGO_ENGINE_TYPE_SHAPE;
- result->engine.length = sizeof (result);
- result->script_shape = basic_engine_shape;
- result->get_coverage = basic_engine_get_coverage;
+void
+PANGO_MODULE_ENTRY(init) (GTypeModule *module)
+{
+ basic_engine_fc_register_type (module);
+}
- return (PangoEngine *)result;
+void
+PANGO_MODULE_ENTRY(exit) (void)
+{
}
-/* List the engines contained within this module
- */
void
PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
int *n_engines)
@@ -255,18 +255,11 @@ PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
*n_engines = G_N_ELEMENTS (script_engines);
}
-/* Load a particular engine given the ID for the engine
- */
PangoEngine *
-PANGO_MODULE_ENTRY(load) (const char *id)
+PANGO_MODULE_ENTRY(create) (const char *id)
{
if (!strcmp (id, SCRIPT_ENGINE_NAME))
- return basic_engine_fc_new ();
+ return g_object_new (basic_engine_fc_type, NULL);
else
return NULL;
}
-
-void
-PANGO_MODULE_ENTRY(unload) (PangoEngine *engine)
-{
-}
diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c
index c63a016a..9e00139c 100644
--- a/modules/basic/basic-win32.c
+++ b/modules/basic/basic-win32.c
@@ -34,6 +34,10 @@
#include "basic-common.h"
+/* No extra fields needed */
+typedef PangoEngineShape BasicEngineWin32;
+typedef PangoEngineShapeClass BasicEngineWin32Class ;
+
#define SCRIPT_ENGINE_NAME "BasicScriptEngineWin32"
static gboolean pango_win32_debug = FALSE;
@@ -971,7 +975,8 @@ uniscribe_shape (PangoFont *font,
#endif /* HAVE_USP10_H */
static void
-basic_engine_shape (PangoFont *font,
+basic_engine_shape (PangoEngineShape *engine,
+ PangoFont *font,
const char *text,
gint length,
PangoAnalysis *analysis,
@@ -1075,29 +1080,6 @@ basic_engine_shape (PangoFont *font,
}
}
-static PangoCoverage *
-basic_engine_get_coverage (PangoFont *font,
- PangoLanguage *lang)
-{
- return pango_font_get_coverage (font, lang);
-}
-
-static PangoEngine *
-basic_engine_win32_new (void)
-{
- PangoEngineShape *result;
-
- result = g_new (PangoEngineShape, 1);
-
- result->engine.id = SCRIPT_ENGINE_NAME;
- result->engine.type = PANGO_ENGINE_TYPE_SHAPE;
- result->engine.length = sizeof (result);
- result->script_shape = basic_engine_shape;
- result->get_coverage = basic_engine_get_coverage;
-
- return (PangoEngine *)result;
-}
-
static void
init_uniscribe (void)
{
@@ -1133,13 +1115,34 @@ init_uniscribe (void)
#endif
}
-/* The following three functions provide the public module API for
- * Pango
- */
+static void
+basic_engine_win32_class_init (PangoEngineShapeClass *class)
+{
+ class->script_shape = basic_engine_shape;
+}
+
+PANGO_ENGINE_SHAPE_DEFINE_TYPE (BasicEngineWin32, basic_engine_win32,
+ basic_engine_win32_class_init, NULL);
+
+void
+PANGO_MODULE_ENTRY(init) (GTypeModule *module)
+{
+ init_uniscribe ();
-void
+ if (pango_win32_get_debug_flag ())
+ pango_win32_debug = TRUE;
+
+ basic_engine_register_type (module);
+}
+
+void
+PANGO_MODULE_ENTRY(exit) (void)
+{
+}
+
+void
PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
- gint *n_engines)
+ int *n_engines)
{
init_uniscribe ();
@@ -1176,20 +1179,10 @@ PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
}
PangoEngine *
-PANGO_MODULE_ENTRY(load) (const char *id)
+PANGO_MODULE_ENTRY(create) (const char *id)
{
- init_uniscribe ();
-
- if (pango_win32_get_debug_flag ())
- pango_win32_debug = TRUE;
-
if (!strcmp (id, SCRIPT_ENGINE_NAME))
- return basic_engine_win32_new ();
+ return g_object_new (basic_engine_win32_type, NULL);
else
return NULL;
}
-
-void
-PANGO_MODULE_ENTRY(unload) (PangoEngine *engine)
-{
-}
diff --git a/modules/basic/basic-x.c b/modules/basic/basic-x.c
index 2003da18..9b9431a2 100644
--- a/modules/basic/basic-x.c
+++ b/modules/basic/basic-x.c
@@ -29,6 +29,10 @@
#include "basic-common.h"
+/* No extra fields needed */
+typedef PangoEngineShape BasicEngineX;
+typedef PangoEngineShapeClass BasicEngineXClass ;
+
typedef struct _CharRange CharRange;
typedef struct _Charset Charset;
typedef struct _CharsetOrdering CharsetOrdering;
@@ -141,8 +145,6 @@ static PangoEngineInfo script_engines[] = {
}
};
-static gint n_script_engines = G_N_ELEMENTS (script_engines);
-
/*
* X window system script engine portion
*/
@@ -569,7 +571,8 @@ get_char_cache (PangoFont *font,
}
static void
-basic_engine_shape (PangoFont *font,
+basic_engine_shape (PangoEngineShape *engine,
+ PangoFont *font,
const char *text,
gint length,
PangoAnalysis *analysis,
@@ -682,8 +685,9 @@ basic_engine_shape (PangoFont *font,
}
static PangoCoverage *
-basic_engine_get_coverage (PangoFont *font,
- PangoLanguage *lang)
+basic_engine_get_coverage (PangoEngineShape *engine,
+ PangoFont *font,
+ PangoLanguage *lang)
{
CharCache *cache = get_char_cache (font, lang);
PangoCoverage *result = pango_coverage_new ();
@@ -701,20 +705,25 @@ basic_engine_get_coverage (PangoFont *font,
return result;
}
-static PangoEngine *
-basic_engine_x_new ()
+static void
+basic_engine_x_class_init (PangoEngineShapeClass *class)
{
- PangoEngineShape *result;
-
- result = g_new (PangoEngineShape, 1);
+ class->get_coverage = basic_engine_get_coverage;
+ class->script_shape = basic_engine_shape;
+}
+
+PANGO_ENGINE_SHAPE_DEFINE_TYPE (BasicEngineX, basic_engine_x,
+ basic_engine_x_class_init, NULL);
- result->engine.id = SCRIPT_ENGINE_NAME;
- result->engine.type = PANGO_ENGINE_TYPE_SHAPE;
- result->engine.length = sizeof (result);
- result->script_shape = basic_engine_shape;
- result->get_coverage = basic_engine_get_coverage;
+void
+PANGO_MODULE_ENTRY(init) (GTypeModule *module)
+{
+ basic_engine_x_register_type (module);
+}
- return (PangoEngine *)result;
+void
+PANGO_MODULE_ENTRY(exit) (void)
+{
}
void
@@ -722,20 +731,14 @@ PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
int *n_engines)
{
*engines = script_engines;
- *n_engines = n_script_engines;
+ *n_engines = G_N_ELEMENTS (script_engines);
}
PangoEngine *
-PANGO_MODULE_ENTRY(load) (const char *id)
+PANGO_MODULE_ENTRY(create) (const char *id)
{
if (!strcmp (id, SCRIPT_ENGINE_NAME))
- return basic_engine_x_new ();
+ return g_object_new (basic_engine_x_type, NULL);
else
return NULL;
}
-
-void
-PANGO_MODULE_ENTRY(unload) (PangoEngine *engine)
-{
-}
-
diff --git a/modules/hangul/hangul-fc.c b/modules/hangul/hangul-fc.c
index 3ba6a479..94216695 100644
--- a/modules/hangul/hangul-fc.c
+++ b/modules/hangul/hangul-fc.c
@@ -24,11 +24,15 @@
#include "pango-engine.h"
#include "pango-utils.h"
+#include "pangofc-font.h"
#include "hangul-defs.h"
#include "tables-jamos.i"
-#include "pangofc-font.h"
+/* No extra fields needed */
+typedef PangoEngineShape HangulEngineFc;
+typedef PangoEngineShapeClass HangulEngineFcClass ;
+
#define SCRIPT_ENGINE_NAME "HangulScriptEngineFc"
#define RENDER_TYPE PANGO_RENDER_TYPE_FC
@@ -275,7 +279,8 @@ render_syllable (PangoFont *font, gunichar *text, int length,
}
static void
-hangul_engine_shape (PangoFont *font,
+hangul_engine_shape (PangoEngineShape *engine,
+ PangoFont *font,
const char *text,
gint length,
PangoAnalysis *analysis,
@@ -357,42 +362,26 @@ hangul_engine_shape (PangoFont *font,
g_free(jamos);
}
-static PangoCoverage *
-hangul_engine_get_coverage (PangoFont *font,
- PangoLanguage *lang)
+static void
+hangul_engine_fc_class_init (PangoEngineShapeClass *class)
{
- PangoCoverage *result = pango_coverage_new ();
- int i;
-
- /* Well, no unicode rendering engine could render Hangul Jamo area
- _exactly_, I sure. */
- for (i = 0x1100; i <= 0x11ff; i++)
- pango_coverage_set (result, i, PANGO_COVERAGE_FALLBACK);
- pango_coverage_set (result, 0x302e, PANGO_COVERAGE_FALLBACK);
- pango_coverage_set (result, 0x302f, PANGO_COVERAGE_FALLBACK);
- for (i = 0xac00; i <= 0xd7a3; i++)
- pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
- return result;
+ class->script_shape = hangul_engine_shape;
}
-static PangoEngine *
-hangul_engine_xft_new ()
-{
- PangoEngineShape *result;
-
- result = g_new (PangoEngineShape, 1);
+PANGO_ENGINE_SHAPE_DEFINE_TYPE (HangulEngineFc, hangul_engine_fc,
+ hangul_engine_fc_class_init, NULL);
- result->engine.id = SCRIPT_ENGINE_NAME;
- result->engine.type = PANGO_ENGINE_TYPE_SHAPE;
- result->engine.length = sizeof (result);
- result->script_shape = hangul_engine_shape;
- result->get_coverage = hangul_engine_get_coverage;
+void
+PANGO_MODULE_ENTRY(init) (GTypeModule *module)
+{
+ hangul_engine_fc_register_type (module);
+}
- return (PangoEngine *)result;
+void
+PANGO_MODULE_ENTRY(exit) (void)
+{
}
-/* List the engines contained within this module
- */
void
PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
int *n_engines)
@@ -401,18 +390,11 @@ PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
*n_engines = G_N_ELEMENTS (script_engines);
}
-/* Load a particular engine given the ID for the engine
- */
PangoEngine *
-PANGO_MODULE_ENTRY(load) (const char *id)
+PANGO_MODULE_ENTRY(create) (const char *id)
{
if (!strcmp (id, SCRIPT_ENGINE_NAME))
- return hangul_engine_xft_new ();
+ return g_object_new (hangul_engine_fc_type, NULL);
else
return NULL;
}
-
-void
-PANGO_MODULE_ENTRY(unload) (PangoEngine *engine)
-{
-}
diff --git a/modules/hebrew/hebrew-fc.c b/modules/hebrew/hebrew-fc.c
index 273755e4..01a7f2e3 100644
--- a/modules/hebrew/hebrew-fc.c
+++ b/modules/hebrew/hebrew-fc.c
@@ -24,8 +24,13 @@
#include "pango-engine.h"
#include "pango-utils.h"
+#include "pangofc-font.h"
#include "hebrew-shaper.h"
+/* No extra fields needed */
+typedef PangoEngineShape HebrewEngineFc;
+typedef PangoEngineShapeClass HebrewEngineFcClass ;
+
#define MAX_CLUSTER_CHRS 20
static PangoEngineRange hebrew_ranges[] = {
@@ -34,7 +39,6 @@ static PangoEngineRange hebrew_ranges[] = {
{ 0xfb1d, 0xfb4f, "*" } /* Hebrew presentation forms */
};
-#include "pangofc-font.h"
#define SCRIPT_ENGINE_NAME "HebrewScriptEngineFc"
#define RENDER_TYPE PANGO_RENDER_TYPE_FC
@@ -124,11 +128,12 @@ add_cluster(PangoFont *font,
static void
-hebrew_engine_shape (PangoFont *font,
- const char *text,
- gint length,
- PangoAnalysis *analysis,
- PangoGlyphString *glyphs)
+hebrew_engine_shape (PangoEngineShape *engine,
+ PangoFont *font,
+ const char *text,
+ gint length,
+ PangoAnalysis *analysis,
+ PangoGlyphString *glyphs)
{
const char *p;
const char *log_cluster;
@@ -189,31 +194,26 @@ hebrew_engine_shape (PangoFont *font,
hebrew_shaper_bidi_reorder(glyphs);
}
-static PangoCoverage *
-hebrew_engine_get_coverage (PangoFont *font,
- PangoLanguage *lang)
+static void
+hebrew_engine_fc_class_init (PangoEngineShapeClass *class)
{
- return pango_font_get_coverage (font, lang);
+ class->script_shape = hebrew_engine_shape;
}
-static PangoEngine *
-hebrew_engine_fc_new ()
-{
- PangoEngineShape *result;
-
- result = g_new (PangoEngineShape, 1);
+PANGO_ENGINE_SHAPE_DEFINE_TYPE (HebrewEngineFc, hebrew_engine_fc,
+ hebrew_engine_fc_class_init, NULL);
- result->engine.id = SCRIPT_ENGINE_NAME;
- result->engine.type = PANGO_ENGINE_TYPE_SHAPE;
- result->engine.length = sizeof (result);
- result->script_shape = hebrew_engine_shape;
- result->get_coverage = hebrew_engine_get_coverage;
+void
+PANGO_MODULE_ENTRY(init) (GTypeModule *module)
+{
+ hebrew_engine_fc_register_type (module);
+}
- return (PangoEngine *)result;
+void
+PANGO_MODULE_ENTRY(exit) (void)
+{
}
-/* List the engines contained within this module
- */
void
PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
int *n_engines)
@@ -222,18 +222,11 @@ PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
*n_engines = G_N_ELEMENTS (script_engines);
}
-/* Load a particular engine given the ID for the engine
- */
PangoEngine *
-PANGO_MODULE_ENTRY(load) (const char *id)
+PANGO_MODULE_ENTRY(create) (const char *id)
{
if (!strcmp (id, SCRIPT_ENGINE_NAME))
- return hebrew_engine_fc_new ();
+ return g_object_new (hebrew_engine_fc_type, NULL);
else
return NULL;
}
-
-void
-PANGO_MODULE_ENTRY(unload) (PangoEngine *engine)
-{
-}
diff --git a/modules/indic/indic-fc.c b/modules/indic/indic-fc.c
index bd4c8f4b..f70fadfb 100644
--- a/modules/indic/indic-fc.c
+++ b/modules/indic/indic-fc.c
@@ -28,11 +28,14 @@
#include "pango-engine.h"
#include "pango-ot.h"
#include "pango-utils.h"
+#include "pangofc-font.h"
-typedef struct _PangoEngineShapeIndic PangoEngineShapeIndic;
typedef struct _PangoIndicInfo PangoIndicInfo;
-struct _PangoEngineShapeIndic
+typedef struct _IndicEngineFc IndicEngineFc;
+typedef PangoEngineShapeClass IndicEngineFcClass ; /* No extra fields needed */
+
+struct _IndicEngineFc
{
PangoEngineShape shapeEngine;
PangoIndicInfo *indicInfo;
@@ -46,7 +49,6 @@ struct _PangoIndicInfo
gchar *gposQuarkName;
};
-#include "pangofc-font.h"
#define ENGINE_SUFFIX "ScriptEngineFc"
#define RENDER_TYPE PANGO_RENDER_TYPE_FC
@@ -291,7 +293,8 @@ expand_text(const gchar *text, glong length, glong **offsets, glong *n_chars)
/* analysis->shape_engine has the PangoEngine... */
static void
-indic_engine_shape (PangoFont *font,
+indic_engine_shape (PangoEngineShape *engine,
+ PangoFont *font,
const char *text,
gint length,
PangoAnalysis *analysis,
@@ -304,7 +307,7 @@ indic_engine_shape (PangoFont *font,
glong *indices = NULL;
FT_Face face;
PangoOTRuleset *gsub_ruleset = NULL, *gpos_ruleset = NULL;
- PangoEngineShapeIndic *indic_shape_engine = NULL;
+ IndicEngineFc *indic_shape_engine = NULL;
PangoIndicInfo *indic_info = NULL;
PangoFcFont *fc_font;
MPreFixups *mprefixups;
@@ -318,11 +321,7 @@ indic_engine_shape (PangoFont *font,
face = pango_fc_font_lock_face (fc_font);
g_assert (face != NULL);
- indic_shape_engine = (PangoEngineShapeIndic *) analysis->shape_engine;
-
-#if 1
- g_assert (indic_shape_engine->shapeEngine.engine.length == sizeof (PangoEngineShapeIndic));
-#endif
+ indic_shape_engine = (IndicEngineFc *) engine;
indic_info = indic_shape_engine->indicInfo;
@@ -400,33 +399,26 @@ indic_engine_shape (PangoFont *font,
g_free (utf8_offsets);
}
-static PangoCoverage *
-indic_engine_get_coverage (PangoFont *font,
- PangoLanguage *lang)
+static void
+indic_engine_fc_class_init (PangoEngineShapeClass *class)
{
- return pango_font_get_coverage (font, lang);
+ class->script_shape = indic_engine_shape;
}
-static PangoEngine *
-indic_engine_fc_new (gint index)
-{
- PangoEngineShapeIndic *result;
-
- result = g_new (PangoEngineShapeIndic, 1);
-
- result->shapeEngine.engine.id = script_engines[index].id;
- result->shapeEngine.engine.type = PANGO_ENGINE_TYPE_SHAPE;
- result->shapeEngine.engine.length = sizeof (*result);
- result->shapeEngine.script_shape = indic_engine_shape;
- result->shapeEngine.get_coverage = indic_engine_get_coverage;
+PANGO_ENGINE_SHAPE_DEFINE_TYPE (IndicEngineFc, indic_engine_fc,
+ indic_engine_fc_class_init, NULL);
- result->indicInfo = &indic_info[index];
+void
+PANGO_MODULE_ENTRY(init) (GTypeModule *module)
+{
+ indic_engine_fc_register_type (module);
+}
- return (PangoEngine *)result;
+void
+PANGO_MODULE_ENTRY(exit) (void)
+{
}
-/* List the engines contained within this module
- */
void
PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
int *n_engines)
@@ -435,10 +427,8 @@ PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
*n_engines = G_N_ELEMENTS (script_engines);
}
-/* Load a particular engine given the ID for the engine
- */
PangoEngine *
-PANGO_MODULE_ENTRY(load) (const char *id)
+PANGO_MODULE_ENTRY(create) (const char *id)
{
gint i;
@@ -446,14 +436,12 @@ PANGO_MODULE_ENTRY(load) (const char *id)
{
if (!strcmp(id, script_engines[i].id))
{
- return indic_engine_fc_new(i);
+ IndicEngineFc *engine = g_object_new (indic_engine_fc_type, NULL);
+ engine->indicInfo = &indic_info[i];
+
+ return (PangoEngine *)engine;
}
}
return NULL;
}
-
-void
-PANGO_MODULE_ENTRY(unload) (PangoEngine *engine)
-{
-}
diff --git a/modules/thai/thai-fc.c b/modules/thai/thai-fc.c
index 6c537639..9a9839a9 100644
--- a/modules/thai/thai-fc.c
+++ b/modules/thai/thai-fc.c
@@ -31,9 +31,14 @@
#include <glib.h>
#include "pango-engine.h"
+#include "pangofc-font.h"
+
#include "thai-shaper.h"
-#include "pangofc-font.h"
+/* No extra fields needed */
+typedef PangoEngineShape ThaiEngineFc;
+typedef PangoEngineShapeClass ThaiEngineFcClass ;
+
#define SCRIPT_ENGINE_NAME "ThaiScriptEngineFc"
#define RENDER_TYPE PANGO_RENDER_TYPE_FC
@@ -199,31 +204,26 @@ thai_has_glyph (ThaiFontInfo *font_info, PangoGlyph glyph)
return TRUE;
}
-static PangoCoverage *
-thai_engine_get_coverage (PangoFont *font,
- PangoLanguage *lang)
+static void
+thai_engine_fc_class_init (PangoEngineShapeClass *class)
{
- return pango_font_get_coverage (font, lang);
+ class->script_shape = thai_engine_shape;
}
-static PangoEngine *
-thai_engine_fc_new ()
-{
- PangoEngineShape *result;
-
- result = g_new (PangoEngineShape, 1);
+PANGO_ENGINE_SHAPE_DEFINE_TYPE (ThaiEngineFc, thai_engine_fc,
+ thai_engine_fc_class_init, NULL);
- result->engine.id = SCRIPT_ENGINE_NAME;
- result->engine.type = PANGO_ENGINE_TYPE_SHAPE;
- result->engine.length = sizeof (result);
- result->script_shape = thai_engine_shape;
- result->get_coverage = thai_engine_get_coverage;
+void
+PANGO_MODULE_ENTRY(init) (GTypeModule *module)
+{
+ thai_engine_fc_register_type (module);
+}
- return (PangoEngine *)result;
+void
+PANGO_MODULE_ENTRY(exit) (void)
+{
}
-/* List the engines contained within this module
- */
void
PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
int *n_engines)
@@ -232,18 +232,11 @@ PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
*n_engines = G_N_ELEMENTS (script_engines);
}
-/* Load a particular engine given the ID for the engine
- */
PangoEngine *
-PANGO_MODULE_ENTRY(load) (const char *id)
+PANGO_MODULE_ENTRY(create) (const char *id)
{
if (!strcmp (id, SCRIPT_ENGINE_NAME))
- return thai_engine_fc_new ();
+ return g_object_new (thai_engine_fc_type, NULL);
else
return NULL;
}
-
-void
-PANGO_MODULE_ENTRY(unload) (PangoEngine *engine)
-{
-}
diff --git a/modules/thai/thai-shaper.c b/modules/thai/thai-shaper.c
index fd052dd3..4cd98283 100644
--- a/modules/thai/thai-shaper.c
+++ b/modules/thai/thai-shaper.c
@@ -692,7 +692,8 @@ get_next_cluster(const char *text,
}
void
-thai_engine_shape (PangoFont *font,
+thai_engine_shape (PangoEngineShape *engine,
+ PangoFont *font,
const char *text,
gint length,
PangoAnalysis *analysis,
diff --git a/modules/thai/thai-shaper.h b/modules/thai/thai-shaper.h
index 7a9bb31e..b745da86 100644
--- a/modules/thai/thai-shaper.h
+++ b/modules/thai/thai-shaper.h
@@ -54,7 +54,8 @@ thai_has_glyph (ThaiFontInfo *font_info, PangoGlyph glyph);
* Public functions
*/
void
-thai_engine_shape (PangoFont *font,
+thai_engine_shape (PangoEngineShape *engine,
+ PangoFont *font,
const char *text,
gint length,
PangoAnalysis *analysis,