[pango/kill-modules: 13/13] Deprecate module system, skip it for shaper modules



commit 9ad45dededbf68232dec03f26e0374a9f609f6f7
Author: Behdad Esfahbod <behdad behdad org>
Date:   Mon Jul 28 18:37:36 2014 -0400

    Deprecate module system, skip it for shaper modules
    
    Now shaper is discovered via (previously unused!) font->find_shaper().
    I'm keeping that just to allow clients override shaping.  Though,
    even that I'm not sure we want to keep.
    
    Wraps shaper in PangoEngineShape structs to keep PangoAnalysis API
    intact.
    
    Deprecated pango-modules.h and some pango-engine.h.  Language modules
    are not moved yet.
    
    Wired up PangoFc and PangoWin32.  PangoCoretext coming soon.

 configure.ac                  |    4 +-
 pango/modules.c               |  439 +++--------------------------------------
 pango/pango-context.c         |  176 +++++------------
 pango/pango-engine.h          |   32 ++--
 pango/pango-modules.h         |    4 +
 pango/pangocoretext-fontmap.c |    4 -
 pango/pangocoretext-private.h |   13 +-
 pango/pangocoretext-shape.c   |   86 ++-------
 pango/pangofc-font.c          |   49 +++--
 pango/pangofc-fontmap.c       |   11 -
 pango/pangofc-private.h       |    9 +-
 pango/pangofc-shape.c         |   83 +-------
 pango/pangowin32-fontmap.c    |    4 -
 pango/pangowin32-private.h    |   13 +-
 pango/pangowin32-shape.c      |  147 ++-------------
 pango/pangowin32.c            |   41 ++++-
 16 files changed, 224 insertions(+), 891 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e702653..1a0c5d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -467,7 +467,6 @@ GOBJECT_INTROSPECTION_CHECK([0.9.5])
 # Modules to build
 #
 arabic_modules="arabic-lang"
-basic_modules="basic-fc,basic-win32,basic-coretext"
 indic_modules="indic-lang"
 thai_modules=""
 
@@ -475,7 +474,7 @@ if $have_libthai ; then
   thai_modules="thai-lang"
 fi
 
-all_modules="$arabic_modules,$basic_modules,$indic_modules,$thai_modules"
+all_modules="$arabic_modules,$indic_modules,$thai_modules"
 
 INCLUDED_FC_MODULES=
 INCLUDED_WIN32_MODULES=
@@ -839,7 +838,6 @@ pango/pangoxft.rc
 pango-view/Makefile
 modules/Makefile
 modules/arabic/Makefile
-modules/basic/Makefile
 modules/indic/Makefile
 modules/thai/Makefile
 examples/Makefile
diff --git a/pango/modules.c b/pango/modules.c
index fd40e62..299fa60 100644
--- a/pango/modules.c
+++ b/pango/modules.c
@@ -41,344 +41,24 @@
 #include "pango-impl-utils.h"
 #include "modules.h"
 
-typedef struct _PangoModule      PangoModule;
-typedef struct _PangoModuleClass PangoModuleClass;
-
-#define PANGO_TYPE_MODULE           (pango_module_get_type ())
-#define PANGO_MODULE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), PANGO_TYPE_MODULE, PangoModule))
-#define PANGO_IS_MODULE(module)  (G_TYPE_CHECK_INSTANCE_TYPE ((module), PANGO_TYPE_MODULE))
-
-typedef struct _PangoMapInfo PangoMapInfo;
-typedef struct _PangoEnginePair PangoEnginePair;
-typedef struct _PangoSubmap PangoSubmap;
-
-/**
- * PangoMap:
- *
- * A #PangoMap structure can be used to determine the engine to
- * use for each character.
- */
-struct _PangoMap
-{
-  GArray *entries;
-};
-
-/**
- * PangoMapEntry:
- *
- * A #PangoMapEntry contains information about the engine that should be used
- * for the codepoint to which this entry belongs and also whether the engine
- * matches the language tag for this entry's map exactly or just approximately.
- */
-struct _PangoMapEntry
-{
-  GSList *exact;
-  GSList *fallback;
-};
-
-struct _PangoMapInfo
-{
-  PangoLanguage *language;
-  guint engine_type_id;
-  guint render_type_id;
-  PangoMap *map;
-};
-
-struct _PangoEnginePair
-{
-  PangoEngineInfo info;
-  PangoModule *module;
-  PangoEngine *engine;
-};
-
-struct _PangoModule
-{
-  GTypeModule parent_instance;
-
-  void         (*list)   (PangoEngineInfo **engines, gint *n_engines);
-  void         (*init)   (GTypeModule *module);
-  void         (*exit)   (void);
-  PangoEngine *(*create) (const gchar *id);
-};
-
-struct _PangoModuleClass
-{
-  GTypeModuleClass parent_class;
-};
-
-G_LOCK_DEFINE_STATIC (maps);
-static GList *maps = NULL;
-/* the following are readonly after init_modules */
-static GSList *registered_engines = NULL;
-
-static void build_map    (PangoMapInfo *info);
-static void init_modules (void);
-
-static GType pango_module_get_type (void);
-
 /**
  * pango_find_map:
  * @language: the language tag for which to find the map
  * @engine_type_id: the engine type for the map to find
  * @render_type_id: the render type for the map to find
  *
- * Locate a #PangoMap for a particular engine type and render
- * type. The resulting map can be used to determine the engine
- * for each character.
+ * Do not use.  Does not do anything.
+ *
+ * Return value: %NULL.
  *
- * Return value: the suitable #PangoMap.
+ * Deprecated: 1.37
  **/
 PangoMap *
