summaryrefslogtreecommitdiff
path: root/pango/pangowin32.c
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/pangowin32.c
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/pangowin32.c')
-rw-r--r--pango/pangowin32.c55
1 files changed, 34 insertions, 21 deletions
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 */