summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2014-07-28 18:37:36 -0400
committerBehdad Esfahbod <behdad@behdad.org>2015-04-04 16:13:40 -0700
commit7d30b3f91958a3ff45ee2b8e5de2b6186cadfb72 (patch)
treec598289612344faffb3b0225707f1c2ed2282de8 /pango
parent14c11dd96e1547aaede1bb05a0243f5b0b53186e (diff)
downloadpango-7d30b3f91958a3ff45ee2b8e5de2b6186cadfb72.tar.gz
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, PangoWin32, and PangoCoretext shapers.
Diffstat (limited to 'pango')
-rw-r--r--pango/modules.c439
-rw-r--r--pango/pango-context.c176
-rw-r--r--pango/pango-engine.h32
-rw-r--r--pango/pango-modules.h4
-rw-r--r--pango/pangocoretext-fontmap.c4
-rw-r--r--pango/pangocoretext-private.h11
-rw-r--r--pango/pangocoretext-shape.c89
-rw-r--r--pango/pangocoretext.c35
-rw-r--r--pango/pangocoretext.h3
-rw-r--r--pango/pangofc-font.c49
-rw-r--r--pango/pangofc-font.h4
-rw-r--r--pango/pangofc-fontmap.c11
-rw-r--r--pango/pangofc-fontmap.h2
-rw-r--r--pango/pangofc-private.h9
-rw-r--r--pango/pangofc-shape.c85
-rw-r--r--pango/pangowin32-fontmap.c4
-rw-r--r--pango/pangowin32-private.h12
-rw-r--r--pango/pangowin32-shape.c147
-rw-r--r--pango/pangowin32.c55
19 files changed, 258 insertions, 913 deletions
diff --git a/pango/modules.c b/pango/modules.c
index 3d082760..299fa605 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: (nullable): 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 6f72653b..2a7dd541 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -607,34 +607,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))
@@ -644,14 +641,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;
}
}
@@ -660,17 +657,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;
@@ -680,13 +675,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);
@@ -763,12 +756,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
@@ -995,8 +985,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;
@@ -1167,60 +1155,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;
}
@@ -1259,69 +1221,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 *
@@ -1416,9 +1342,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)
{
@@ -1433,7 +1356,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)
@@ -1554,7 +1477,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 dc146c00..b493040e 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 aec79e76..344ef419 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 168b47e9..6102139f 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -718,7 +718,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;
@@ -726,9 +725,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 8076eaea..899cd09b 100644
--- a/pango/pangocoretext-private.h
+++ b/pango/pangocoretext-private.h
@@ -24,8 +24,6 @@
#ifndef __PANGOCORETEXT_PRIVATE_H__
#define __PANGOCORETEXT_PRIVATE_H__
-#include <pango/pango-fontmap.h>
-#include <pango/pango-context.h>
#include "pangocoretext.h"
G_BEGIN_DECLS
@@ -107,6 +105,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_core_text_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 ce6a62a5..4be12159 100644
--- a/pango/pangocoretext-shape.c
+++ b/pango/pangocoretext-shape.c
@@ -1,5 +1,5 @@
/* Pango
- * basic-coretext.c
+ * pangocoretext-shape.c
*
* Copyright (C) 2005 Imendio AB
* Copyright (C) 2010 Kristian Rietveld <kris@gtk.org>
@@ -25,31 +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"
-#include "pango-impl-utils.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,
@@ -73,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
@@ -155,7 +132,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
@@ -367,15 +344,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_core_text_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;
@@ -507,40 +483,3 @@ basic_engine_shape (PangoEngineShape *engine,
if (analysis->level & 1)
pango_glyph_string_reverse_range (glyphs, 0, glyphs->num_glyphs);
}
-
-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/pangocoretext.c b/pango/pangocoretext.c
index d75b2e8d..dc5769bc 100644
--- a/pango/pangocoretext.c
+++ b/pango/pangocoretext.c
@@ -137,13 +137,44 @@ pango_core_text_font_get_coverage (PangoFont *font,
return pango_coverage_ref (priv->coverage);
}
+/* Wrap shaper in PangoEngineShape to pass it through old API,
+ * from times when there were modules and engines. */
+typedef PangoEngineShape PangoCoreTextShapeEngine;
+typedef PangoEngineShapeClass PangoCoreTextShapeEngineClass;
+static GType pango_core_text_shape_engine_get_type (void) G_GNUC_CONST;
+G_DEFINE_TYPE (PangoCoreTextShapeEngine, pango_core_text_shape_engine, PANGO_TYPE_ENGINE_SHAPE);
+static void
+_pango_core_text_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_core_text_shape (font, item_text, item_length, analysis, glyphs,
+ paragraph_text, paragraph_length);
+}
+static void
+pango_core_text_shape_engine_class_init (PangoEngineShapeClass *class)
+{
+ class->script_shape = _pango_core_text_shape_engine_shape;
+}
+static void
+pango_core_text_shape_engine_init (PangoEngineShape *object)
+{
+}
+
static PangoEngineShape *
pango_core_text_font_find_shaper (PangoFont *font,
PangoLanguage *language,
guint32 ch)
{
- /* FIXME: Implement */
- return NULL;
+ static PangoEngineShape *shaper;
+ if (!shaper)
+ shaper = g_object_new (pango_core_text_shape_engine_get_type(), NULL); /* XXX MT-unsafe */
+ return shaper;
}
static PangoFontMap *
diff --git a/pango/pangocoretext.h b/pango/pangocoretext.h
index 9449189a..a7444436 100644
--- a/pango/pangocoretext.h
+++ b/pango/pangocoretext.h
@@ -23,8 +23,7 @@
#ifndef __PANGOCORETEXT_H__
#define __PANGOCORETEXT_H__
-#include <pango/pango-context.h>
-#include <pango/pango-font.h>
+#include <pango/pango.h>
#include <Carbon/Carbon.h>
G_BEGIN_DECLS
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 9ae2f56c..79dbbbcf 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-font.h b/pango/pangofc-font.h
index 51a6e952..1189cfe3 100644
--- a/pango/pangofc-font.h
+++ b/pango/pangofc-font.h
@@ -22,12 +22,10 @@
#ifndef __PANGO_FC_FONT_H__
#define __PANGO_FC_FONT_H__
+#include <pango/pango.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include <fontconfig/fontconfig.h>
-#include <pango/pango-font.h>
-#include <pango/pango-fontmap.h>
-#include <pango/pango-glyph.h>
G_BEGIN_DECLS
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index d12ead6c..026101df 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-fontmap.h b/pango/pangofc-fontmap.h
index 612996c8..fee5faa5 100644
--- a/pango/pangofc-fontmap.h
+++ b/pango/pangofc-fontmap.h
@@ -22,8 +22,8 @@
#ifndef __PANGO_FC_FONT_MAP_H__
#define __PANGO_FC_FONT_MAP_H__
+#include <pango/pango.h>
#include <fontconfig/fontconfig.h>
-#include <pango/pango-fontmap.h>
#include <pango/pangofc-decoder.h>
#include <pango/pangofc-font.h>
diff --git a/pango/pangofc-private.h b/pango/pangofc-private.h
index 32045670..5c993969 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 d77dacef..8db471a6 100644
--- a/pango/pangofc-shape.c
+++ b/pango/pangofc-shape.c
@@ -1,5 +1,5 @@
/* Pango
- * basic-fc.c: Basic shaper for FreeType-based backends
+ * pangofc-shape.c: Basic shaper for FreeType-based backends
*
* Copyright (C) 2000, 2007, 2009 Red Hat Software
* Authors:
@@ -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 4cd9fa87..306d8316 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 ba95f9bc..ad6ce2a3 100644
--- a/pango/pangowin32-private.h
+++ b/pango/pangowin32-private.h
@@ -52,8 +52,7 @@
#define PING(printlist)
#endif
-#include <pango/pango-modules.h>
-#include <pango/pangowin32.h>
+#include "pangowin32.h"
typedef enum
{
@@ -275,6 +274,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 e9d020da..aa69d2c7 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 89059178..6e2ba260 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,
@@ -877,20 +877,6 @@ pango_win32_font_describe_absolute (PangoFont *font)
return desc;
}
-static PangoMap *
-pango_win32_get_shaper_map (PangoLanguage *lang)
-{
- 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_WIN32);
-
- return pango_find_map (lang, engine_type_id, render_type_id);
-}
-
static gint
pango_win32_coverage_language_classify (PangoLanguage *lang)
{
@@ -949,17 +935,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 */