-pango_find_map (PangoLanguage *language,
-               guint          engine_type_id,
-               guint          render_type_id)
-{
-  GList *tmp_list;
-  PangoMapInfo *map_info = NULL;
-  gboolean found_earlier = FALSE;
-
-  G_LOCK (maps);
-
-  tmp_list = maps;
-  while (tmp_list)
-    {
-      map_info = tmp_list->data;
-      if (map_info->engine_type_id == engine_type_id &&
-         map_info->render_type_id == render_type_id)
-       {
-         if (map_info->language == language)
-           break;
-         else
-           found_earlier = TRUE;
-       }
-
-      tmp_list = tmp_list->next;
-    }
-
-  if (!tmp_list)
-    {
-      map_info = g_slice_new (PangoMapInfo);
-      map_info->language = language;
-      map_info->engine_type_id = engine_type_id;
-      map_info->render_type_id = render_type_id;
-
-      build_map (map_info);
-
-      maps = g_list_prepend (maps, map_info);
-    }
-  else if (found_earlier)
-    {
-      /* Move the found map to the beginning of the list
-       * for speed next time around if we had to do
-       * any failing comparison. (No longer so important,
-       * since we don't strcmp.)
-       */
-      maps = g_list_remove_link(maps, tmp_list);
-      maps = g_list_prepend(maps, tmp_list->data);
-      g_list_free_1(tmp_list);
-    }
-
-  G_UNLOCK (maps);
-
-  return map_info->map;
-}
-
-G_DEFINE_TYPE (PangoModule, pango_module, G_TYPE_TYPE_MODULE);
-
-static gboolean
-pango_module_load (GTypeModule *module)
-{
-  PangoModule *pango_module = PANGO_MODULE (module);
-
-  /* call the module's init function to let it */
-  /* setup anything it needs to set up. */
-  pango_module->init (module);
-
-  return TRUE;
-}
-
-static void
-pango_module_unload (GTypeModule *module)
-{
-  PangoModule *pango_module = PANGO_MODULE (module);
-
-  pango_module->exit();
-}
-
-/* This only will ever be called if an error occurs during
- * initialization
- */
-static void
-pango_module_finalize (GObject *object)
-{
-  G_OBJECT_CLASS (pango_module_parent_class)->finalize (object);
-}
-
-static void
-pango_module_init (PangoModule *self)
+pango_find_map (PangoLanguage *language G_GNUC_UNUSED,
+               guint          engine_type_id G_GNUC_UNUSED,
+               guint          render_type_id G_GNUC_UNUSED)
 {
-}
-
-static void
-pango_module_class_init (PangoModuleClass *class)
-{
-  GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class);
-  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
-
-  module_class->load = pango_module_load;
-  module_class->unload = pango_module_unload;
-
-  gobject_class->finalize = pango_module_finalize;
-}
-
-G_LOCK_DEFINE_STATIC (engine);
-
-static PangoEngine *
-pango_engine_pair_get_engine (PangoEnginePair *pair)
-{
-  G_LOCK (engine);
-
-  if (!pair->engine)
-    {
-      if (g_type_module_use (G_TYPE_MODULE (pair->module)))
-       {
-         pair->engine = pair->module->create (pair->info.id);
-         g_type_module_unuse (G_TYPE_MODULE (pair->module));
-       }
-    }
-
-  G_UNLOCK (engine);
-
-  return pair->engine;
-}
-
-static void
-handle_included_module (PangoIncludedModule *included_module,
-                       GSList             **engine_list)
-{
-  PangoModule *module = g_object_new (PANGO_TYPE_MODULE, NULL);
-  PangoEngineInfo *engine_info;
-  int n_engines;
-  int i;
-
-  module->list = included_module->list;
-  module->init = included_module->init;
-  module->exit = included_module->exit;
-  module->create = included_module->create;
-
-  module->list (&engine_info, &n_engines);
-
-  for (i = 0; i < n_engines; i++)
-    {
-      PangoEnginePair *pair = g_slice_new (PangoEnginePair);
-
-      pair->info = engine_info[i];
-      pair->module = module;
-      pair->engine = NULL;
-
-      *engine_list = g_slist_prepend (*engine_list, pair);
-    }
-}
-
-static void
-init_modules (void)
-{
-  static gsize init = 0;
-  int i;
-
-  if (g_once_init_enter (&init))
-    {
-#if !GLIB_CHECK_VERSION (2, 35, 3)
-      /* Make sure that the type system is initialized */
-      g_type_init ();
-#endif
-
-      for (i = 0; _pango_included_lang_modules[i].list; i++)
-        pango_module_register (&_pango_included_lang_modules[i]);
-
-      g_once_init_leave (&init, 1);
-    }
-}
-
-static void
-map_add_engine (PangoMapInfo    *info,
-               PangoEnginePair *pair)
-{
-  PangoMap *map = info->map;
-  int i;
-
-  for (i=0; i<pair->info.n_scripts; i++)
-    {
-      PangoScript script;
-      PangoMapEntry *entry;
-      gboolean is_exact = FALSE;
-
-      if (pair->info.scripts[i].langs)
-       {
-         if (pango_language_matches (info->language, pair->info.scripts[i].langs))
-           is_exact = TRUE;
-       }
-
-      script = pair->info.scripts[i].script;
-      if ((guint)script >= map->entries->len)
-       g_array_set_size (map->entries, script + 1);
-
-      entry = &g_array_index (map->entries, PangoMapEntry, script);
-
-      if (is_exact)
-       entry->exact = g_slist_prepend (entry->exact, pair);
-      else
-       entry->fallback = g_slist_prepend (entry->fallback, pair);
-    }
-}
-
-static void
-map_add_engine_list (PangoMapInfo *info,
-                    GSList       *engines,
-                    const char   *engine_type,
-                    const char   *render_type)
-{
-  GSList *tmp_list = engines;
-
-  while (tmp_list)
-    {
-      PangoEnginePair *pair = tmp_list->data;
-      tmp_list = tmp_list->next;
-
-      if (strcmp (pair->info.engine_type, engine_type) == 0 &&
-         strcmp (pair->info.render_type, render_type) == 0)
-       {
-         map_add_engine (info, pair);
-       }
-    }
-}
-
-static void
-build_map (PangoMapInfo *info)
-{
-  const char *engine_type = g_quark_to_string (info->engine_type_id);
-  const char *render_type = g_quark_to_string (info->render_type_id);
-
-  init_modules();
-
-  /* XXX: Can this even happen, now all modules are built statically? */
-  if (!registered_engines)
-    {
-      static gboolean no_module_warning = FALSE; /* MT-safe */
-      if (!no_module_warning)
-       {
-         g_critical ("No modules found:\n"
-                     "No builtin or dynamically loaded modules were found.\n"
-                     "PangoFc will not work correctly.");
-
-         no_module_warning = TRUE;
-       }
-    }
-
-  info->map = g_slice_new (PangoMap);
-  info->map->entries = g_array_new (FALSE, TRUE, sizeof (PangoMapEntry));
-
-  map_add_engine_list (info, registered_engines, engine_type, render_type);
+  return NULL;
 }
 
 /**
@@ -386,51 +66,17 @@ build_map (PangoMapInfo *info)
  * @map: a #PangoMap
  * @script: a #PangoScript
  *
- * Returns the best engine listed in the map for a given script
+ * Do not use.  Does not do anything.
+ *
+ * Return value: %NULL.
  *
- * Return value: the best engine, if one is listed for the script,
- *    or %NULL. The lookup may cause the engine to be loaded;
- *    once an engine is loaded, it won't be unloaded. If multiple
- *    engines are exact for the script, the choice of which is
- *    returned is arbitrary.
+ * Deprecated: 1.37
  **/
 PangoEngine *
-pango_map_get_engine (PangoMap   *map,
-                     PangoScript script)
+pango_map_get_engine (PangoMap   *map G_GNUC_UNUSED,
+                     PangoScript script G_GNUC_UNUSED)
 {
-  PangoMapEntry *entry = NULL;
-  PangoMapEntry *common_entry = NULL;
-
-  if ((guint)script < map->entries->len)
-    entry = &g_array_index (map->entries, PangoMapEntry, script);
-
-  if (PANGO_SCRIPT_COMMON < map->entries->len)
-    common_entry = &g_array_index (map->entries, PangoMapEntry, PANGO_SCRIPT_COMMON);
-
-  if (entry && entry->exact)
-    return pango_engine_pair_get_engine (entry->exact->data);
-  else if (common_entry && common_entry->exact)
-    return pango_engine_pair_get_engine (common_entry->exact->data);
-  else if (entry && entry->fallback)
-    return pango_engine_pair_get_engine (entry->fallback->data);
-  else if (common_entry && common_entry->fallback)
-    return pango_engine_pair_get_engine (common_entry->fallback->data);
-  else
-    return NULL;
-}
-
-static void
-append_engines (GSList **engine_list,
-               GSList  *pair_list)
-{
-  GSList *l;
-
-  for (l = pair_list; l; l = l->next)
-    {
-      PangoEngine *engine = pango_engine_pair_get_engine (l->data);
-      if (engine)
-       *engine_list = g_slist_append (*engine_list, engine);
-    }
+  return NULL;
 }
 
 /**
@@ -442,63 +88,28 @@ append_engines (GSList **engine_list,
  * @fallback_engines: location to store list of engines that approximately
  *  handle this script.
  *
- * Finds engines in the map that handle the given script. The returned
- * lists should be freed with g_slist_free, but the engines in the
- * lists are owned by GLib and will be kept around permanently, so
- * they should not be unref'ed.
+ * Do not use.  Does not do anything.
  *
  * Since: 1.4
+ * Deprecated: 1.37
  **/
 void
