summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheppitak Karoonboonyanan <tkaroonb@src.gnome.org>2004-06-07 08:11:17 +0000
committerTheppitak Karoonboonyanan <tkaroonb@src.gnome.org>2004-06-07 08:11:17 +0000
commiteaf70a1a0807a0b1b7cce348bcda6a90f5a42e6b (patch)
treed2d1baba9006c2019a394fb8756d21dc6b824560
parent1a4db6e6d3354bdbf954c94b6ee46c7be8ad85d6 (diff)
downloadpango-eaf70a1a0807a0b1b7cce348bcda6a90f5a42e6b.tar.gz
Add OpenType support in Thai module. (#141541)
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.pre-1-106
-rw-r--r--ChangeLog.pre-1-66
-rw-r--r--ChangeLog.pre-1-86
-rw-r--r--modules/thai/Makefile.am2
-rw-r--r--modules/thai/thai-ot.c163
-rw-r--r--modules/thai/thai-ot.h18
-rw-r--r--modules/thai/thai-shaper.c2
8 files changed, 208 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0e530a47..2b67cd94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Jun 7 2004 Theppitak Karoonboonyanan <thep@linux.thai.net>
+
+ * modules/thai/Makefile.am modules/thai/thai-shaper.c
+ (thai_engine_shape) +modules/thai/thai-ot.c +modules/thai/thai-ot.h:
+ Add OpenType support in Thai module. (#141541)
+
Fri May 28 2004 Theppitak Karoonboonyanan <thep@linux.thai.net>
* pango/opentype/pango-ot-buffer.c (apply_gpos_ltr): Negate y offset
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 0e530a47..2b67cd94 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,9 @@
+Mon Jun 7 2004 Theppitak Karoonboonyanan <thep@linux.thai.net>
+
+ * modules/thai/Makefile.am modules/thai/thai-shaper.c
+ (thai_engine_shape) +modules/thai/thai-ot.c +modules/thai/thai-ot.h:
+ Add OpenType support in Thai module. (#141541)
+
Fri May 28 2004 Theppitak Karoonboonyanan <thep@linux.thai.net>
* pango/opentype/pango-ot-buffer.c (apply_gpos_ltr): Negate y offset
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 0e530a47..2b67cd94 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,9 @@
+Mon Jun 7 2004 Theppitak Karoonboonyanan <thep@linux.thai.net>
+
+ * modules/thai/Makefile.am modules/thai/thai-shaper.c
+ (thai_engine_shape) +modules/thai/thai-ot.c +modules/thai/thai-ot.h:
+ Add OpenType support in Thai module. (#141541)
+
Fri May 28 2004 Theppitak Karoonboonyanan <thep@linux.thai.net>
* pango/opentype/pango-ot-buffer.c (apply_gpos_ltr): Negate y offset
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 0e530a47..2b67cd94 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,9 @@
+Mon Jun 7 2004 Theppitak Karoonboonyanan <thep@linux.thai.net>
+
+ * modules/thai/Makefile.am modules/thai/thai-shaper.c
+ (thai_engine_shape) +modules/thai/thai-ot.c +modules/thai/thai-ot.h:
+ Add OpenType support in Thai module. (#141541)
+
Fri May 28 2004 Theppitak Karoonboonyanan <thep@linux.thai.net>
* pango/opentype/pango-ot-buffer.c (apply_gpos_ltr): Negate y offset
diff --git a/modules/thai/Makefile.am b/modules/thai/Makefile.am
index bfa4a78e..2db1bee5 100644
--- a/modules/thai/Makefile.am
+++ b/modules/thai/Makefile.am
@@ -31,7 +31,7 @@ module_LTLIBRARIES += pango-thai-fc.la
endif
endif
-thai_fc_sources = $(common_sources) thai-fc.c
+thai_fc_sources = $(common_sources) thai-fc.c thai-ot.c thai-ot.h
pango_thai_fc_la_LDFLAGS = -export-dynamic -avoid-version -module $(no_undefined)
pango_thai_fc_la_LIBADD = $(pangoft2libs)
diff --git a/modules/thai/thai-ot.c b/modules/thai/thai-ot.c
new file mode 100644
index 00000000..33fdce3f
--- /dev/null
+++ b/modules/thai/thai-ot.c
@@ -0,0 +1,163 @@
+/* Pango
+ * thai-ot.c:
+ *
+ * Copyright (C) 2004 Theppitak Karoonboonyanan
+ * Author: Theppitak Karoonboonyanan <thep@linux.thai.net>
+ */
+
+#include <string.h>
+
+#include "thai-ot.h"
+
+static void
+maybe_add_gsub_feature (PangoOTRuleset *ruleset,
+ PangoOTInfo *info,
+ guint script_index,
+ PangoOTTag feature_tag,
+ gulong property_bit)
+{
+ guint feature_index;
+
+ /* 0xffff == default language system */
+ if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GSUB,
+ feature_tag, script_index, 0xffff, &feature_index))
+ {
+ pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GSUB, feature_index,
+ property_bit);
+ }
+}
+
+static void
+maybe_add_gpos_feature (PangoOTRuleset *ruleset,
+ PangoOTInfo *info,
+ guint script_index,
+ PangoOTTag feature_tag,
+ gulong property_bit)
+{
+ guint feature_index;
+
+ if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GPOS,
+ feature_tag, script_index, 0xffff, &feature_index))
+ {
+ pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GPOS, feature_index,
+ property_bit);
+ }
+}
+
+static PangoOTRuleset *
+get_gsub_ruleset (FT_Face face)
+{
+ PangoOTInfo *info = pango_ot_info_get (face);
+ GQuark ruleset_quark = g_quark_from_string ("thai-gsub-ruleset");
+ PangoOTRuleset *ruleset;
+
+ if (!info)
+ return NULL;
+
+ ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark);
+
+ if (!ruleset)
+ {
+ PangoOTTag thai_tag = FT_MAKE_TAG ('t', 'h', 'a', 'i');
+ guint script_index;
+
+ ruleset = pango_ot_ruleset_new (info);
+
+ if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB,
+ thai_tag, &script_index))
+ {
+ maybe_add_gsub_feature (ruleset, info, script_index, FT_MAKE_TAG ('c','c','m','p'), 0xFFFF);
+ maybe_add_gsub_feature (ruleset, info, script_index, FT_MAKE_TAG ('l','i','g','a'), 0xFFFF);
+ }
+
+ g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset,
+ (GDestroyNotify)g_object_unref);
+ }
+
+ return ruleset;
+}
+
+
+static PangoOTRuleset *
+get_gpos_ruleset (FT_Face face)
+{
+ PangoOTInfo *info = pango_ot_info_get (face);
+ GQuark ruleset_quark = g_quark_from_string ("thai-gpos-ruleset");
+ PangoOTRuleset *ruleset;
+
+ if (!info)
+ return NULL;
+
+ ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark);
+
+ if (!ruleset)
+ {
+ PangoOTTag thai_tag = FT_MAKE_TAG ('t', 'h', 'a', 'i');
+ guint script_index;
+
+ ruleset = pango_ot_ruleset_new (info);
+
+ if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS,
+ thai_tag, &script_index))
+ {
+ maybe_add_gpos_feature (ruleset, info, script_index, FT_MAKE_TAG ('k','e','r','n'), 0xFFFF);
+ maybe_add_gpos_feature (ruleset, info, script_index, FT_MAKE_TAG ('m','a','r','k'), 0xFFFF);
+ maybe_add_gpos_feature (ruleset, info, script_index, FT_MAKE_TAG ('m','k','m','k'), 0xFFFF);
+ }
+
+ g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset,
+ (GDestroyNotify)g_object_unref);
+ }
+
+ return ruleset;
+}
+
+
+void
+thai_ot_shape (PangoFont *font,
+ PangoGlyphString *glyphs)
+{
+ FT_Face face;
+ PangoOTRuleset *gsub_ruleset, *gpos_ruleset;
+ PangoFcFont *fc_font;
+
+ g_return_if_fail (font != NULL);
+ g_return_if_fail (glyphs != NULL);
+
+ fc_font = PANGO_FC_FONT (font);
+ face = pango_fc_font_lock_face (fc_font);
+ g_assert (face != NULL);
+
+ gsub_ruleset = get_gsub_ruleset (face);
+ gpos_ruleset = get_gpos_ruleset (face);
+
+ if (gsub_ruleset != NULL || gpos_ruleset != NULL)
+ {
+ gint i;
+ PangoOTBuffer *buffer;
+
+ /* prepare ot buffer */
+ buffer = pango_ot_buffer_new (fc_font);
+ for (i = 0; i < glyphs->num_glyphs; i++)
+ {
+ pango_ot_buffer_add_glyph (buffer,
+ glyphs->glyphs[i].glyph,
+ 0,
+ glyphs->log_clusters[i]);
+ }
+
+ /* do gsub processing */
+ if (gsub_ruleset != NULL)
+ pango_ot_ruleset_substitute (gsub_ruleset, buffer);
+
+ /* do gpos processing */
+ if (gpos_ruleset != NULL)
+ pango_ot_ruleset_position (gpos_ruleset, buffer);
+
+ pango_ot_buffer_output (buffer, glyphs);
+ pango_ot_buffer_destroy (buffer);
+ }
+
+ pango_fc_font_unlock_face (fc_font);
+}
+
diff --git a/modules/thai/thai-ot.h b/modules/thai/thai-ot.h
new file mode 100644
index 00000000..43f79ef8
--- /dev/null
+++ b/modules/thai/thai-ot.h
@@ -0,0 +1,18 @@
+/* Pango
+ * thai-ot.h:
+ *
+ * Copyright (C) 2004 Theppitak Karoonboonyanan
+ * Author: Theppitak Karoonboonyanan <thep@linux.thai.net>
+ */
+
+#ifndef __THAI_OT_H__
+#define __THAI_OT_H__
+
+#include "pango-ot.h"
+
+void
+thai_ot_shape (PangoFont *font,
+ PangoGlyphString *glyphs);
+
+#endif /* __THAI_OT_H__ */
+
diff --git a/modules/thai/thai-shaper.c b/modules/thai/thai-shaper.c
index baae3a79..3a0b4d88 100644
--- a/modules/thai/thai-shaper.c
+++ b/modules/thai/thai-shaper.c
@@ -32,6 +32,7 @@
#include <glib.h>
#include "pango-engine.h"
#include "thai-shaper.h"
+#include "thai-ot.h"
#define MAX_CLUSTER_CHRS 256
#define MAX_GLYPHS 256
@@ -703,5 +704,6 @@ thai_engine_shape (PangoEngineShape *engine,
p = get_next_cluster (p, text + length - p, cluster, &num_chrs);
add_cluster (font_info, glyphs, log_cluster - text, cluster, num_chrs);
}
+ thai_ot_shape (font, glyphs);
}