summaryrefslogtreecommitdiff
path: root/pango/break.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2015-04-04 18:46:20 -0700
committerBehdad Esfahbod <behdad@behdad.org>2015-04-04 18:48:43 -0700
commit137832fa931e875b900dedd1c8909b46d1f7e8ad (patch)
treea9086e8e1f7707a4cc92369491c28d392f827018 /pango/break.c
parentef69cbb18b00d7e454cf881a8f58bdabad04ecef (diff)
downloadpango-137832fa931e875b900dedd1c8909b46d1f7e8ad.tar.gz
[modules] Move language modules in source tree and remove modules/
This should complete the kill-modules effort. What is left is leftover removal and unbreaking stuff. Bug 733882 - Kill Pango modules, engines, and config files
Diffstat (limited to 'pango/break.c')
-rw-r--r--pango/break.c86
1 files changed, 74 insertions, 12 deletions
diff --git a/pango/break.c b/pango/break.c
index 4076d9fb..64b6d370 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -22,7 +22,7 @@
#include "config.h"
#include "pango-break.h"
-#include "pango-modules.h"
+#include "pango-engine-private.h"
#include "pango-script-private.h"
#include "pango-impl-utils.h"
#include <string.h>
@@ -1849,10 +1849,7 @@ pango_get_log_attrs (const char *text,
PangoLogAttr *log_attrs,
int attrs_len)
{
- PangoMap *lang_map;
int chars_broken;
- static guint engine_type_id = 0; /* MT-safe */
- static guint render_type_id = 0; /* MT-safe */
PangoAnalysis analysis = { NULL };
PangoScriptIter iter;
@@ -1863,13 +1860,6 @@ pango_get_log_attrs (const char *text,
pango_default_break (text, length, &analysis, log_attrs, attrs_len);
- if (engine_type_id == 0)
- engine_type_id = g_quark_from_static_string (PANGO_ENGINE_TYPE_LANG);
- if (render_type_id == 0)
- render_type_id = g_quark_from_static_string (PANGO_RENDER_TYPE_NONE);
-
- lang_map = pango_find_map (language, engine_type_id, render_type_id);
-
chars_broken = 0;
_pango_script_iter_init (&iter, text, length);
@@ -1880,7 +1870,7 @@ pango_get_log_attrs (const char *text,
pango_script_iter_get_range (&iter, &run_start, &run_end, &script);
analysis.script = script;
- analysis.lang_engine = (PangoEngineLang*) pango_map_get_engine (lang_map, analysis.script);
+ analysis.lang_engine = _pango_get_language_engine ();
chars_broken += tailor_segment (run_start, run_end, chars_broken, &analysis, log_attrs);
}
@@ -1891,3 +1881,75 @@ pango_get_log_attrs (const char *text,
chars_broken + 1,
attrs_len);
}
+
+#include "break-arabic.c"
+#include "break-indic.c"
+#include "break-thai.c"
+
+static void
+break_script (const char *item_text,
+ unsigned int item_length,
+ const PangoAnalysis *analysis,
+ PangoLogAttr *attrs,
+ int attrs_len)
+{
+ switch (analysis->script)
+ {
+ case PANGO_SCRIPT_ARABIC:
+ break_arabic (item_text, item_length, analysis, attrs, attrs_len);
+ break;
+
+ case PANGO_SCRIPT_DEVANAGARI:
+ case PANGO_SCRIPT_BENGALI:
+ case PANGO_SCRIPT_GURMUKHI:
+ case PANGO_SCRIPT_GUJARATI:
+ case PANGO_SCRIPT_ORIYA:
+ case PANGO_SCRIPT_TAMIL:
+ case PANGO_SCRIPT_TELUGU:
+ case PANGO_SCRIPT_KANNADA:
+ case PANGO_SCRIPT_MALAYALAM:
+ case PANGO_SCRIPT_SINHALA:
+ break_indic (item_text, item_length, analysis, attrs, attrs_len);
+ break;
+
+ case PANGO_SCRIPT_THAI:
+ break_thai (item_text, item_length, analysis, attrs, attrs_len);
+ break;
+ }
+}
+
+
+/* Wrap language breaker in PangoEngineLang to pass it through old API,
+ * from times when there were modules and engines. */
+typedef PangoEngineLang PangoLanguageEngine;
+typedef PangoEngineLangClass PangoLanguageEngineClass;
+static GType pango_language_engine_get_type (void) G_GNUC_CONST;
+G_DEFINE_TYPE (PangoLanguageEngine, pango_language_engine, PANGO_TYPE_ENGINE_LANG);
+static void
+_pango_language_engine_break (PangoEngineLang *engine G_GNUC_UNUSED,
+ const char *item_text,
+ int item_length,
+ PangoAnalysis *analysis,
+ PangoLogAttr *attrs,
+ int attrs_len)
+{
+ break_script (item_text, item_length, analysis, attrs, attrs_len);
+}
+static void
+pango_language_engine_class_init (PangoEngineLangClass *class)
+{
+ class->script_break = _pango_language_engine_break;
+}
+static void
+pango_language_engine_init (PangoEngineLang *object)
+{
+}
+
+PangoEngineLang *
+_pango_get_language_engine (void)
+{
+ static PangoEngineLang *engine;
+ if (g_once_init_enter (&engine))
+ g_once_init_leave (&engine, g_object_new (pango_language_engine_get_type(), NULL));
+ return engine;
+}