-pango_map_get_engines (PangoMap     *map,
-                      PangoScript   script,
-                      GSList      **exact_engines,
-                      GSList      **fallback_engines)
+pango_map_get_engines (PangoMap     *map G_GNUC_UNUSED,
+                      PangoScript   script G_GNUC_UNUSED,
+                      GSList      **exact_engines G_GNUC_UNUSED,
+                      GSList      **fallback_engines G_GNUC_UNUSED)
 {
-  PangoMapEntry *entry = NULL;
-  PangoMapEntry *common_entry = NULL;
-
-  if ((guint)script < map->entries->len)
-    entry = &g_array_index (map->entries, PangoMapEntry, script);
-
-  if (PANGO_SCRIPT_COMMON < map->entries->len)
-    common_entry = &g_array_index (map->entries, PangoMapEntry, PANGO_SCRIPT_COMMON);
-
-  if (exact_engines)
-    {
-      *exact_engines = NULL;
-      if (entry && entry->exact)
-       append_engines (exact_engines, entry->exact);
-      else if (common_entry && common_entry->exact)
-       append_engines (exact_engines, common_entry->exact);
-    }
-
-  if (fallback_engines)
-    {
-      *fallback_engines = NULL;
-      if (entry && entry->fallback)
-       append_engines (fallback_engines, entry->fallback);
-      else if (common_entry && common_entry->fallback)
-       append_engines (fallback_engines, common_entry->fallback);
-    }
 }
 
 /**
  * pango_module_register:
  * @module: a #PangoIncludedModule
  *
- * Registers a statically linked module with Pango. The
- * #PangoIncludedModule structure that is passed in contains the
- * functions that would otherwise be loaded from a dynamically loaded
- * module.
+ * Do not use.  Does not do anything.
+ *
+ * Deprecated: 1.37
  **/
 void
-pango_module_register (PangoIncludedModule *module)
+pango_module_register (PangoIncludedModule *module G_GNUC_UNUSED)
 {
-  GSList *tmp_list = NULL;
-
-  handle_included_module (module, &tmp_list);
-
-  registered_engines = g_slist_concat (registered_engines,
-                                      g_slist_reverse (tmp_list));
 }
diff --git a/pango/pango-context.c b/pango/pango-context.c
index 4e1fb1f..0019282 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -608,34 +608,31 @@ advance_attr_iterator_to (PangoAttrIterator *iterator,
 
 typedef struct {
   GHashTable *hash;
-} ShaperFontCache;
+} FontCache;
 
 typedef struct {
-  PangoEngineShape *shape_engine;
   PangoFont *font;
-} ShaperFontElement;
+} FontElement;
 
 static void
-shaper_font_cache_destroy (ShaperFontCache *cache)
+font_cache_destroy (FontCache *cache)
 {
   g_hash_table_destroy (cache->hash);
-  g_slice_free (ShaperFontCache, cache);
+  g_slice_free (FontCache, cache);
 }
 
 static void
-shaper_font_element_destroy (ShaperFontElement *element)
+font_element_destroy (FontElement *element)
 {
-  if (element->shape_engine)
-    g_object_unref (element->shape_engine);
   if (element->font)
     g_object_unref (element->font);
-  g_slice_free (ShaperFontElement, element);
+  g_slice_free (FontElement, element);
 }
 
-static ShaperFontCache *
-get_shaper_font_cache (PangoFontset *fontset)
+static FontCache *
+get_font_cache (PangoFontset *fontset)
 {
-  ShaperFontCache *cache;
+  FontCache *cache;
 
   static GQuark cache_quark = 0; /* MT-safe */
   if (G_UNLIKELY (!cache_quark))
@@ -645,14 +642,14 @@ retry:
   cache = g_object_get_qdata (G_OBJECT (fontset), cache_quark);
   if (G_UNLIKELY (!cache))
     {
-      cache = g_slice_new (ShaperFontCache);
+      cache = g_slice_new (FontCache);
       cache->hash = g_hash_table_new_full (g_direct_hash, NULL,
-                                          NULL, (GDestroyNotify)shaper_font_element_destroy);
+                                          NULL, (GDestroyNotify)font_element_destroy);
       if (!g_object_replace_qdata (G_OBJECT (fontset), cache_quark, NULL,
-                                   cache, (GDestroyNotify)shaper_font_cache_destroy,
+                                   cache, (GDestroyNotify)font_cache_destroy,
                                    NULL))
         {
-          shaper_font_cache_destroy (cache);
+          font_cache_destroy (cache);
           goto retry;
         }
     }
@@ -661,17 +658,15 @@ retry:
 }
 
 static gboolean
