diff options
author | Owen Taylor <otaylor@redhat.com> | 2003-08-03 21:57:35 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2003-08-03 21:57:35 +0000 |
commit | 2584212cd0976f5f95d9381e829917e7d2a10d28 (patch) | |
tree | 5773e9f6802f8316c5c7463aa55677babe67343c /modules/basic | |
parent | 95a8d1788e884b7d8d29d4171a1adc51c61e880e (diff) | |
download | pango-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/basic')
-rw-r--r-- | modules/basic/basic-fc.c | 51 | ||||
-rw-r--r-- | modules/basic/basic-win32.c | 75 | ||||
-rw-r--r-- | modules/basic/basic-x.c | 53 |
3 files changed, 84 insertions, 95 deletions
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) -{ -} - |