-shaper_font_cache_get (ShaperFontCache   *cache,
-                      gunichar           wc,
-                      PangoEngineShape **shape_engine,
-                      PangoFont        **font)
+font_cache_get (FontCache   *cache,
+               gunichar     wc,
+               PangoFont  **font)
 {
-  ShaperFontElement *element;
+  FontElement *element;
 
   element = g_hash_table_lookup (cache->hash, GUINT_TO_POINTER (wc));
   if (element)
     {
-      *shape_engine = element->shape_engine;
       *font = element->font;
 
       return TRUE;
@@ -681,13 +676,11 @@ shaper_font_cache_get (ShaperFontCache   *cache,
 }
 
 static void
-shaper_font_cache_insert (ShaperFontCache   *cache,
-                         gunichar           wc,
-                         PangoEngineShape  *shape_engine,
-                         PangoFont         *font)
+font_cache_insert (FontCache   *cache,
+                  gunichar           wc,
+                  PangoFont         *font)
 {
-  ShaperFontElement *element = g_slice_new (ShaperFontElement);
-  element->shape_engine = shape_engine ? g_object_ref (shape_engine) : NULL;
+  FontElement *element = g_slice_new (FontElement);
   element->font = font ? g_object_ref (font) : NULL;
 
   g_hash_table_insert (cache->hash, GUINT_TO_POINTER (wc), element);
@@ -764,12 +757,9 @@ struct _ItemizeState
   PangoEngineLang *lang_engine;
 
   PangoFontset *current_fonts;
-  ShaperFontCache *cache;
+  FontCache *cache;
   PangoFont *base_font;
   gboolean enable_fallback;
-
-  GSList *exact_engines;
-  GSList *fallback_engines;
 };
 
 static void
@@ -975,8 +965,6 @@ itemize_state_init (ItemizeState      *state,
   state->lang_engine = NULL;
   state->current_fonts = NULL;
   state->cache = NULL;
-  state->exact_engines = NULL;
-  state->fallback_engines = NULL;
   state->base_font = NULL;
 
   state->changed = EMBEDDING_CHANGED | SCRIPT_CHANGED | LANG_CHANGED | FONT_CHANGED | WIDTH_CHANGED;
@@ -1147,60 +1135,34 @@ itemize_state_add_character (ItemizeState     *state,
   state->result = g_list_prepend (state->result, state->item);
 }
 
-static void
-get_engines (PangoContext  *context,
-            PangoLanguage *lang,
-            PangoScript    script,
-            GSList       **exact_engines,
-            GSList       **fallback_engines)
-{
-  const char *engine_type = pango_font_map_get_shape_engine_type (context->font_map);
-  PangoMap *shaper_map = pango_find_map (lang,
-                                        g_quark_from_string (PANGO_ENGINE_TYPE_SHAPE),
-                                        g_quark_from_string (engine_type));
-  pango_map_get_engines (shaper_map, script,
-                        exact_engines, fallback_engines);
-}
-
 typedef struct {
   PangoLanguage *lang;
   gunichar wc;
-  GSList *engines;
-  PangoEngineShape *shape_engine;
   PangoFont *font;
-} GetShaperFontInfo;
+} GetFontInfo;
 
 static gboolean
-get_shaper_and_font_foreach (PangoFontset *fontset,
-                            PangoFont    *font,
-                            gpointer      data)
+get_font_foreach (PangoFontset *fontset,
+                 PangoFont    *font,
+                 gpointer      data)
 {
-  GetShaperFontInfo *info = data;
-  GSList *l;
+  GetFontInfo *info = data;
+  PangoEngineShape *engine;
+  PangoCoverageLevel level;
 
   if (G_UNLIKELY (!font))
     return FALSE;
 
-  for (l = info->engines; l; l = l->next)
+  engine = pango_font_find_shaper (font, info->lang, info->wc),
+  level = _pango_engine_shape_covers (engine, font, info->lang, info->wc);
+  if (level != PANGO_COVERAGE_NONE)
     {
-      PangoEngineShape *engine = l->data;
-      PangoCoverageLevel level;
-
-      level = _pango_engine_shape_covers (engine, font,
-                                         info->lang, info->wc);
-      if (level != PANGO_COVERAGE_NONE)
-       {
-         info->shape_engine = engine;
-         info->font = font;
-         return TRUE;
-       }
+      info->font = font;
+      return TRUE;
     }
 
-  if (!fontset && info->engines && info->engines->next == NULL)
+  if (!fontset)
     {
-      /* We are in no-fallback mode and there's only one engine, just
-       * return it. */
-      info->shape_engine = (PangoEngineShape *) info->engines->data;
       info->font = font;
       return TRUE;
     }
@@ -1239,69 +1201,33 @@ get_shaper_and_font (ItemizeState      *state,
                     PangoEngineShape **shape_engine,
                     PangoFont        **font)
 {
-  GetShaperFontInfo info;
+  GetFontInfo info;
 
   /* We'd need a separate cache when fallback is disabled, but since lookup
    * with fallback disabled is faster anyways, we just skip caching */
-  if (state->enable_fallback && shaper_font_cache_get (state->cache, wc, shape_engine, font))
-    return *shape_engine != NULL;
-
-  if (!state->exact_engines && !state->fallback_engines)
-    get_engines (state->context, state->derived_lang, get_script (state),
-                &state->exact_engines, &state->fallback_engines);
+  if (state->enable_fallback && font_cache_get (state->cache, wc, font))
+  {
+    *shape_engine = pango_font_find_shaper (*font, state->derived_lang, wc);
+    return TRUE;
+  }
 
   info.lang = state->derived_lang;
   info.wc = wc;
-  info.shape_engine = NULL;
   info.font = NULL;
 
-  info.engines = state->exact_engines;
-  if (info.engines)
-    {
-      if (state->enable_fallback)
-       pango_fontset_foreach (state->current_fonts, get_shaper_and_font_foreach, &info);
-      else
-       get_shaper_and_font_foreach (NULL, get_base_font (state), &info);
-
-      if (info.shape_engine)
-       {
-         *shape_engine = info.shape_engine;
-         *font = info.font;
-
-         /* skip caching if fallback disabled (see above) */
-         if (state->enable_fallback)
-           shaper_font_cache_insert (state->cache, wc, *shape_engine, *font);
-
-         return TRUE;
-       }
-    }
-
-  info.engines = state->fallback_engines;
-  if (info.engines)
-    {
-      if (state->enable_fallback)
-       pango_fontset_foreach (state->current_fonts, get_shaper_and_font_foreach, &info);
-      else
-       get_shaper_and_font_foreach (NULL, get_base_font (state), &info);
-    }
+  if (state->enable_fallback)
+    pango_fontset_foreach (state->current_fonts, get_font_foreach, &info);
+  else
+    get_font_foreach (NULL, get_base_font (state), &info);
 
-  *shape_engine = info.shape_engine;
   *font = info.font;
+  *shape_engine = pango_font_find_shaper (*font, state->derived_lang, wc);
 
   /* skip caching if fallback disabled (see above) */
   if (state->enable_fallback)
-    shaper_font_cache_insert (state->cache, wc, *shape_engine, *font);
-
-  return *shape_engine != NULL;
-}
+    font_cache_insert (state->cache, wc, *font);
 
-static void
-itemize_state_reset_shape_engines (ItemizeState *state)
-{
-  g_slist_free (state->exact_engines);
-  state->exact_engines = NULL;
-  g_slist_free (state->fallback_engines);
-  state->fallback_engines = NULL;
+  return TRUE;
 }
 
 static PangoLanguage *
@@ -1396,9 +1322,6 @@ itemize_state_update_for_new_run (ItemizeState *state)
       state->lang_engine = (PangoEngineLang *)pango_map_get_engine (lang_map, state->script);
     }
 
-  if (state->changed & (SCRIPT_CHANGED | DERIVED_LANG_CHANGED))
-    itemize_state_reset_shape_engines (state);
-
   if (state->changed & (FONT_CHANGED | DERIVED_LANG_CHANGED) &&
       state->current_fonts)
     {
@@ -1413,7 +1336,7 @@ itemize_state_update_for_new_run (ItemizeState *state)
                                                          state->context,
                                                          state->font_desc,
                                                          state->derived_lang);
-      state->cache = get_shaper_font_cache (state->current_fonts);
+      state->cache = get_font_cache (state->current_fonts);
     }
 
   if ((state->changed & FONT_CHANGED) && state->base_font)
@@ -1534,7 +1457,6 @@ itemize_state_finish (ItemizeState *state)
   _pango_script_iter_fini (&state->script_iter);
   pango_font_description_free (state->font_desc);
 
-  itemize_state_reset_shape_engines (state);
   if (state->current_fonts)
     g_object_unref (state->current_fonts);
   if (state->base_font)
diff --git a/pango/pango-engine.h b/pango/pango-engine.h
index 0b8abbe..daf6605 100644
--- a/pango/pango-engine.h
+++ b/pango/pango-engine.h
@@ -212,6 +212,7 @@ struct _PangoEngineShapeClass
                        PangoGlyphString    *glyphs,
                        const char          *paragraph_text,
                        unsigned int         paragraph_length);
+  G_DEPRECATED
   PangoCoverageLevel (*covers)   (PangoEngineShape *engine,
                                  PangoFont        *font,
                                  PangoLanguage    *language,
@@ -271,14 +272,11 @@ struct _PangoEngineInfo
  * @engines: location to store a pointer to an array of engines.
  * @n_engines: location to store the number of elements in @engines.
  *
- * Function to be provided by a module to list the engines that the
- * module supplies. The function stores a pointer to an array
- * of #PangoEngineInfo structures and the length of that array in
- * the given location.
+ * Do not use.
  *
- * Note that script_engine_init() will not be called before this
- * function.
+ * Deprecated: 1.37
  **/
+G_DEPRECATED
 void script_engine_list (PangoEngineInfo **engines,
                         int              *n_engines);
 
@@ -287,33 +285,33 @@ void script_engine_list (PangoEngineInfo **engines,
  * @module: a #GTypeModule structure used to associate any
  *  GObject types created in this module with the module.
  *
- * Function to be provided by a module to register any
- * GObject types in the module.
+ * Do not use.
+ *
+ * Deprecated: 1.37
  **/
+G_DEPRECATED
 void script_engine_init (GTypeModule *module);
 
 
 /**
  * script_engine_exit:
  *
- * Function to be provided by the module that is called
- * when the module is unloading. Frequently does nothing.
+ * Do not use.
+ *
+ * Deprecated: 1.37
  **/
+G_DEPRECATED
 void script_engine_exit (void);
 
 /**
  * script_engine_create:
  * @id: the ID of an engine as reported by script_engine_list.
  *
- * Function to be provided by the module to create an instance
- * of one of the engines implemented by the module.
+ * Do not use.
  *
- * Return value: a newly created #PangoEngine of the specified
- *  type, or %NULL if an error occurred. (In normal operation,
- *  a module should not return %NULL. A %NULL return is only
- *  acceptable in the case where system misconfiguration or
- *  bugs in the driver routine are encountered.)
+ * Deprecated: 1.37
  **/
+G_DEPRECATED
 PangoEngine *script_engine_create (const char *id);
 
 /* Utility macro used by PANGO_ENGINE_LANG_DEFINE_TYPE and
diff --git a/pango/pango-modules.h b/pango/pango-modules.h
index aec79e7..344ef41 100644
--- a/pango/pango-modules.h
+++ b/pango/pango-modules.h
@@ -53,15 +53,19 @@ struct _PangoIncludedModule
   PangoEngine *(*create) (const char       *id);
 };
 
+G_DEPRECATED
 PangoMap *     pango_find_map        (PangoLanguage       *language,
                                      guint                engine_type_id,
                                      guint                render_type_id);
+G_DEPRECATED
 PangoEngine *  pango_map_get_engine  (PangoMap            *map,
                                      PangoScript          script);
+G_DEPRECATED
 void           pango_map_get_engines (PangoMap            *map,
                                      PangoScript          script,
                                      GSList             **exact_engines,
                                      GSList             **fallback_engines);
+G_DEPRECATED
 void           pango_module_register (PangoIncludedModule *module);
 
 #endif /* PANGO_ENABLE_BACKEND */
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
index 6044773..3f589c9 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -715,7 +715,6 @@ static void
 pango_core_text_family_class_init (PangoCoreTextFamilyClass *klass)
 {
   GObjectClass *object_class = (GObjectClass *)klass;
-  int i;
   PangoFontFamilyClass *pfclass = PANGO_FONT_FAMILY_CLASS(klass);
 
   object_class->finalize = pango_core_text_family_finalize;
@@ -723,9 +722,6 @@ pango_core_text_family_class_init (PangoCoreTextFamilyClass *klass)
   pfclass->list_faces = pango_core_text_family_list_faces;
   pfclass->get_name = pango_core_text_family_get_name;
   pfclass->is_monospace = pango_core_text_family_is_monospace;
-
-  for (i = 0; _pango_included_core_text_modules[i].list; i++)
-    pango_module_register (&_pango_included_core_text_modules[i]);
 }
 
 static void
diff --git a/pango/pangocoretext-private.h b/pango/pangocoretext-private.h
index 8076eae..4fc1f1e 100644
--- a/pango/pangocoretext-private.h
+++ b/pango/pangocoretext-private.h
@@ -24,8 +24,8 @@
 #ifndef __PANGOCORETEXT_PRIVATE_H__
 #define __PANGOCORETEXT_PRIVATE_H__
 
-#include <pango/pango-fontmap.h>
-#include <pango/pango-context.h>
+#include "pango-fontmap.h"
+#include "pango-context.h"
 #include "pangocoretext.h"
 
 G_BEGIN_DECLS
@@ -107,6 +107,15 @@ const PangoMatrix    *pango_core_text_font_key_get_matrix           (const Pango
 PangoGravity          pango_core_text_font_key_get_gravity          (const PangoCoreTextFontKey *key);
 CTFontDescriptorRef   pango_core_text_font_key_get_ctfontdescriptor (const PangoCoreTextFontKey *key);
 
+void
+_pango_coretext_shape (PangoFont           *font,
+                      const char          *text,
+                      gint                 length,
+                      const PangoAnalysis *analysis,
+                      PangoGlyphString    *glyphs,
+                      const char          *paragraph_text G_GNUC_UNUSED,
+                      unsigned int         paragraph_length G_GNUC_UNUSED);
+
 G_END_DECLS
 
 #endif /* __PANGOCORETEXT_PRIVATE_H__ */
diff --git a/pango/pangocoretext-shape.c b/pango/pangocoretext-shape.c
index 31825ed..8f66684 100644
--- a/pango/pangocoretext-shape.c
+++ b/pango/pangocoretext-shape.c
@@ -25,30 +25,8 @@
 #include <glib.h>
 #include <string.h>
 #include <Carbon/Carbon.h>
-#include "pango-engine.h"
 #include "pango-utils.h"
-#include "pango-fontmap.h"
-#include "pangocoretext.h"
-
-/* No extra fields needed */
-typedef PangoEngineShape      BasicEngineCoreText;
-typedef PangoEngineShapeClass BasicEngineCoreTextClass ;
-
-#define SCRIPT_ENGINE_NAME "BasicScriptEngineCoreText"
-#define RENDER_TYPE PANGO_RENDER_TYPE_CORE_TEXT
-
-static PangoEngineScriptInfo basic_scripts[] = {
-  { PANGO_SCRIPT_COMMON,   "" }
-};
-
-static PangoEngineInfo script_engines[] = {
-  {
-    SCRIPT_ENGINE_NAME,
-    PANGO_ENGINE_TYPE_SHAPE,
-    RENDER_TYPE,
-    basic_scripts, G_N_ELEMENTS(basic_scripts)
-  }
-};
+#include "pangocoretext-private.h"
 
 static void
 set_glyph (PangoFont        *font,
@@ -72,10 +50,10 @@ set_glyph (PangoFont        *font,
 
 /* The "RunIterator" helps us to iterate over the array of runs that is obtained from
  * the CoreText type setter. Even though Pango considers the string that is passed to
- * the shaping engine a single run, CoreText might consider it to consist out of
+ * the shape function a single run, CoreText might consider it to consist out of
  * multiple runs. Because of this, we have an interface around the CoreText array of
- * runs that works like iterating a single array, which makes our job in the shaping
- * engine function easier.
+ * runs that works like iterating a single array, which makes our job in the shape
+ * function easier.
  */
 
 struct RunIterator
@@ -142,7 +120,7 @@ run_iterator_get_glyph_count (struct RunIterator *iter)
 /* These functions are commented out to silence the compiler, but
  * kept around because they might be of use when fixing the more
  * intricate issues noted in the comment in the function
- * basic_engine_shape() below.
+ * pangocoretext_shape() below.
  */
 #if 0
 static gboolean
@@ -353,15 +331,14 @@ create_core_text_glyph_list (const char *text,
 }
 
 
-static void
-basic_engine_shape (PangoEngineShape    *engine,
-                   PangoFont           *font,
-                   const char          *text,
-                   gint                 length,
-                   const PangoAnalysis *analysis,
-                   PangoGlyphString    *glyphs,
-                   const char          *paragraph_text G_GNUC_UNUSED,
-                   unsigned int         paragraph_length G_GNUC_UNUSED)
+void
+_pango_coretext_shape (PangoFont           *font,
+                      const char          *text,
+                      gint                 length,
+                      const PangoAnalysis *analysis,
+                      PangoGlyphString    *glyphs,
+                      const char          *paragraph_text G_GNUC_UNUSED,
+                      unsigned int         paragraph_length G_GNUC_UNUSED)
 {
   const char *p;
   gulong n_chars, gs_i, gs_prev_i;
@@ -490,40 +467,3 @@ basic_engine_shape (PangoEngineShape    *engine,
   g_slist_foreach (glyph_list, glyph_info_free, NULL);
   g_slist_free (glyph_list);
 }
-
-static void
-basic_engine_core_text_class_init (PangoEngineShapeClass *class)
-{
-  class->script_shape = basic_engine_shape;
-}
-
-PANGO_ENGINE_SHAPE_DEFINE_TYPE (BasicEngineCoreText, basic_engine_core_text,
-                               basic_engine_core_text_class_init, NULL);
-
-void
-PANGO_MODULE_ENTRY(init) (GTypeModule *module)
-{
-  basic_engine_core_text_register_type (module);
-}
-
-void
-PANGO_MODULE_ENTRY(exit) (void)
-{
-}
-
-void
-PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
-                         int              *n_engines)
-{
-  *engines = script_engines;
-  *n_engines = G_N_ELEMENTS (script_engines);
-}
-
-PangoEngine *
-PANGO_MODULE_ENTRY(create) (const char *id)
-{
-  if (!strcmp (id, SCRIPT_ENGINE_NAME))
-    return g_object_new (basic_engine_core_text_type, NULL);
-  else
-    return NULL;
-}
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 7056bca..46dcd17 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -42,8 +42,8 @@
 #include "pangofc-font.h"
 #include "pangofc-fontmap.h"
 #include "pangofc-private.h"
+#include "pango-engine.h"
 #include "pango-layout.h"
-#include "pango-modules.h"
 #include "pango-impl-utils.h"
 
 #include <fontconfig/fcfreetype.h>
@@ -307,18 +307,33 @@ pango_fc_font_describe_absolute (PangoFont *font)
   return desc;
 }
 
-static PangoMap *
-pango_fc_get_shaper_map (PangoLanguage *language)
+/* Wrap shaper in PangoEngineShape to pass it through old API,
+ * from times when there were modules and engines. */
+typedef PangoEngineShape      PangoFcShapeEngine;
+typedef PangoEngineShapeClass PangoFcShapeEngineClass;
+static GType pango_fc_shape_engine_get_type (void) G_GNUC_CONST;
+G_DEFINE_TYPE (PangoFcShapeEngine, pango_fc_shape_engine, PANGO_TYPE_ENGINE_SHAPE);
+static void
+_pango_fc_shape_engine_shape (PangoEngineShape    *engine G_GNUC_UNUSED,
+                             PangoFont           *font,
+                             const char          *item_text,
+                             unsigned int         item_length,
+                             const PangoAnalysis *analysis,
+                             PangoGlyphString    *glyphs,
+                             const char          *paragraph_text,
+                             unsigned int         paragraph_length)
+{
+  _pango_fc_shape (font, item_text, item_length, analysis, glyphs,
+                  paragraph_text, paragraph_length);
+}
+static void
+pango_fc_shape_engine_class_init (PangoEngineShapeClass *class)
+{
+  class->script_shape = _pango_fc_shape_engine_shape;
+}
+static void
+pango_fc_shape_engine_init (PangoEngineShape *object)
 {
-  static guint engine_type_id = 0; /* MT-safe */
-  static guint render_type_id = 0; /* MT-safe */
-
-  if (engine_type_id == 0)
-    engine_type_id = g_quark_from_static_string (PANGO_ENGINE_TYPE_SHAPE);
-  if (render_type_id == 0)
-    render_type_id = g_quark_from_static_string (PANGO_RENDER_TYPE_FC);
-
-  return pango_find_map (language, engine_type_id, render_type_id);
 }
 
 static PangoEngineShape *
@@ -326,12 +341,10 @@ pango_fc_font_find_shaper (PangoFont     *font G_GNUC_UNUSED,
                           PangoLanguage *language,
                           guint32        ch)
 {
-  PangoMap *shaper_map = NULL;
-  PangoScript script;
-
-  shaper_map = pango_fc_get_shaper_map (language);
-  script = pango_script_for_unichar (ch);
-  return (PangoEngineShape *)pango_map_get_engine (shaper_map, script);
+  static PangoEngineShape *shaper;
+  if (!shaper)
+    shaper = g_object_new (pango_fc_shape_engine_get_type(), NULL); /* XXX MT-unsafe */
+  return shaper;
 }
 
 static PangoCoverage *
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index e703458..13e1e4e 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -1054,23 +1054,12 @@ G_DEFINE_ABSTRACT_TYPE (PangoFcFontMap, pango_fc_font_map, PANGO_TYPE_FONT_MAP)
 static void
 pango_fc_font_map_init (PangoFcFontMap *fcfontmap)
 {
-  static gsize registered_modules = 0; /* MT-safe */
   PangoFcFontMapPrivate *priv;
 
   priv = fcfontmap->priv = G_TYPE_INSTANCE_GET_PRIVATE (fcfontmap,
                                                        PANGO_TYPE_FC_FONT_MAP,
                                                        PangoFcFontMapPrivate);
 
-  if (g_once_init_enter (&registered_modules))
-    {
-      int i;
-
-      for (i = 0; _pango_included_fc_modules[i].list; i++)
-       pango_module_register (&_pango_included_fc_modules[i]);
-
-      g_once_init_leave(&registered_modules, 1);
-    }
-
   priv->n_families = -1;
 
   priv->font_hash = g_hash_table_new ((GHashFunc)pango_fc_font_key_hash,
diff --git a/pango/pangofc-private.h b/pango/pangofc-private.h
index 3204567..5c99396 100644
--- a/pango/pangofc-private.h
+++ b/pango/pangofc-private.h
@@ -100,7 +100,14 @@ void            pango_fc_font_get_raw_extents    (PangoFcFont    *font,
 PangoFontMetrics *pango_fc_font_create_base_metrics_for_context (PangoFcFont   *font,
                                                                 PangoContext  *context);
 
-
+void
+_pango_fc_shape (PangoFont           *font,
+                const char          *item_text,
+                unsigned int         item_length,
+                const PangoAnalysis *analysis,
+                PangoGlyphString    *glyphs,
+                const char          *paragraph_text,
+                unsigned int         paragraph_length);
 
 /* To be made public at some point */
 
diff --git a/pango/pangofc-shape.c b/pango/pangofc-shape.c
index 93c4478..3935d2d 100644
--- a/pango/pangofc-shape.c
+++ b/pango/pangofc-shape.c
@@ -27,37 +27,12 @@
 
 #define PANGO_ENABLE_BACKEND 1 /* XXX */
 
-#include "pango-engine.h"
-#include "pango-utils.h"
-#include "pangofc-fontmap.h"
-#include "pangofc-font.h"
+#include "pangofc-private.h"
 #include <hb-ft.h>
 #include <hb-glib.h>
 
 #define PANGO_UNITS_26_6(d)    ((d) << 4)
 
-
-/* No extra fields needed */
-typedef PangoEngineShape      BasicEngineFc;
-typedef PangoEngineShapeClass BasicEngineFcClass;
-
-#define SCRIPT_ENGINE_NAME "BasicScriptEngineFc"
-#define RENDER_TYPE PANGO_RENDER_TYPE_FC
-
-static PangoEngineScriptInfo basic_scripts[] = {
-  { PANGO_SCRIPT_COMMON,   "" }
-};
-
-static PangoEngineInfo script_engines[] = {
-  {
-    SCRIPT_ENGINE_NAME,
-    PANGO_ENGINE_TYPE_SHAPE,
-    RENDER_TYPE,
-    basic_scripts, G_N_ELEMENTS(basic_scripts)
-  }
-};
-
-
 /* cache a single hb_buffer_t */
 static hb_buffer_t *cached_buffer = NULL; /* MT-safe */
 G_LOCK_DEFINE_STATIC (cached_buffer);
@@ -299,17 +274,14 @@ pango_fc_get_hb_font_funcs (void)
 }
 
 
-
-
-static void
-basic_engine_shape (PangoEngineShape    *engine G_GNUC_UNUSED,
-                   PangoFont           *font,
-                   const char          *item_text,
-                   unsigned int         item_length,
-                   const PangoAnalysis *analysis,
-                   PangoGlyphString    *glyphs,
-                   const char          *paragraph_text,
-                   unsigned int         paragraph_length)
+void
+_pango_fc_shape (PangoFont           *font,
+                const char          *item_text,
+                unsigned int         item_length,
+                const PangoAnalysis *analysis,
+                PangoGlyphString    *glyphs,
+                const char          *paragraph_text,
+                unsigned int         paragraph_length)
 {
   PangoFcHbContext context;
   PangoFcFont *fc_font;
@@ -444,40 +416,3 @@ basic_engine_shape (PangoEngineShape    *engine G_GNUC_UNUSED,
   hb_face_destroy (hb_face);
   pango_fc_font_unlock_face (fc_font);
 }
-
-static void
-basic_engine_fc_class_init (PangoEngineShapeClass *class)
-{
-  class->script_shape = basic_engine_shape;
-}
-
-PANGO_ENGINE_SHAPE_DEFINE_TYPE (BasicEngineFc, basic_engine_fc,
-                               basic_engine_fc_class_init, NULL)
-
-void
-PANGO_MODULE_ENTRY(init) (GTypeModule *module)
-{
-  basic_engine_fc_register_type (module);
-}
-
-void
-PANGO_MODULE_ENTRY(exit) (void)
-{
-}
-
-void
-PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
-                         int              *n_engines)
-{
-  *engines = script_engines;
-  *n_engines = G_N_ELEMENTS (script_engines);
-}
-
-PangoEngine *
-PANGO_MODULE_ENTRY(create) (const char *id)
-{
-  if (!strcmp (id, SCRIPT_ENGINE_NAME))
-    return g_object_new (basic_engine_fc_type, NULL);
-  else
-    return NULL;
-}
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index 4cd9fa8..306d831 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -721,7 +721,6 @@ _pango_win32_font_map_class_init (PangoWin32FontMapClass *class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (class);
   PangoFontMapClass *fontmap_class = PANGO_FONT_MAP_CLASS (class);
-  int i;
 
   class->find_font = pango_win32_font_map_real_find_font;
   object_class->finalize = pango_win32_font_map_finalize;
@@ -732,9 +731,6 @@ _pango_win32_font_map_class_init (PangoWin32FontMapClass *class)
   fontmap_class->shape_engine_type = PANGO_RENDER_TYPE_WIN32;
 
   pango_win32_get_dc ();
-
-  for (i = 0; _pango_included_win32_modules[i].list; i++)
-    pango_module_register (&_pango_included_win32_modules[i]);
 }
 
 /**
diff --git a/pango/pangowin32-private.h b/pango/pangowin32-private.h
index ba95f9b..7485708 100644
--- a/pango/pangowin32-private.h
+++ b/pango/pangowin32-private.h
@@ -52,8 +52,8 @@
 #define PING(printlist)
 #endif
 
-#include <pango/pango-modules.h>
-#include <pango/pangowin32.h>
+#include "pango-modules.h"
+#include "pangowin32.h"
 
 typedef enum
   {
@@ -275,6 +275,15 @@ gboolean   _pango_win32_get_name_record        (HDC                 hdc,
 
 HFONT          _pango_win32_font_get_hfont         (PangoFont          *font);
 
+void
+_pango_win32_shape (PangoFont          *font,
+                   const char          *text,
+                   unsigned int         length,
+                   const PangoAnalysis *analysis,
+                   PangoGlyphString    *glyphs,
+                   const char          *paragraph_text G_GNUC_UNUSED,
+                   unsigned int         paragraph_length G_GNUC_UNUSED);
+
 extern HDC _pango_win32_hdc;
 extern OSVERSIONINFO _pango_win32_os_version_info;
 extern gboolean _pango_win32_debug;
diff --git a/pango/pangowin32-shape.c b/pango/pangowin32-shape.c
index db92a38..787bab6 100644
--- a/pango/pangowin32-shape.c
+++ b/pango/pangowin32-shape.c
@@ -1,5 +1,5 @@
 /* Pango
- * basic-win32.c:
+ * pangowin32-shape.c:
  *
  * Copyright (C) 1999 Red Hat Software
  * Copyright (C) 2001 Alexander Larsson
@@ -22,88 +22,23 @@
 
 #include "config.h"
 
-#define BASIC_WIN32_DEBUGGING
+/*#define BASIC_WIN32_DEBUGGING */
 
 #include <math.h>
 #include <stdlib.h>
 
 #include <glib.h>
 
-#include "pangowin32.h"
+#include "pangowin32-private.h"
 
 extern HFONT _pango_win32_font_get_hfont (PangoFont *font);
 
-#include "pango-engine.h"
 #include "pango-utils.h"
 
-/* No extra fields needed */
-typedef PangoEngineShape      BasicEngineWin32;
-typedef PangoEngineShapeClass BasicEngineWin32Class ;
-
-#define SCRIPT_ENGINE_NAME "BasicScriptEngineWin32"
-
 static gboolean pango_win32_debug = FALSE;
 
 #include <usp10.h>
 
-static HDC hdc;
-
-#ifdef BASIC_WIN32_DEBUGGING
-static const SCRIPT_PROPERTIES **scripts;
-static int nscripts;
-#endif
-
-static PangoEngineScriptInfo uniscribe_scripts[] = {
-  /* We claim to cover everything ;-) */
-  { PANGO_SCRIPT_COMMON,  "" },
-};
-
-static PangoEngineScriptInfo basic_scripts[] = {
-  /* Those characters that can be rendered legibly without Uniscribe.
-   * I am not certain this list is correct.
-   */
-  { PANGO_SCRIPT_ARMENIAN, "*" },
-  { PANGO_SCRIPT_BOPOMOFO, "*" },
-  { PANGO_SCRIPT_CHEROKEE, "*" },
-  { PANGO_SCRIPT_COPTIC,   "*" },
-  { PANGO_SCRIPT_CYRILLIC, "*" },
-  { PANGO_SCRIPT_DESERET,  "*" },
-  { PANGO_SCRIPT_ETHIOPIC, "*" },
-  { PANGO_SCRIPT_GEORGIAN, "*" },
-  { PANGO_SCRIPT_GOTHIC,   "*" },
-  { PANGO_SCRIPT_GREEK,    "*" },
-  { PANGO_SCRIPT_HAN,      "*" },
-  { PANGO_SCRIPT_HANGUL,   "*" },
-  { PANGO_SCRIPT_HIRAGANA, "*" },
-  { PANGO_SCRIPT_KATAKANA, "*" },
-  { PANGO_SCRIPT_LATIN,    "*" },
-  { PANGO_SCRIPT_OGHAM,    "*" },
-  { PANGO_SCRIPT_OLD_ITALIC, "*" },
-  { PANGO_SCRIPT_RUNIC,     "*" },
-  { PANGO_SCRIPT_THAI,      "*" },
-  { PANGO_SCRIPT_CANADIAN_ABORIGINAL, "*" },
-  { PANGO_SCRIPT_YI,       "*" },
-  { PANGO_SCRIPT_BRAILLE,  "*" },
-  { PANGO_SCRIPT_CYPRIOT,  "*" },
-  { PANGO_SCRIPT_LIMBU,    "*" },
-  { PANGO_SCRIPT_OSMANYA,  "*" },
-  { PANGO_SCRIPT_SHAVIAN,  "*" },
-  { PANGO_SCRIPT_LINEAR_B, "*" },
-  { PANGO_SCRIPT_UGARITIC, "*" },
-
-  /* Claim to handle everything as a fallback */
-  { PANGO_SCRIPT_COMMON,   "" }
-};
-
-static PangoEngineInfo script_engines[] = {
-  {
-    SCRIPT_ENGINE_NAME,
-    PANGO_ENGINE_TYPE_SHAPE,
-    PANGO_RENDER_TYPE_WIN32,
-    NULL, 0
-  }
-};
-
 static PangoGlyph
 find_char (PangoFont *font,
           gunichar   wc)
@@ -520,6 +455,11 @@ itemize_shape_and_place (PangoFont           *font,
 
 #ifdef BASIC_WIN32_DEBUGGING
       if (pango_win32_debug)
+       {
+       static const SCRIPT_PROPERTIES **scripts;
+       static int nscripts;
+       if (!nscripts)
+         ScriptGetProperties (&scripts, &nscripts);
        g_print ("  Item %d: iCharPos=%d eScript=%d (%s) %s%s%s%s%s%s%s wchar_t %d--%d (%d)\n",
                 item, items[item].iCharPos, script,
                 lang_name (scripts[script]->langid),
@@ -569,7 +509,7 @@ itemize_shape_and_place (PangoFont           *font,
        {
 #ifdef BASIC_WIN32_DEBUGGING
          if (pango_win32_debug)
-           g_print ("pango-basic-win32: ScriptShape failed\n");
+           g_print ("pangowin32-shape: ScriptShape failed\n");
 #endif
          return FALSE;
        }
@@ -594,7 +534,7 @@ itemize_shape_and_place (PangoFont           *font,
        {
 #ifdef BASIC_WIN32_DEBUGGING
          if (pango_win32_debug)
-           g_print ("pango-basic-win32: ScriptPlace failed\n");
+           g_print ("pangowin32-shape: ScriptPlace failed\n");
 #endif
          return FALSE;
        }
@@ -648,6 +588,7 @@ uniscribe_shape (PangoFont           *font,
 {
   wchar_t *wtext;
   long wlen;
+  HDC hdc = _pango_win32_hdc;
   gboolean retval = TRUE;
 
   if (!pango_win32_font_select_font (font, hdc))
@@ -710,9 +651,8 @@ text_is_simple (const char *text,
   return retval;
 }
 
-static void
-basic_engine_shape (PangoEngineShape   *engine,
-                   PangoFont           *font,
+void
+_pango_win32_shape (PangoFont          *font,
                    const char          *text,
                    unsigned int         length,
                    const PangoAnalysis *analysis,
@@ -814,64 +754,3 @@ basic_engine_shape (PangoEngineShape       *engine,
        }
     }
 }
-
-static void
-init_uniscribe (void)
-{
-#ifdef BASIC_WIN32_DEBUGGING
-  ScriptGetProperties (&scripts, &nscripts);
-#endif
-  hdc = pango_win32_get_dc ();
-}
-
-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 ();
-
-  if (pango_win32_get_debug_flag ())
-    pango_win32_debug = TRUE;
-
-  basic_engine_win32_register_type (module);
-}
-
-void
-PANGO_MODULE_ENTRY(exit) (void)
-{
-}
-
-void
-PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines,
-                         int              *n_engines)
-{
-  init_uniscribe ();
-
-  script_engines[0].scripts = basic_scripts;
-  script_engines[0].n_scripts = G_N_ELEMENTS (basic_scripts);
-
-  /* This is stupid, we rewrite the previous two lines.  Not
-   * going to touch it now. */
-  script_engines[0].scripts = uniscribe_scripts;
-  script_engines[0].n_scripts = G_N_ELEMENTS (uniscribe_scripts);
-
-  *engines = script_engines;
-  *n_engines = G_N_ELEMENTS (script_engines);
-}
-
-PangoEngine *
-PANGO_MODULE_ENTRY(create) (const char *id)
-{
-  if (!strcmp (id, SCRIPT_ENGINE_NAME))
-    return g_object_new (basic_engine_win32_type, NULL);
-  else
-    return NULL;
-}
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index 6948037..fabde2f 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -156,7 +156,7 @@ _pango_win32_font_init (PangoWin32Font *win32font)
 HDC
 pango_win32_get_dc (void)
 {
-  if (_pango_win32_hdc == NULL)
+  if (_pango_win32_hdc == NULL) /* TODO: MT-unsafe. Use g_once_init/leave */
     {
       _pango_win32_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
       memset (&_pango_win32_os_version_info, 0,
@@ -945,17 +945,44 @@ pango_win32_font_get_coverage (PangoFont     *font,
   return coverage;
 }
 
+/* Wrap shaper in PangoEngineShape to pass it through old API,
+ * from times when there were modules and engines. */
+typedef PangoEngineShape      PangoWin32ShapeEngine;
+typedef PangoEngineShapeClass PangoWin32ShapeEngineClass;
+static GType pango_win32_shape_engine_get_type (void) G_GNUC_CONST;
+G_DEFINE_TYPE (PangoWin32ShapeEngine, pango_win32_shape_engine, PANGO_TYPE_ENGINE_SHAPE);
+static void
+_pango_win32_shape_engine_shape (PangoEngineShape    *engine G_GNUC_UNUSED,
+                                PangoFont           *font,
+                                const char          *item_text,
+                                unsigned int         item_length,
+                                const PangoAnalysis *analysis,
+                                PangoGlyphString    *glyphs,
+                                const char          *paragraph_text,
+                                unsigned int         paragraph_length)
+{
+  _pango_win32_shape (font, item_text, item_length, analysis, glyphs,
+                     paragraph_text, paragraph_length);
+}
+static void
+pango_win32_shape_engine_class_init (PangoEngineShapeClass *class)
+{
+  class->script_shape = _pango_win32_shape_engine_shape;
+}
+static void
+pango_win32_shape_engine_init (PangoEngineShape *object)
+{
+}
+
 static PangoEngineShape *
 pango_win32_font_find_shaper (PangoFont     *font,
                              PangoLanguage *lang,
                              guint32        ch)
 {
-  PangoMap *shape_map = NULL;
-  PangoScript script;
-
-  shape_map = pango_win32_get_shaper_map (lang);
-  script = pango_script_for_unichar (ch);
-  return (PangoEngineShape *)pango_map_get_engine (shape_map, script);
+  static PangoEngineShape *shaper;
+  if (!shaper)
+    shaper = g_object_new (pango_win32_shape_engine_get_type(), NULL); /* XXX MT-unsafe */
+  return shaper;
 }
 
 /* Utility functions */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]