diff options
Diffstat (limited to 'modules')
36 files changed, 234 insertions, 7998 deletions
diff --git a/modules/Makefile.am b/modules/Makefile.am index dc8a2c85..73b42f4d 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -3,13 +3,8 @@ SUBDIRS = \ arabic \ basic \ - hangul \ - hebrew \ indic \ - khmer \ - syriac \ - thai \ - tibetan + thai EXTRA_DIST = \ Module.mk \ diff --git a/modules/arabic/Makefile.am b/modules/arabic/Makefile.am index 935eb039..2a20532b 100644 --- a/modules/arabic/Makefile.am +++ b/modules/arabic/Makefile.am @@ -1,27 +1,5 @@ include $(top_srcdir)/modules/Module.mk -if HAVE_FREETYPE -INCLUDES += $(FREETYPE_CFLAGS) -if INCLUDE_ARABIC_FC -noinst_LTLIBRARIES += libpango-arabic-fc.la -else -if DYNAMIC_ARABIC_FC -module_LTLIBRARIES += pango-arabic-fc.la -endif -endif -endif - -fc_sources = \ - arabic-fc.c \ - arabic-ot.c \ - arabic-ot.h - -pango_arabic_fc_la_LDFLAGS = -module $(MODULE_LIBTOOL_OPTIONS) -pango_arabic_fc_la_LIBADD = $(pangoft2libs) -pango_arabic_fc_la_SOURCES = $(fc_sources) -libpango_arabic_fc_la_SOURCES = $(fc_sources) -libpango_arabic_fc_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_arabic_fc - if INCLUDE_ARABIC_LANG noinst_LTLIBRARIES += libpango-arabic-lang.la diff --git a/modules/arabic/arabic-fc.c b/modules/arabic/arabic-fc.c deleted file mode 100644 index 4b024e14..00000000 --- a/modules/arabic/arabic-fc.c +++ /dev/null @@ -1,226 +0,0 @@ -/* Pango - * arabic-fc.c: Arabic shaper for FreeType-based backends - * - * Copyright (C) 2000, 2003, 2007 Red Hat Software - * Authors: - * Owen Taylor <otaylor@redhat.com> - * Behdad Esfahbod <behdad@behdad.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#include <string.h> - -#include "arabic-ot.h" - -#include "pango-engine.h" -#include "pango-utils.h" -#include "pangofc-font.h" - -/* No extra fields needed */ -typedef PangoEngineShape ArabicEngineFc; -typedef PangoEngineShapeClass ArabicEngineFcClass ; - -#define SCRIPT_ENGINE_NAME "ArabicScriptEngineFc" -#define RENDER_TYPE PANGO_RENDER_TYPE_FC - -static PangoEngineScriptInfo arabic_scripts[] = { - { PANGO_SCRIPT_ARABIC, "*" }, - { PANGO_SCRIPT_NKO, "*" } -}; - -static PangoEngineInfo script_engines[] = { - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - RENDER_TYPE, - arabic_scripts, G_N_ELEMENTS(arabic_scripts) - } -}; - -static const PangoOTFeatureMap gsub_features[] = -{ - {"ccmp", PANGO_OT_ALL_GLYPHS}, - {"locl", PANGO_OT_ALL_GLYPHS}, - {"isol", isolated}, - {"fina", final}, - {"medi", medial}, - {"init", initial}, - {"rlig", PANGO_OT_ALL_GLYPHS}, - {"calt", PANGO_OT_ALL_GLYPHS}, - {"liga", PANGO_OT_ALL_GLYPHS}, - /* 'dlig' should be turned-on/off-able. lets turn off for now. */ - /* {"dlig", PANGO_OT_ALL_GLYPHS}, */ - {"cswh", PANGO_OT_ALL_GLYPHS}, - {"mset", PANGO_OT_ALL_GLYPHS} -}; - -static const PangoOTFeatureMap gpos_features[] = -{ - {"curs", PANGO_OT_ALL_GLYPHS}, - {"kern", PANGO_OT_ALL_GLYPHS}, - {"mark", PANGO_OT_ALL_GLYPHS}, - {"mkmk", PANGO_OT_ALL_GLYPHS} -}; - -static void -arabic_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED, - PangoFont *font, - const char *text, - gint length, - const PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - PangoFcFont *fc_font; - FT_Face face; - PangoOTRulesetDescription desc; - const PangoOTRuleset *ruleset; - PangoOTBuffer *buffer; - gulong *properties = NULL; - glong n_chars; - gunichar *wcs; - const char *p; - int cluster = 0; - gboolean rtl = analysis->level % 2 != 0; - gboolean reverse; - int i; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - if (!face) - return; - - buffer = pango_ot_buffer_new (fc_font); - pango_ot_buffer_set_rtl (buffer, rtl); - pango_ot_buffer_set_zero_width_marks (buffer, TRUE); - - wcs = g_utf8_to_ucs4_fast (text, length, &n_chars); - properties = g_new0 (gulong, n_chars); - - reverse = !rtl ^ (analysis->gravity == PANGO_GRAVITY_NORTH || analysis->gravity == PANGO_GRAVITY_WEST); - Arabic_Assign_Properties (wcs, properties, n_chars, reverse); - - g_free (wcs); - - p = text; - for (i=0; i < n_chars; i++) - { - gunichar wc; - PangoGlyph glyph; - - wc = g_utf8_get_char (p); - - if (g_unichar_type (wc) != G_UNICODE_NON_SPACING_MARK) - cluster = p - text; - - if (pango_is_zero_width (wc)) - glyph = PANGO_GLYPH_EMPTY; - else - { - gunichar c = wc; - - if (analysis->level % 2) - g_unichar_get_mirror_char (c, &c); - - /* Hack - Microsoft fonts are strange and don't contain the - * correct rules to shape ARABIC LETTER FARSI YEH in - * medial/initial position. It looks identical to ARABIC LETTER - * YEH in these positions, so we substitute if the font contains - * ARABIC LETTER YEH - */ - if (c == 0x6cc && - ((properties[i] & (initial | medial)) != (initial | medial)) && - pango_fc_font_has_char (fc_font, 0x64a)) - c = 0x64a; - - glyph = pango_fc_font_get_glyph (fc_font, c); - } - - if (!glyph) - glyph = PANGO_GET_UNKNOWN_GLYPH (wc); - - pango_ot_buffer_add_glyph (buffer, glyph, properties[i], cluster); - - p = g_utf8_next_char (p); - } - - g_free (properties); - - desc.script = analysis->script; - desc.language = analysis->language; - - desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features); - desc.static_gsub_features = gsub_features; - desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features); - desc.static_gpos_features = gpos_features; - - /* TODO populate other_features from analysis->extra_attrs */ - desc.n_other_features = 0; - desc.other_features = NULL; - - ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc); - - pango_ot_ruleset_substitute (ruleset, buffer); - pango_ot_ruleset_position (ruleset, buffer); - pango_ot_buffer_output (buffer, glyphs); - - pango_ot_buffer_destroy (buffer); - - pango_fc_font_unlock_face (fc_font); -} - -static void -arabic_engine_fc_class_init (PangoEngineShapeClass *class) -{ - class->script_shape = arabic_engine_shape; -} - -PANGO_ENGINE_SHAPE_DEFINE_TYPE (ArabicEngineFc, arabic_engine_fc, - arabic_engine_fc_class_init, NULL) - -void -PANGO_MODULE_ENTRY(init) (GTypeModule *module) -{ - arabic_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 (arabic_engine_fc_type, NULL); - else - return NULL; -} diff --git a/modules/arabic/arabic-ot.c b/modules/arabic/arabic-ot.c deleted file mode 100644 index 32532ad0..00000000 --- a/modules/arabic/arabic-ot.c +++ /dev/null @@ -1,503 +0,0 @@ -/* This file is taken from the FreeType (1) tree. It's been reindented - * to roughly match Pango guidelines (in anticipation of future changes), - * but not otherwise much altered. - */ - -/****************************************************************************/ -/* */ -/* The FreeType project -- a free and portable quality TrueType renderer. */ -/* */ -/* Copyright 1996-2000 by */ -/* D. Turner, R.Wilhelm, and W. Lemberg */ -/* */ -/* arabic -- An implementation of the contextual algorithm given in the */ -/* Unicode 2.0 book to assign the `isolated', `initial', `medial', and */ -/* `final' properties to an input string of character codes for the Arabic */ -/* script. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* The code, like the FreeType code it is derived from is dual-licensed */ -/* under the GNU General Public License and the FreeType license. See */ -/* pango/opentype/COPYING for full details of this licensing scheme. */ -/****************************************************************************/ - -#include "config.h" - -#include "arabic-ot.h" - - -/* - * - * Here a table of the joining classes for characters in the range - * U+0620 - U+06FF, U+0750 - U+077F and U+08A0 - U+08FF. - * - * The following character also has a joining class: - * - * U+200D ZERO WIDTH JOINER -> causing - * - * All other characters are given the joining class `none'. - * - */ - -static const joining_class arabic[] = -{ - /* U+0620 */ - dual, none, right, right, - right, right, dual, right, - dual, right, dual, dual, - dual, dual, dual, right, - - /* U+0630 */ - right, right, right, dual, - dual, dual, dual, dual, - dual, dual, dual, dual, - dual, dual, dual, dual, - - /* U+0640 */ - causing, dual, dual, dual, - dual, dual, dual, dual, - right, dual, dual, transparent, - transparent, transparent, transparent, transparent, - - /* U+0650 */ - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, none, - - /* U+0660 */ - none, none, none, none, - none, none, none, none, - none, none, none, none, - none, none, dual, dual, - - /* U+0670 */ - transparent, right, right, right, - none, right, right, right, - dual, dual, dual, dual, - dual, dual, dual, dual, - - /* U+0680 */ - dual, dual, dual, dual, - dual, dual, dual, dual, - right, right, right, right, - right, right, right, right, - - /* U+0690 */ - right, right, right, right, - right, right, right, right, - right, right, dual, dual, - dual, dual, dual, dual, - - /* U+06A0 */ - dual, dual, dual, dual, - dual, dual, dual, dual, - dual, dual, dual, dual, - dual, dual, dual, dual, - - /* U+06B0 */ - dual, dual, dual, dual, - dual, dual, dual, dual, - dual, dual, dual, dual, - dual, dual, dual, dual, - - /* U+06C0 */ - right, dual, dual, right, - right, right, right, right, - right, right, right, right, - dual, right, dual, right, - - /* U+06D0 */ - dual, dual, right, right, - none, right, transparent, transparent, - transparent, transparent, transparent, transparent, - transparent, none, none, transparent, - - /* U+06E0 */ - transparent, transparent, transparent, transparent, - transparent, none, none, transparent, - transparent, none, transparent, transparent, - transparent, transparent, right, right, - - /* U+06F0 */ - none, none, none, none, - none, none, none, none, - none, none, dual, dual, - dual, none, none, dual -}; - -static const joining_class arabic_supplement[] = -{ - /* U+0750 */ - dual, dual, dual, dual, - dual, dual, dual, dual, - dual, right, right, right, - dual, dual, dual, dual, - - /* U+0760 */ - dual, dual, dual, dual, - dual, dual, dual, dual, - dual, dual, dual, right, - right, dual, dual, dual, - - /* U+0770 */ - dual, right, dual, right, - right, dual, dual, dual, - right, right, dual, dual, - dual, dual, dual, dual, -}; - -static const joining_class arabic_extended_a[] = -{ - /* U+08A0 */ - dual, none, dual, dual, - dual, dual, dual, dual, - dual, dual, right, right, - right, none, none, none, - - /* U+08B0 */ - none, none, none, none, - none, none, none, none, - none, none, none, none, - none, none, none, none, - - /* U+08C0 */ - none, none, none, none, - none, none, none, none, - none, none, none, none, - none, none, none, none, - - /* U+08D0 */ - none, none, none, none, - none, none, none, none, - none, none, none, none, - none, none, none, none, - - /* U+08E0 */ - none, none, none, none, - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, transparent, - - /* U+08F0 */ - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, none, -}; - -/* Here a table of the joining classes for characters in the range - * U+07C0 - U+07FF. - * - * The following character also has a joining class: - * - * U+200C ZERO WIDTH NON-JOINER -> causing - * - * All other characters are given the joining class `none'. - */ -static const joining_class nko[] = -{ - /* U+07C0 */ - none, none, none, none, - none, none, none, none, - none, none, dual, dual, - dual, dual, dual, dual, - - /* U+07D0 */ - dual, dual, dual, dual, - dual, dual, dual, dual, - dual, dual, dual, dual, - dual, dual, dual, dual, - - /* U+07E0 */ - dual, dual, dual, dual, - dual, dual, dual, dual, - dual, dual, dual, transparent, - transparent, transparent, transparent, transparent, - - /* U+07F0 */ - transparent, transparent, transparent, transparent, - none, none, none, none, - none, none, causing, none, - none, none, none, none, -}; - -#if 0 -struct cgc_ -{ - FT_UShort char_code; - FT_UShort glyph_index; - FT_UShort class; -}; - -typedef struct cgc_ cgc; - -int compare_cgc (const void* a, - const void* b) -{ - return (((cgc*)a)->glyph_index > ((cgc*)b)->glyph_index) ? - 1 : ((((cgc*)a)->glyph_index == ((cgc*)b)->glyph_index) ? - 0 : -1); -} - - -TT_Error Build_Arabic_Glyph_Properties (TT_CharMap char_map, - TT_UShort max_glyphs, - TTO_GDEFHeader** gdef) -{ - TT_UShort i, j, num_glyphs; - - cgc Arabic[0x0700 - 0x0620]; - - TT_UShort glyph_indices[0x700 - 0x0620]; - TT_UShort classes[0x700 - 0x0620]; - - if (!gdef) - return TT_Err_Invalid_Argument; - - j = 0; - - for (i = 0x0620; i < 0x0700; i++) - { - Arabic[j].char_code = i; - Arabic[j].class = (arabic[i - 0x0620] == transparent) ? - MARK_GLYPH : SIMPLE_GLYPH; - Arabic[j].glyph_index = TT_Char_Index (char_map, i); - if (Arabic[j].glyph_index) - j++; - } - num_glyphs = j; - - if (!num_glyphs) - { - /* no Arabic font */ - *gdef = NULL; - return TT_Err_Ok; - } - - /* sort it */ - - qsort (Arabic, num_glyphs, sizeof (cgc), compare_cgc); - - /* write it to the arrays, removing duplicates */ - - glyph_indices[0] = Arabic[0].glyph_index; - classes[0] = Arabic[0].class; - - j = 1; - - for (i = 1; i < num_glyphs; i++) - { - glyph_indices[j] = Arabic[i].glyph_index; - classes[j] = Arabic[i].class; - - if (glyph_indices[j - 1] != glyph_indices[j]) - j++; - } - num_glyphs = j; - - TT_GDEF_Build_ClassDefinition (*gdef, max_glyphs, num_glyphs, - glyph_indices, classes); - - return TT_Err_Ok; -} -#endif - -/* The joining rules as given in the Unicode 2.0 book (characters are - * here specified as appearing in the byte stream, i.e. *not* in - * visual order). Joining classes are given in angle brackets, glyph - * forms in square brackets. Glyphs affected by a specific rule are - * enclosed with vertical bars. - * - * Note: The description of the joining algorithm in the book is - * severely broken. You can get a corrected version from - * www.unicode.org (as of 29-Jun-1999, this hasn't appeared). - * - * R1: <anything1> <transparent> <anything2> - * - * apply joining rules for - * <anything1> <anything2> -> [shape1] [shape2] - * - * -> [shape1] [isolated] [shape2] - * - * R2: <causing|left|dual> |<right>| - * - * -> [final] - * - * R3: |<left>| <causing|right|dual> - * - * -> [initial] - * - * R4: <causing|left|dual> |<dual>| <causing|right|dual> - * - * -> [medial] - * - * R5: <causing|left|dual> |<dual>| <!(causing|right|dual)> - * - * -> [final] - * - * R6: <!(causing|left|dual)> |<dual>| <causing|right|dual> - * - * -> [initial] - * - * R7: If R1-R6 fail: - * - * <anything> -> [isolated] - */ - -/* `direction' can be -1, 0, or 1 to indicate the last non-transparent - * glyph, the current glyph, and the next non-transparent glyph, - * respectively. - */ - -static joining_class Get_Joining_Class (gunichar* string, - int pos, - int length, - int direction, - gboolean reverse) -{ - joining_class j; - - - while (1) - { - if (pos == 0 && direction < 0) - return none; - - pos += direction; - - if (pos >= length) - return none; - - if (string[pos] >= 0x0620 && - string[pos] < 0x0700) - j = arabic[string[pos] - 0x0620]; - else if (string[pos] >= 0x0750 && - string[pos] < 0x0780) - j = arabic_supplement[string[pos] - 0x0750]; - else if (string[pos] >= 0x07C0 && - string[pos] < 0x0800) - j = nko[string[pos] - 0x07C0]; - else if (string[pos] >= 0x08A0 && - string[pos] < 0x08FF) - j = arabic_extended_a[string[pos] - 0x08A0]; - else if (string[pos] == 0x200D) - return causing; - else - return none; - - if (!direction || j != transparent) - { - if (G_UNLIKELY (reverse)) - return j == right ? left : j == left ? right : j; - else - return j; - } - } -} - - -FT_Error Arabic_Assign_Properties (gunichar *string, - gulong *properties, - int length, - gboolean reverse) -{ - joining_class previous, current, next; - int i; - - if (!string || !properties || length == 0) - return FT_Err_Invalid_Argument; - - for (i = 0; i < length; i++) - { - previous = Get_Joining_Class (string, i, length, -1, reverse); - current = Get_Joining_Class (string, i, length, 0, reverse); - next = Get_Joining_Class (string, i, length, 1, reverse); - - /* R1 */ - - if (current == transparent) - { - properties[i] |= isolated_p; - continue; - } - - /* R2 */ - - if (previous == causing || - previous == left || - previous == dual ) - if (current == right) - { - properties[i] |= reverse ? initial_p : final_p; - continue; - } - - /* R3 */ - - if (current == left) - if (next == causing || - next == right || - next == dual ) - { - properties[i] |= reverse ? final_p : initial_p; - continue; - } - - /* R4 */ - - if (previous == causing || - previous == left || - previous == dual ) - if (current == dual) - if (next == causing || - next == right || - next == dual ) - { - properties[i] |= medial_p; - continue; - } - - /* R5 */ - - if (previous == causing || - previous == left || - previous == dual ) - if (current == dual) - if (!(next == causing || - next == right || - next == dual )) - { - properties[i] |= reverse ? initial_p : final_p; - continue; - } - - /* R6 */ - - if (!(previous == causing || - previous == left || - previous == dual )) - if (current == dual) - if (next == causing || - next == right || - next == dual ) - { - properties[i] |= reverse ? final_p : initial_p; - continue; - } - - /* R7 */ - - properties[i] |= isolated_p; - } - - return FT_Err_Ok; -} - - -/* End */ diff --git a/modules/arabic/arabic-ot.h b/modules/arabic/arabic-ot.h deleted file mode 100644 index db9a9aa9..00000000 --- a/modules/arabic/arabic-ot.h +++ /dev/null @@ -1,80 +0,0 @@ -/* This file is taken from the FreeType (1) tree. It's been reindented - * to roughly match Pango guidelines (in anticipation of future changes), - * but not otherwise much altered. - */ - -/****************************************************************************/ -/* */ -/* The FreeType project -- a free and portable quality TrueType renderer. */ -/* */ -/* Copyright 1996-2000 by */ -/* D. Turner, R.Wilhelm, and W. Lemberg */ -/* */ -/* arabic -- An implementation of the contextual algorithm given in the */ -/* Unicode 2.0 book to assign the `isolated', `initial', `medial', and */ -/* `final' properties to an input string of character codes for the Arabic */ -/* script. */ -/* */ -/* This file is part of the FreeType project, and may only be used */ -/* modified and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/* The file LICENSE.TXT can be found in the Pango distribution as */ -/* pango/opentype/FT-license.txt */ -/****************************************************************************/ - -#include <pango/pango-ot.h> - - -enum joining_type_ -{ - isolated = 1, /* nominal */ - final = 2, /* right_joining */ - initial = 4, /* left_joining */ - medial = 8 /* double_joining */ -}; - -typedef enum joining_type_ joining_type; - - - /* A glyph's property value as needed by e.g. TT_GSUB_Apply_String() - specifies which features should *not* be applied */ - -enum arabic_glyph_property_ -{ - isolated_p = final | initial | medial, - final_p = isolated | initial | medial, - initial_p = isolated | final | medial, - medial_p = isolated | final | initial -}; - -typedef enum arabic_glyph_property_ arabic_glyph_property; - - -enum joining_class_ -{ - right, - left, /* not used */ - dual, - causing, - none, - transparent -}; - -typedef enum joining_class_ joining_class; - - -FT_Error Arabic_Assign_Properties (gunichar *string, - gulong *properties, - int length, - gboolean reverse); -#if 0 -TT_Error Build_Arabic_Glyph_Properties (TT_CharMap char_map, - TT_UShort max_glyphs, - TTO_GDEFHeader** gdef ); -#endif - - -/* End */ diff --git a/modules/basic/Makefile.am b/modules/basic/Makefile.am index a264d704..70e4b6b1 100644 --- a/modules/basic/Makefile.am +++ b/modules/basic/Makefile.am @@ -19,7 +19,7 @@ libpango_basic_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_basic_x if HAVE_FREETYPE -INCLUDES += $(FREETYPE_CFLAGS) +INCLUDES += $(FREETYPE_CFLAGS) $(HARFBUZZ_CFLAGS) if INCLUDE_BASIC_FC noinst_LTLIBRARIES += libpango-basic-fc.la else diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c index e3852c39..e263b4c7 100644 --- a/modules/basic/basic-fc.c +++ b/modules/basic/basic-fc.c @@ -1,7 +1,7 @@ /* Pango * basic-fc.c: Basic shaper for FreeType-based backends * - * Copyright (C) 2000, 2007 Red Hat Software + * Copyright (C) 2000, 2007, 2009 Red Hat Software * Authors: * Owen Taylor <otaylor@redhat.com> * Behdad Esfahbod <behdad@behdad.org> @@ -25,12 +25,17 @@ #include "config.h" #include <string.h> +#define PANGO_ENABLE_BACKEND 1 /* XXX */ #include <glib/gprintf.h> #include "pango-engine.h" #include "pango-utils.h" #include "pangofc-font.h" -#include "pango-ot.h" +#include <hb-ft.h> +#include <hb-glib.h> + +#define PANGO_UNITS_26_6(d) ((d) << 4) + /* No extra fields needed */ typedef PangoEngineShape BasicEngineFc; @@ -40,47 +45,6 @@ typedef PangoEngineShapeClass BasicEngineFcClass; #define RENDER_TYPE PANGO_RENDER_TYPE_FC static PangoEngineScriptInfo basic_scripts[] = { - /* Listed in OpenType "Standard scripts" standard */ - { PANGO_SCRIPT_LATIN, "*" }, - { PANGO_SCRIPT_CYRILLIC, "*" }, - { PANGO_SCRIPT_GREEK, "*" }, - { PANGO_SCRIPT_ARMENIAN, "*" }, - { PANGO_SCRIPT_GEORGIAN, "*" }, - { PANGO_SCRIPT_RUNIC, "*" }, - { PANGO_SCRIPT_OGHAM, "*" }, - - /* The following are simple and can be shaped easily too */ - - { PANGO_SCRIPT_BOPOMOFO, "*" }, - { PANGO_SCRIPT_CHEROKEE, "*" }, - { PANGO_SCRIPT_COPTIC, "*" }, - { PANGO_SCRIPT_DESERET, "*" }, - { PANGO_SCRIPT_ETHIOPIC, "*" }, - { PANGO_SCRIPT_GOTHIC, "*" }, - { PANGO_SCRIPT_HAN, "*" }, - { PANGO_SCRIPT_HIRAGANA, "*" }, - { PANGO_SCRIPT_KATAKANA, "*" }, - { PANGO_SCRIPT_OLD_ITALIC, "*" }, - { PANGO_SCRIPT_CANADIAN_ABORIGINAL, "*" }, - { PANGO_SCRIPT_YI, "*" }, - - /* Unicode-4.0 additions */ - { PANGO_SCRIPT_BRAILLE, "*" }, - { PANGO_SCRIPT_CYPRIOT, "*" }, - { PANGO_SCRIPT_LIMBU, "*" }, - { PANGO_SCRIPT_OSMANYA, "*" }, - { PANGO_SCRIPT_SHAVIAN, "*" }, - { PANGO_SCRIPT_LINEAR_B, "*" }, - { PANGO_SCRIPT_UGARITIC, "*" }, - - /* Unicode-4.1 additions */ - { PANGO_SCRIPT_GLAGOLITIC, "*" }, - - /* Unicode-5.0 additions */ - { PANGO_SCRIPT_CUNEIFORM, "*" }, - { PANGO_SCRIPT_PHOENICIAN, "*" }, - - /* In fact any script we don't know how to shape can go here */ { PANGO_SCRIPT_COMMON, "" } }; @@ -93,128 +57,260 @@ static PangoEngineInfo script_engines[] = { } }; -static const PangoOTFeatureMap gsub_features[] = -{ - {"ccmp", PANGO_OT_ALL_GLYPHS}, - {"locl", PANGO_OT_ALL_GLYPHS}, - {"liga", PANGO_OT_ALL_GLYPHS}, - {"clig", PANGO_OT_ALL_GLYPHS} -}; -static const PangoOTFeatureMap gpos_features[] = -{ - {"kern", PANGO_OT_ALL_GLYPHS}, - {"mark", PANGO_OT_ALL_GLYPHS}, - {"mkmk", PANGO_OT_ALL_GLYPHS} -}; +/* cache a single hb_buffer_t */ +static hb_buffer_t *cached_buffer = NULL; +G_LOCK_DEFINE_STATIC (cached_buffer); -static const PangoOTFeatureMap vertical_gsub_features[] = +static hb_buffer_t * +create_buffer (void) { - {"ccmp", PANGO_OT_ALL_GLYPHS}, - {"locl", PANGO_OT_ALL_GLYPHS}, - {"vert", PANGO_OT_ALL_GLYPHS} -}; + hb_buffer_t *buffer; + + buffer = hb_buffer_create (); + hb_buffer_set_unicode_funcs (buffer, hb_glib_get_unicode_funcs ()); -static const PangoOTFeatureMap vertical_gpos_features[] = + return buffer; +} + +static hb_buffer_t * +acquire_buffer (gboolean *free_buffer) { - {"vkrn", PANGO_OT_ALL_GLYPHS} -}; + hb_buffer_t *buffer; + + if (G_LIKELY (G_TRYLOCK (cached_buffer))) + { + if (G_UNLIKELY (!cached_buffer)) + cached_buffer = create_buffer (); + + buffer = cached_buffer; + *free_buffer = FALSE; + } + else + { + buffer = create_buffer (); + *free_buffer = TRUE; + } + + return buffer; +} static void -basic_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED, - PangoFont *font, - const char *text, - gint length, - const PangoAnalysis *analysis, - PangoGlyphString *glyphs) +release_buffer (hb_buffer_t *buffer, gboolean free_buffer) { + if (G_LIKELY (!free_buffer)) + { + hb_buffer_reset (buffer); + G_UNLOCK (cached_buffer); + } + else + hb_buffer_destroy (buffer); +} + +typedef struct _PangoFcHbContext { + FT_Face ft_face; PangoFcFont *fc_font; - FT_Face face; - PangoOTRulesetDescription desc; - const PangoOTRuleset *ruleset; - PangoOTBuffer *buffer; - glong n_chars; - const char *p; - int cluster = 0; - int i; +} PangoFcHbContext; - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); +static hb_bool_t +pango_fc_hb_font_get_glyph (hb_font_t *font, void *font_data, + hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data G_GNUC_UNUSED) +{ + PangoFcHbContext *context = (PangoFcHbContext *) font_data; + PangoFcFont *fc_font = context->fc_font; - fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - if (!face) - return; + *glyph = pango_fc_font_get_glyph (fc_font, unicode); + if (G_LIKELY (*glyph)) + return TRUE; - buffer = pango_ot_buffer_new (fc_font); - pango_ot_buffer_set_rtl (buffer, analysis->level % 2 != 0); + *glyph = PANGO_GET_UNKNOWN_GLYPH (unicode); + return FALSE; +} - n_chars = g_utf8_strlen (text, length); - pango_glyph_string_set_size (glyphs, n_chars); +static hb_bool_t +pango_fc_hb_font_get_glyph_contour_point (hb_font_t *font, void *font_data, + hb_codepoint_t glyph, unsigned int point_index, + hb_position_t *x, hb_position_t *y, + void *user_data G_GNUC_UNUSED) +{ + return FALSE; +#if 0 + FT_Face ft_face = (FT_Face) font_data; + int load_flags = FT_LOAD_DEFAULT; - p = text; - for (i=0; i < n_chars; i++) - { - gunichar wc; - PangoGlyph glyph; + /* TODO: load_flags, embolden, etc */ + + if (HB_UNLIKELY (FT_Load_Glyph (ft_face, glyph, load_flags))) + return FALSE; - wc = g_utf8_get_char (p); + if (HB_UNLIKELY (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)) + return FALSE; - if (g_unichar_type (wc) != G_UNICODE_NON_SPACING_MARK) - cluster = p - text; + if (HB_UNLIKELY (point_index >= (unsigned int) ft_face->glyph->outline.n_points)) + return FALSE; - if (pango_is_zero_width (wc)) - glyph = PANGO_GLYPH_EMPTY; - else - { - gunichar c = wc; + *x = ft_face->glyph->outline.points[point_index].x; + *y = ft_face->glyph->outline.points[point_index].y; - if (analysis->level % 2) - g_unichar_get_mirror_char (c, &c); + return TRUE; +#endif +} - glyph = pango_fc_font_get_glyph (fc_font, c); - } +static hb_position_t +pango_fc_hb_font_get_glyph_h_advance (hb_font_t *font, void *font_data, + hb_codepoint_t glyph, + void *user_data G_GNUC_UNUSED) +{ + PangoFcHbContext *context = (PangoFcHbContext *) font_data; + PangoFcFont *fc_font = context->fc_font; + PangoRectangle logical; - if (!glyph) - glyph = PANGO_GET_UNKNOWN_GLYPH (wc); + pango_font_get_glyph_extents ((PangoFont *) fc_font, glyph, NULL, &logical); - pango_ot_buffer_add_glyph (buffer, glyph, 0, cluster); + return logical.width; +} - p = g_utf8_next_char (p); - } +static hb_bool_t +pango_fc_hb_font_get_glyph_extents (hb_font_t *font, void *font_data, + hb_codepoint_t glyph, + hb_glyph_extents_t *extents, + void *user_data G_GNUC_UNUSED) +{ + PangoFcHbContext *context = (PangoFcHbContext *) font_data; + PangoFcFont *fc_font = context->fc_font; + PangoRectangle ink; - desc.script = analysis->script; - desc.language = analysis->language; + pango_font_get_glyph_extents ((PangoFont *) fc_font, glyph, &ink, NULL); + + extents->x_bearing = ink.x; + extents->y_bearing = ink.y; + extents->width = ink.width; + extents->height = ink.height; + + return TRUE; +} + +static hb_position_t +pango_fc_hb_font_get_h_kerning (hb_font_t *font, void *font_data, + hb_codepoint_t left_glyph, hb_codepoint_t right_glyph, + void *user_data G_GNUC_UNUSED) +{ + PangoFcHbContext *context = (PangoFcHbContext *) font_data; + FT_Face ft_face = context->ft_face; + FT_Vector kerning; + + if (FT_Get_Kerning (ft_face, left_glyph, right_glyph, FT_KERNING_DEFAULT, &kerning)) + return 0; + + return PANGO_UNITS_26_6 (kerning.x); +} + +static hb_font_funcs_t * +pango_fc_get_hb_font_funcs (void) +{ + static hb_font_funcs_t *funcs; + + if (G_UNLIKELY (!funcs)) { + funcs = hb_font_funcs_create (); + hb_font_funcs_set_glyph_func (funcs, pango_fc_hb_font_get_glyph, NULL, NULL); + /* XXX vertical */ + hb_font_funcs_set_glyph_h_advance_func (funcs, pango_fc_hb_font_get_glyph_h_advance, NULL, NULL); + hb_font_funcs_set_glyph_extents_func (funcs, pango_fc_hb_font_get_glyph_extents, NULL, NULL); + hb_font_funcs_set_glyph_contour_point_func (funcs, pango_fc_hb_font_get_glyph_contour_point, NULL, NULL); + hb_font_funcs_set_glyph_h_kerning_func (funcs, pango_fc_hb_font_get_h_kerning, NULL, NULL); + } + + return funcs; +} - if (PANGO_GRAVITY_IS_VERTICAL (analysis->gravity)) - { - desc.n_static_gsub_features = G_N_ELEMENTS (vertical_gsub_features); - desc.static_gsub_features = vertical_gsub_features; - desc.n_static_gpos_features = G_N_ELEMENTS (vertical_gpos_features); - desc.static_gpos_features = vertical_gpos_features; - } - else - { - desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features); - desc.static_gsub_features = gsub_features; - desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features); - desc.static_gpos_features = gpos_features; - } - /* TODO populate other_features from analysis->extra_attrs */ - desc.n_other_features = 0; - desc.other_features = NULL; - ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc); - pango_ot_ruleset_substitute (ruleset, buffer); - pango_ot_ruleset_position (ruleset, buffer); - pango_ot_buffer_output (buffer, glyphs); +static void +basic_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED, + PangoFont *font, + const char *text, + gint length, + const PangoAnalysis *analysis, + PangoGlyphString *glyphs) +{ + PangoFcHbContext context; + PangoFcFont *fc_font; + FT_Face ft_face; + hb_font_t *hb_font; + hb_buffer_t *hb_buffer; + gboolean free_buffer; + gboolean is_hinted; + hb_glyph_info_t *hb_glyph; + hb_glyph_position_t *hb_position; + int last_cluster; + guint i, num_glyphs; - pango_ot_buffer_destroy (buffer); + g_return_if_fail (font != NULL); + g_return_if_fail (text != NULL); + g_return_if_fail (length >= 0); + g_return_if_fail (analysis != NULL); + + fc_font = PANGO_FC_FONT (font); + ft_face = pango_fc_font_lock_face (fc_font); + if (!ft_face) + return; + + /* TODO: Cache hb_font? */ + context.ft_face = ft_face; + context.fc_font = fc_font; + hb_font = hb_font_create (hb_ft_face_create_cached (ft_face)); + hb_font_set_funcs (hb_font, + pango_fc_get_hb_font_funcs (), + &context, + NULL); + hb_font_set_scale (hb_font, + /* XXX CTM */ + (((guint64) ft_face->size->metrics.x_scale * ft_face->units_per_EM) >> 12), + -(((guint64) ft_face->size->metrics.y_scale * ft_face->units_per_EM) >> 12)); + is_hinted = fc_font->is_hinted; + hb_font_set_ppem (hb_font, + is_hinted ? ft_face->size->metrics.x_ppem : 0, + is_hinted ? ft_face->size->metrics.y_ppem : 0); + + hb_buffer = acquire_buffer (&free_buffer); + /* setup buffer */ + hb_buffer_set_direction (hb_buffer, analysis->level % 2 != 0 ? HB_DIRECTION_RTL : HB_DIRECTION_LTR); + hb_buffer_set_script (hb_buffer, hb_glib_script_to_script (analysis->script)); + hb_buffer_set_language (hb_buffer, hb_language_from_string (pango_language_to_string (analysis->language), -1)); + hb_buffer_add_utf8 (hb_buffer, text, length, 0, length); + + hb_shape (hb_font, hb_buffer, NULL, 0); + + /* buffer output */ + num_glyphs = hb_buffer_get_length (hb_buffer); + hb_glyph = hb_buffer_get_glyph_infos (hb_buffer, NULL); + hb_position = hb_buffer_get_glyph_positions (hb_buffer, NULL); + pango_glyph_string_set_size (glyphs, num_glyphs); + last_cluster = -1; + for (i = 0; i < num_glyphs; i++) + { + glyphs->glyphs[i].glyph = hb_glyph->codepoint; + glyphs->log_clusters[i] = hb_glyph->cluster; + glyphs->glyphs[i].attr.is_cluster_start = glyphs->log_clusters[i] != last_cluster; + last_cluster = glyphs->log_clusters[i]; + + /* XXX + if (is_hinted) + advance = PANGO_UNITS_ROUND (advance); + */ + glyphs->glyphs[i].geometry.width = hb_position->x_advance; + glyphs->glyphs[i].geometry.x_offset = hb_position->x_offset; + glyphs->glyphs[i].geometry.y_offset = hb_position->y_offset; + + hb_glyph++; + hb_position++; + } + release_buffer (hb_buffer, free_buffer); + hb_font_destroy (hb_font); pango_fc_font_unlock_face (fc_font); } diff --git a/modules/hangul/Makefile.am b/modules/hangul/Makefile.am deleted file mode 100644 index 4937d1b7..00000000 --- a/modules/hangul/Makefile.am +++ /dev/null @@ -1,26 +0,0 @@ -include $(top_srcdir)/modules/Module.mk - -if HAVE_FREETYPE -INCLUDES += $(FREETYPE_CFLAGS) -if INCLUDE_HANGUL_FC -noinst_LTLIBRARIES += libpango-hangul-fc.la -else -if DYNAMIC_HANGUL_FC -module_LTLIBRARIES += pango-hangul-fc.la -endif -endif -endif - -fc_sources = hangul-fc.c hangul-defs.h - -pango_hangul_fc_la_LDFLAGS = -module $(MODULE_LIBTOOL_OPTIONS) -pango_hangul_fc_la_LIBADD = $(pangoft2libs) -pango_hangul_fc_la_SOURCES = $(fc_sources) -libpango_hangul_fc_la_SOURCES = $(fc_sources) -libpango_hangul_fc_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_hangul_fc - - -EXTRA_DIST = \ - tables-jamos.i - --include $(top_srcdir)/git.mk diff --git a/modules/hangul/hangul-defs.h b/modules/hangul/hangul-defs.h deleted file mode 100644 index 8cef8ba8..00000000 --- a/modules/hangul/hangul-defs.h +++ /dev/null @@ -1,91 +0,0 @@ -/* Pango - * hangul-defs.h: - * - * Copyright (C) 2002-2006 Changwoo Ryu - * Author: Changwoo Ryu <cwryu@debian.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* See 3.12 "Conjoining Jamo Behavior" in the Unicode Book for more - * information - */ - -/* The start of the Hangul Syllables (U+AC00-U+D7A3) */ -#define SBASE 0xAC00 -#define SCOUNT 11172 - -/* The starts/ends of the leading consonants (choseong), the vowels - * (jungseong) and the trailing consonants (jongseong). - */ -#define LBASE 0x1100 -#define VBASE 0x1161 -#define TBASE 0x11A7 -#define LEND 0x115F -#define VEND 0x11A7 -#define TEND 0x11FF - -/* Number of modern jamos */ -#define LCOUNT 19 -#define VCOUNT 21 -#define TCOUNT 28 -#define NCOUNT (VCOUNT * TCOUNT) /* number of syllables of a given choseong */ - -/* choseong and jungseong filler */ -#define LFILL 0x115F -#define VFILL 0x1160 - -/* Old tone marks. */ -#define HTONE1 0x302E -#define HTONE2 0x302F - -/* Useful macros - */ - -#define IS_JAMO(wc) ((wc) >= LBASE && (wc) <= TEND) -#define IS_L(wc) ((wc) >= LBASE && (wc) <= LEND) -#define IS_V(wc) ((wc) >= VFILL && (wc) <= VEND) -#define IS_T(wc) ((wc) > TBASE && (wc) <= TEND) -#define IS_M(wc) ((wc) == HTONE1 || (wc) == HTONE2) -#define IS_S(wc) (SBASE <= (wc) && (wc) < (SBASE + SCOUNT)) - -/* jamo which can be composited as a precomposed syllable */ -#define IS_L_S(wc) ((wc) >= LBASE && (wc) < (LBASE + LCOUNT)) -#define IS_V_S(wc) ((wc) >= VBASE && (wc) < (VBASE + VCOUNT)) -#define IS_T_S(wc) ((wc) > TBASE && (wc) < (TBASE + TCOUNT)) - -/* if a syllable has a jongseong */ -#define S_HAS_T(s) (((s) - SBASE) % TCOUNT) - -/* non hangul */ -#define IS_HANGUL(wc) (IS_S(wc) || IS_JAMO(wc) || IS_M(wc)) - -/* syllable boundary condition */ -#define IS_BOUNDARY(prev,next) \ - ((!IS_L(prev) && IS_S(wc)) || \ - !IS_HANGUL(next) || \ - (IS_S(prev) && S_HAS_T(prev) && IS_L(next)) || \ - (IS_T(prev) && (IS_L(next) || IS_V(next))) || \ - (IS_S(prev) && !S_HAS_T(prev) && IS_L(next)) || \ - (IS_V(prev) && IS_L(next)) || \ - IS_M(prev)) - -/* composing/decomposing */ -#define S_FROM_LVT(l,v,t) (SBASE + (((l) - LBASE) * VCOUNT + ((v) - VBASE)) * TCOUNT + ((t) - TBASE)) -#define S_FROM_LV(l,v) (SBASE + (((l) - LBASE) * VCOUNT + ((v) - VBASE)) * TCOUNT) -#define L_FROM_S(s) (LBASE + (((s) - SBASE) / NCOUNT)) -#define V_FROM_S(s) (VBASE + (((s) - SBASE) % NCOUNT) / TCOUNT) -#define T_FROM_S(s) (TBASE + (((s) - SBASE) % TCOUNT)) diff --git a/modules/hangul/hangul-fc.c b/modules/hangul/hangul-fc.c deleted file mode 100644 index 2ef56ec9..00000000 --- a/modules/hangul/hangul-fc.c +++ /dev/null @@ -1,499 +0,0 @@ -/* Pango - * hangul-fc.c: Hangul shaper for FreeType based backends - * - * Copyright (C) 2002-2006 Changwoo Ryu - * Author: Changwoo Ryu <cwryu@debian.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#include <string.h> - -#include "pango-engine.h" -#include "pango-utils.h" -#include "pangofc-font.h" - -#include "hangul-defs.h" -#include "tables-jamos.i" - -/* No extra fields needed */ -typedef PangoEngineShape HangulEngineFc; -typedef PangoEngineShapeClass HangulEngineFcClass ; - -#define SCRIPT_ENGINE_NAME "HangulScriptEngineFc" -#define RENDER_TYPE PANGO_RENDER_TYPE_FC - -static PangoEngineScriptInfo hangul_scripts[] = { - { PANGO_SCRIPT_HANGUL, "*" } -}; - -static PangoEngineInfo script_engines[] = { - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - RENDER_TYPE, - hangul_scripts, G_N_ELEMENTS(hangul_scripts) - } -}; - -static void -set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGlyph glyph) -{ - PangoRectangle logical_rect; - - glyphs->glyphs[i].glyph = glyph; - glyphs->glyphs[i].geometry.x_offset = 0; - glyphs->glyphs[i].geometry.y_offset = 0; - glyphs->log_clusters[i] = offset; - - pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect); - glyphs->glyphs[i].geometry.width = logical_rect.width; -} - -/* Add a Hangul tone mark glyph in a glyph string. - * Non-spacing glyph works pretty much automatically. - * Spacing-glyph takes some care: - * 1. Make a room for a tone mark at the beginning(leftmost end) of a cluster - * to attach it to. - * 2. Adjust x_offset so that it is drawn to the left of a cluster. - * 3. Set the logical width to zero. - */ - -static void -set_glyph_tone (PangoFont *font, PangoGlyphString *glyphs, int i, - int offset, PangoGlyph glyph) -{ - PangoRectangle logical_rect, ink_rect; - PangoRectangle logical_rect_cluster; - - glyphs->glyphs[i].glyph = glyph; - glyphs->glyphs[i].geometry.y_offset = 0; - glyphs->log_clusters[i] = offset; - - pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, - &ink_rect, &logical_rect); - - /* tone mark is not the first in a glyph string. We have info. on the - * preceding glyphs in a glyph string - */ - { - int j = i - 1; - /* search for the beg. of the preceding cluster */ - while (j >= 0 && glyphs->log_clusters[j] == glyphs->log_clusters[i - 1]) - j--; - - /* In .._extents_range(...,start,end,...), to my surprise start is - * inclusive but end is exclusive !! - */ - pango_glyph_string_extents_range (glyphs, j + 1, i, font, - NULL, &logical_rect_cluster); - - /* logical_rect_cluster.width is all the offset we need so that the - * inherent x_offset in the glyph (ink_rect.x) should be canceled out. - */ - glyphs->glyphs[i].geometry.x_offset = - logical_rect_cluster.width - - ink_rect.x ; - - - /* make an additional room for a tone mark if it has a spacing glyph - * because that's likely to be an indication that glyphs for other - * characters in the font are not designed for combining with tone marks. - */ - if (logical_rect.width) - { - glyphs->glyphs[i].geometry.x_offset -= ink_rect.width; - glyphs->glyphs[j + 1].geometry.width += ink_rect.width; - glyphs->glyphs[j + 1].geometry.x_offset += ink_rect.width; - } - } - - glyphs->glyphs[i].geometry.width = 0; -} - - -#define find_char(font,wc) \ - pango_fc_font_get_glyph((PangoFcFont *)font, wc) - -static void -render_tone (PangoFont *font, gunichar tone, PangoGlyphString *glyphs, - int *n_glyphs, int cluster_offset) -{ - int index; - - index = find_char (font, tone); - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - if (index) - { - set_glyph_tone (font, glyphs, *n_glyphs, cluster_offset, index); - } - else - { - /* fall back : HTONE1(0x302e) => middle-dot, HTONE2(0x302f) => colon */ - index = find_char (font, tone == HTONE1 ? 0x00b7 : 0x003a); - if (index) - { - set_glyph_tone (font, glyphs, *n_glyphs, cluster_offset, index); - } - else - set_glyph (font, glyphs, *n_glyphs, cluster_offset, - PANGO_GET_UNKNOWN_GLYPH (tone)); - } - (*n_glyphs)++; -} - -/* This is a fallback for when we get a tone mark not preceded - * by a syllable. - */ -static void -render_isolated_tone (PangoFont *font, gunichar tone, PangoGlyphString *glyphs, - int *n_glyphs, int cluster_offset) -{ -#if 0 /* FIXME: what kind of hack is it? it draws dummy glyphs. */ - /* Find a base character to render the mark on - */ - int index = find_char (font, 0x25cc); /* DOTTED CIRCLE */ - if (!index) - index = find_char (font, 0x25cb); /* WHITE CIRCLE, in KSC-5601 */ - if (!index) - index = find_char (font, ' '); /* Space */ - if (!index) /* Unknown glyph box with 0000 in it */ - index = find_char (font, PANGO_GET_UNKNOWN_GLYPH (0)); - - /* Add the base character - */ - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); - (*n_glyphs)++; -#endif - - /* And the tone mark - */ - render_tone(font, tone, glyphs, n_glyphs, cluster_offset); -} - -static void -render_syllable (PangoFont *font, const char *str, int length, - PangoGlyphString *glyphs, int *n_glyphs, int cluster_offset) -{ - int n_prev_glyphs = *n_glyphs; - int index; - gunichar wc = 0, tone = 0, text[4]; - int i, j, composed = 0; - const char *p; - - /* Normalize it only when the entire sequence is equivalent to a - * precomposed syllable. It's usually better than prefix - * normalization both for poor-featured fonts and for smart fonts. - * I have seen no smart font which can render S+T as a syllable - * form. - */ - - if (length == 3 || length == 4) - { - p = str; - text[0] = g_utf8_get_char(p); - p = g_utf8_next_char(p); - text[1] = g_utf8_get_char(p); - p = g_utf8_next_char(p); - text[2] = g_utf8_get_char(p); - - if (length == 4 && !IS_M(g_utf8_get_char(g_utf8_next_char(p)))) - goto lvt_out; /* draw the tone mark later */ - - if (IS_L_S(text[0]) && IS_V_S(text[1]) && IS_T_S(text[2])) - { - composed = 3; - wc = S_FROM_LVT(text[0], text[1], text[2]); - str = g_utf8_next_char(p); - goto normalize_out; - } - } - lvt_out: - - if (length == 2 || length == 3) - { - p = str; - text[0] = g_utf8_get_char(p); - p = g_utf8_next_char(p); - text[1] = g_utf8_get_char(p); - - if (length == 3 && !IS_M(g_utf8_get_char(g_utf8_next_char(p)))) - goto lv_out; /* draw the tone mark later */ - if (IS_L_S(text[0]) && IS_V_S(text[1])) - { - composed = 2; - wc = S_FROM_LV(text[0], text[1]); - str = g_utf8_next_char(p); - } - else if (IS_S(text[0] && !S_HAS_T(text[0]) && IS_T_S(text[1]))) - { - composed = 2; - wc = text[0] + (text[1] - TBASE); - str = g_utf8_next_char(p); - goto normalize_out; - } - } - lv_out: - normalize_out: - - if (composed) - { - index = find_char (font, wc); - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - if (!index) - set_glyph (font, glyphs, *n_glyphs, cluster_offset, - PANGO_GET_UNKNOWN_GLYPH (wc)); - else - set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); - (*n_glyphs)++; - length -= composed; - } - - /* Render the remaining text as uncomposed forms as a fallback. */ - for (i = 0; i < length; i++, str = g_utf8_next_char(str)) - { - int jindex; - int oldlen; - - wc = g_utf8_get_char(str); - - if (wc == LFILL || wc == VFILL) - continue; - - if (IS_M(wc)) - { - tone = wc; - break; - } - - if (IS_S(wc)) - { - oldlen = *n_glyphs; - - text[0] = L_FROM_S(wc); - text[1] = V_FROM_S(wc); - if (S_HAS_T(wc)) - { - text[2] = T_FROM_S(wc); - composed = 3; - } - else - composed = 2; - - for (j = 0; j < composed; j++) - { - index = find_char (font, text[j]); - if (index) - { - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); - (*n_glyphs)++; - } - else - goto decompose_cancel; - } - - continue; - - decompose_cancel: - /* The font doesn't have jamos. Cancel it. */ - *n_glyphs = oldlen; - pango_glyph_string_set_size (glyphs, *n_glyphs); - } - - index = find_char (font, wc); - if (index) - { - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); - (*n_glyphs)++; - continue; - } - else if (IS_S(wc)) - { - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - set_glyph (font, glyphs, *n_glyphs, cluster_offset, - PANGO_GET_UNKNOWN_GLYPH (wc)); - (*n_glyphs)++; - continue; - } - - /* This font has no glyphs on the Hangul Jamo area! Find a - fallback from the Hangul Compatibility Jamo area. */ - jindex = wc - LBASE; - oldlen = *n_glyphs; - for (j = 0; j < 3 && (__jamo_to_ksc5601[jindex][j] != 0); j++) - { - gunichar comp_wc; - comp_wc = __jamo_to_ksc5601[jindex][j] - KSC_JAMOBASE + UNI_JAMOBASE; - index = (comp_wc >= 0x3131) ? find_char (font, comp_wc) : 0; - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - if (!index) - { - *n_glyphs = oldlen; - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - set_glyph (font, glyphs, *n_glyphs, cluster_offset, - PANGO_GET_UNKNOWN_GLYPH (wc)); - (*n_glyphs)++; - break; - } - else - set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); - (*n_glyphs)++; - } - } - if (n_prev_glyphs == *n_glyphs) - { - index = find_char (font, 0x3164); /* U+3164 HANGUL FILLER */ - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - if (!index) - set_glyph (font, glyphs, *n_glyphs, cluster_offset, - PANGO_GET_UNKNOWN_GLYPH (index)); - else - set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); - glyphs->log_clusters[*n_glyphs] = cluster_offset; - (*n_glyphs)++; - } - if (tone) - render_tone(font, tone, glyphs, n_glyphs, cluster_offset); -} - -static void -render_basic (PangoFont *font, gunichar wc, - PangoGlyphString *glyphs, int *n_glyphs, int cluster_offset) -{ - int index; - - if (wc == 0xa0) /* non-break-space */ - wc = 0x20; - - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - - if (pango_is_zero_width (wc)) - set_glyph (font, glyphs, *n_glyphs, cluster_offset, PANGO_GLYPH_EMPTY); - else - { - index = find_char (font, wc); - if (index) - set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); - else - set_glyph (font, glyphs, *n_glyphs, cluster_offset, PANGO_GET_UNKNOWN_GLYPH (wc)); - } - (*n_glyphs)++; -} - -static void -hangul_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED, - PangoFont *font, - const char *text, - gint length, - const PangoAnalysis *analysis G_GNUC_UNUSED, - PangoGlyphString *glyphs) -{ - int n_chars = g_utf8_strlen (text, length); - int n_glyphs; - int i; - const char *p, *start; - - int n_jamos; - gunichar prev = 0; - - n_glyphs = 0; - start = p = text; - n_jamos = 0; - - for (i = 0; i < n_chars; i++) - { - gunichar wc; - - wc = g_utf8_get_char (p); - - /* Check syllable boundaries. */ - if (n_jamos && IS_BOUNDARY (prev, wc)) - { - if (n_jamos == 1 && IS_S (prev)) - /* common case which the most people use */ - render_basic (font, prev, glyphs, &n_glyphs, start - text); - else - /* possibly complex composition */ - render_syllable (font, start, n_jamos, glyphs, - &n_glyphs, start - text); - n_jamos = 0; - start = p; - } - - prev = wc; - - if (!IS_HANGUL (wc)) - { - render_basic (font, wc, glyphs, &n_glyphs, start - text); - start = g_utf8_next_char (p); - } - else if (IS_M (wc) && !n_jamos) - { - /* Tone mark not following syllable */ - render_isolated_tone (font, wc, glyphs, &n_glyphs, start - text); - start = g_utf8_next_char (p); - } - else - n_jamos++; - p = g_utf8_next_char (p); - } - - if (n_jamos == 1 && IS_S (prev)) - render_basic (font, prev, glyphs, &n_glyphs, start - text); - else if (n_jamos > 0) - render_syllable (font, start, n_jamos, glyphs, &n_glyphs, - start - text); -} - -static void -hangul_engine_fc_class_init (PangoEngineShapeClass *class) -{ - class->script_shape = hangul_engine_shape; -} - -PANGO_ENGINE_SHAPE_DEFINE_TYPE (HangulEngineFc, hangul_engine_fc, - hangul_engine_fc_class_init, NULL) - -void -PANGO_MODULE_ENTRY(init) (GTypeModule *module) -{ - hangul_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 (hangul_engine_fc_type, NULL); - else - return NULL; -} diff --git a/modules/hangul/tables-jamos.i b/modules/hangul/tables-jamos.i deleted file mode 100644 index e5ea5942..00000000 --- a/modules/hangul/tables-jamos.i +++ /dev/null @@ -1,401 +0,0 @@ -/* -*-c-*- */ - -#define KSC_JAMOBASE 0x2420 -#define UNI_JAMOBASE 0x3130 - -#define KSC_KIYEOK 0x2421 -#define KSC_SSANGKIYEOK 0x2422 -#define KSC_KIYEOK_SIOS 0x2423 -#define KSC_NIEUN 0x2424 -#define KSC_NIEUN_CIEUC 0x2425 -#define KSC_NIEUN_HIEUH 0x2426 -#define KSC_TIKEUT 0x2427 -#define KSC_SSANGTIKEUT 0x2428 -#define KSC_RIEUL 0x2429 -#define KSC_RIEUL_KIYEOK 0x242a -#define KSC_RIEUL_MIEUM 0x242b -#define KSC_RIEUL_PIEUP 0x242c -#define KSC_RIEUL_SIOS 0x242d -#define KSC_RIEUL_THIEUTH 0x242e -#define KSC_RIEUL_PHIEUPH 0x242f -#define KSC_RIEUL_HIEUH 0x2430 -#define KSC_MIEUM 0x2431 -#define KSC_PIEUP 0x2432 -#define KSC_SSANGPIEUP 0x2433 -#define KSC_PIEUP_SIOS 0x2434 -#define KSC_SIOS 0x2435 -#define KSC_SSANGSIOS 0x2436 -#define KSC_IEUNG 0x2437 -#define KSC_CIEUC 0x2438 -#define KSC_SSANGCIEUC 0x2439 -#define KSC_CHIEUCH 0x243a -#define KSC_KHIEUKH 0x243b -#define KSC_THIEUTH 0x243c -#define KSC_PHIEUPH 0x243d -#define KSC_HIEUH 0x243e - -#define KSC_A 0x243f -#define KSC_AE 0x2440 -#define KSC_YA 0x2441 -#define KSC_YAE 0x2442 -#define KSC_EO 0x2443 -#define KSC_E 0x2444 -#define KSC_YEO 0x2445 -#define KSC_YE 0x2446 -#define KSC_O 0x2447 -#define KSC_WA 0x2448 -#define KSC_WAE 0x2449 -#define KSC_OE 0x244a -#define KSC_YO 0x244b -#define KSC_U 0x244c -#define KSC_WEO 0x244d -#define KSC_WE 0x244e -#define KSC_WI 0x244f -#define KSC_YU 0x2450 -#define KSC_EU 0x2451 -#define KSC_YI 0x2452 -#define KSC_I 0x2453 - -#define KSC_SSANGNIEUN 0x2455 -#define KSC_NIEUN_TIKEUT 0x2456 -#define KSC_NIEUN_SIOS 0x2457 -#define KSC_NIEUN_PANSIOS 0x2458 -#define KSC_RIEUL_KIYEOK_SIOS 0x2459 -#define KSC_RIEUL_TIKEUT 0x245a -#define KSC_RIEUL_PIEUP_SIOS 0x245b -#define KSC_RIEUL_PANSIOS 0x245c -#define KSC_RIEUL_YEORINHIEUH 0x245d -#define KSC_MIEUM_PIEUP 0x245e -#define KSC_MIEUM_SIOS 0x245f -#define KSC_MIEUM_PANSIOS 0x2460 -#define KSC_KAPYEOUNMIEUM 0x2461 -#define KSC_PIEUP_KIYEOK 0x2462 -#define KSC_PIEUP_TIKEUT 0x2463 -#define KSC_PIEUP_SIOS_KIYEOK 0x2464 -#define KSC_PIEUP_SIOS_TIKEUT 0x2465 -#define KSC_PIEUP_CIEUC 0x2466 -#define KSC_PIEUP_THIEUTH 0x2467 -#define KSC_KAPYEOUNPIEUP 0x2468 -#define KSC_KAPYEOUNSSANGPIEUP 0x2469 -#define KSC_SIOS_KIYEOK 0x246a -#define KSC_SIOS_NIEUN 0x246b -#define KSC_SIOS_TIKEUT 0x246c -#define KSC_SIOS_PIEUP 0x246d -#define KSC_SIOS_CIEUC 0x246e -#define KSC_PANSIOS 0x246f -#define KSC_SSANGIEUNG 0x2470 -#define KSC_YESIEUNG 0x2471 -#define KSC_IEUNG_CIEUC 0x2472 -#define KSC_IEUNG_PANSIOS 0x2473 -#define KSC_KAPYEOUNPHIEUPH 0x2474 -#define KSC_SSANGHIEUH 0x2475 -#define KSC_YEORINHIEUH 0x2476 -#define KSC_YO_YA 0x2477 -#define KSC_YO_YAE 0x2478 -#define KSC_YO_I 0x2479 -#define KSC_YU_YEO 0x247a -#define KSC_YU_YE 0x247b -#define KSC_YU_I 0x247c -#define KSC_ARAEA 0x247d -#define KSC_ARAEA_I 0x247e - -/* - * Some jamos are not representable with KSC5601. These are ugly - * fallbacks: - * - * CHITUEUMSIOS: 0x233c (less than) - * CEONGCHITUEUMSIOS: 0x233e (greater than) - * CHITUEUMCIEUC 0x237b (left bracket) - * CEONGEUMCIEUC 0x237d (right bracket) - * CHITUEUMCHIEUCH 0x237b (left brace) - * CEONGEUMCHIEUCH 0x237d (right brace) - */ -#define KSC_CHITUEUMSIOS 0x233c -#define KSC_CEONGCHITUEUMSIOS 0x233e -#define KSC_CHITUEUMCIEUC 0x235b -#define KSC_CEONGEUMCIEUC 0x235d -#define KSC_CHITUEUMCHIEUCH 0x237b -#define KSC_CEONGEUMCHIEUCH 0x237d - -static const guint16 __jamo_to_ksc5601[0x100][3] = -{ - /* - * CHOSEONG - */ - /* CHOSEONG 0x1100 -- 0x1112 : matched to each ksc5601 Jamos extactly. */ - {KSC_KIYEOK, 0, 0}, - {KSC_SSANGKIYEOK, 0, 0}, - {KSC_NIEUN, 0, 0}, - {KSC_TIKEUT, 0, 0}, - {KSC_SSANGTIKEUT, 0, 0}, - {KSC_RIEUL, 0, 0}, - {KSC_MIEUM, 0, 0}, - {KSC_PIEUP, 0, 0}, - {KSC_SSANGPIEUP, 0, 0}, - {KSC_SIOS, 0, 0}, - {KSC_SSANGSIOS, 0, 0}, - {KSC_IEUNG, 0, 0}, - {KSC_CIEUC, 0, 0}, - {KSC_SSANGCIEUC, 0, 0}, - {KSC_CHIEUCH, 0, 0}, - {KSC_KHIEUKH, 0, 0}, - {KSC_THIEUTH, 0, 0}, - {KSC_PHIEUPH, 0, 0}, - {KSC_HIEUH, 0, 0}, - /* Some of the following are representable as a glyph, the others not. */ - {KSC_NIEUN, KSC_KIYEOK, 0}, - {KSC_SSANGNIEUN, 0, 0}, - {KSC_NIEUN_TIKEUT, 0, 0}, - {KSC_NIEUN, KSC_PIEUP, 0}, - {KSC_TIKEUT, KSC_KIYEOK, 0}, - {KSC_RIEUL, KSC_NIEUN, 0}, - {KSC_RIEUL, KSC_RIEUL, 0}, - {KSC_RIEUL_HIEUH, 0, 0}, - {KSC_RIEUL, KSC_IEUNG, 0}, - {KSC_MIEUM_PIEUP, 0, 0}, - {KSC_KAPYEOUNMIEUM, 0, 0}, - {KSC_PIEUP_KIYEOK, 0, 0}, - {KSC_PIEUP, KSC_NIEUN, 0}, - {KSC_PIEUP_TIKEUT, 0, 0}, - {KSC_PIEUP_SIOS, 0, 0}, - {KSC_PIEUP_SIOS_KIYEOK, 0, 0}, - {KSC_PIEUP_SIOS_TIKEUT, 0, 0}, - {KSC_PIEUP, KSC_SIOS, KSC_PIEUP}, - {KSC_PIEUP, KSC_SIOS, KSC_SIOS}, - {KSC_PIEUP, KSC_SIOS, KSC_CIEUC}, - {KSC_PIEUP_CIEUC, 0, 0}, - {KSC_PIEUP, KSC_CHIEUCH, 0}, - {KSC_PIEUP_THIEUTH, 0, 0}, - {KSC_PIEUP, KSC_PHIEUPH, 0}, - {KSC_KAPYEOUNPIEUP, 0, 0}, - {KSC_KAPYEOUNSSANGPIEUP, 0, 0}, - {KSC_SIOS_KIYEOK, 0, 0}, - {KSC_SIOS_NIEUN, 0, 0}, - {KSC_SIOS_TIKEUT, 0, 0}, - {KSC_SIOS, KSC_RIEUL, 0}, - {KSC_SIOS, KSC_MIEUM, 0}, - {KSC_SIOS_PIEUP, 0, 0}, - {KSC_SIOS, KSC_PIEUP, KSC_KIYEOK}, - {KSC_SIOS, KSC_SIOS, KSC_SIOS}, - {KSC_SIOS, KSC_IEUNG, 0}, - {KSC_SIOS_CIEUC, 0, 0}, - {KSC_SIOS, KSC_CHIEUCH, 0}, - {KSC_SIOS, KSC_KHIEUKH, 0}, - {KSC_SIOS, KSC_THIEUTH, 0}, - {KSC_SIOS, KSC_PHIEUPH, 0}, - {KSC_SIOS, KSC_HIEUH, 0}, - {KSC_CHITUEUMSIOS, 0, 0}, - {KSC_CHITUEUMSIOS, KSC_CHITUEUMSIOS, 0}, - {KSC_CEONGCHITUEUMSIOS, 0, 0}, - {KSC_CEONGCHITUEUMSIOS, KSC_CEONGCHITUEUMSIOS, 0}, - {KSC_PANSIOS, 0, 0}, - {KSC_IEUNG, KSC_KIYEOK, 0}, - {KSC_IEUNG, KSC_TIKEUT, 0}, - {KSC_IEUNG, KSC_MIEUM, 0}, - {KSC_IEUNG, KSC_PIEUP, 0}, - {KSC_IEUNG, KSC_SIOS, 0}, - {KSC_IEUNG_PANSIOS, 0, 0}, - {KSC_SSANGIEUNG, 0, 0}, - {KSC_IEUNG_CIEUC, 0, 0}, - {KSC_IEUNG, KSC_CHIEUCH, 0}, - {KSC_IEUNG, KSC_THIEUTH, 0}, - {KSC_IEUNG, KSC_PHIEUPH, 0}, - {KSC_YESIEUNG, 0, 0}, - {KSC_CIEUC, KSC_IEUNG, 0}, - {KSC_CHITUEUMCIEUC, 0, 0}, - {KSC_CHITUEUMCIEUC, KSC_CHITUEUMCIEUC, 0}, - {KSC_CEONGEUMCIEUC, 0, 0}, - {KSC_CEONGEUMCIEUC, KSC_CEONGEUMCIEUC, 0}, - {KSC_CHIEUCH, KSC_KHIEUKH, 0}, - {KSC_CHIEUCH, KSC_HIEUH, 0}, - {KSC_CHITUEUMCHIEUCH, 0, 0}, - {KSC_CEONGEUMCHIEUCH, 0, 0}, - {KSC_PHIEUPH, KSC_PIEUP, 0}, - {KSC_KAPYEOUNPHIEUPH, 0, 0}, - {KSC_SSANGHIEUH, 0, 0}, - {KSC_YEORINHIEUH, 0, 0}, - /* 0x115A ~ 0x115E -- reserved */ - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - /* CHOSEONG FILLER */ - {0, 0, 0}, - - /* - * JUNGSEONG - */ - /* - * JUNGSEONG - */ - {0, 0, 0}, /* JUNGSEONG FILL */ - /* JUNGSEONG 0x1161 -- 0x1175 : matched to each ksc5601 Jamos extactly. */ - {KSC_A, 0, 0}, - {KSC_AE, 0, 0}, - {KSC_YA, 0, 0}, - {KSC_YAE, 0, 0}, - {KSC_EO, 0, 0}, - {KSC_E, 0, 0}, - {KSC_YEO, 0, 0}, - {KSC_YE, 0, 0}, - {KSC_O, 0, 0}, - {KSC_WA, 0, 0}, - {KSC_WAE, 0, 0}, - {KSC_OE, 0, 0}, - {KSC_YO, 0, 0}, - {KSC_U, 0, 0}, - {KSC_WEO, 0, 0}, - {KSC_WE, 0, 0}, - {KSC_WI, 0, 0}, - {KSC_YU, 0, 0}, - {KSC_EU, 0, 0}, - {KSC_YI, 0, 0}, - {KSC_I, 0, 0}, - /* Some of the following are representable as a glyph, the others not. */ - {KSC_A, KSC_O, 0}, - {KSC_A, KSC_U, 0}, - {KSC_YA, KSC_O, 0}, - {KSC_YA, KSC_YO, 0}, - {KSC_EO, KSC_O, 0}, - {KSC_EO, KSC_U, 0}, - {KSC_EO, KSC_EU, 0}, - {KSC_YEO, KSC_O, 0}, - {KSC_YEO, KSC_U, 0}, - {KSC_O, KSC_EO, 0}, - {KSC_O, KSC_E, 0}, - {KSC_O, KSC_YE, 0}, - {KSC_O, KSC_O, 0}, - {KSC_O, KSC_U, 0}, - {KSC_YO_YA, 0, 0}, - {KSC_YO_YAE, 0, 0}, - {KSC_YO, KSC_YEO, 0}, - {KSC_YO, KSC_O, 0}, - {KSC_YO_I, 0, 0}, - {KSC_U, KSC_A, 0}, - {KSC_U, KSC_AE, 0}, - {KSC_U, KSC_EO, KSC_EU}, - {KSC_U, KSC_YE, 0}, - {KSC_U, KSC_U, 0}, - {KSC_YU, KSC_A, 0}, - {KSC_YU, KSC_EO, 0}, - {KSC_YU, KSC_E, 0}, - {KSC_YU_YEO, 0, 0}, - {KSC_YU_YE, 0, 0}, - {KSC_YU, KSC_U, 0}, - {KSC_YU_I, 0, 0}, - {KSC_EU, KSC_U, 0}, - {KSC_EU, KSC_EU, 0}, - {KSC_YI, KSC_U, 0}, - {KSC_I, KSC_A, 0}, - {KSC_I, KSC_YA, 0}, - {KSC_I, KSC_O, 0}, - {KSC_I, KSC_U, 0}, - {KSC_I, KSC_EU, 0}, - {KSC_I, KSC_ARAEA, 0}, - {KSC_ARAEA, 0, 0}, - {KSC_ARAEA, KSC_EO, 0}, - {KSC_ARAEA, KSC_U, 0}, - {KSC_ARAEA, KSC_I, 0}, - {KSC_ARAEA, KSC_ARAEA, 0}, - /* 0x11A3 ~ 0x11A7 -- reserved */ - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, /* (INTERNAL) JONGSEONG FILL */ - - /* - * JONGSEONG - */ - {KSC_KIYEOK, 0, 0}, - {KSC_SSANGKIYEOK, 0, 0}, - {KSC_KIYEOK_SIOS, 0, 0}, - {KSC_NIEUN, 0, 0}, - {KSC_NIEUN_CIEUC, 0, 0}, - {KSC_NIEUN_HIEUH, 0, 0}, - {KSC_TIKEUT, 0, 0}, - {KSC_RIEUL, 0, 0}, - {KSC_RIEUL_KIYEOK, 0, 0}, - {KSC_RIEUL_MIEUM, 0, 0}, - {KSC_RIEUL_PIEUP, 0, 0}, - {KSC_RIEUL_SIOS, 0, 0}, - {KSC_RIEUL_TIKEUT, 0, 0}, - {KSC_RIEUL_PHIEUPH, 0, 0}, - {KSC_RIEUL_HIEUH, 0, 0}, - {KSC_MIEUM, 0, 0}, - {KSC_PIEUP, 0, 0}, - {KSC_PIEUP_SIOS, 0, 0}, - {KSC_SIOS, 0, 0}, - {KSC_SSANGSIOS, 0, 0}, - {KSC_IEUNG, 0, 0}, - {KSC_CIEUC, 0, 0}, - {KSC_CHIEUCH, 0, 0}, - {KSC_KHIEUKH, 0, 0}, - {KSC_THIEUTH, 0, 0}, - {KSC_PHIEUPH, 0, 0}, - {KSC_HIEUH, 0, 0}, - {KSC_KIYEOK, KSC_RIEUL, 0}, - {KSC_KIYEOK, KSC_SIOS, KSC_KIYEOK}, - {KSC_NIEUN, KSC_KIYEOK, 0}, - {KSC_NIEUN_TIKEUT, 0, 0}, - {KSC_NIEUN_SIOS, 0, 0}, - {KSC_NIEUN_PANSIOS, 0, 0}, - {KSC_NIEUN, KSC_THIEUTH, 0}, - {KSC_TIKEUT, KSC_KIYEOK, 0}, - {KSC_TIKEUT, KSC_RIEUL, 0}, - {KSC_RIEUL_KIYEOK_SIOS, 0, 0}, - {KSC_RIEUL, KSC_NIEUN, 0}, - {KSC_RIEUL_TIKEUT, 0, 0}, - {KSC_RIEUL, KSC_TIKEUT, KSC_HIEUH}, - {KSC_RIEUL, KSC_RIEUL, 0}, - {KSC_RIEUL, KSC_MIEUM, KSC_KIYEOK}, - {KSC_RIEUL, KSC_MIEUM, KSC_SIOS}, - {KSC_RIEUL_PIEUP_SIOS, 0, 0}, - {KSC_RIEUL, KSC_PHIEUPH, KSC_HIEUH}, - {KSC_RIEUL, KSC_KAPYEOUNPIEUP, 0}, - {KSC_RIEUL, KSC_SIOS, KSC_SIOS}, - {KSC_RIEUL_PANSIOS, 0, 0}, - {KSC_RIEUL, KSC_KHIEUKH, 0}, - {KSC_RIEUL_YEORINHIEUH, 0, 0}, - {KSC_MIEUM, KSC_KIYEOK, 0}, - {KSC_MIEUM, KSC_RIEUL, 0}, - {KSC_MIEUM_PIEUP, 0, 0}, - {KSC_MIEUM_SIOS, 0, 0}, - {KSC_MIEUM, KSC_SIOS, KSC_SIOS}, - {KSC_MIEUM_PANSIOS, 0, 0}, - {KSC_MIEUM, KSC_CHIEUCH, 0}, - {KSC_MIEUM, KSC_HIEUH, 0}, - {KSC_KAPYEOUNMIEUM, 0, 0}, - {KSC_PIEUP, KSC_RIEUL, 0}, - {KSC_PIEUP, KSC_PHIEUPH, 0}, - {KSC_PIEUP, KSC_HIEUH, 0}, - {KSC_KAPYEOUNPIEUP, 0, 0}, - {KSC_SIOS_KIYEOK, 0, 0}, - {KSC_SIOS_TIKEUT, 0, 0}, - {KSC_SIOS, KSC_RIEUL, 0}, - {KSC_SIOS_PIEUP, 0, 0}, - {KSC_PANSIOS, 0, 0}, - {KSC_IEUNG, KSC_KIYEOK, 0}, - {KSC_IEUNG, KSC_KIYEOK, KSC_KIYEOK}, - {KSC_SSANGIEUNG, 0, 0}, - {KSC_IEUNG, KSC_KHIEUKH, 0}, - {KSC_YESIEUNG, 0, 0}, - {KSC_YESIEUNG, KSC_SIOS, 0}, - {KSC_YESIEUNG, KSC_PANSIOS, 0}, - {KSC_PHIEUPH, KSC_PIEUP, 0}, - {KSC_KAPYEOUNPHIEUPH, 0, 0}, - {KSC_HIEUH, KSC_NIEUN, 0}, - {KSC_HIEUH, KSC_RIEUL, 0}, - {KSC_HIEUH, KSC_MIEUM, 0}, - {KSC_HIEUH, KSC_PIEUP, 0}, - {KSC_YEORINHIEUH, 0, 0}, - /* reserved */ - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0} -}; - diff --git a/modules/hebrew/Makefile.am b/modules/hebrew/Makefile.am deleted file mode 100644 index 52abcda1..00000000 --- a/modules/hebrew/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -include $(top_srcdir)/modules/Module.mk - -common_sources = hebrew-shaper.c hebrew-shaper.h - -if HAVE_FREETYPE -INCLUDES += $(FREETYPE_CFLAGS) -if INCLUDE_HEBREW_FC -noinst_LTLIBRARIES += libpango-hebrew-fc.la -else -if DYNAMIC_HEBREW_FC -module_LTLIBRARIES += pango-hebrew-fc.la -endif -endif -endif - -hebrew_fc_sources = $(common_sources) hebrew-fc.c - -pango_hebrew_fc_la_LDFLAGS = -module $(MODULE_LIBTOOL_OPTIONS) -pango_hebrew_fc_la_LIBADD = $(pangoft2libs) -pango_hebrew_fc_la_SOURCES = $(hebrew_fc_sources) -libpango_hebrew_fc_la_SOURCES = $(hebrew_fc_sources) -libpango_hebrew_fc_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_hebrew_fc - --include $(top_srcdir)/git.mk diff --git a/modules/hebrew/hebrew-fc.c b/modules/hebrew/hebrew-fc.c deleted file mode 100644 index 12f25c5e..00000000 --- a/modules/hebrew/hebrew-fc.c +++ /dev/null @@ -1,355 +0,0 @@ -/* Pango - * hebrew-fc.h: Hebrew shaper for FreeType-based backends - * - * Copyright (C) 2000, 2007 Red Hat Software - * Authors: - * Owen Taylor <otaylor@redhat.com> - * Dov Grobgeld <dov.grobgeld@weizmann.ac.il> - * Behdad Esfahbod <behdad@behdad.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#include <string.h> - -#include <pango/pango-ot.h> - -#include "pango-engine.h" -#include "pango-utils.h" -#include "pangofc-font.h" -#include "hebrew-shaper.h" - -/* No extra fields needed */ -typedef PangoEngineShape HebrewEngineFc; -typedef PangoEngineShapeClass HebrewEngineFcClass ; - -#define MAX_CLUSTER_CHRS 20 - -static PangoEngineScriptInfo hebrew_scripts[] = { - { PANGO_SCRIPT_HEBREW, "*" } -}; - -#define SCRIPT_ENGINE_NAME "HebrewScriptEngineFc" -#define RENDER_TYPE PANGO_RENDER_TYPE_FC - -static PangoEngineInfo script_engines[] = { - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - RENDER_TYPE, - hebrew_scripts, G_N_ELEMENTS(hebrew_scripts) - } -}; - -static void -get_cluster_glyphs(PangoFont *font, - gunichar cluster[], - gint cluster_size, - gboolean do_mirror, - /* output */ - gint glyph_num[], - PangoGlyph glyph[], - gint widths[], - PangoRectangle ink_rects[]) -{ - int i; - for (i=0; i<cluster_size; i++) - { - PangoRectangle logical_rect; - gunichar wc = cluster[i]; - gunichar mirrored_ch; - - if (do_mirror) - if (pango_get_mirror_char (wc, &mirrored_ch)) - wc = mirrored_ch; - - if (pango_is_zero_width (wc)) - glyph_num[i] = PANGO_GLYPH_EMPTY; - else - { - glyph_num[i] = pango_fc_font_get_glyph ((PangoFcFont *)font, wc); - - if (!glyph_num[i]) - glyph_num[i] = PANGO_GET_UNKNOWN_GLYPH ( wc); - } - - glyph[i] = glyph_num[i]; - - pango_font_get_glyph_extents (font, - glyph[i], &ink_rects[i], &logical_rect); - - /* Assign the base char width to the last character in the cluster */ - if (i==0) - { - widths[i] = 0; - widths[cluster_size-1] = logical_rect.width; - } - else if (i < cluster_size-1) - widths[i] = 0; - } -} - -static void -add_glyph (PangoGlyphString *glyphs, - gint cluster_start, - PangoGlyph glyph, - gboolean is_combining, - gint width, - gint x_offset, - gint y_offset - ) -{ - gint index = glyphs->num_glyphs; - - pango_glyph_string_set_size (glyphs, index + 1); - - glyphs->glyphs[index].glyph = glyph; - glyphs->glyphs[index].attr.is_cluster_start = is_combining ? 0 : 1; - - glyphs->log_clusters[index] = cluster_start; - - glyphs->glyphs[index].geometry.x_offset = x_offset; - glyphs->glyphs[index].geometry.y_offset = y_offset; - glyphs->glyphs[index].geometry.width = width; -} - -static void -add_cluster(PangoGlyphString *glyphs, - int cluster_size, - int cluster_start, - PangoGlyph glyph[], - int width[], - int x_offset[], - int y_offset[]) -{ - int i; - - for (i=0; i<cluster_size; i++) - { - add_glyph (glyphs, cluster_start, glyph[i], - i == 0 ? FALSE : TRUE, width[i], x_offset[i], y_offset[i]); - } -} - -static void -fallback_shape (PangoEngineShape *engine G_GNUC_UNUSED, - PangoFont *font, - const char *text, - gint length, - const PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - const char *p; - const char *log_cluster; - gunichar cluster[MAX_CLUSTER_CHRS]; - gint cluster_size; - gint glyph_num[MAX_CLUSTER_CHRS]; - gint glyph_width[MAX_CLUSTER_CHRS], x_offset[MAX_CLUSTER_CHRS], y_offset[MAX_CLUSTER_CHRS]; - PangoRectangle ink_rects[MAX_CLUSTER_CHRS]; - PangoGlyph glyph[MAX_CLUSTER_CHRS]; - - pango_glyph_string_set_size (glyphs, 0); - - p = text; - while (p < text + length) - { - log_cluster = p; - p = hebrew_shaper_get_next_cluster (p, text + length - p, - /* output */ - cluster, &cluster_size); - get_cluster_glyphs(font, - cluster, - cluster_size, - analysis->level % 2, - /* output */ - glyph_num, - glyph, - glyph_width, - ink_rects); - - /* Kern the glyphs! */ - hebrew_shaper_get_cluster_kerning(cluster, - cluster_size, - /* Input and output */ - ink_rects, - glyph_width, - /* output */ - x_offset, - y_offset); - - add_cluster(glyphs, - cluster_size, - log_cluster - text, - glyph, - glyph_width, - x_offset, - y_offset); - - } - - if (analysis->level % 2) - hebrew_shaper_bidi_reorder(glyphs); -} - -static const PangoOTFeatureMap gsub_features[] = -{ - {"ccmp", PANGO_OT_ALL_GLYPHS}, - {"locl", PANGO_OT_ALL_GLYPHS}, - {"rlig", PANGO_OT_ALL_GLYPHS}, - /* 'dlig' should be turned-on/off-able. lets turn off for now. */ - /* {"dlig", PANGO_OT_ALL_GLYPHS}, */ -}; - -static const PangoOTFeatureMap gpos_features[] = -{ - {"kern", PANGO_OT_ALL_GLYPHS}, - {"mark", PANGO_OT_ALL_GLYPHS}, - {"mkmk", PANGO_OT_ALL_GLYPHS} -}; - -static void -hebrew_engine_shape (PangoEngineShape *engine, - PangoFont *font, - const char *text, - gint length, - const PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - PangoFcFont *fc_font; - FT_Face face; - PangoOTRulesetDescription desc; - const PangoOTRuleset *ruleset; - PangoOTBuffer *buffer; - guint n_gpos_features = 0; - glong n_chars; - const char *p; - int cluster = 0; - int i; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - if (!face) - return; - - desc.script = analysis->script; - desc.language = analysis->language; - - desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features); - desc.static_gsub_features = gsub_features; - desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features); - desc.static_gpos_features = gpos_features; - - /* TODO populate other_features from analysis->extra_attrs */ - desc.n_other_features = 0; - desc.other_features = NULL; - - ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc); - - pango_ot_ruleset_get_feature_count (ruleset, NULL, &n_gpos_features); - if (n_gpos_features == 0) - { - fallback_shape (engine, font, text, length, analysis, glyphs); - goto out; - } - - buffer = pango_ot_buffer_new (fc_font); - pango_ot_buffer_set_rtl (buffer, analysis->level % 2 != 0); - - n_chars = g_utf8_strlen (text, length); - - p = text; - for (i=0; i < n_chars; i++) - { - gunichar wc; - PangoGlyph glyph; - - wc = g_utf8_get_char (p); - - if (g_unichar_type (wc) != G_UNICODE_NON_SPACING_MARK) - cluster = p - text; - - if (pango_is_zero_width (wc)) - glyph = PANGO_GLYPH_EMPTY; - else - { - gunichar c = wc; - - if (analysis->level % 2) - g_unichar_get_mirror_char (c, &c); - - glyph = pango_fc_font_get_glyph (fc_font, c); - } - - if (!glyph) - glyph = PANGO_GET_UNKNOWN_GLYPH (wc); - - pango_ot_buffer_add_glyph (buffer, glyph, 0, cluster); - - p = g_utf8_next_char (p); - } - - pango_ot_ruleset_substitute (ruleset, buffer); - pango_ot_ruleset_position (ruleset, buffer); - pango_ot_buffer_output (buffer, glyphs); - - pango_ot_buffer_destroy (buffer); - - out: - pango_fc_font_unlock_face (fc_font); -} - -static void -hebrew_engine_fc_class_init (PangoEngineShapeClass *class) -{ - class->script_shape = hebrew_engine_shape; -} - -PANGO_ENGINE_SHAPE_DEFINE_TYPE (HebrewEngineFc, hebrew_engine_fc, - hebrew_engine_fc_class_init, NULL) - -void -PANGO_MODULE_ENTRY(init) (GTypeModule *module) -{ - hebrew_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 (hebrew_engine_fc_type, NULL); - else - return NULL; -} diff --git a/modules/hebrew/hebrew-shaper.c b/modules/hebrew/hebrew-shaper.c deleted file mode 100644 index db3055b7..00000000 --- a/modules/hebrew/hebrew-shaper.c +++ /dev/null @@ -1,477 +0,0 @@ -/* Pango - * hebrew-shaper.c: - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * Author: Chookij Vanatham <Chookij.Vanatham@Eng.Sun.COM> - * - * Hebrew points positioning improvements 2001 - * Author: Dov Grobgeld <dov.grobgeld@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Note March 9, 2003: I fixed a crash with regards to precomposed - * characters, by wraping all of them to be considered as ALEF as - * far as consideration about composability is concerned. The rendering - * with regards to precomposed characters AND nikud comes out really - * bad though, and should be fixed, once I have more time. - */ - -#include "config.h" -#include <glib.h> -#include "pango-engine.h" -#include "hebrew-shaper.h" - -/* Wrap all characters above 0xF00 to ALEF. */ -#define ishebrew(wc) ((wc)>0x590 && (wc)<0x600) -#define ucs2iso8859_8(wc) ((unsigned int)((unsigned int)(wc) - 0x0590 + 0x10)) -#define iso8859_8_2uni(c) ((gunichar)(c) - 0x10 + 0x0590) - -#define MAX_CLUSTER_CHRS 256 - -/* Define Hebrew character classes */ -#define _ND 0 -#define _SP 1 -#define _NS (1<<1) -#define _DA (1<<2) /* only for dagesh... */ - -#define NoDefine _ND -#define SpacingLetter _SP -#define NonSpacingPunc _NS - -/* Define Hebrew character types */ -#define __ND 0 -#define __SP 1 -#define __NS 2 -#define __DA 3 - -/* Unicode definitions needed in logics below... */ -#define UNI_ALEF 0x05D0 -#define UNI_BET 0x05D1 -#define UNI_GIMMEL 0x05d2 -#define UNI_DALED 0x05D3 -#define UNI_KAF 0x05DB -#define UNI_FINAL_KAF 0x05DA -#define UNI_VAV 0x05D5 -#define UNI_YOD 0x05D9 -#define UNI_RESH 0x05E8 -#define UNI_LAMED 0x05DC -#define UNI_SHIN 0x05E9 -#define UNI_FINAL_PE 0x05E3 -#define UNI_PE 0x05E4 -#define UNI_QOF 0x05E7 -#define UNI_TAV 0x05EA -#define UNI_SHIN_DOT 0x05C1 -#define UNI_SIN_DOT 0x05C2 -#define UNI_MAPIQ 0x05BC -#define UNI_SHEVA 0x05B0 -#define UNI_HOLAM 0x05B9 -#define UNI_QUBUTS 0x05BB -#define UNI_HATAF_SEGOL 0x05B1 -#define UNI_HATAF_QAMATZ 0x05B3 -#define UNI_TSERE 0x05B5 -#define UNI_QAMATS 0x05B8 -#define UNI_QUBUTS 0x05BB - -/*====================================================================== -// In the tables below all Hebrew characters are categorized to -// one of the following four classes: -// -// non used entries Not defined (ND) -// accents, points Non spacing (NS) -// punctuation and characters Spacing characters (SP) -// dagesh "Dagesh" (DA) -//----------------------------------------------------------------------*/ -static const gint char_class_table[128] = { - /* 0, 1, 2, 3, 4, 5, 6, 7 */ - - /*00*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - - /*10*/ _ND, _NS, _NS, _NS, _NS, _NS, _NS, _NS, - _NS, _NS, _NS, _NS, _NS, _NS, _NS, _NS, - /*20*/ _NS, _NS, _ND, _NS, _NS, _NS, _NS, _NS, - _NS, _NS, _NS, _NS, _NS, _NS, _NS, _NS, - /*30*/ _NS, _NS, _NS, _NS, _NS, _NS, _NS, _NS, - _NS, _NS, _ND, _NS, _DA, _NS, _SP, _NS, - /*40*/ _SP, _NS, _NS, _SP, _NS, _ND, _ND, _ND, - _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - /*50*/ _SP, _SP, _SP, _SP, _SP, _SP, _SP, _SP, - _SP, _SP, _SP, _SP, _SP, _SP, _SP, _SP, - /*60*/ _SP, _SP, _SP, _SP, _SP, _SP, _SP, _SP, - _SP, _SP, _SP, _ND, _ND, _ND, _ND, _ND, - /*70*/ _SP, _SP, _SP, _SP, _SP, _ND, _ND, _ND, - _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, -}; - -static const gint char_type_table[128] = { - /* 0, 1, 2, 3, 4, 5, 6, 7 */ - - /*00*/ __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND, - __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND, - - /*10*/ __ND, __NS, __NS, __NS, __NS, __NS, __NS, __NS, - __NS, __NS, __NS, __NS, __NS, __NS, __NS, __NS, - /*20*/ __NS, __NS, __ND, __NS, __NS, __NS, __NS, __NS, - __NS, __NS, __NS, __NS, __NS, __NS, __NS, __NS, - /*30*/ __NS, __NS, __NS, __NS, __NS, __NS, __NS, __NS, - __NS, __NS, __ND, __NS, __DA, __NS, __SP, __NS, - /*40*/ __SP, __NS, __NS, __SP, __NS, __ND, __ND, __ND, - __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND, - /*50*/ __SP, __SP, __SP, __SP, __SP, __SP, __SP, __SP, - __SP, __SP, __SP, __SP, __SP, __SP, __SP, __SP, - /*60*/ __SP, __SP, __SP, __SP, __SP, __SP, __SP, __SP, - __SP, __SP, __SP, __ND, __ND, __ND, __ND, __ND, - /*70*/ __SP, __SP, __SP, __SP, __SP, __ND, __ND, __ND, - __ND, __ND, __ND, __ND, __ND, __ND, __ND, __ND, -}; - -/*====================================================================== -// The following table answers the question whether two characters -// are composible or not. The decision is made by looking at the -// char_type_table values for the first character in a cluster -// vs a following charactrer. The only three combinations that -// are composible in Hebrew according to the table are: -// -// 1. a spacing character followed by non-spacing character -// 2. a spacing character followed by a dagesh. -// 3. a dagesh followed by a non-spacing character. -// -// Note that a spacing character may be followed by several non-spacing -// accents, as the decision is always made on the base character of -// a combination. -//----------------------------------------------------------------------*/ -static const gboolean compose_table[4][4] = { - /* Cn */ /* 0, 1, 2, 3, */ -/* Cn-1 00 */ { FALSE, FALSE, FALSE, FALSE }, - /* 10 */ { FALSE, FALSE, TRUE, TRUE }, - /* 20 */ { FALSE, FALSE, FALSE, FALSE }, - /* 30 */ { FALSE, FALSE, TRUE, FALSE }, -}; - -/* Treat all characters above 0xF000 as characters */ -#define is_hebrew(wc) ((wc) >= 0x590 && (wc) < 0x600) -#define is_char_class(wc, mask) (char_class_table[ucs2iso8859_8 ((wc))] & (mask)) -#define is_composible(cur_wc, nxt_wc) (compose_table[char_type_table[ucs2iso8859_8 (cur_wc)]]\ - [char_type_table[ucs2iso8859_8 (nxt_wc)]]) - -const char * -hebrew_shaper_get_next_cluster(const char *text, - gint length, - gunichar *cluster, - gint *num_chrs) -{ - const char *p; - gint n_chars = 0; - - p = text; - - while (p < text + length && n_chars < MAX_CLUSTER_CHRS) - { - gunichar current = g_utf8_get_char (p); - - if (!ishebrew (current) || - (n_chars == 0 && is_char_class(current, ~(NoDefine|SpacingLetter)))) - { - /* Not a legal Hebrew cluster */ - - if (n_chars == 0) - { - cluster[n_chars++] = current; - p = g_utf8_next_char (p); - } - break; - } - else if (n_chars == 0 || - is_composible (cluster[0], current)) - { - cluster[n_chars++] = current; - p = g_utf8_next_char (p); - } - else - break; - } - - *num_chrs = n_chars; - return p; -} - -void -hebrew_shaper_get_cluster_kerning(gunichar *cluster, - gint cluster_length, - PangoRectangle ink_rect[], - - /* input and output */ - gint width[], - gint x_offset[], - gint y_offset[]) -{ - int i; - int base_ink_x_offset, base_ink_y_offset, base_ink_width, base_ink_height; - gunichar base_char = cluster[0]; - - x_offset[0] = 0; - y_offset[0] = 0; - - if (cluster_length == 1) - { - /* Make lone 'vav dot' have zero width */ - if (base_char == UNI_SHIN_DOT - || base_char == UNI_SIN_DOT - || base_char == UNI_HOLAM - ) { - x_offset[0] = -ink_rect[0].x - ink_rect[0].width; - width[0] = 0; - } - - return; - } - - base_ink_x_offset = ink_rect[0].x; - base_ink_y_offset = ink_rect[0].y; - base_ink_width = ink_rect[0].width; - base_ink_height = ink_rect[0].height; - - /* Do heuristics */ - for (i=1; i<cluster_length; i++) - { - int gl = cluster[i]; - x_offset[i] = 0; - y_offset[i] = 0; - - /* Check if it is a point */ - if (gl < 0x5B0 || gl >= 0x05D0) - continue; - - /* Center dot of VAV */ - if (gl == UNI_MAPIQ && base_char == UNI_VAV) - { - x_offset[i] = base_ink_x_offset - ink_rect[i].x; - - /* If VAV is a vertical bar without a roof, then we - need to make room for the dot by increasing the - cluster width. But how can I check if that is the - case?? - */ - /* This is wild, but it does the job of differentiating - between two M$ fonts... Base the decision on the - aspect ratio of the vav... - */ - if (base_ink_height > base_ink_width * 3.5) - { - int j; - double space = 0.7; - double kern = 0.5; - - /* Shift all characters to make place for the mapiq */ - for (j=0; j<i; j++) - x_offset[j] += ink_rect[i].width*(1+space-kern); - - width[cluster_length-1] += ink_rect[i].width*(1+space-kern); - x_offset[i] -= ink_rect[i].width*(kern); - } - } - - /* Dot over SHIN */ - else if (gl == UNI_SHIN_DOT && base_char == UNI_SHIN) - { - x_offset[i] = base_ink_x_offset + base_ink_width - - ink_rect[i].x - ink_rect[i].width; - } - - /* Dot over SIN */ - else if (gl == UNI_SIN_DOT && base_char == UNI_SHIN) - { - x_offset[i] = base_ink_x_offset - ink_rect[i].x; - } - - /* VOWEL DOT above to any other character than - SHIN or VAV should stick out a bit to the left. */ - else if ((gl == UNI_SIN_DOT || gl == UNI_HOLAM) - && base_char != UNI_SHIN && base_char != UNI_VAV) - { - x_offset[i] = base_ink_x_offset -ink_rect[i].x - ink_rect[i].width * 3/ 2; - } - - /* VOWELS under resh or vav are right aligned, if they are - narrower than the characters. Otherwise they are centered. - */ - else if ((base_char == UNI_VAV - || base_char == UNI_RESH - || base_char == UNI_YOD - || base_char == UNI_DALED - ) - && ((gl >= UNI_SHEVA && gl <= UNI_QAMATS) || - gl == UNI_QUBUTS) - && ink_rect[i].width < base_ink_width - ) - { - x_offset[i] = base_ink_x_offset + base_ink_width - - ink_rect[i].x - ink_rect[i].width; - } - - /* VOWELS under FINAL KAF are offset centered and offset in - y */ - else if ((base_char == UNI_FINAL_KAF - ) - && ((gl >= UNI_SHEVA && gl <= UNI_QAMATS) || - gl == UNI_QUBUTS)) - { - /* x are at 1/3 to take into accoun the stem */ - x_offset[i] = base_ink_x_offset - ink_rect[i].x - + base_ink_width * 1/3 - ink_rect[i].width/2; - - /* Center in y */ - y_offset[i] = base_ink_y_offset - ink_rect[i].y - + base_ink_height * 1/2 - ink_rect[i].height/2; - } - - - /* MAPIQ in PE or FINAL PE */ - else if (gl == UNI_MAPIQ - && (base_char == UNI_PE || base_char == UNI_FINAL_PE)) - { - x_offset[i]= base_ink_x_offset - ink_rect[i].x - + base_ink_width * 2/3 - ink_rect[i].width/2; - - /* Another option is to offset the MAPIQ in y... - glyphs->glyphs[cluster_start_idx+i].geometry.y_offset - -= base_ink_height/5; */ - } - - /* MAPIQ in SHIN should be moved a bit to the right */ - else if (gl == UNI_MAPIQ - && base_char == UNI_SHIN) - { - x_offset[i]= base_ink_x_offset - ink_rect[i].x - + base_ink_width * 3/5 - ink_rect[i].width/2; - } - - /* MAPIQ in YUD is right aligned */ - else if (gl == UNI_MAPIQ - && base_char == UNI_YOD) - { - x_offset[i]= base_ink_x_offset - ink_rect[i].x; - - /* Lower left in y */ - y_offset[i] = base_ink_y_offset - ink_rect[i].y - + base_ink_height - ink_rect[i].height*1.75; - - if (base_ink_height > base_ink_width * 2) - { - int j; - double space = 0.7; - double kern = 0.5; - - /* Shift all cluster characters to make space for mapiq */ - for (j=0; j<i; j++) - x_offset[j] += ink_rect[i].width*(1+space-kern); - - width[cluster_length-1] += ink_rect[i].width*(1+space-kern); - } - - } - - /* VOWEL DOT next to any other character */ - else if ((gl == UNI_SIN_DOT || gl == UNI_HOLAM) - && (base_char != UNI_VAV)) - { - x_offset[i] = base_ink_x_offset -ink_rect[i].x; - } - - /* Move nikud of taf a bit ... */ - else if (base_char == UNI_TAV && gl == UNI_MAPIQ) - { - x_offset[i] = base_ink_x_offset - ink_rect[i].x - + base_ink_width * 5/8 - ink_rect[i].width/2; - } - - /* Move center dot of characters with a right stem and no - left stem. */ - else if (gl == UNI_MAPIQ && - (base_char == UNI_BET - || base_char == UNI_DALED - || base_char == UNI_KAF - || base_char == UNI_GIMMEL - )) - { - x_offset[i] = base_ink_x_offset - ink_rect[i].x - + base_ink_width * 3/8 - ink_rect[i].width/2; - } - - /* Right align wide nikud under QOF */ - else if (base_char == UNI_QOF && - ( (gl >= UNI_HATAF_SEGOL - && gl <= UNI_HATAF_QAMATZ) - || (gl >= UNI_TSERE - && gl<= UNI_QAMATS) - || (gl == UNI_QUBUTS))) - { - x_offset[i] = base_ink_x_offset + base_ink_width - - ink_rect[i].x - ink_rect[i].width; - } - - /* Center by default */ - else - { - x_offset[i] = base_ink_x_offset - ink_rect[i].x - + base_ink_width/2 - ink_rect[i].width/2; - } - } - -} - -void -hebrew_shaper_swap_range (PangoGlyphString *glyphs, - int start, - int end) -{ - int i, j; - - for (i = start, j = end - 1; i < j; i++, j--) - { - PangoGlyphInfo glyph_info; - gint log_cluster; - - glyph_info = glyphs->glyphs[i]; - glyphs->glyphs[i] = glyphs->glyphs[j]; - glyphs->glyphs[j] = glyph_info; - - log_cluster = glyphs->log_clusters[i]; - glyphs->log_clusters[i] = glyphs->log_clusters[j]; - glyphs->log_clusters[j] = log_cluster; - } -} - -void -hebrew_shaper_bidi_reorder(PangoGlyphString *glyphs) -{ - int start, end; - - /* Swap all glyphs */ - hebrew_shaper_swap_range (glyphs, 0, glyphs->num_glyphs); - - /* Now reorder glyphs within each cluster back to LTR */ - for (start = 0; start < glyphs->num_glyphs;) - { - end = start; - while (end < glyphs->num_glyphs && - glyphs->log_clusters[end] == glyphs->log_clusters[start]) - end++; - - hebrew_shaper_swap_range (glyphs, start, end); - start = end; - } -} diff --git a/modules/hebrew/hebrew-shaper.h b/modules/hebrew/hebrew-shaper.h deleted file mode 100644 index 24603433..00000000 --- a/modules/hebrew/hebrew-shaper.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Pango - * hebrew-shaper.h: Hebrew shaper internal functions - * - * Copyright (c) 2001 by Sun Microsystems, Inc. - * Author: Chookij Vanatham <Chookij.Vanatham@Eng.Sun.COM> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef HEBREW_SHAPER_H -#define HEBREW_SHAPER_H - -const char * -hebrew_shaper_get_next_cluster(const char *text, - gint length, - gunichar *cluster, - gint *num_chrs); - -void -hebrew_shaper_get_cluster_kerning(gunichar *cluster, - gint cluster_length, - PangoRectangle ink_rect[], - - /* input and output */ - gint width[], - gint x_offset[], - gint y_offset[]); - -void -hebrew_shaper_swap_range (PangoGlyphString *glyphs, - int start, - int end); - -void -hebrew_shaper_bidi_reorder(PangoGlyphString *glyphs); - -#endif diff --git a/modules/indic/Makefile.am b/modules/indic/Makefile.am index eb08cfa9..599a2eb5 100644 --- a/modules/indic/Makefile.am +++ b/modules/indic/Makefile.am @@ -1,31 +1,5 @@ include $(top_srcdir)/modules/Module.mk -if HAVE_FREETYPE -INCLUDES += $(FREETYPE_CFLAGS) -if INCLUDE_INDIC_FC -noinst_LTLIBRARIES += libpango-indic-fc.la -else -if DYNAMIC_INDIC_FC -module_LTLIBRARIES += pango-indic-fc.la -endif -endif -endif - -fc_sources = \ - indic-fc.c \ - indic-ot-class-tables.c \ - indic-ot.c \ - indic-ot.h \ - mprefixups.c \ - mprefixups.h - -pango_indic_fc_la_LDFLAGS = -module $(MODULE_LIBTOOL_OPTIONS) -pango_indic_fc_la_LIBADD = $(pangoft2libs) -pango_indic_fc_la_SOURCES = $(fc_sources) -libpango_indic_fc_la_SOURCES = $(fc_sources) -libpango_indic_fc_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_indic_fc - - if INCLUDE_INDIC_LANG noinst_LTLIBRARIES += libpango-indic-lang.la else diff --git a/modules/indic/indic-fc.c b/modules/indic/indic-fc.c deleted file mode 100644 index 3a232be4..00000000 --- a/modules/indic/indic-fc.c +++ /dev/null @@ -1,348 +0,0 @@ -/* Pango - * indic-xft.c: - * - * Copyright (C) 2001, 2002 IBM Corporation - * Author: Eric Mader <mader@jtcsv.com> - * Based on arabic-xft.c by Owen Taylor <otaylor@redhat.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include <string.h> - -#include "indic-ot.h" - -#include "pango-engine.h" -#include "pango-ot.h" -#include "pango-utils.h" -#include "pangofc-font.h" - -typedef struct _PangoIndicInfo PangoIndicInfo; - -typedef struct _IndicEngineFc IndicEngineFc; -typedef PangoEngineShapeClass IndicEngineFcClass ; /* No extra fields needed */ - -struct _IndicEngineFc -{ - PangoEngineShape shapeEngine; - const IndicOTClassTable *classTable; -}; - -#define ENGINE_SUFFIX "ScriptEngineFc" -#define RENDER_TYPE PANGO_RENDER_TYPE_FC - -#define INDIC_ENGINE_INFO(script) {#script ENGINE_SUFFIX, PANGO_ENGINE_TYPE_SHAPE, RENDER_TYPE, script##_scripts, G_N_ELEMENTS(script##_scripts)} - -#define INDIC_OT_CLASS_TABLE(script) &script##_class_table - -static PangoEngineScriptInfo deva_scripts[] = { - { PANGO_SCRIPT_DEVANAGARI, "*" } -}; - -static PangoEngineScriptInfo beng_scripts[] = { - {PANGO_SCRIPT_BENGALI, "*" } -}; - -static PangoEngineScriptInfo guru_scripts[] = { - { PANGO_SCRIPT_GURMUKHI, "*" } -}; - -static PangoEngineScriptInfo gujr_scripts[] = { - { PANGO_SCRIPT_GUJARATI, "*" } -}; - -static PangoEngineScriptInfo orya_scripts[] = { - { PANGO_SCRIPT_ORIYA, "*" } -}; - -static PangoEngineScriptInfo taml_scripts[] = { - { PANGO_SCRIPT_TAMIL, "*" } -}; - -static PangoEngineScriptInfo telu_scripts[] = { - { PANGO_SCRIPT_TELUGU, "*" } -}; - -static PangoEngineScriptInfo knda_scripts[] = { - { PANGO_SCRIPT_KANNADA, "*" } -}; - -static PangoEngineScriptInfo mlym_scripts[] = { - { PANGO_SCRIPT_MALAYALAM, "*" } -}; - -static PangoEngineScriptInfo sinh_scripts[] = { - { PANGO_SCRIPT_SINHALA, "*" } -}; - -static PangoEngineInfo script_engines[] = { - INDIC_ENGINE_INFO(deva), INDIC_ENGINE_INFO(beng), INDIC_ENGINE_INFO(guru), - INDIC_ENGINE_INFO(gujr), INDIC_ENGINE_INFO(orya), INDIC_ENGINE_INFO(taml), - INDIC_ENGINE_INFO(telu), INDIC_ENGINE_INFO(knda), INDIC_ENGINE_INFO(mlym), - INDIC_ENGINE_INFO(sinh) -}; - -/* - * WARNING: These entries need to be in the same order as the entries - * in script_engines[]. - * - * FIXME: remove this requirement, either by encapsulating the order - * in a macro that calls a body macro that can be redefined, or by - * putting the pointers to the PangoEngineInfo in PangoIndicInfo... - */ -static const IndicOTClassTable *indic_ot_class_tables[] = { - INDIC_OT_CLASS_TABLE(deva), INDIC_OT_CLASS_TABLE(beng), INDIC_OT_CLASS_TABLE(guru), - INDIC_OT_CLASS_TABLE(gujr), INDIC_OT_CLASS_TABLE(orya), INDIC_OT_CLASS_TABLE(taml), - INDIC_OT_CLASS_TABLE(telu), INDIC_OT_CLASS_TABLE(knda), INDIC_OT_CLASS_TABLE(mlym), - INDIC_OT_CLASS_TABLE(sinh) -}; - -static const PangoOTFeatureMap gsub_features[] = -{ - {"ccmp", PANGO_OT_ALL_GLYPHS}, - {"locl", PANGO_OT_ALL_GLYPHS}, - {"init", init}, - {"nukt", nukt}, - {"akhn", akhn}, - {"rphf", rphf}, - {"blwf", blwf}, - {"half", half}, - {"pstf", pstf}, - {"vatu", vatu}, - {"pres", pres}, - {"blws", blws}, - {"abvs", abvs}, - {"psts", psts}, - {"haln", haln}, - {"calt", PANGO_OT_ALL_GLYPHS} -}; - -static const PangoOTFeatureMap gpos_features[] = -{ - {"blwm", blwm}, - {"abvm", abvm}, - {"dist", dist}, - {"kern", PANGO_OT_ALL_GLYPHS}, - {"mark", PANGO_OT_ALL_GLYPHS}, - {"mkmk", PANGO_OT_ALL_GLYPHS} -}; - -static void -set_glyphs (PangoFont *font, - const gunichar *wcs, - gulong *tags, - glong n_glyphs, - PangoOTBuffer *buffer, - gboolean process_zwj) -{ - gint i; - PangoFcFont *fc_font; - - g_assert (font); - - fc_font = PANGO_FC_FONT (font); - - for (i = 0; i < n_glyphs; i++) - { - guint glyph; - - if (pango_is_zero_width (wcs[i]) && - (!process_zwj || wcs[i] != 0x200D)) - glyph = PANGO_GLYPH_EMPTY; - else - { - glyph = pango_fc_font_get_glyph (fc_font, wcs[i]); - - if (!glyph) - glyph = PANGO_GET_UNKNOWN_GLYPH ( wcs[i]); - } - pango_ot_buffer_add_glyph (buffer, glyph, tags[i], i); - } -} - -/* - * FIXME: should this check for null pointers, etc.? - */ -static gunichar * -expand_text(const gchar *text, glong length, glong **offsets, glong *n_chars) -{ - const gchar *p; - gunichar *wcs, *wco; - glong i, *oo; - - *n_chars = g_utf8_strlen (text, length); - wcs = g_new (gunichar, *n_chars); - *offsets = g_new (glong, *n_chars + 1); - - p = text; - wco = wcs; - oo = *offsets; - for (i = 0; i < *n_chars; i++) - { - *wco++ = g_utf8_get_char (p); - *oo++ = p - text; - - p = g_utf8_next_char (p); - } - - *oo = p - text; - - return wcs; -} - - -/* analysis->shape_engine has the PangoEngine... */ -static void -indic_engine_shape (PangoEngineShape *engine, - PangoFont *font, - const char *text, - gint length, - const PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - PangoFcFont *fc_font; - FT_Face face; - PangoOTRulesetDescription desc; - const PangoOTRuleset *ruleset; - PangoOTBuffer *buffer; - glong i, n_chars, n_glyphs; - gulong *tags = NULL; - gunichar *wc_in = NULL, *wc_out = NULL; - glong *utf8_offsets = NULL; - glong *indices = NULL; - IndicEngineFc *indic_shape_engine = NULL; - MPreFixups *mprefixups; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - if (!face) - return; - - indic_shape_engine = (IndicEngineFc *) engine; - - wc_in = expand_text (text, length, &utf8_offsets, &n_chars); - - n_glyphs = indic_ot_reorder (wc_in, utf8_offsets, n_chars, indic_shape_engine->classTable, NULL, NULL, NULL, NULL); - - wc_out = g_new (gunichar, n_glyphs); - indices = g_new (glong, n_glyphs); - tags = g_new (gulong, n_glyphs); - - n_glyphs = indic_ot_reorder (wc_in, utf8_offsets, n_chars, indic_shape_engine->classTable, wc_out, indices, tags, &mprefixups); - - pango_glyph_string_set_size (glyphs, n_glyphs); - buffer = pango_ot_buffer_new (fc_font); - pango_ot_buffer_set_rtl (buffer, analysis->level % 2 != 0); - - set_glyphs(font, wc_out, tags, n_glyphs, buffer, - (indic_shape_engine->classTable->scriptFlags & SF_PROCESS_ZWJ) != 0); - - desc.script = analysis->script; - desc.language = analysis->language; - - desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features); - desc.static_gsub_features = gsub_features; - desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features); - desc.static_gpos_features = gpos_features; - - /* TODO populate other_features from analysis->extra_attrs */ - desc.n_other_features = 0; - desc.other_features = NULL; - - ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc); - - /* do gsub processing */ - pango_ot_ruleset_substitute (ruleset, buffer); - - /* Fix pre-modifiers for some scripts before base consonant */ - if (mprefixups) - { - indic_mprefixups_apply (mprefixups, buffer); - indic_mprefixups_free (mprefixups); - } - - /* do gpos processing */ - pango_ot_ruleset_position (ruleset, buffer); - - pango_ot_buffer_output (buffer, glyphs); - - /* Get the right log_clusters values */ - for (i = 0; i < glyphs->num_glyphs; i += 1) - glyphs->log_clusters[i] = indices[glyphs->log_clusters[i]]; - - pango_fc_font_unlock_face (fc_font); - - pango_ot_buffer_destroy (buffer); - g_free (tags); - g_free (indices); - g_free (wc_out); - g_free (wc_in); - g_free (utf8_offsets); -} - -static void -indic_engine_fc_class_init (PangoEngineShapeClass *class) -{ - class->script_shape = indic_engine_shape; -} - -PANGO_ENGINE_SHAPE_DEFINE_TYPE (IndicEngineFc, indic_engine_fc, - indic_engine_fc_class_init, NULL) - -void -PANGO_MODULE_ENTRY(init) (GTypeModule *module) -{ - indic_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) -{ - guint i; - - for (i = 0; i < G_N_ELEMENTS(script_engines); i += 1) - { - if (!strcmp(id, script_engines[i].id)) - { - IndicEngineFc *engine = g_object_new (indic_engine_fc_type, NULL); - engine->classTable = indic_ot_class_tables[i]; - - return (PangoEngine *)engine; - } - } - - return NULL; -} diff --git a/modules/indic/indic-ot-class-tables.c b/modules/indic/indic-ot-class-tables.c deleted file mode 100644 index fca63aec..00000000 --- a/modules/indic/indic-ot-class-tables.c +++ /dev/null @@ -1,524 +0,0 @@ -/* Pango - * indic-ot-class-tables.c: - * - * Copyright (C) 2001, 2002 IBM Corporation. All Rights Reserved. - * Author: Eric Mader <mader@jtcsv.com> - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished - * to do so, provided that the above copyright notice(s) and this - * permission notice appear in all copies of the Software and that - * both the above copyright notice(s) and this permission notice - * appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR - * ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written - * authorization of the copyright holder. - */ - -#include "config.h" - -#include "indic-ot.h" - - -/* - * Split matra table indices - */ -#define _x1 (1 << CF_INDEX_SHIFT) -#define _x2 (2 << CF_INDEX_SHIFT) -#define _x3 (3 << CF_INDEX_SHIFT) -#define _x4 (4 << CF_INDEX_SHIFT) -#define _x5 (5 << CF_INDEX_SHIFT) -#define _x6 (6 << CF_INDEX_SHIFT) -#define _x7 (7 << CF_INDEX_SHIFT) -#define _x8 (8 << CF_INDEX_SHIFT) -#define _x9 (9 << CF_INDEX_SHIFT) - -/* - * Simple classes - */ -#define _xx (CC_RESERVED) -#define _ma (CC_MODIFYING_MARK_ABOVE) -#define _mp (CC_MODIFYING_MARK_POST) -#define _iv (CC_INDEPENDENT_VOWEL) -#define _ct (CC_CONSONANT | CF_CONSONANT) -#define _cn (CC_CONSONANT_WITH_NUKTA | CF_CONSONANT) -#define _nu (CC_NUKTA) -#define _dv (CC_DEPENDENT_VOWEL) -#define _dl (_dv | CF_MATRA_PRE) -#define _db (_dv | CF_MATRA_BELOW) -#define _da (_dv | CF_MATRA_ABOVE) -#define _dr (_dv | CF_MATRA_POST) -#define _lm (_dv | CF_LENGTH_MARK) -#define _vr (CC_VIRAMA) -#define _al (CC_AL_LAKUNA) - -/* - * Split matras - */ -#define _s1 (_dv | _x1) -#define _s2 (_dv | _x2) -#define _s3 (_dv | _x3) -#define _s4 (_dv | _x4) -#define _s5 (_dv | _x5) -#define _s6 (_dv | _x6) -#define _s7 (_dv | _x7) -#define _s8 (_dv | _x8) -#define _s9 (_dv | _x9) - -/* - * consonants with special forms - * NOTE: this assumes that no consonants with nukta have - * special forms... (Bengali RA?) - */ -#define _bb (_ct | CF_BELOW_BASE) -#define _pb (_ct | CF_POST_BASE) -#define _vt (_bb | CF_VATTU) -#define _rv (_vt | CF_REPH) -#define _rp (_pb | CF_REPH) -#define _rb (_bb | CF_REPH) - - -/* - * Character class tables - */ -static const IndicOTCharClass devaCharClasses[] = -{ - _xx, _ma, _ma, _mp, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, /* 0900 - 090F */ - _iv, _iv, _iv, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, /* 0910 - 091F */ - _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _cn, _ct, _ct, _ct, _ct, _ct, _ct, /* 0920 - 092F */ - _rv, _cn, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _dr, _dl, /* 0930 - 093F */ - _dr, _db, _db, _db, _db, _da, _da, _da, _da, _dr, _dr, _dr, _dr, _vr, _xx, _xx, /* 0940 - 094F */ - _xx, _xx, _db, _da, _da, _xx, _xx, _xx, _cn, _cn, _cn, _cn, _cn, _cn, _cn, _cn, /* 0950 - 095F */ - _iv, _iv, _db, _db, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0960 - 096F */ - _xx, _xx, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _ct, _ct, _ct, _ct, _ct /* 0970 - 097F */ -}; - -/* As a hack, BENGALI LETTER A (U+0985) and BENGALI LETTER E (U+098F) - * are marked as consonants below; this gives approximately the - * right behavior for the sequences "a halant ya aa" and - * "e halant ya aa". - */ -static const IndicOTCharClass bengCharClasses[] = -{ - _xx, _ma, _mp, _mp, _xx, _ct, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _ct, /* 0980 - 098F */ - _iv, _xx, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, /* 0990 - 099F */ - _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _bb, _ct, _ct, _pb, /* 09A0 - 09AF */ - _rv, _xx, _ct, _xx, _xx, _xx, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _dr, _dl, /* 09B0 - 09BF */ - _dr, _db, _db, _db, _db, _xx, _xx, _dl, _dl, _xx, _xx, _s1, _s2, _vr, _xx, _xx, /* 09C0 - 09CF */ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _dr, _xx, _xx, _xx, _xx, _cn, _cn, _xx, _cn, /* 09D0 - 09DF */ - _iv, _iv, _db, _db, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 09E0 - 09EF */ - _rv, _ct, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx /* 09F0 - 09FA */ -}; - -static const IndicOTCharClass guruCharClasses[] = -{ - _xx, _ma, _ma, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _xx, _iv, /* 0A00 - 0A0F */ - _iv, _xx, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, /* 0A10 - 0A1F */ - _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _bb, /* 0A20 - 0A2F */ - _vt, _xx, _ct, _cn, _xx, _bb, _cn, _xx, _ct, _bb, _xx, _xx, _nu, _xx, _dr, _dl, /* 0A30 - 0A3F */ - _dr, _db, _db, _xx, _xx, _xx, _xx, _da, _da, _xx, _xx, _da, _da, _vr, _xx, _xx, /* 0A40 - 0A4F */ - _xx, _db, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _cn, _cn, _cn, _ct, _xx, _cn, _xx, /* 0A50 - 0A5F */ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0A60 - 0A6F */ - _ma, _ma, _iv, _iv, _xx, _db /* 0A70 - 0A75 */ -}; - -static const IndicOTCharClass gujrCharClasses[] = -{ - _xx, _ma, _ma, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _xx, _iv, /* 0A80 - 0A8F */ - _iv, _iv, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, /* 0A90 - 0A9F */ - _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _ct, /* 0AA0 - 0AAF */ - _rv, _xx, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _dr, _dl, /* 0AB0 - 0ABF */ - _dr, _db, _db, _db, _db, _da, _xx, _da, _da, _dr, _xx, _dr, _dr, _vr, _xx, _xx, /* 0AC0 - 0ACF */ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0AD0 - 0ADF */ - _iv, _xx, _db, _db, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx /* 0AE0 - 0AEF */ -}; - -static const IndicOTCharClass oryaCharClasses[] = -{ - _xx, _ma, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _iv, /* 0B00 - 0B0F */ - _iv, _xx, _xx, _iv, _iv, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _ct, _bb, /* 0B10 - 0B1F */ - _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _pb, /* 0B20 - 0B2F */ - _rb, _xx, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _xx, _xx, _nu, _xx, _dr, _da, /* 0B30 - 0B3F */ - _dr, _db, _db, _db, _db, _xx, _xx, _dl, _s1, _xx, _xx, _s2, _s3, _vr, _xx, _xx, /* 0B40 - 0B4F */ - _xx, _xx, _xx, _xx, _xx, _xx, _da, _dr, _xx, _xx, _xx, _xx, _cn, _cn, _xx, _pb, /* 0B50 - 0B5F */ - _iv, _iv, _db, _db, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0B60 - 0B6F */ - _xx, _bb /* 0B70 - 0B71 */ -}; - -static const IndicOTCharClass tamlCharClasses[] = -{ - _xx, _xx, _ma, _xx, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _iv, _iv, /* 0B80 - 0B8F */ - _iv, _xx, _iv, _iv, _iv, _ct, _xx, _xx, _xx, _ct, _ct, _xx, _ct, _xx, _ct, _ct, /* 0B90 - 0B9F */ - _xx, _xx, _xx, _ct, _ct, _xx, _xx, _xx, _ct, _ct, _ct, _xx, _xx, _xx, _ct, _ct, /* 0BA0 - 0BAF */ - _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _xx, _xx, _dr, _dr, /* 0BB0 - 0BBF */ - _da, _dr, _dr, _xx, _xx, _xx, _dl, _dl, _dl, _xx, _s1, _s2, _s3, _vr, _xx, _xx, /* 0BC0 - 0BCF */ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _dr, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0BD0 - 0BDF */ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0BE0 - 0BEF */ - _xx, _xx, _xx /* 0BF0 - 0BF2 */ -}; - -/* FIXME: Should some of the bb's be pb's? (KA, NA, MA, YA, VA, etc. (approx 13)) */ -static const IndicOTCharClass teluCharClasses[] = -{ - _xx, _mp, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _iv, /* 0C00 - 0C0F */ - _iv, _xx, _iv, _iv, _iv, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, /* 0C10 - 0C1F */ - _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _bb, /* 0C20 - 0C2F */ - _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _xx, _xx, _xx, _xx, _da, _da, /* 0C30 - 0C3F */ - _da, _dr, _dr, _lm, _lm, _xx, _da, _da, _s1, _xx, _da, _da, _da, _vr, _xx, _xx, /* 0C40 - 0C4F */ - _xx, _xx, _xx, _xx, _xx, _da, _db, _xx, _bb, _bb, _xx, _xx, _xx, _xx, _xx, _xx, /* 0C50 - 0C5F */ - _iv, _iv, _lm, _lm, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0C60 - 0C6F */ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx /* 0C70 - 0C7F */ -}; - -/* U+CC3 and U+CC4 are _lm here not _dr since the Kannada rendering - * rules want them below and to the right of the entire cluster. They - * aren't, strictly speaking, length marks, however. - * - * There's some information about this in: - * - * http://brahmi.sourceforge.net/docs/KannadaComputing.html - */ -static const IndicOTCharClass kndaCharClasses[] = -{ - _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _iv, /* 0C80 - 0C8F */ - _iv, _xx, _iv, _iv, _iv, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, /* 0C90 - 0C9F */ - _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _bb, /* 0CA0 - 0CAF */ - _rb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _xx, _xx, _nu, _xx, _dr, _da, /* 0CB0 - 0CBF */ - _s1, _dr, _dr, _lm, _lm, _xx, _da, _s2, _s3, _xx, _s4, _s5, _da, _vr, _xx, _xx, /* 0CC0 - 0CCF */ - _xx, _xx, _xx, _xx, _xx, _lm, _lm, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _ct, _xx, /* 0CD0 - 0CDF */ - _iv, _iv, _lm, _lm, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx /* 0CE0 - 0CEF */ -}; - -/* - * FIXME: this is correct for old-style Malayalam (MAL) but not for reformed Malayalam (MLR) - * FIXME: should there be a REPH for old-style Malayalam? - */ -static const IndicOTCharClass mlymCharClasses[] = -{ - _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _iv, /* 0D00 - 0D0F */ - _iv, _xx, _iv, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, /* 0D10 - 0D1F */ - _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _pb, /* 0D20 - 0D2F */ - _cn, _cn, _ct, _ct, _ct, _pb, _ct, _ct, _ct, _ct, _xx, _xx, _xx, _xx, _dr, _dr, /* 0D30 - 0D3F */ - _dr, _dr, _dr, _dr, _dr, _xx, _dl, _dl, _dl, _xx, _s1, _s2, _s3, _vr, _xx, _xx, /* 0D40 - 0D4F */ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _dr, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0D50 - 0D5F */ - _iv, _iv, _db, _db, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0D60 - 0D6F */ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx /* 0D70 - 0D7F */ -}; - -static const IndicOTCharClass sinhCharClasses[] = -{ - _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, /* 0D80 - 0D8F */ - _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _ct, _ct, _ct, _ct, _ct, _ct, /* 0D90 - 0D9F */ - _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, /* 0DA0 - 0DAF */ - _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _xx, _xx, /* 0DB0 - 0DBF */ - _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _xx, _al, _xx, _xx, _xx, _xx, _dr, /* 0DC0 - 0DCF */ - _dr, _dr, _da, _da, _db, _xx, _db, _xx, _dr, _dl, _s1, _dl, _s2, _s3, _s4, _dr, /* 0DD0 - 0DDF */ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0DE0 - 0DEF */ - _xx, _xx, _dr, _dr, _xx /* 0DF0 - 0DF4 */ -}; - - -/* - * Split matra tables - */ -static const IndicOTSplitMatra bengSplitTable[] = {{0x09C7, 0x09BE}, {0x09C7, 0x09D7}}; - -static const IndicOTSplitMatra oryaSplitTable[] = {{0x0B47, 0x0B56}, {0x0B47, 0x0B3E}, {0x0B47, 0x0B57}}; - -static const IndicOTSplitMatra tamlSplitTable[] = {{0x0BC6, 0x0BBE}, {0x0BC7, 0x0BBE}, {0x0BC6, 0x0BD7}}; - -static const IndicOTSplitMatra teluSplitTable[] = {{0x0C46, 0x0C56}}; - -static const IndicOTSplitMatra kndaSplitTable[] = {{0x0CBF, 0x0CD5}, {0x0CC6, 0x0CD5}, {0x0CC6, 0x0CD6}, {0x0CC6, 0x0CC2}, - {0x0CC6, 0x0CC2, 0x0CD5}}; - -static const IndicOTSplitMatra mlymSplitTable[] = {{0x0D46, 0x0D3E}, {0x0D47, 0x0D3E}, {0x0D46, 0x0D57}}; - -static const IndicOTSplitMatra sinhSplitTable[] = {{0x0DD9, 0x0DCA}, {0x0DD9, 0x0DCF}, {0x0DD9, 0x0DCF, 0x0DCA}, - {0x0DD9, 0x0DDF} }; - - -/* - * Script Flags - */ - -/* - * FIXME: post 'GSUB' reordering of MATRA_PRE's for Malayalam and Tamil - * FIXME: reformed Malayalam needs to reorder VATTU to before base glyph... - * FIXME: eyelash RA only for Devanagari?? - */ -#define DEVA_SCRIPT_FLAGS (SF_EYELASH_RA | SF_NO_POST_BASE_LIMIT) -#define BENG_SCRIPT_FLAGS (SF_REPH_AFTER_BELOW | SF_NO_POST_BASE_LIMIT) -#define GURU_SCRIPT_FLAGS (SF_NO_POST_BASE_LIMIT) -#define GUJR_SCRIPT_FLAGS (SF_NO_POST_BASE_LIMIT) -#define ORYA_SCRIPT_FLAGS (SF_REPH_AFTER_BELOW | SF_NO_POST_BASE_LIMIT) -#define TAML_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT) -#define TELU_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | 3) -#define KNDA_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | 3) -#define MLYM_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT | SF_PROCESS_ZWJ) -#define SINH_SCRIPT_FLAGS (SF_NO_POST_BASE_LIMIT | SF_PROCESS_ZWJ) - -/* - * Indic Class Tables - */ -/* Add a little macro to compute lastChar based on size of the charClasses * table */ -#define INDIC_OT_CLASS_TABLE_DEFINE(name, firstChar, worstCaseExpansion, scriptFlags, charClasses, splitMatraTable) \ - const IndicOTClassTable name = {firstChar, firstChar + G_N_ELEMENTS (charClasses) - 1, \ - worstCaseExpansion, scriptFlags, charClasses, splitMatraTable} -INDIC_OT_CLASS_TABLE_DEFINE (deva_class_table, 0x0900, 2, DEVA_SCRIPT_FLAGS, devaCharClasses, NULL); -INDIC_OT_CLASS_TABLE_DEFINE (beng_class_table, 0x0980, 3, BENG_SCRIPT_FLAGS, bengCharClasses, bengSplitTable); -INDIC_OT_CLASS_TABLE_DEFINE (guru_class_table, 0x0A00, 2, GURU_SCRIPT_FLAGS, guruCharClasses, NULL); -INDIC_OT_CLASS_TABLE_DEFINE (gujr_class_table, 0x0A80, 2, GUJR_SCRIPT_FLAGS, gujrCharClasses, NULL); -INDIC_OT_CLASS_TABLE_DEFINE (orya_class_table, 0x0B00, 3, ORYA_SCRIPT_FLAGS, oryaCharClasses, oryaSplitTable); -INDIC_OT_CLASS_TABLE_DEFINE (taml_class_table, 0x0B80, 3, TAML_SCRIPT_FLAGS, tamlCharClasses, tamlSplitTable); -INDIC_OT_CLASS_TABLE_DEFINE (telu_class_table, 0x0C00, 3, TELU_SCRIPT_FLAGS, teluCharClasses, teluSplitTable); -INDIC_OT_CLASS_TABLE_DEFINE (knda_class_table, 0x0C80, 4, KNDA_SCRIPT_FLAGS, kndaCharClasses, kndaSplitTable); -INDIC_OT_CLASS_TABLE_DEFINE (mlym_class_table, 0x0D00, 3, MLYM_SCRIPT_FLAGS, mlymCharClasses, mlymSplitTable); -INDIC_OT_CLASS_TABLE_DEFINE (sinh_class_table, 0x0D80, 4, SINH_SCRIPT_FLAGS, sinhCharClasses, sinhSplitTable); - -const IndicOTSplitMatra *indic_ot_get_split_matra(const IndicOTClassTable *class_table, IndicOTCharClass char_class) -{ - gint32 index = (char_class & CF_INDEX_MASK) >> CF_INDEX_SHIFT; - - return &class_table->splitMatraTable[index - 1]; -} - -gboolean indic_ot_is_vm_above(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_VM_ABOVE(char_class); -} - -gboolean indic_ot_is_vm_post(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_VM_POST(char_class); -} - -gboolean indic_ot_is_consonant(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_CONSONANT(char_class); -} - -gboolean indic_ot_is_reph(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_REPH(char_class); -} - -gboolean indic_ot_is_virama(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return (IS_VIRAMA(char_class) || IS_AL_LAKUNA(char_class)); -} - -gboolean indic_ot_is_al_lakuna(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_AL_LAKUNA(char_class); -} - -gboolean indic_ot_is_nukta(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_NUKTA(char_class); -} - -gboolean indic_ot_is_vattu(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_VATTU(char_class); -} - -gboolean indic_ot_is_matra(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_MATRA(char_class); -} - -gboolean indic_ot_is_split_matra(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_SPLIT_MATRA(char_class); -} - -gboolean indic_ot_is_m_pre(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_M_PRE(char_class); -} - -gboolean indic_ot_is_m_below(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_M_BELOW(char_class); -} - -gboolean indic_ot_is_m_above(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_M_ABOVE(char_class); -} - -gboolean indic_ot_is_m_post(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_M_POST(char_class); -} - -gboolean indic_ot_is_length_mark(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return IS_LENGTH_MARK(char_class); -} - -gboolean indic_ot_has_post_or_below_base_form(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return HAS_POST_OR_BELOW_BASE_FORM(char_class); -} - -gboolean indic_ot_has_post_base_form(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return HAS_POST_BASE_FORM(char_class); -} - -gboolean indic_ot_has_below_base_form(const IndicOTClassTable *class_table, gunichar ch) -{ - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, ch); - - return HAS_BELOW_BASE_FORM(char_class); -} - -IndicOTCharClass indic_ot_get_char_class(const IndicOTClassTable *class_table, gunichar ch) -{ - if (ch == C_SIGN_ZWJ) { - return CF_CONSONANT | CC_ZERO_WIDTH_MARK; - } - - if (ch == C_SIGN_ZWNJ) { - return CC_ZERO_WIDTH_MARK; - } - - if (ch < class_table->firstChar || ch > class_table->lastChar) { - return CC_RESERVED; - } - - return class_table->charClasses[ch - class_table->firstChar]; -} - -static const gint8 stateTable[][CC_COUNT] = -{ -/* xx ma mp iv ct cn nu dv vr zw al */ - { 1, 1, 1, 5, 3, 2, 1, 1, 1, 1, 1}, - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, - {-1, 6, 1, -1, -1, -1, -1, 5, 4, -1, -1}, - {-1, 6, 1, -1, -1, -1, 2, 5, 4, 10, 9}, - {-1, -1, -1, -1, 3, 2, -1, -1, -1, 8, -1}, - {-1, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1}, - {-1, 7, 1, -1, -1, -1, -1, -1, -1, -1, -1}, - {-1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, 3, 2, -1, -1, -1, -1, -1}, - {-1, -1, -1, -1, -1, -1, -1, -1, -1, 8, -1}, - {-1, -1, -1, -1, -1, -1, -1, -1, 8, -1, 8} - -}; - -glong indic_ot_find_syllable(const IndicOTClassTable *class_table, const gunichar *chars, glong prev, glong char_count) -{ - glong cursor = prev; - gint8 state = 0; - - while (cursor < char_count) { - IndicOTCharClass char_class = indic_ot_get_char_class(class_table, chars[cursor]); - - state = stateTable[state][char_class & CF_CLASS_MASK]; - - /*for the components of split matra*/ - if ((char_count >= cursor + 3) && - (chars[cursor] == 0x0DD9 && chars[cursor + 1] == 0x0DCF && chars[cursor + 2] == 0x0DCA)) { /*for 3 split matra of Sinhala*/ - return cursor + 3; - } - else if ((char_count >= cursor + 3) && - (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CC2 && chars[cursor + 2] == 0x0CD5)) { /*for 3 split matra of Kannada*/ - return cursor + 3; - } - /*for 2 split matra*/ - else if (char_count >= cursor + 2) { - /*for Bengali*/ - if ((chars[cursor] == 0x09C7 && chars[cursor + 1] == 0x09BE) || - (chars[cursor] == 0x09C7 && chars[cursor + 1] == 0x09D7) || - /*for Oriya*/ - (chars[cursor] == 0x0B47 && chars[cursor + 1] == 0x0B3E) || - (chars[cursor] == 0x0B47 && chars[cursor + 1] == 0x0B56) || - (chars[cursor] == 0x0B47 && chars[cursor + 1] == 0x0B57) || - /*for Tamil*/ - (chars[cursor] == 0x0BC6 && chars[cursor + 1] == 0x0BBE) || - (chars[cursor] == 0x0BC6 && chars[cursor + 1] == 0x0BD7) || - (chars[cursor] == 0x0BC7 && chars[cursor + 1] == 0x0BBE) || - /*for Malayalam*/ - (chars[cursor] == 0x0D46 && chars[cursor + 1] == 0x0D3E) || - (chars[cursor] == 0x0D46 && chars[cursor + 1] == 0x0D57) || - (chars[cursor] == 0x0D47 && chars[cursor + 1] == 0x0D3E) || - /*for Sinhala*/ - (chars[cursor] == 0x0DD9 && chars[cursor + 1] == 0x0DCA) || - (chars[cursor] == 0x0DD9 && chars[cursor + 1] == 0x0DCF) || - (chars[cursor] == 0x0DD9 && chars[cursor + 1] == 0x0DDF) || - (chars[cursor] == 0x0DDC && chars[cursor + 1] == 0x0DCA) || - /*for Telugu*/ - (chars[cursor] == 0x0C46 && chars[cursor + 1] == 0x0C56) || - /*for Kannada*/ - (chars[cursor] == 0x0CBF && chars[cursor + 1] == 0x0CD5) || - (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CD5) || - (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CD6) || - (chars[cursor] == 0x0CC6 && chars[cursor + 1] == 0x0CC2) || - (chars[cursor] == 0x0CCA && chars[cursor + 1] == 0x0CD5)) - return cursor + 2; - } - - if (state < 0) { - break; - } - - cursor += 1; - } - - return cursor; -} - diff --git a/modules/indic/indic-ot.c b/modules/indic/indic-ot.c deleted file mode 100644 index 60f253b6..00000000 --- a/modules/indic/indic-ot.c +++ /dev/null @@ -1,520 +0,0 @@ -/* Pango - * indic-ot.c: - * - * Copyright (C) 2001, 2002 IBM Corporation. All Rights Reserved. - * Author: Eric Mader <mader@jtcsv.com> - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished - * to do so, provided that the above copyright notice(s) and this - * permission notice appear in all copies of the Software and that - * both the above copyright notice(s) and this permission notice - * appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR - * ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written - * authorization of the copyright holder. - */ - -#include "config.h" - -#include "indic-ot.h" -#include "mprefixups.h" -/* - * FIXME: should the IndicOutput stuff be moved - * to a separate .h and .c file just to keep the - * clutter down here? (it's not really usefull - * anyplace else, is it?) - */ -struct _Output -{ - glong fOutIndex; - - const glong *fOriginalOffsets; - - gunichar *fOutChars; - glong *fCharIndices; - gulong *fCharTags; - - gunichar fMpre; - gunichar fMbelow; - gunichar fMabove; - gunichar fMpost; - gunichar fLengthMark; - gunichar fAlLakuna; /* to handle Al-Lakuna in sinhala split matras */ - glong fMatraIndex; - gulong fMatraTags; - gboolean fMatraWordStart; - glong fMPreOutIndex; - - MPreFixups *fMPreFixups; -}; - -typedef struct _Output Output; - -static void initOutput(Output *output, const glong *originalOffsets, gunichar *outChars, glong *charIndices, gulong *charTags, MPreFixups *mpreFixups) -{ - output->fOriginalOffsets = originalOffsets; - - output->fOutChars = outChars; - output->fCharIndices = charIndices; - output->fCharTags = charTags; - - output->fOutIndex = 0; - output->fMatraTags = 0; - - output->fMpre = output->fMbelow = output->fMabove = output->fMpost = output->fLengthMark = output->fAlLakuna = 0; - - output->fMPreOutIndex = -1; - output->fMPreFixups = mpreFixups; -} - -static void saveMatra(Output *output, gunichar matra, IndicOTCharClass matraClass) -{ - /* FIXME: check if already set, or if not a matra... */ - if (IS_M_PRE(matraClass)) { - output->fMpre = matra; - } else if (IS_M_BELOW(matraClass)) { - output->fMbelow = matra; - } else if (IS_M_ABOVE(matraClass)) { - output->fMabove = matra; - } else if (IS_M_POST(matraClass)) { - output->fMpost = matra; - } else if (IS_LENGTH_MARK(matraClass)) { - output->fLengthMark = matra; - } else if (IS_AL_LAKUNA(matraClass)) { - output->fAlLakuna = matra; - } -} - -static void initMatra(Output *output, guint32 matraIndex, gulong matraTags, gboolean wordStart) -{ - output->fMpre = output->fMbelow = output->fMabove = output->fMpost = output->fLengthMark = output->fAlLakuna = 0; - output->fMPreOutIndex = -1; - output->fMatraIndex = matraIndex; - output->fMatraTags = matraTags; - output->fMatraWordStart = wordStart; -} - -static gboolean noteMatra(Output *output, const IndicOTClassTable *classTable, gunichar matra) -{ - IndicOTCharClass matraClass = indic_ot_get_char_class(classTable, matra); - - if (IS_MATRA(matraClass)) { - if (IS_SPLIT_MATRA(matraClass)) { - const IndicOTSplitMatra *splitMatra = indic_ot_get_split_matra(classTable, matraClass); - int i; - - for (i = 0; i < 3 && (*splitMatra)[i] != 0; i += 1) { - gunichar piece = (*splitMatra)[i]; - IndicOTCharClass pieceClass = indic_ot_get_char_class(classTable, piece); - - saveMatra(output, piece, pieceClass); - } - } else { - saveMatra(output, matra, matraClass); - } - - return TRUE; - } else - return FALSE; -} - -static void noteBaseConsonant(Output *output) -{ - if (output->fMPreFixups && output->fMPreOutIndex >= 0) { - indic_mprefixups_add(output->fMPreFixups, output->fOutIndex, output->fMPreOutIndex); - } -} - -static void writeChar(Output *output, gunichar ch, guint32 charIndex, gulong charTags) -{ - if (output->fOutChars != NULL) { - output->fOutChars[output->fOutIndex] = ch; - output->fCharIndices[output->fOutIndex] = output->fOriginalOffsets[charIndex]; - output->fCharTags[output->fOutIndex] = charTags; - } - - output->fOutIndex += 1; -} - -static void writeMpre(Output *output) -{ - if (output->fMpre != 0) { - gulong tags = output->fMatraTags; - if (output->fMatraWordStart) - tags &= ~init; - - output->fMPreOutIndex = output->fOutIndex; - writeChar(output, output->fMpre, output->fMatraIndex, tags); - } -} - -static void writeMbelow(Output *output) -{ - if (output->fMbelow != 0) { - writeChar(output, output->fMbelow, output->fMatraIndex, output->fMatraTags); - } -} - -static void writeMabove(Output *output) -{ - if (output->fMabove != 0) { - writeChar(output, output->fMabove, output->fMatraIndex, output->fMatraTags); - } -} - -static void writeMpost(Output *output) -{ - if (output->fMpost != 0) { - writeChar(output, output->fMpost, output->fMatraIndex, output->fMatraTags); - } -} - -static void writeLengthMark(Output *output) -{ - if (output->fLengthMark != 0) { - writeChar(output, output->fLengthMark, output->fMatraIndex, output->fMatraTags); - } -} - -static void writeAlLakuna(Output *output) -{ - if (output->fAlLakuna != 0) { - writeChar(output, output->fAlLakuna, output->fMatraIndex, output->fMatraTags); - } -} - -static glong getOutputIndex(Output *output) -{ - return output->fOutIndex; -} - -#define false 0 -#define true 1 - -glong indic_ot_reorder(const gunichar *chars, const glong *utf8_offsets, glong char_count, const IndicOTClassTable *class_table, gunichar *out_chars, glong *char_indices, gulong *char_tags, MPreFixups **outMPreFixups) -{ - MPreFixups *mpreFixups = NULL; - Output output; - glong i, prev = 0; - gboolean last_in_word = FALSE; - - if (outMPreFixups && (class_table->scriptFlags & SF_MPRE_FIXUP)) { - mpreFixups = indic_mprefixups_new (char_count); - } - - initOutput(&output, utf8_offsets, out_chars, char_indices, char_tags, mpreFixups); - - while (prev < char_count) { - glong syllable = indic_ot_find_syllable(class_table, chars, prev, char_count); - glong matra, vmabove, vmpost = syllable; - - while (vmpost > prev && indic_ot_is_vm_post(class_table, chars[vmpost - 1])) { - vmpost -= 1; - } - - vmabove = vmpost; - while (vmabove > prev && indic_ot_is_vm_above(class_table, chars[vmabove - 1])) { - vmabove -= 1; - } - - matra = vmabove - 1; - initMatra(&output, prev, blwf_p, !last_in_word); - while (noteMatra(&output, class_table, chars[matra]) && - matra != prev) - matra--; - - last_in_word = TRUE; - switch (indic_ot_get_char_class(class_table, chars[prev]) & CF_CLASS_MASK) { - case CC_RESERVED: - last_in_word = FALSE; - /* Fall through */ - case CC_INDEPENDENT_VOWEL: - case CC_ZERO_WIDTH_MARK: - for (i = prev; i < syllable; i += 1) { - writeChar(&output, chars[i], /*i*/ prev, blwf_p); - } - - break; - - case CC_MODIFYING_MARK_ABOVE: - case CC_MODIFYING_MARK_POST: - case CC_NUKTA: - case CC_VIRAMA: - /* patch for rendering fix for Malayalam SAMVRUTHOKARA by suresh */ - if (chars[prev - 1] == 0x0D41) { - writeChar(&output, chars[prev], prev, blwf_p); - break; - } - /* end patch */ - - case CC_AL_LAKUNA: - writeChar(&output, C_DOTTED_CIRCLE, prev, blwf_p); - writeChar(&output, chars[prev], prev, blwf_p); - break; - - case CC_DEPENDENT_VOWEL: - writeMpre(&output); - writeChar(&output, C_DOTTED_CIRCLE, prev, blwf_p); - writeMbelow(&output); - writeMabove(&output); - writeMpost(&output); - writeLengthMark(&output); - writeAlLakuna(&output); - break; - - case CC_CONSONANT: - case CC_CONSONANT_WITH_NUKTA: - { - guint32 length = vmabove - prev; - glong lastConsonant = vmabove - 1; - glong baseLimit = prev; - glong baseConsonant, postBase, postBaseLimit; - gboolean seenVattu, seenBelowBaseForm, supressVattu; - glong bcSpan; - - /* Check for REPH at front of syllable */ - if (length > 2 && indic_ot_is_reph(class_table, chars[prev]) && indic_ot_is_virama(class_table, chars[prev + 1])) { - baseLimit += 2; - - /* Check for eyelash RA, if the script supports it */ - if ((class_table->scriptFlags & SF_EYELASH_RA) != 0 && - chars[baseLimit] == C_SIGN_ZWJ) { - if (length > 3) { - baseLimit += 1; - } else { - baseLimit -= 2; - } - } - } - - while (lastConsonant > baseLimit && !indic_ot_is_consonant(class_table, chars[lastConsonant])) { - lastConsonant -= 1; - } - - baseConsonant = lastConsonant; - postBase = lastConsonant + 1; - - postBaseLimit = class_table->scriptFlags & SF_POST_BASE_LIMIT_MASK; - seenVattu = false; - seenBelowBaseForm = false; - - while (baseConsonant > baseLimit) { - IndicOTCharClass charClass = indic_ot_get_char_class(class_table, chars[baseConsonant]); - - if (IS_CONSONANT(charClass)) { - if (postBaseLimit == 0 || seenVattu || - (baseConsonant > baseLimit && !indic_ot_is_virama(class_table, chars[baseConsonant - 1])) || - !HAS_POST_OR_BELOW_BASE_FORM(charClass)) { - break; - } - - seenVattu = IS_VATTU(charClass); - - if (HAS_POST_BASE_FORM(charClass)) { - if (seenBelowBaseForm) { - break; - } - - postBase = baseConsonant; - } else if (HAS_BELOW_BASE_FORM(charClass)) { - seenBelowBaseForm = true; - } - - postBaseLimit -= 1; - } - - baseConsonant -= 1; - } - - /* Write Mpre */ - writeMpre(&output); - - /* Write eyelash RA */ - /* NOTE: baseLimit == prev + 3 iff eyelash RA present... */ - if (baseLimit == prev + 3) { - writeChar(&output, chars[prev], prev, half_p); - writeChar(&output, chars[prev + 1], prev /*+ 1*/, half_p); - writeChar(&output, chars[prev + 2], prev /*+ 2*/, half_p); - } - - /* write any pre-base consonants */ - supressVattu = true; - - for (i = baseLimit; i < baseConsonant; i += 1) { - gunichar ch = chars[i]; - /* Applying blwf to the first consonant doesn't makes sense - * since the below-form follows the consonant that it is - * put under */ - gulong tag = (i == baseLimit) ? half_p : blwf_p; - IndicOTCharClass charClass = indic_ot_get_char_class(class_table, ch); - - if (IS_CONSONANT(charClass)) { - if (IS_VATTU(charClass) && supressVattu) { - tag = nukt_p; - } - else if ((i + 2 < baseConsonant) && (chars[i + 2] == C_SIGN_ZWNJ)) { - tag = nukt_p; - } - - supressVattu = IS_VATTU(charClass); - } else if (IS_VIRAMA(charClass) && chars[i + 1] == C_SIGN_ZWNJ) - { - tag = nukt_p; - } - - writeChar(&output, ch, /*i*/ prev, tag); - } - - bcSpan = baseConsonant + 1; - - if (bcSpan < vmabove && indic_ot_is_nukta(class_table, chars[bcSpan])) { - bcSpan += 1; - } - - if (baseConsonant == lastConsonant && bcSpan < vmabove && indic_ot_is_virama(class_table, chars[bcSpan])) { - bcSpan += 1; - - if (bcSpan < vmabove && chars[bcSpan] == C_SIGN_ZWNJ) { - bcSpan += 1; - } - } - - /* note the base consonant for post-GSUB fixups */ - noteBaseConsonant(&output); - - /* write base consonant */ - for (i = baseConsonant; i < bcSpan; i += 1) { - writeChar(&output, chars[i], /*i*/ prev, nukt_p); - } - - if ((class_table->scriptFlags & SF_MATRAS_AFTER_BASE) != 0) { - gboolean is_for_0C48 = FALSE; - if (output.fOutChars != NULL) { /*for 0x0C48 of Telugu*/ - int t; - for (t = prev; t < syllable; t++) { - if (chars[t] == 0x0C48) { - writeMabove(&output); - writeMbelow(&output); - writeMpost(&output); - - is_for_0C48 = TRUE; - break; - } - } - } - - if (!is_for_0C48) { - writeMbelow(&output); - writeMabove(&output); - writeMpost(&output); - } - } - - /* write below-base consonants */ - if (baseConsonant != lastConsonant) { - for (i = bcSpan + 1; i < postBase; i += 1) { - writeChar(&output, chars[i], /*i*/ prev, blwf_p); - } - - if (postBase > lastConsonant) { - /* write halant that was after base consonant */ - writeChar(&output, chars[bcSpan], /*bcSpan*/ prev, blwf_p); - } - } - - /* write Mbelow, Mabove */ - if ((class_table->scriptFlags & SF_MATRAS_AFTER_BASE) == 0) { - writeMbelow(&output); - writeMabove(&output); - } - - if ((class_table->scriptFlags & SF_REPH_AFTER_BELOW) != 0) { - if (baseLimit == prev + 2) { - writeChar(&output, chars[prev], prev, rphf_p); - writeChar(&output, chars[prev + 1], prev /*+ 1*/, rphf_p); - } - - /* write VMabove */ - for (i = vmabove; i < vmpost; i += 1) { - writeChar(&output, chars[i], /*i*/ prev, blwf_p); - } - } - - /* write post-base consonants */ - if (baseConsonant != lastConsonant) { - if (postBase <= lastConsonant) { - for (i = postBase; i <= lastConsonant; i += 1) { - writeChar(&output, chars[i], /*i*/ prev, pstf_p); - } - - /* write halant that was after base consonant */ - writeChar(&output, chars[bcSpan], /*bcSpan*/ prev, blwf_p); - } - - /* write the training halant, if there is one */ - if (lastConsonant < matra && indic_ot_is_virama(class_table, chars[matra])) { - writeChar(&output, chars[matra], /*matra*/ prev, nukt_p); - } - } - - /* write Mpost */ - if ((class_table->scriptFlags & SF_MATRAS_AFTER_BASE) == 0) { - writeMpost(&output); - } - - writeLengthMark(&output); - writeAlLakuna(&output); - - /* write reph */ - if ((class_table->scriptFlags & SF_REPH_AFTER_BELOW) == 0) { - if (baseLimit == prev + 2) { - writeChar(&output, chars[prev], prev, rphf_p); - writeChar(&output, chars[prev + 1], prev /*+ 1*/, rphf_p); - } - - /* write VMabove */ - for (i = vmabove; i < vmpost; i += 1) { - writeChar(&output, chars[i], /*i*/ prev, blwf_p); - } - } - - /* write VMpost */ - for (i = vmpost; i < syllable; i += 1) { - writeChar(&output, chars[i], /*i*/ prev, blwf_p); - } - - break; - } - - default: - break; - } - - - prev = syllable; - } - - if (outMPreFixups) { - *outMPreFixups = mpreFixups; - } - - return getOutputIndex(&output); -} diff --git a/modules/indic/indic-ot.h b/modules/indic/indic-ot.h deleted file mode 100644 index 47dd39f2..00000000 --- a/modules/indic/indic-ot.h +++ /dev/null @@ -1,238 +0,0 @@ -/* Pango - * indic-ot.h: - * - * Copyright (C) 2001, 2002 IBM Corporation. All Rights Reserved. - * Author: Eric Mader <mader@jtcsv.com> - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished - * to do so, provided that the above copyright notice(s) and this - * permission notice appear in all copies of the Software and that - * both the above copyright notice(s) and this permission notice - * appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR - * ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written - * authorization of the copyright holder. - */ - -#ifndef __INDIC_OT_H__ -#define __INDIC_OT_H__ - -#include <pango/pango-glyph.h> -#include <pango/pango-types.h> -#include "mprefixups.h" - -G_BEGIN_DECLS - -#ifdef PANGO_ENABLE_ENGINE - -/* Characters that get refered to by name... */ -#define C_SIGN_ZWNJ 0x200C -#define C_SIGN_ZWJ 0x200D -#define C_DOTTED_CIRCLE 0x25CC - -/* - * The characters that a split matra splits into. - * Unused characters will be zero. - */ -typedef gunichar IndicOTSplitMatra[3]; - -/* - * Character class values - */ -typedef enum -{ - CC_RESERVED, - CC_MODIFYING_MARK_ABOVE, - CC_MODIFYING_MARK_POST, - CC_INDEPENDENT_VOWEL, - CC_CONSONANT, - CC_CONSONANT_WITH_NUKTA, - CC_NUKTA, - CC_DEPENDENT_VOWEL, - CC_VIRAMA, - CC_ZERO_WIDTH_MARK, - CC_AL_LAKUNA, - CC_COUNT -} IndicOTCharClassValues; - -/* - * Character class flags - */ -#define CF_CLASS_MASK 0x0000FFFFU - -#define CF_CONSONANT 0x80000000U - -#define CF_REPH 0x40000000U -#define CF_VATTU 0x20000000U -#define CF_BELOW_BASE 0x10000000U -#define CF_POST_BASE 0x08000000U - -#define CF_MATRA_PRE 0x04000000U -#define CF_MATRA_BELOW 0x02000000U -#define CF_MATRA_ABOVE 0x01000000U -#define CF_MATRA_POST 0x00800000U -#define CF_LENGTH_MARK 0x00400000U - -#define CF_INDEX_MASK 0x000F0000U -#define CF_INDEX_SHIFT 16 - -/* - * Character class: a character class value - * ORed with character class flags. - */ -typedef glong IndicOTCharClass; - -/* - * Script flags - */ -#define SF_MATRAS_AFTER_BASE 0x80000000U -#define SF_REPH_AFTER_BELOW 0x40000000U -#define SF_EYELASH_RA 0x20000000U -#define SF_MPRE_FIXUP 0x10000000U -#define SF_PROCESS_ZWJ 0x08000000U - -#define SF_POST_BASE_LIMIT_MASK 0x0000FFFFU -#define SF_NO_POST_BASE_LIMIT 0x00007FFFU - -typedef guint32 IndicOTScriptFlags; - -/* - * Bit flags for the indic feature tags - */ -enum indic_glyph_feature_ -{ - nukt = 0x0001, - akhn = 0x0002, - rphf = 0x0004, - blwf = 0x0008, - half = 0x0010, - pstf = 0x0020, - vatu = 0x0040, - pres = 0x0080, - blws = 0x0100, - abvs = 0x0200, - psts = 0x0400, - haln = 0x0800, - blwm = 0x1000, - abvm = 0x2000, - dist = 0x4000, - junk = 0x8000, - init = 0x10000 -}; - -/* - * Complement of the feature flags that - * will be assigned to specific glyphs. - * - * The names come from the ICU implementation, - * which listed the actual tags in an order - * such that tags could be assigned using the - * address of the first one: &tags[0], &tags[1], - * &tags[2], &tags[3]. The name of each set here - * is the name of the first tag in the ICU list. - */ -enum indic_glyph_property_ -{ - rphf_p = (junk | dist | init), - blwf_p = (junk | dist | init | rphf), - half_p = (junk | dist | init | rphf | blwf), - pstf_p = (junk | dist | init | rphf | blwf | half), - nukt_p = (junk | dist | init | rphf | blwf | half | pstf) -}; - -/* - * Macros to test the charClass flags for various things. - */ -#define IS_VM_ABOVE(charClass) ((charClass & CF_CLASS_MASK) == CC_MODIFYING_MARK_ABOVE) -#define IS_VM_POST(charClass) ((charClass & CF_CLASS_MASK) == CC_MODIFYING_MARK_POST) -#define IS_CONSONANT(charClass) ((charClass & CF_CONSONANT) != 0) -#define IS_REPH(charClass) ((charClass & CF_REPH) != 0) -#define IS_NUKTA(charClass) ((charClass & CF_CLASS_MASK) == CC_NUKTA) -#define IS_VIRAMA(charClass) ((charClass & CF_CLASS_MASK) == CC_VIRAMA) -#define IS_AL_LAKUNA(charClass) ((charClass & CF_CLASS_MASK) == CC_AL_LAKUNA) -#define IS_VATTU(charClass) ((charClass & CF_VATTU) != 0) -#define IS_MATRA(charClass) ((charClass & CF_CLASS_MASK) == CC_DEPENDENT_VOWEL) -#define IS_SPLIT_MATRA(charClass) ((charClass & CF_INDEX_MASK) != 0) -#define IS_M_PRE(charClass) ((charClass & CF_MATRA_PRE) != 0) -#define IS_M_BELOW(charClass) ((charClass & CF_MATRA_BELOW) != 0) -#define IS_M_ABOVE(charClass) ((charClass & CF_MATRA_ABOVE) != 0) -#define IS_M_POST(charClass) ((charClass & CF_MATRA_POST) != 0) -#define IS_LENGTH_MARK(charClass) ((charClass & CF_LENGTH_MARK) != 0) -#define HAS_POST_OR_BELOW_BASE_FORM(charClass) ((charClass & (CF_POST_BASE | CF_BELOW_BASE)) != 0) -#define HAS_POST_BASE_FORM(charClass) ((charClass & CF_POST_BASE) != 0) -#define HAS_BELOW_BASE_FORM(charClass) ((charClass & CF_BELOW_BASE) != 0) - -struct _IndicOTClassTable -{ - gunichar firstChar; - gunichar lastChar; - glong worstCaseExpansion; - IndicOTScriptFlags scriptFlags; - - const IndicOTCharClass *charClasses; - const IndicOTSplitMatra *splitMatraTable; -}; - -typedef struct _IndicOTClassTable IndicOTClassTable; - -extern const IndicOTClassTable deva_class_table; -extern const IndicOTClassTable beng_class_table; -extern const IndicOTClassTable guru_class_table; -extern const IndicOTClassTable gujr_class_table; -extern const IndicOTClassTable orya_class_table; -extern const IndicOTClassTable taml_class_table; -extern const IndicOTClassTable telu_class_table; -extern const IndicOTClassTable knda_class_table; -extern const IndicOTClassTable mlym_class_table; -extern const IndicOTClassTable sinh_class_table; - -const IndicOTSplitMatra *indic_ot_get_split_matra(const IndicOTClassTable *class_table, IndicOTCharClass char_class); - -IndicOTCharClass indic_ot_get_char_class(const IndicOTClassTable *class_table, gunichar ch); - -gboolean indic_ot_is_vm_above(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_vm_post(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_consonant(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_reph(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_virama(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_al_lakuna(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_nukta(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_vattu(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_matra(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_split_matra(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_m_pre(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_m_below(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_m_above(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_m_post(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_is_length_mark(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_has_post_or_below_base_form(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_has_post_base_form(const IndicOTClassTable *class_table, gunichar ch); -gboolean indic_ot_has_below_base_form(const IndicOTClassTable *class_table, gunichar ch); - -glong indic_ot_find_syllable(const IndicOTClassTable *class_table, const gunichar *chars, glong prev, glong char_count); - -glong indic_ot_reorder(const gunichar *chars, const glong *utf8_offsets, glong char_count, const IndicOTClassTable *class_table, gunichar *out_chars, glong *char_indices, gulong *char_tags, MPreFixups **outMPreFixups); - -#endif /* PANGO_ENABLE_ENGINE */ - -G_END_DECLS - -#endif /* __INDIC_OT_H__ */ diff --git a/modules/indic/mprefixups.c b/modules/indic/mprefixups.c deleted file mode 100644 index a599e6d6..00000000 --- a/modules/indic/mprefixups.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * mprefixups.h: Handle left matra placement - * - * Author: Sivaraj Doddannan - * Ported from IBM's ICU engine. Original copyright: - * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#include <pango/pango-types.h> -#include "mprefixups.h" -#include <stdio.h> - -struct _FixupData -{ - glong fBaseIndex; - glong fMPreIndex; -}; - -MPreFixups *indic_mprefixups_new(glong char_count) -{ - MPreFixups *mprefixups = g_new (MPreFixups, 1); - mprefixups->fFixupCount = 0; - mprefixups->fFixupData = g_new (FixupData, char_count); - - return mprefixups; -} - -void indic_mprefixups_free (MPreFixups *mprefixups) -{ - g_free (mprefixups->fFixupData); - g_free (mprefixups); -} - -void indic_mprefixups_add (MPreFixups *mprefixups, glong baseIndex, glong mpreIndex) -{ - /* NOTE: don't add the fixup data if the mpre is right - * before the base consonant glyph. - */ - if (baseIndex - mpreIndex > 1) { - mprefixups->fFixupData[mprefixups->fFixupCount].fBaseIndex = baseIndex; - mprefixups->fFixupData[mprefixups->fFixupCount].fMPreIndex = mpreIndex; - - mprefixups->fFixupCount += 1; - } -} - -void indic_mprefixups_apply(MPreFixups *mprefixups, PangoOTBuffer *buffer) -{ - glong fixup; - - for (fixup = 0; fixup < mprefixups->fFixupCount; fixup += 1) { - gulong baseIndex = mprefixups->fFixupData[fixup].fBaseIndex; - gulong mpreIndex = mprefixups->fFixupData[fixup].fMPreIndex; - glong baseGlyph = -1; - glong mpreGlyph = -1; - glong mpreLimit = -1; - glong mpreCount, moveCount, mpreDest; - glong i; - PangoOTGlyph *glyphs; - int n_glyphs; - PangoOTGlyph *mpreSave; - - /* determine post GSUB location of baseIndex and mpreIndex */ - - pango_ot_buffer_get_glyphs (buffer, &glyphs, &n_glyphs); - - for (i = 0; i < n_glyphs; i++) { - if ((baseIndex >= glyphs[i].cluster) && (baseIndex-glyphs[i].cluster) % 2 == 0) /* bug 441654 */ - baseGlyph = i; - if (glyphs[i].cluster == mpreIndex) { - if (mpreGlyph < 0) - mpreGlyph = i; - mpreLimit = i + 1; - } - } - if (baseGlyph < 0 || mpreGlyph < 0 || mpreLimit >= baseGlyph) { - continue; - } - - mpreCount = mpreLimit - mpreGlyph; - moveCount = baseGlyph - mpreLimit; - mpreDest = baseGlyph - mpreCount; - - mpreSave = g_new (PangoOTGlyph, mpreCount); - - for (i = 0; i < mpreCount; i += 1) { - mpreSave[i] = glyphs[mpreGlyph + i]; - } - - for (i = 0; i < moveCount; i += 1) { - glyphs[mpreGlyph + i] = glyphs[mpreLimit + i]; - } - - for (i = 0; i < mpreCount; i += 1) { - glyphs[mpreDest + i] = mpreSave[i]; - } - - g_free(mpreSave); - } -} diff --git a/modules/indic/mprefixups.h b/modules/indic/mprefixups.h deleted file mode 100644 index 22336dba..00000000 --- a/modules/indic/mprefixups.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * mprefixups.c: Handle left matra placement - * - * Author: Sivaraj Doddannan - * Ported from IBM's ICU engine. Original copyright: - * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __MPREFIXUPS_H -#define __MPREFIXUPS_H - -#include <pango/pango-types.h> -#include <pango/pango-glyph.h> -#include <pango/pango-ot.h> - -G_BEGIN_DECLS - -typedef struct _FixupData FixupData; - -struct _MPreFixups { - glong fFixupCount; - FixupData *fFixupData; -}; - -typedef struct _MPreFixups MPreFixups; - -MPreFixups *indic_mprefixups_new(glong char_count); -void indic_mprefixups_free(MPreFixups *mprefixups); -void indic_mprefixups_add(MPreFixups *mprefixups, glong baseIndex, glong mpreIndex); -void indic_mprefixups_apply(MPreFixups *mprefixups, PangoOTBuffer *buffer); - - -G_END_DECLS - -#endif - diff --git a/modules/khmer/Makefile.am b/modules/khmer/Makefile.am deleted file mode 100644 index f191ea51..00000000 --- a/modules/khmer/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -include $(top_srcdir)/modules/Module.mk - -if HAVE_FREETYPE -INCLUDES += $(FREETYPE_CFLAGS) -if INCLUDE_KHMER_FC -noinst_LTLIBRARIES += libpango-khmer-fc.la -else -if DYNAMIC_KHMER_FC -module_LTLIBRARIES += pango-khmer-fc.la -endif -endif -endif - -fc_sources = \ - khmer-fc.c - -pango_khmer_fc_la_LDFLAGS = -module $(MODULE_LIBTOOL_OPTIONS) -pango_khmer_fc_la_LIBADD = $(pangoft2libs) -pango_khmer_fc_la_SOURCES = $(fc_sources) -libpango_khmer_fc_la_SOURCES = $(fc_sources) -libpango_khmer_fc_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_khmer_fc - --include $(top_srcdir)/git.mk diff --git a/modules/khmer/khmer-fc.c b/modules/khmer/khmer-fc.c deleted file mode 100644 index 14357d78..00000000 --- a/modules/khmer/khmer-fc.c +++ /dev/null @@ -1,721 +0,0 @@ -/* Pango - * khmer-fc.c: Shaper for Khmer script - * - * Copyright (C) 2004 Open Forum of Cambodia (www.forum.org.kh / www.khmeros.info) - * Authors: Jens Herden <jens@khmeros.info> and Javier Sola <javier@khmeros.info> - * - * Based on code from other shapers - * Copyright (C) 1999-2004 Red Hat Software - * Author: Owen Taylor <otaylor@redhat.com> - - * Partially based on Indic shaper - * Copyright (C) 2001, 2002 IBM Corporation - * Author: Eric Mader <mader@jtcsv.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * The license on the original Indic shaper code is as follows: - * - * * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished - * to do so, provided that the above copyright notice(s) and this - * permission notice appear in all copies of the Software and that - * both the above copyright notice(s) and this permission notice - * appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR - * ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written - * authorization of the copyright holder. - */ -#include "config.h" -#include <string.h> - -#include "pango-engine.h" -#include "pango-ot.h" -#include "pango-utils.h" -#include "pangofc-font.h" - - -#define SCRIPT_ENGINE_NAME "KhmerScriptEngineFc" -#define RENDER_TYPE PANGO_RENDER_TYPE_FC - - -typedef PangoEngineShape KhmerEngineFc; -typedef PangoEngineShapeClass KhmerEngineFcClass ; - - -static PangoEngineScriptInfo khmer_scripts[] = -{ - { PANGO_SCRIPT_KHMER, "*" } -}; - -static PangoEngineInfo script_engines[] = -{ - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - RENDER_TYPE, - khmer_scripts, G_N_ELEMENTS (khmer_scripts) - } -}; - - -/* Vocabulary - * Base -> A consonant or an independent vowel in its full (not subscript) form. It is the - * center of the syllable, it can be surrounded by coeng (subscript) consonants, vowels, - * split vowels, signs... but there is only one base in a syllable, it has to be coded as - * the first character of the syllable. - * split vowel --> vowel that has two parts placed separately (e.g. Before and after the consonant). - * Khmer language has five of them. Khmer split vowels either have one part before the - * base and one after the base or they have a part before the base and a part above the base. - * The first part of all Khmer split vowels is the same character, identical to - * the glyph of Khmer dependent vowel SRA EI - * coeng --> modifier used in Khmer to construct coeng (subscript) consonants - * Differently than indian languages, the coeng modifies the consonant that follows it, - * not the one preceding it Each consonant has two forms, the base form and the subscript form - * the base form is the normal one (using the consonants code-point), the subscript form is - * displayed when the combination coeng + consonant is encountered. - * Consonant of type 1 -> A consonant which has subscript for that only occupies space under a base consonant - * Consonant of type 2.-> Its subscript form occupies space under and before the base (only one, RO) - * Consonant of Type 3 -> Its subscript form occupies space under and after the base (KHO, CHHO, THHO, BA, YO, SA) - * Consonant shifter -> Khmer has to series of consonants. The same dependent vowel has different sounds - * if it is attached to a consonant of the first series or a consonant of the second series - * Most consonants have an equivalent in the other series, but some of theme exist only in - * one series (for example SA). If we want to use the consonant SA with a vowel sound that - * can only be done with a vowel sound that corresponds to a vowel accompanying a consonant - * of the other series, then we need to use a consonant shifter: TRIISAP or MUSIKATOAN - * x17C9 y x17CA. TRIISAP changes a first series consonant to second series sound and - * MUSIKATOAN a second series consonant to have a first series vowel sound. - * Consonant shifter are both normally supercript marks, but, when they are followed by a - * superscript, they change shape and take the form of subscript dependent vowel SRA U. - * If they are in the same syllable as a coeng consonant, Unicode 3.0 says that they - * should be typed before the coeng. Unicode 4.0 breaks the standard and says that it should - * be placed after the coeng consonant. - * Dependent vowel -> In khmer dependent vowels can be placed above, below, before or after the base - * Each vowel has its own position. Only one vowel per syllable is allowed. - * Signs -> Khmer has above signs and post signs. Only one above sign and/or one post sign are - * Allowed in a syllable. - * - * - * order is important here! This order must be the same that is found in each horizontal - * line in the statetable for Khmer (see khmerStateTable) . - */ -enum KhmerCharClassValues -{ - CC_RESERVED = 0, - CC_CONSONANT = 1, /* Consonant of type 1 or independent vowel */ - CC_CONSONANT2 = 2, /* Consonant of type 2 */ - CC_CONSONANT3 = 3, /* Consonant of type 3 */ - CC_ZERO_WIDTH_NJ_MARK = 4, /* Zero Width non joiner character (0x200C) */ - CC_CONSONANT_SHIFTER = 5, - CC_ROBAT = 6, /* Khmer special diacritic accent -treated differently in state table */ - CC_COENG = 7, /* Subscript consonant combining character */ - CC_DEPENDENT_VOWEL = 8, - CC_SIGN_ABOVE = 9, - CC_SIGN_AFTER = 10, - CC_ZERO_WIDTH_J_MARK = 11, /* Zero width joiner character */ - CC_COUNT = 12 /* This is the number of character classes */ -}; - - -enum KhmerCharClassFlags -{ - CF_CLASS_MASK = 0x0000FFFF, - - CF_CONSONANT = 0x01000000, /* flag to speed up comparing */ - CF_SPLIT_VOWEL = 0x02000000, /* flag for a split vowel -> the first part is added in front of the syllable */ - CF_DOTTED_CIRCLE = 0x04000000, /* add a dotted circle if a character with this flag is the first in a syllable */ - CF_COENG = 0x08000000, /* flag to speed up comparing */ - CF_SHIFTER = 0x10000000, /* flag to speed up comparing */ - CF_ABOVE_VOWEL = 0x20000000, /* flag to speed up comparing */ - - /* position flags */ - CF_POS_BEFORE = 0x00080000, - CF_POS_BELOW = 0x00040000, - CF_POS_ABOVE = 0x00020000, - CF_POS_AFTER = 0x00010000, - CF_POS_MASK = 0x000f0000 -}; - - -/* Characters that get refrered to by name */ -enum KhmerChar -{ - C_SIGN_ZWNJ = 0x200C, - C_SIGN_ZWJ = 0x200D, - C_DOTTED_CIRCLE = 0x25CC, - C_RO = 0x179A, - C_VOWEL_AA = 0x17B6, - C_SIGN_NIKAHIT = 0x17C6, - C_VOWEL_E = 0x17C1, - C_COENG = 0x17D2 -}; - - -enum -{ - /* simple classes, they are used in the state table (in this file) to control the length of a syllable - * they are also used to know where a character should be placed (location in reference to the base character) - * and also to know if a character, when independently displayed, should be displayed with a dotted-circle to - * indicate error in syllable construction - */ - _xx = CC_RESERVED, - _sa = CC_SIGN_ABOVE | CF_DOTTED_CIRCLE | CF_POS_ABOVE, - _sp = CC_SIGN_AFTER | CF_DOTTED_CIRCLE| CF_POS_AFTER, - _c1 = CC_CONSONANT | CF_CONSONANT, - _c2 = CC_CONSONANT2 | CF_CONSONANT, - _c3 = CC_CONSONANT3 | CF_CONSONANT, - _rb = CC_ROBAT | CF_POS_ABOVE | CF_DOTTED_CIRCLE, - _cs = CC_CONSONANT_SHIFTER | CF_DOTTED_CIRCLE | CF_SHIFTER, - _dl = CC_DEPENDENT_VOWEL | CF_POS_BEFORE | CF_DOTTED_CIRCLE, - _db = CC_DEPENDENT_VOWEL | CF_POS_BELOW | CF_DOTTED_CIRCLE, - _da = CC_DEPENDENT_VOWEL | CF_POS_ABOVE | CF_DOTTED_CIRCLE | CF_ABOVE_VOWEL, - _dr = CC_DEPENDENT_VOWEL | CF_POS_AFTER | CF_DOTTED_CIRCLE, - _co = CC_COENG | CF_COENG | CF_DOTTED_CIRCLE, - - /* split vowel */ - _va = _da | CF_SPLIT_VOWEL, - _vr = _dr | CF_SPLIT_VOWEL -}; - - -/* Character class: a character class value - * ORed with character class flags. - */ -typedef glong KhmerCharClass; - - -/* Character class tables - * _xx character does not combine into syllable, such as numbers, puntuation marks, non-Khmer signs... - * _sa Sign placed above the base - * _sp Sign placed after the base - * _c1 Consonant of type 1 or independent vowel (independent vowels behave as type 1 consonants) - * _c2 Consonant of type 2 (only RO) - * _c3 Consonant of type 3 - * _rb Khmer sign robat u17CC. combining mark for subscript consonants - * _cd Consonant-shifter - * _dl Dependent vowel placed before the base (left of the base) - * _db Dependent vowel placed below the base - * _da Dependent vowel placed above the base - * _dr Dependent vowel placed behind the base (right of the base) - * _co Khmer combining mark COENG u17D2, combines with the consonant or independent vowel following - * it to create a subscript consonant or independent vowel - * _va Khmer split vowel in wich the first part is before the base and the second one above the base - * _vr Khmer split vowel in wich the first part is before the base and the second one behind (right of) the base - */ -static const KhmerCharClass khmerCharClasses[] = -{ - _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c1, _c1, /* 1780 - 178F */ - _c1, _c1, _c1, _c1, _c3, _c1, _c1, _c1, _c1, _c3, _c2, _c1, _c1, _c1, _c3, _c3, /* 1790 - 179F */ - _c1, _c3, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, _c1, /* 17A0 - 17AF */ - _c1, _c1, _c1, _c1, _dr, _dr, _dr, _da, _da, _da, _da, _db, _db, _db, _va, _vr, /* 17B0 - 17BF */ - _vr, _dl, _dl, _dl, _vr, _vr, _sa, _sp, _sp, _cs, _cs, _sa, _rb, _sa, _sa, _sa, /* 17C0 - 17CF */ - _sa, _sa, _co, _sa, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _sa, _xx, _xx, /* 17D0 - 17DF */ -}; - -/* this define must reflect the range of khmerCharClasses */ -#define firstChar 0x1780 -#define lastChar 0x17df - - - -/* The stateTable is used to calculate the end (the length) of a well - * formed Khmer Syllable. - * - * Each horizontal line is ordered exactly the same way as the values in KhmerClassTable - * CharClassValues. This coincidence of values allows the follow up of the table. - * - * Each line corresponds to a state, which does not necessarily need to be a type - * of component... for example, state 2 is a base, with is always a first character - * in the syllable, but the state could be produced a consonant of any type when - * it is the first character that is analysed (in ground state). - * - * Differentiating 3 types of consonants is necessary in order to - * forbid the use of certain combinations, such as having a second - * coeng after a coeng RO, - * The inexistent possibility of having a type 3 after another type 3 is permitted, - * eliminating it would very much complicate the table, and it does not create typing - * problems, as the case above. - * - * The table is quite complex, in order to limit the number of coeng consonants - * to 2 (by means of the table). - * - * There a peculiarity, as far as Unicode is concerned: - * - The consonant-shifter is considered in two possible different - * locations, the one considered in Unicode 3.0 and the one considered in - * Unicode 4.0. (there is a backwards compatibility problem in this standard). - * - * - * xx independent character, such as a number, punctuation sign or non-khmer char - * - * c1 Khmer consonant of type 1 or an independent vowel - * that is, a letter in which the subscript for is only under the - * base, not taking any space to the right or to the left - * - * c2 Khmer consonant of type 2, the coeng form takes space under - * and to the left of the base (only RO is of this type) - * - * c3 Khmer consonant of type 3. Its subscript form takes space under - * and to the right of the base. - * - * cs Khmer consonant shifter - * - * rb Khmer robat - * - * co coeng character (u17D2) - * - * dv dependent vowel (including split vowels, they are treated in the same way). - * even if dv is not defined above, the component that is really tested for is - * KhmerClassTable::CC_DEPENDENT_VOWEL, which is common to all dependent vowels - * - * zwj Zero Width joiner - * - * zwnj Zero width non joiner - * - * sa above sign - * - * sp post sign - * - * there are lines with equal content but for an easier understanding - * (and maybe change in the future) we did not join them - */ -static const gint8 khmerStateTable[][CC_COUNT] = -{ -/* xx c1 c2 c3 zwnj cs rb co dv sa sp zwj */ - { 1, 2, 2, 2, 1, 1, 1, 6, 1, 1, 1, 2}, /* 0 - ground state */ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 1 - exit state (or sign to the right of the syllable) */ - {-1, -1, -1, -1, 3, 4, 5, 6, 16, 17, 1, -1}, /* 2 - Base consonant */ - {-1, -1, -1, -1, -1, 4, -1, -1, 16, -1, -1, -1}, /* 3 - First ZWNJ before a register shifter - It can only be followed by a shifter or a vowel */ - {-1, -1, -1, -1, 15, -1, -1, 6, 16, 17, 1, 14}, /* 4 - First register shifter */ - {-1, -1, -1, -1, -1, -1, -1, -1, 20, -1, 1, -1}, /* 5 - Robat */ - {-1, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1}, /* 6 - First Coeng */ - {-1, -1, -1, -1, 12, 13, -1, 10, 16, 17, 1, 14}, /* 7 - First consonant of type 1 after coeng */ - {-1, -1, -1, -1, 12, 13, -1, -1, 16, 17, 1, 14}, /* 8 - First consonant of type 2 after coeng */ - {-1, -1, -1, -1, 12, 13, -1, 10, 16, 17, 1, 14}, /* 9 - First consonant or type 3 after ceong */ - {-1, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, -1}, /* 10 - Second Coeng (no register shifter before) */ - {-1, -1, -1, -1, 15, -1, -1, -1, 16, 17, 1, 14}, /* 11 - Second coeng consonant (or ind. vowel) no register shifter before */ - {-1, -1, -1, -1, -1, 13, -1, -1, 16, -1, -1, -1}, /* 12 - Second ZWNJ before a register shifter */ - {-1, -1, -1, -1, 15, -1, -1, -1, 16, 17, 1, 14}, /* 13 - Second register shifter */ - {-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, /* 14 - ZWJ before vowel */ - {-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, /* 15 - ZWNJ before vowel */ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 1, 18}, /* 16 - dependent vowel */ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 18}, /* 17 - sign above */ - {-1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1}, /* 18 - ZWJ after vowel */ - {-1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1}, /* 19 - Third coeng */ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1}, /* 20 - dependent vowel after a Robat */ -}; - - -enum property_flags -{ - abvf = 0x0001, - pref = 0x0002, - pstf = 0x0004, - blwf = 0x0008, - - pres = 0x0010, - blws = 0x0020, - abvs = 0x0040, - psts = 0x0080, - clig = 0x0100, - - dist = 0x0200, - blwm = 0x0400, - abvm = 0x0800, -}; - - -enum properties -{ - blwf_p = /*(blwf | blws | clig | dist | blwm)*/ (abvf | pref | pstf | pres | abvs | psts | abvm), - pstf_p = /*(blwf | blws | pref | pres | pstf | psts | clig | dist | blwm)*/ (abvf | abvs | abvm), - abvf_p = /*(abvf | abvs | clig | dist | abvm)*/ (pref | pstf | blwf | pres | blws | psts | blwm), - pref_p = /*(pref | pres | clig | dist)*/ (abvf | pstf | blwf | blws | abvs | psts | blwm | abvm), - default_p = /*(pres | blws | clig | dist | abvm | blwm)*/ (pref | blwf |abvf | pstf | abvs | psts) -}; - - -/* Below we define how a character in the input string is either in the khmerCharClasses table - * (in which case we get its type back), a ZWJ or ZWNJ (two characters that may appear - * within the syllable, but are not in the table) we also get their type back, or an unknown object - * in which case we get _xx (CC_RESERVED) back - */ -static KhmerCharClass -get_char_class (gunichar ch) -{ - if (ch == C_SIGN_ZWJ) - return CC_ZERO_WIDTH_J_MARK; - - if (ch == C_SIGN_ZWNJ) - return CC_ZERO_WIDTH_NJ_MARK; - - if (ch < firstChar || ch > lastChar) - return CC_RESERVED; - - return khmerCharClasses[ch - firstChar]; -} - - -/* Given an input string of characters and a location in which to start looking - * calculate, using the state table, which one is the last character of the syllable - * that starts in the starting position. - */ -static glong -find_syllable (const gunichar *chars, - glong start, - glong char_count) -{ - glong cursor = start; - gint8 state = 0; - KhmerCharClass charClass; - - while (cursor < char_count) - { - charClass = get_char_class (chars[cursor]) & CF_CLASS_MASK; - state = khmerStateTable[state][charClass]; - - if (state < 0) - break; - - cursor += 1; - } - - return cursor; -} - -static const PangoOTFeatureMap gsub_features[] = -{ - {"ccmp", PANGO_OT_ALL_GLYPHS}, - {"locl", PANGO_OT_ALL_GLYPHS}, - {"pref", pref}, - {"blwf", blwf}, - {"abvf", abvf}, - {"pstf", pstf}, - {"pres", pres}, - {"blws", blws}, - {"abvs", abvs}, - {"psts", psts}, - {"clig", clig}, - {"calt", PANGO_OT_ALL_GLYPHS} -}; - -static const PangoOTFeatureMap gpos_features[] = -{ - {"dist", dist}, - {"blwm", blwm}, - {"abvm", abvm}, - {"kern", PANGO_OT_ALL_GLYPHS}, - {"mark", PANGO_OT_ALL_GLYPHS}, - {"mkmk", PANGO_OT_ALL_GLYPHS} -}; - -static PangoGlyph -get_index (PangoFcFont *fc_font, gunichar wc) -{ - PangoGlyph index = pango_fc_font_get_glyph (fc_font, wc); - if (!index) - index = PANGO_GET_UNKNOWN_GLYPH ( wc); - return index; -} - - -static void -khmer_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED, - PangoFont *font, - const char *text, - int length, - const PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - PangoFcFont *fc_font; - FT_Face face; - PangoOTRulesetDescription desc; - const PangoOTRuleset *ruleset; - PangoOTBuffer *buffer; - glong n_chars; - gunichar *wcs; - const char *p; - int i; - glong syllable; - KhmerCharClass charClass; - glong cursor = 0; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - if (!face) - return; - - buffer = pango_ot_buffer_new (fc_font); - pango_ot_buffer_set_rtl (buffer, analysis->level % 2 != 0); - - wcs = g_utf8_to_ucs4_fast (text, length, &n_chars); - - p = text; - /* This loop only exits when we reach the end of a run, which may contain - * several syllables. - */ - while (cursor < n_chars) - { - /* write a pre vowel or the pre part of a split vowel first - * and look out for coeng + ro. RO is the only vowel of type 2, and - * therefore the only one that requires saving space before the base. - */ - glong coengRo = -1; /* There is no Coeng Ro, if found this value will change */ - - syllable = find_syllable (wcs, cursor, n_chars); - - for (i = cursor; i < syllable; i += 1) - { - charClass = get_char_class (wcs[i]); - - /* if a split vowel, write the pre part. In Khmer the pre part - * is the same for all split vowels, same glyph as pre vowel C_VOWEL_E - */ - if (charClass & CF_SPLIT_VOWEL) - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_VOWEL_E), pref_p, p - text); - break; /* there can be only one vowel */ - } - - /* if a vowel with pos before write it out */ - if (charClass & CF_POS_BEFORE) - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pref_p, p - text); - break; /* there can be only one vowel */ - } - - /* look for coeng + ro and remember position - * works because coeng + ro is always in front of a vowel (if there is a vowel) - * and because CC_CONSONANT2 is enough to identify it, as it is the only consonant - * with this flag - */ - if ((charClass & CF_COENG) && (i + 1 < syllable) && - ((get_char_class (wcs[i + 1]) & CF_CLASS_MASK) == CC_CONSONANT2)) - { - coengRo = i; - } - } - - /* write coeng + ro if found */ - if (coengRo > -1) - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_COENG), pref_p, p - text); - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_RO), pref_p, p - text); - } - - /* shall we add a dotted circle? - * If in the position in which the base should be (first char in the string) there is - * a character that has the Dotted circle flag (a character that cannot be a base) - * then write a dotted circle - */ - if (get_char_class (wcs[cursor]) & CF_DOTTED_CIRCLE) - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_DOTTED_CIRCLE), default_p, p - text); - } - - /* copy what is left to the output, skipping before vowels and - * coeng Ro if they are present - */ - for (i = cursor; i < syllable; i += 1) - { - charClass = get_char_class (wcs[i]); - - /* skip a before vowel, it was already processed */ - if (charClass & CF_POS_BEFORE) - { - p = g_utf8_next_char (p); - continue; - } - - /* skip coeng + ro, it was already processed */ - if (i == coengRo) - { - p = g_utf8_next_char (p); - i += 1; - p = g_utf8_next_char (p); - continue; - } - - switch (charClass & CF_POS_MASK) - { - case CF_POS_ABOVE : - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), abvf_p, p - text); - break; - - case CF_POS_AFTER : - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pstf_p, p - text); - break; - - case CF_POS_BELOW : - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text); - break; - - default: - /* assign the correct flags to a coeng consonant - * Consonants of type 3 are taged as Post forms and those type 1 as below forms - */ - if ((charClass & CF_COENG) && i + 1 < syllable) - { - if ((get_char_class (wcs[i + 1]) & CF_CLASS_MASK) == CC_CONSONANT3) - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pstf_p, p - text); - p = g_utf8_next_char (p); - i += 1; - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pstf_p, p - text); - break; - } - else - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text); - p = g_utf8_next_char (p); - i += 1; - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text); - break; - } - } - - /* if a shifter is followed by an above vowel change the shifter to below form, - * an above vowel can have two possible positions i + 1 or i + 3 - * (position i+1 corresponds to unicode 3, position i+3 to Unicode 4) - * and there is an extra rule for C_VOWEL_AA + C_SIGN_NIKAHIT also for two - * different positions, right after the shifter or after a vowel (Unicode 4) - */ - if ((charClass & CF_SHIFTER) && (i + 1 < syllable)) - { - if (get_char_class (wcs[i + 1]) & CF_ABOVE_VOWEL) - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text); - break; - } - if (i + 2 < syllable && - (wcs[i + 1] == C_VOWEL_AA) && - (wcs[i + 2] == C_SIGN_NIKAHIT) ) - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text); - break; - } - if (i + 3 < syllable && (get_char_class (wcs[i + 3]) & CF_ABOVE_VOWEL) ) - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text); - break; - } - if (i + 4 < syllable && - (wcs[i + 3] == C_VOWEL_AA) && - (wcs[i + 4] == C_SIGN_NIKAHIT) ) - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text); - break; - } - - } - - /* default - any other characters */ - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), default_p, p - text); - break; - } /* switch */ - p = g_utf8_next_char (p); - } /* for */ - - cursor = syllable; /* move the pointer to the start of next syllable */ - } /* while */ - - desc.script = analysis->script; - desc.language = analysis->language; - - desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features); - desc.static_gsub_features = gsub_features; - desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features); - desc.static_gpos_features = gpos_features; - - /* TODO populate other_features from analysis->extra_attrs */ - desc.n_other_features = 0; - desc.other_features = NULL; - - ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc); - - pango_ot_ruleset_substitute (ruleset, buffer); - pango_ot_ruleset_position (ruleset, buffer); - pango_ot_buffer_output (buffer, glyphs); - - g_free (wcs); - pango_ot_buffer_destroy (buffer); - - pango_fc_font_unlock_face (fc_font); -} - - -static void -khmer_engine_fc_class_init (PangoEngineShapeClass *class) -{ - class->script_shape = khmer_engine_shape; -} - -PANGO_ENGINE_SHAPE_DEFINE_TYPE (KhmerEngineFc, khmer_engine_fc, - khmer_engine_fc_class_init, NULL) - - -void -PANGO_MODULE_ENTRY(init) (GTypeModule *module) -{ - khmer_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 (khmer_engine_fc_type, NULL); - else - return NULL; -} diff --git a/modules/syriac/Makefile.am b/modules/syriac/Makefile.am deleted file mode 100644 index 68a4441e..00000000 --- a/modules/syriac/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -include $(top_srcdir)/modules/Module.mk - -if HAVE_FREETYPE -INCLUDES += $(FREETYPE_CFLAGS) -if INCLUDE_SYRIAC_FC -noinst_LTLIBRARIES += libpango-syriac-fc.la -else -if DYNAMIC_SYRIAC_FC -module_LTLIBRARIES += pango-syriac-fc.la -endif -endif -endif - -fc_sources = \ - syriac-fc.c \ - syriac-ot.c \ - syriac-ot.h - -pango_syriac_fc_la_LDFLAGS = -module $(MODULE_LIBTOOL_OPTIONS) -pango_syriac_fc_la_LIBADD = $(pangoft2libs) -pango_syriac_fc_la_SOURCES = $(fc_sources) -libpango_syriac_fc_la_SOURCES = $(fc_sources) -libpango_syriac_fc_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_syriac_fc - --include $(top_srcdir)/git.mk diff --git a/modules/syriac/syriac-fc.c b/modules/syriac/syriac-fc.c deleted file mode 100644 index 7ba05fb4..00000000 --- a/modules/syriac/syriac-fc.c +++ /dev/null @@ -1,212 +0,0 @@ -/* Pango - * syriac-fc.h: - * - * Copyright (C) 2000, 2003, 2007 Red Hat Software - * Copyright (C) 2004 Emil Soleyman-Zomalan - * Authors: - * Owen Taylor <otaylor@redhat.com> - * Emil Soleyman-Zomalan <emil@soleyman.com> - * Behdad Esfahbod <behdad@behdad.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#include "config.h" -#include <string.h> - -#include "syriac-ot.h" - -#include "pango-engine.h" -#include "pango-utils.h" -#include "pangofc-font.h" - -/* No extra fields needed */ -typedef PangoEngineShape SyriacEngineFc; -typedef PangoEngineShapeClass SyriacEngineFcClass ; - -#define SCRIPT_ENGINE_NAME "SyriacScriptEngineFc" -#define RENDER_TYPE PANGO_RENDER_TYPE_FC - -static PangoEngineScriptInfo syriac_scripts[] = { - { PANGO_SCRIPT_SYRIAC, "*" }, -}; - -static PangoEngineInfo script_engines[] = { - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - RENDER_TYPE, - syriac_scripts, G_N_ELEMENTS(syriac_scripts) - } -}; - -static const PangoOTFeatureMap gsub_features[] = -{ - {"ccmp", PANGO_OT_ALL_GLYPHS}, - {"locl", PANGO_OT_ALL_GLYPHS}, - {"isol", isolated}, - {"fina", final}, - {"fin2", final2}, - {"fin3", final3}, - {"medi", medial}, - {"med2", medial2}, - {"init", initial}, - {"rlig", PANGO_OT_ALL_GLYPHS}, - {"calt", PANGO_OT_ALL_GLYPHS}, - {"liga", PANGO_OT_ALL_GLYPHS}, - /* 'dlig' should be turned-on/off-able. lets turn off for now. */ - /* {"dlig", PANGO_OT_ALL_GLYPHS}, */ -}; - -static const PangoOTFeatureMap gpos_features[] = -{ - {"kern", PANGO_OT_ALL_GLYPHS}, - {"mark", PANGO_OT_ALL_GLYPHS}, - {"mkmk", PANGO_OT_ALL_GLYPHS} -}; - -static void -syriac_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED, - PangoFont *font, - const char *text, - gint length, - const PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - PangoFcFont *fc_font; - FT_Face face; - PangoOTRulesetDescription desc; - const PangoOTRuleset *ruleset; - PangoOTBuffer *buffer; - gulong *properties = NULL; - glong n_chars; - gunichar *wcs; - const char *p; - int cluster = 0; - int i; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - if (!face) - return; - - buffer = pango_ot_buffer_new (fc_font); - pango_ot_buffer_set_rtl (buffer, analysis->level % 2 != 0); - pango_ot_buffer_set_zero_width_marks (buffer, TRUE); - - wcs = g_utf8_to_ucs4_fast (text, length, &n_chars); - properties = g_new0 (gulong, n_chars); - - syriac_assign_properties (wcs, properties, n_chars); - - g_free (wcs); - - p = text; - for (i=0; i < n_chars; i++) - { - gunichar wc; - PangoGlyph glyph; - - wc = g_utf8_get_char (p); - - if (g_unichar_type (wc) != G_UNICODE_NON_SPACING_MARK) - cluster = p - text; - - if (pango_is_zero_width (wc)) - glyph = PANGO_GLYPH_EMPTY; - else - { - gunichar c = wc; - - if (analysis->level % 2) - g_unichar_get_mirror_char (c, &c); - - glyph = pango_fc_font_get_glyph (fc_font, c); - } - - if (!glyph) - glyph = PANGO_GET_UNKNOWN_GLYPH (wc); - - pango_ot_buffer_add_glyph (buffer, glyph, properties[i], cluster); - - p = g_utf8_next_char (p); - } - - g_free (properties); - - desc.script = analysis->script; - desc.language = analysis->language; - - desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features); - desc.static_gsub_features = gsub_features; - desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features); - desc.static_gpos_features = gpos_features; - - /* TODO populate other_features from analysis->extra_attrs */ - desc.n_other_features = 0; - desc.other_features = NULL; - - ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc); - - pango_ot_ruleset_substitute (ruleset, buffer); - pango_ot_ruleset_position (ruleset, buffer); - pango_ot_buffer_output (buffer, glyphs); - - pango_ot_buffer_destroy (buffer); - - pango_fc_font_unlock_face (fc_font); -} - -static void -syriac_engine_fc_class_init (PangoEngineShapeClass *class) -{ - class->script_shape = syriac_engine_shape; -} - -PANGO_ENGINE_SHAPE_DEFINE_TYPE (SyriacEngineFc, syriac_engine_fc, - syriac_engine_fc_class_init, NULL) - -void -PANGO_MODULE_ENTRY(init) (GTypeModule *module) -{ - syriac_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 (syriac_engine_fc_type, NULL); - else - return NULL; -} diff --git a/modules/syriac/syriac-ot.c b/modules/syriac/syriac-ot.c deleted file mode 100644 index 0fbb64e0..00000000 --- a/modules/syriac/syriac-ot.c +++ /dev/null @@ -1,361 +0,0 @@ -/* Pango - * syriac-ot.h: Determine what OpenType features to apply to characters based - * on the rules for Syriac from the OpenType standard. - * - * Copyright (C) 2004 Emil Soleyman-Zomalan - * Author: Emil Soleyman-Zomalan <emil@soleyman.com> - * - * This file is based on the Arabic shaping code from FreeType 1 tree; original - * copyright notice: - * - * The FreeType project -- a free and portable quality TrueType renderer. - * - * Copyright 1996-2000 by - * D. Turner, R.Wilhelm, and W. Lemberg - * - * The code, like the FreeType code it is derived from is dual-licensed - * under the GNU General Public License and the FreeType license. See - * pango/opentype/COPYING for full details of this licensing scheme. - */ -#include "config.h" -#include "syriac-ot.h" - -/* Here a table of the joining classes for characters in the range - * U+0700 - U+074F. - * - * The following character also has a joining class: - * - * U+200C ZERO WIDTH NON-JOINER -> causing - * - * All other characters are given the joining class `none'. - */ -static const JoiningClass syriac[] = -{ - /* U+0700 */ - none, none, none, none, - none, none, none, none, - none, none, none, none, - none, none, none, transparent, - - /* U+0710 */ - right, none, dual, dual, - dual, right, right, right, - right, right, dual, dual, - dual, dual, right, dual, - - /* U+0720 */ - dual, dual, dual, dual, - dual, dual, dual, dual, - right, dual, right, dual, - right, none, none, none, - - /* U+0730 */ - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, transparent, - - /* U+0740 */ - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, transparent, - transparent, transparent, transparent, none, - none, right, dual, dual -}; - -/* `direction' can be -1, 0, or 1 to indicate the last non-transparent - * glyph, the current glyph, and the next non-transparent glyph, - * respectively. - */ -static JoiningClass -Get_Joining_Class (gunichar* string, - int pos, - int length, - int direction) -{ - JoiningClass j; - - while (1) - { - if (pos == 0 && direction < 0) - return none; - - pos += direction; - - if (pos >= length) - return none; - - if (string[pos] < 0x0700 || - string[pos] >= 0x074F) - { - if (string[pos] == 0x200C) - return causing; - else - return none; - } - else - j = syriac[string[pos] - 0x0700]; - - if (!direction || j != transparent) - return j; - } -} - - -/* The rules here are roughly based on the Arabic rules from the Unicode - * 2.0 standard (which differ from the Unicode-4.0 rules), augmented - * with the Syriac rules from the Unicode-4.0 standard. The numbers - * R1...R11 below do not correspond to either the Arabic or the Syriac - * rule numbering from the Unicode standard. - * - * Characters are here specified as appearing in the byte stream, i.e. - * *not* in visual order. Joining classes are given in angle brackets, - * glyph forms in square brackets. Glyphs affected by a specific rule are - * enclosed with vertical bars. - * - * - * Glyphs: 0x0715 (Dalath), 0x0716 (Dalath Rish), 0x072A (Rish), - * 0x0722 (Nun), 0x071F (Kaph) - * - * - * R1: <anything1> <transparent> <anything2> - * - * apply joining rules for - * <anything1> <anything2> -> [shape1] [shape2] - * -> [shape1] [isolated] [shape2] - * - * - * R2: <causing|right> <0x0722|0x071F> <!(causing|right|dual)> - * -> [isolated] - * - * The Nun and Kaph characters each have 3 different glyphs - * with two of those glyphs coming at the final position. - * However, one of those final glyphs should really be of the - * isolated glyph form where the preceding character cannot be - * joined to and there is no next character. - * - * This rule exists to combine similar exception for both - * characters without increasing the complexity in the other - * rules. - * - * - * R3: <causing|right|dual> && <!(0x0715|0x0716|0x072A)> |<alaph>| - * - * -> [final2] - * - * If the preceding glyph cannot be joined to the current - * glyph and the preceding character is not a Dalath, Rish, - * or Dotless Dalath Rish, then the Alaph takes this contextual - * position. - * - * The [final2] joining rule is placed ahead of the [final] to - * give it greater precedence when choosing the correct glyph. - * If it comes after the [final] rule, the incorrect glyph is - * inserted into position. - * - * - * R4: <0x0715|0x0715|0x072A> |<alaph>| - * - * -> [final3] - * - * If the previous glyph is a Dalath, Rish, or Dotless Dalath - * Rish, then the Alaph takes this contextual position. - * - * The [final3] joining rule is placed ahead of the [final] to - * give it greater precedence when choosing the correct glyph. - * If it comes after the [final] rule, the incorrect glyph is - * inserted into position. - * - * - * R5: <causing|right|dual> |<right>| - * - * -> [final] - * - * - * R6: <causing|right|dual> |<dual>| <!(causing|right|dual)> - * - * -> [final] - * - * - * R7: <causing|left|dual> |<dual>| <causing|right|dual> - * - * -> [medial] - * - * - * R8: <causing|right> |<alaph>| <causing|right|dual> - * - * -> [medial2] - * - * If the Alaph glyph falls in the middle of a Syriac word and - * the preceding character cannot be joined to, then the Alaph - * takes this contextual position. - * - * - * R9: |<left>| <causing|right|dual> - * - * -> [initial] - * - * - * R10: <!(causing|left|dual)> |<dual>| <causing|right|dual> - * - * -> [initial] - * - * - * R11: <anything> -> [isolated] - * - * This joining rule is placed at the end of these features - * because when it is placed at the beginning of all of them - * it tends to break the cursive nature of Syriac writing -- - * it inserts the isolated glyph of each character into that - * position with no joining occurring all throughout a text - * document. - */ - -FT_Error -syriac_assign_properties (gunichar *string, - gulong *properties, - int length) -{ - JoiningClass previous, current, next; - int i; - - if (!string || !properties || length == 0) - return FT_Err_Invalid_Argument; - - for (i = 0; i < length; i++) - { - previous = Get_Joining_Class (string, i, length, -1); - current = Get_Joining_Class (string, i, length, 0); - next = Get_Joining_Class (string, i, length, 1); - - /* R1 */ - - if (current == transparent) - { - properties[i] |= isolated_p; - continue; - } - - /* R2 */ - - if (string[i] == 0x0722 || - string[i] == 0x071F) - if (previous == causing || - previous == right) - if (!(next == causing || - next == right || - next == dual)) - { - properties[i] |= isolated_p; - continue; - } - - /* R3 */ - - if (string[i] == 0x0710) - if (previous == causing || - previous == right) - if (!(string[i - 1] == 0x0715 || - string[i - 1] == 0x0716 || - string[i - 1] == 0x072A)) - { - properties[i] |= final2_p; - continue; - } - - /* R4 */ - - if (string[i] == 0x0710) - if (previous == causing || - previous == right) - if (string[i - 1] == 0x0715 || - string[i - 1] == 0x0716 || - string[i - 1] == 0x072A) - { - properties[i] |= final3_p; - continue; - } - - /* R5 */ - - if (previous == causing || - previous == right || - previous == dual) - if (current == right) - { - properties[i] |= final_p; - continue; - } - - /* R6 */ - - if (previous == causing || - previous == right || - previous == dual) - if (current == dual) - if (!(next == causing || - next == right || - next == dual )) - { - properties[i] |= final_p; - continue; - } - - /* R7 */ - - if (previous == causing || - previous == left || - previous == dual) - if (current == dual) - if (next == causing || - next == right || - next == dual ) - { - properties[i] |= medial_p; - continue; - } - - /* R8 */ - - if (string[i] == 0x0710) - if (previous == causing || - previous == right) - if (next == causing || - next == right || - next == dual) - { - properties[i] |= medial2_p; - continue; - } - - /* R9 */ - - if (current == left) - if (next == causing || - next == right || - next == dual) - { - properties[i] |= initial_p; - continue; - } - - /* R10 */ - - if (!(previous == causing || - previous == left || - previous == dual )) - if (current == dual) - if (next == causing || - next == right || - next == dual) - { - properties[i] |= initial_p; - continue; - } - - /* R11 */ - - properties[i] |= isolated_p; - } - - return FT_Err_Ok; -} diff --git a/modules/syriac/syriac-ot.h b/modules/syriac/syriac-ot.h deleted file mode 100644 index e9aea543..00000000 --- a/modules/syriac/syriac-ot.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Pango - * syriac-ot.h: Determine what OpenType features to apply to characters based - * on the rules for Syriac from the OpenType standard. - * - * Copyright (C) 2004 Emil Soleyman-Zomalan - * Author: Emil Soleyman-Zomalan <emil@soleyman.com> - * - * This file is based on the Arabic shaping code from FreeType 1 tree; original - * copyright notice: - * - * The FreeType project -- a free and portable quality TrueType renderer. - * - * Copyright 1996-2000 by - * D. Turner, R.Wilhelm, and W. Lemberg - * - * The code, like the FreeType code it is derived from is dual-licensed - * under the GNU Public License and the FreeType license. See see - * pango/opentype/FT-license.txt for full details of the FreeType - * license. - */ - -#ifndef __SYRIAC_OT_H__ -#define __SYRIAC_OT_H__ - -#include <pango/pango-ot.h> - -G_BEGIN_DECLS - -typedef enum -{ - isolated = 1 << 0, /* nominal */ - final = 1 << 1, /* right_joining */ - initial = 1 << 2, /* left_joining */ - medial = 1 << 3, /* double_joining */ - medial2 = 1 << 4, /* double_joining, applies to Alaph only */ - final2 = 1 << 5, /* right_joining, applies to Alaph only */ - final3 = 1 << 6 /* right_joining, applies to Alaph only */ -} JoiningType; - -/* A glyph's property value as needed by e.g. TT_GSUB_Apply_String() - specifies which features should *not* be applied */ -typedef enum -{ - isolated_p = final | initial | medial | medial2 | final2 | final3, - final_p = isolated | initial | medial | medial2 | final2 | final3, - initial_p = isolated | final | medial | medial2 | final2 | final3, - medial_p = isolated | final | initial | medial2 | final2 | final3, - medial2_p = isolated | final | initial | medial | final2 | final3, - final2_p = isolated | final | initial | medial | medial2 | final3, - final3_p = isolated | final | initial | medial | medial2 | final2 -} SyriacGlyphForm; - -typedef enum -{ - right, - left, /* not used */ - dual, - causing, - none, - transparent -} JoiningClass; - -FT_Error syriac_assign_properties (gunichar *string, - gulong *properties, - int length); - -G_END_DECLS - -#endif /* __SYRIAC_OT_H__ */ diff --git a/modules/thai/Makefile.am b/modules/thai/Makefile.am index 870434e6..ba9fa842 100644 --- a/modules/thai/Makefile.am +++ b/modules/thai/Makefile.am @@ -1,27 +1,5 @@ include $(top_srcdir)/modules/Module.mk -shaper_sources = thai-charprop.c thai-charprop.h thai-shaper.c thai-shaper.h - -if HAVE_FREETYPE -INCLUDES += $(FREETYPE_CFLAGS) -if INCLUDE_THAI_FC -noinst_LTLIBRARIES += libpango-thai-fc.la -else -if DYNAMIC_THAI_FC -module_LTLIBRARIES += pango-thai-fc.la -endif -endif -endif - -thai_fc_sources = $(shaper_sources) thai-fc.c - -pango_thai_fc_la_LDFLAGS = -module $(MODULE_LIBTOOL_OPTIONS) -pango_thai_fc_la_LIBADD = $(pangoft2libs) -pango_thai_fc_la_SOURCES = $(thai_fc_sources) -libpango_thai_fc_la_SOURCES = $(thai_fc_sources) -libpango_thai_fc_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_thai_fc - - if INCLUDE_THAI_LANG noinst_LTLIBRARIES += libpango-thai-lang.la else diff --git a/modules/thai/thai-charprop.c b/modules/thai/thai-charprop.c deleted file mode 100644 index a51e3a3d..00000000 --- a/modules/thai/thai-charprop.c +++ /dev/null @@ -1,164 +0,0 @@ -/* Pango - * thai-charprop.c: character property tables - * - * Copyright (C) 2004 Theppitak Karoonboonyanan - * Copyright (C) 2002 Software and Language Engineering Laboratory, NECTEC - * Author: Theppitak Karoonboonyanan <thep@linux.thai.net> - * - * Copyright (c) 1996-2000 by Sun Microsystems, Inc. - * Author: Chookij Vanatham <Chookij.Vanatham@Eng.Sun.COM> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#include "config.h" -#include "thai-charprop.h" - -const gshort thai_char_type[256] = { - /* 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, A, B, C, D, E, F */ - - /* CL1 */ - /*00*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - /*10*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - - /* Lao zone: [U+0E80..U+0EDF] */ - /*20*/ _ND, _NC, _NC, _ND, _NC, _ND, _ND, _NC, - _NC, _ND, _NC, _ND, _ND, _NC, _ND, _ND, - /*30*/ _ND, _ND, _ND, _ND, _NC, _NC, _NC, _NC, - _ND, _NC, _NC, _UC, _NC, _UC, _NC, _UC, - /*40*/ _ND, _NC, _UC, _NC, _ND, _NC, _ND, _NC, - _ND, _ND, _NC, _NC, _ND, _NC, _NC, _ND, - /*50*/ _ND, _AV, _ND, _AM, _AV, _AV, _AV, _AV, - _BV, _BV, _ND, _AV, _BD, _NC, _ND, _ND, - /*60*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _AD, - _TN, _TN, _TN, _TN, _AD, _AD, _ND, _ND, - /*70*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - _ND, _ND, _ND, _ND, _NC, _NC, _ND, _ND, - - /* CL2 */ - /*80*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - /*90*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - - /* Thai zone: [U+0E00..U+0E5F] */ - /*A0*/ _ND, _NC, _NC, _NC, _NC, _NC, _NC, _NC, - _NC, _NC, _NC, _NC, _NC, _SC, _BC, _BC, - /*B0*/ _SC, _NC, _NC, _NC, _NC, _NC, _NC, _NC, - _NC, _NC, _NC, _UC, _NC, _UC, _NC, _UC, - /*C0*/ _NC, _NC, _NC, _NC, _ND, _NC, _ND, _NC, - _NC, _NC, _NC, _NC, _UC, _NC, _NC, _ND, - /*D0*/ _ND, _AV, _ND, _AM, _AV, _AV, _AV, _AV, - _BV, _BV, _BD, _ND, _ND, _ND, _ND, _ND, - /*E0*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _AD, - _TN, _TN, _TN, _TN, _AD, _AD, _AD, _ND, - /*F0*/ _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, - _ND, _ND, _ND, _ND, _ND, _ND, _ND, _ND, -}; - -const gshort thai_TAC_char_class[256] = { - /* 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, A, B, C, D, E, F */ - - /* CL1 */ - /*00*/ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL, - CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL, - /*10*/ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL, - CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL, - - /* Lao zone: [U+0E80..U+0EDF] */ - /*20*/ NON,CONS,CONS, NON,CONS, NON, NON,CONS, - CONS, NON,CONS, NON, NON,CONS, NON, NON, - /*30*/ NON, NON, NON, NON,CONS,CONS,CONS,CONS, - NON,CONS,CONS,CONS,CONS,CONS,CONS,CONS, - /*40*/ NON,CONS,CONS,CONS, NON,CONS, NON,CONS, - NON, NON,CONS,CONS, NON,CONS,CONS, NON, - /*50*/ FV1, AV2, FV1, AM, AV1, AV3, AV2, AV3, - BV1, BV2, NON, AV2,BCON, FV3, NON, NON, - /*60*/ LV, LV, LV, LV, LV, NON, NON, NON, - TONE,TONE,TONE,TONE, AD1, AD4, NON, NON, - /*70*/ NON, NON, NON, NON, NON, NON, NON, NON, - NON, NON, NON, NON,CONS,CONS, NON,CTRL, - - /* CL2 */ - /*80*/ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL, - CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL, - /*90*/ CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL, - CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL,CTRL, - - /* Thai zone: [U+0E00..U+0E5F] */ - /*A0*/ NON,CONS,CONS,CONS,CONS,CONS,CONS,CONS, - CONS,CONS,CONS,CONS,CONS,CONS,CONS,CONS, - /*B0*/ CONS,CONS,CONS,CONS,CONS,CONS,CONS,CONS, - CONS,CONS,CONS,CONS,CONS,CONS,CONS,CONS, - /*C0*/ CONS,CONS,CONS,CONS, FV3,CONS, FV3,CONS, - CONS,CONS,CONS,CONS,CONS,CONS,CONS, NON, - /*D0*/ FV1, AV2, FV1, AM, AV1, AV3, AV2, AV3, - BV1, BV2, BD, NON, NON, NON, NON, NON, - /*E0*/ LV, LV, LV, LV, LV, FV2, NON, AD2, - TONE,TONE,TONE,TONE, AD1, AD4, AD3, NON, - /*F0*/ NON, NON, NON, NON, NON, NON, NON, NON, - NON, NON, NON, NON, NON, NON, NON,CTRL, -}; - -const gchar thai_TAC_compose_input[20][20] = { - /* row: Cn-1, column: Cn */ - /*CTRL NON CONS LV FV1 FV2 FV3 AM BV1 BV2 - * BD TONE AD1 AD2 AD3 AD4 AV1 AV2 AV3 BCON*/ -/*CTRL*/{'X','A','A','A','A','A','A','R','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*NON */{'X','A','A','A','S','S','A','R','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*CONS*/{'X','A','A','A','A','S','A','C','C','C', - 'C','C','C','C','C','C','C','C','C','C'}, -/*LV */{'X','S','A','S','S','S','S','R','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*FV1 */{'X','A','A','A','A','S','A','R','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*FV2 */{'X','A','A','A','A','S','A','R','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*FV3 */{'X','A','A','A','S','A','S','R','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*AM */{'X','A','A','A','S','S','A','R','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*BV1 */{'X','A','A','A','S','S','A','R','R','R', - 'R','C','C','R','R','C','R','R','R','R'}, -/*BV2 */{'X','A','A','A','S','S','A','R','R','R', - 'R','C','R','R','R','R','R','R','R','R'}, -/*BD */{'X','A','A','A','S','S','A','R','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*TONE*/{'X','A','A','A','A','A','A','C','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*AD1 */{'X','A','A','A','S','S','A','R','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*AD2 */{'X','A','A','A','S','S','A','R','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*AD3 */{'X','A','A','A','S','S','A','R','R','R', - 'R','R','R','R','R','R','R','R','R','R'}, -/*AD4 */{'X','A','A','A','S','S','A','R','R','R', - 'R','C','R','R','R','R','R','R','R','R'}, -/*AV1 */{'X','A','A','A','S','S','A','R','R','R', - 'R','C','C','R','R','C','R','R','R','R'}, -/*AV2 */{'X','A','A','A','S','S','A','R','R','R', - 'R','C','R','R','R','R','R','R','R','R'}, -/*AV3 */{'X','A','A','A','S','S','A','R','R','R', - 'R','C','R','C','R','R','R','R','R','R'}, -/*BCON*/{'X','A','A','A','A','S','A','C','C','C', - 'R','C','R','R','R','C','C','C','C','R'}, -}; - diff --git a/modules/thai/thai-charprop.h b/modules/thai/thai-charprop.h deleted file mode 100644 index 98a8f8d2..00000000 --- a/modules/thai/thai-charprop.h +++ /dev/null @@ -1,99 +0,0 @@ -/* Pango - * thai-charprop.h: - * - * Copyright (C) 1999 Red Hat Software - * Author: Owen Taylor <otaylor@redhat.com> - * - * Copyright (C) 2004 Theppitak Karoonboonyanan - * Copyright (C) 2002 Software and Language Engineering Laboratory, NECTEC - * Author: Theppitak Karoonboonyanan <thep@linux.thai.net> - * - * Copyright (c) 1996-2000 by Sun Microsystems, Inc. - * Author: Chookij Vanatham <Chookij.Vanatham@Eng.Sun.COM> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __THAI_CHARPROP_H__ -#define __THAI_CHARPROP_H__ - -#include <glib.h> - -#define isthai(wc) (0x0E00 <= (wc) && (wc) < 0x0E60) -#define islao(wc) (0x0E80 <= (wc) && (wc) < 0x0EE0) -/* ucs2tis() - * Lao: [0x0E80..0x0EDF] -> [0x20..0x7F] - * Thai: [0x0E00..0x0E5F] -> [0xA0..0xFF] - */ -#define ucs2tis(wc) (((wc) - 0x0E00 + 0x20)^0x80) - -/* Define TACTIS character classes */ -#define CTRL 0 -#define NON 1 -#define CONS 2 -#define LV 3 -#define FV1 4 -#define FV2 5 -#define FV3 6 -#define AM 7 -#define BV1 8 -#define BV2 9 -#define BD 10 -#define TONE 11 -#define AD1 12 -#define AD2 13 -#define AD3 14 -#define AD4 15 -#define AV1 16 -#define AV2 17 -#define AV3 18 -#define BCON 19 - -#define _ND 0 -#define _NC 1 -#define _UC (1<<1) -#define _BC (1<<2) -#define _SC (1<<3) -#define _AV (1<<4) -#define _BV (1<<5) -#define _TN (1<<6) -#define _AD (1<<7) -#define _BD (1<<8) -#define _AM (1<<9) - -#define NoTailCons _NC -#define UpTailCons _UC -#define BotTailCons _BC -#define SpltTailCons _SC -#define Cons (NoTailCons|UpTailCons|BotTailCons|SpltTailCons) -#define AboveVowel _AV -#define BelowVowel _BV -#define Tone _TN -#define AboveDiac _AD -#define BelowDiac _BD -#define SaraAm _AM - -#define is_char_type(wc, mask) (thai_char_type[ucs2tis ((wc))] & (mask)) -#define TAC_char_class(wc) \ - (isthai(wc)||islao(wc) ? thai_TAC_char_class[ucs2tis (wc)] : NON) -#define TAC_compose_input(wc1,wc2) \ - thai_TAC_compose_input[TAC_char_class(wc1)][TAC_char_class(wc2)] - -extern const gshort thai_char_type[256]; -extern const gshort thai_TAC_char_class[256]; -extern const gchar thai_TAC_compose_input[20][20]; - -#endif /* __THAI_CHARPROP_H__ */ diff --git a/modules/thai/thai-fc.c b/modules/thai/thai-fc.c deleted file mode 100644 index 80c945da..00000000 --- a/modules/thai/thai-fc.c +++ /dev/null @@ -1,358 +0,0 @@ -/* Pango - * thai-fc.c: - * - * Copyright (C) 1999, 2007 Red Hat Software - * Copyright (C) 2002 NECTEC - * Copyright (c) 1996-2000 by Sun Microsystems, Inc. - * Authors: - * Owen Taylor <otaylor@redhat.com> - * Theppitak Karoonboonyanan <thep@links.nectec.or.th> - * Chookij Vanatham <Chookij.Vanatham@Eng.Sun.COM> - * Behdad Esfahbod <behdad@behdad.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#include "config.h" -#include <string.h> - -#include <glib.h> -#include "pango-ot.h" - -#include "pango-engine.h" -#include "pangofc-font.h" - -#include "thai-shaper.h" - -/* No extra fields needed */ -typedef PangoEngineShape ThaiEngineFc; -typedef PangoEngineShapeClass ThaiEngineFcClass ; - -#define SCRIPT_ENGINE_NAME "ThaiScriptEngineFc" -#define RENDER_TYPE PANGO_RENDER_TYPE_FC - -/* We handle the range U+0e01 to U+0e5b exactly - */ -static PangoEngineScriptInfo thai_scripts[] = { - { PANGO_SCRIPT_THAI, "*" }, - { PANGO_SCRIPT_LAO, "*" }, -}; - -static PangoEngineInfo script_engines[] = { - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - RENDER_TYPE, - thai_scripts, G_N_ELEMENTS(thai_scripts) - } -}; - -/* TIS-to-Unicode glyph maps for characters 0x80-0xff - */ -static const int tis620_0[128] = { - /**/ 0, 0, 0, 0, 0, 0, 0, 0, - /**/ 0, 0, 0, 0, 0, 0, 0, 0, - /**/ 0, 0, 0, 0, 0, 0, 0, 0, - /**/ 0, 0, 0, 0, 0, 0, 0, 0, - 0x0020, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, - 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, - 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, - 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, - 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, - 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, - 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, - 0x0e38, 0x0e39, 0x0e3a, 0, 0, 0, 0, 0x0e3f, - 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, - 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f, - 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, - 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0, 0, 0, 0 -}; - -static const int tis620_1[128] = { - 0xf89e, 0, 0, 0xf88c, 0xf88f, 0xf892, 0xf895, 0xf898, - 0xf88b, 0xf88e, 0xf891, 0xf894, 0xf897, 0, 0, 0xf899, - 0xf89a, 0, 0xf884, 0xf889, 0xf885, 0xf886, 0xf887, 0xf888, - 0xf88a, 0xf88d, 0xf890, 0xf893, 0xf896, 0, 0, 0, - /**/ 0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, - 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, - 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, - 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, - 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, - 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, - 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, - 0x0e38, 0x0e39, 0x0e3a, 0, 0, 0, 0, 0x0e3f, - 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, - 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0, 0x0e4f, - 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, - 0x0e58, 0x0e59, 0, 0, 0xf89b, 0xf89c, 0xf89d, 0 -}; - -static const int tis620_2[128] = { - 0xf700, 0xf701, 0xf702, 0xf703, 0xf704, 0x2026, 0xf705, 0xf706, - 0xf707, 0xf708, 0xf709, 0xf70a, 0xf70b, 0xf70c, 0xf70d, 0xf70e, - 0xf70f, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, - 0xf710, 0xf711, 0xf712, 0xf713, 0xf714, 0xf715, 0xf716, 0xf717, - 0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, - 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, - 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, - 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, - 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, - 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, - 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, - 0x0e38, 0x0e39, 0x0e3a, 0, 0, 0, 0, 0x0e3f, - 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, - 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f, - 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, - 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0xf718, 0xf719, 0xf71a, 0 -}; - -static const int lao_0[128] = { - /**/ 0, 0, 0, 0, 0, 0, 0, 0, - /**/ 0, 0, 0, 0, 0, 0, 0, 0, - /**/ 0, 0, 0, 0, 0, 0, 0, 0, - /**/ 0, 0, 0, 0, 0, 0, 0, 0, - 0x0020, 0x0e81, 0x0e82, 0, 0x0e84, 0, 0, 0x0e87, - 0x0e88, 0, 0x0e8a, 0, 0, 0x0e8d, 0, 0, - 0, 0, 0, 0, 0x0e94, 0x0e95, 0x0e96, 0x0e97, - /**/ 0, 0x0e99, 0x0e9a, 0x0e9b, 0x0e9c, 0x0e9d, 0x0e9e, 0x0e9f, - /**/ 0, 0x0ea1, 0x0ea2, 0x0ea3, 0, 0x0ea5, 0, 0x0ea7, - /**/ 0, 0, 0x0eaa, 0x0eab, 0, 0x0ead, 0x0eae, 0x0eaf, - 0x0eb0, 0x0eb1, 0x0eb2, 0x0eb3, 0x0eb4, 0x0eb5, 0x0eb6, 0x0eb7, - 0x0eb8, 0x0eb9, 0, 0x0ebb, 0x0ebc, 0x0ebd, 0, 0, - 0x0ec0, 0x0ec1, 0x0ec2, 0x0ec3, 0x0ec4, 0, 0x0ec6, 0, - 0x0ec8, 0x0ec9, 0x0eca, 0x0ecb, 0x0ecc, 0x0ecd, 0, 0, - 0x0ed0, 0x0ed1, 0x0ed2, 0x0ed3, 0x0ed4, 0x0ed5, 0x0ed6, 0x0ed7, - 0x0ed8, 0x0ed9, 0, 0, 0x0edc, 0x0edd, 0, 0 -}; -static int -contain_glyphs(PangoFont *font, const int glyph_map[128]) -{ - PangoFcFont *fc_font = (PangoFcFont *)font; - unsigned char c; - - for (c = 0; c < 0x80; c++) - { - if (glyph_map[c]) - { - if (!pango_fc_font_has_char (fc_font, glyph_map[c])) - return 0; - } - } - return 1; -} - -/* Returns a structure with information we will use to rendering given the - * #PangoFont. This is computed once per font and cached for later retrieval. - */ -static ThaiFontInfo * -thai_get_font_info (PangoFont *font, - const PangoOTRuleset *ruleset) -{ - ThaiFontInfo *font_info; - static GQuark info_id = 0; - - if (G_UNLIKELY (!info_id)) - info_id = g_quark_from_string ("thai-font-info"); - - font_info = g_object_get_qdata (G_OBJECT (font), info_id); - - if (G_UNLIKELY (!font_info)) - { - /* No cached information not found, so we need to compute it - * from scratch - */ - font_info = g_new (ThaiFontInfo, 1); - font_info->font = font; - - /* detect font set by determining availibility of OT ruleset & glyphs */ - if (pango_ot_ruleset_get_feature_count (ruleset, NULL, NULL)) - font_info->font_set = THAI_FONT_TIS; - else if (contain_glyphs(font, tis620_2)) - font_info->font_set = THAI_FONT_TIS_WIN; - else if (contain_glyphs(font, tis620_1)) - font_info->font_set = THAI_FONT_TIS_MAC; - else - font_info->font_set = THAI_FONT_TIS; - - g_object_set_qdata_full (G_OBJECT (font), info_id, font_info, (GDestroyNotify)g_free); - } - - return font_info; -} - -static gunichar -get_glyph_index_tis (ThaiFontInfo *font_info, guchar c) -{ - if (!(c & 0x80)) - return lao_0[c]; - - switch (font_info->font_set) { - default: - case THAI_FONT_NONE: return 0; - case THAI_FONT_TIS: return tis620_0[c & 0x7f]; - case THAI_FONT_TIS_MAC: return tis620_1[c & 0x7f]; - case THAI_FONT_TIS_WIN: return tis620_2[c & 0x7f]; - } -} - -PangoGlyph -thai_get_glyph_tis (ThaiFontInfo *font_info, guchar c) -{ - return thai_get_glyph_uni (font_info, get_glyph_index_tis (font_info, c)); -} - -PangoGlyph -thai_make_glyph_tis (ThaiFontInfo *font_info, guchar c) -{ - return thai_make_glyph_uni (font_info, get_glyph_index_tis (font_info, c)); -} - -PangoGlyph -thai_get_glyph_uni (ThaiFontInfo *font_info, gunichar uc) -{ - return pango_fc_font_get_glyph ((PangoFcFont *)font_info->font, uc); -} - -PangoGlyph -thai_make_glyph_uni (ThaiFontInfo *font_info, gunichar uc) -{ - PangoGlyph result; - PangoFcFont *fc_font = (PangoFcFont *)font_info->font; - - result = pango_fc_font_get_glyph (fc_font, uc); - if (result) - return result; - else - return PANGO_GET_UNKNOWN_GLYPH ( uc); -} - -static const PangoOTFeatureMap gsub_features[] = -{ - {"ccmp", PANGO_OT_ALL_GLYPHS}, - {"locl", PANGO_OT_ALL_GLYPHS}, - {"liga", PANGO_OT_ALL_GLYPHS}, -}; - -static const PangoOTFeatureMap gpos_features[] = -{ - {"kern", PANGO_OT_ALL_GLYPHS}, - {"mark", PANGO_OT_ALL_GLYPHS}, - {"mkmk", PANGO_OT_ALL_GLYPHS} -}; - -static void -thai_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED, - PangoFont *font, - const char *text, - gint length, - const PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - PangoFcFont *fc_font; - FT_Face face; - PangoOTRulesetDescription desc; - const PangoOTRuleset *ruleset; - PangoOTBuffer *buffer; - gint i; - ThaiFontInfo *font_info; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - if (!face) - return; - - desc.script = analysis->script; - desc.language = analysis->language; - - desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features); - desc.static_gsub_features = gsub_features; - desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features); - desc.static_gpos_features = gpos_features; - - /* TODO populate other_features from analysis->extra_attrs */ - desc.n_other_features = 0; - desc.other_features = NULL; - - ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc); - - font_info = thai_get_font_info (font, ruleset); - - thai_set_glyphs (font_info, text, length, analysis->script, glyphs); - - buffer = pango_ot_buffer_new (PANGO_FC_FONT (font)); - pango_ot_buffer_set_rtl (buffer, analysis->level % 2 != 0); - - for (i = 0; i < glyphs->num_glyphs; i++) - pango_ot_buffer_add_glyph (buffer, - glyphs->glyphs[i].glyph, - 0, - glyphs->log_clusters[i]); - - pango_ot_ruleset_substitute (ruleset, buffer); - pango_ot_ruleset_position (ruleset, buffer); - - pango_ot_buffer_output (buffer, glyphs); - pango_ot_buffer_destroy (buffer); -} - -PangoGlyph -thai_make_unknown_glyph (ThaiFontInfo *font_info G_GNUC_UNUSED, gunichar uc) -{ - return PANGO_GET_UNKNOWN_GLYPH (uc); -} - -static void -thai_engine_fc_class_init (PangoEngineShapeClass *class) -{ - class->script_shape = thai_engine_shape; -} - -PANGO_ENGINE_SHAPE_DEFINE_TYPE (ThaiEngineFc, thai_engine_fc, - thai_engine_fc_class_init, NULL) - -void -PANGO_MODULE_ENTRY(init) (GTypeModule *module) -{ - thai_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 (thai_engine_fc_type, NULL); - else - return NULL; -} diff --git a/modules/thai/thai-shaper.c b/modules/thai/thai-shaper.c deleted file mode 100644 index 4ed173c8..00000000 --- a/modules/thai/thai-shaper.c +++ /dev/null @@ -1,548 +0,0 @@ -/* Pango - * thai-shaper.c: - * - * Copyright (C) 1999 Red Hat Software - * Author: Owen Taylor <otaylor@redhat.com> - * - * Copyright (C) 2005 Theppitak Karoonboonyanan - * Copyright (C) 2002 Software and Language Engineering Laboratory, NECTEC - * Author: Theppitak Karoonboonyanan <thep@links.nectec.or.th> - * - * Copyright (c) 1996-2000 by Sun Microsystems, Inc. - * Author: Chookij Vanatham <Chookij.Vanatham@Eng.Sun.COM> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#include "config.h" -#include <string.h> - -#include <glib.h> -#include "pango-engine.h" -#include "thai-charprop.h" -#include "thai-shaper.h" - -#define MAX_CLUSTER_CHRS 256 -#define MAX_GLYPHS 256 - - -typedef struct { - guchar Start_TONE_AD, Start_AV, Start_BV_BD, Start_TailCutCons; - - guchar ShiftDown_TONE_AD[8]; - guchar ShiftDownLeft_TONE_AD[8]; - guchar ShiftLeft_TONE_AD[8]; - guchar ShiftLeft_AV[7]; - guchar ShiftDown_BV_BD[3]; - guchar TailCutCons[4]; - - guchar AmComp[2]; /* Sara Am components */ -} ThaiShapeTable; - -#define shiftdown_tone_ad(c,tbl) \ - ((tbl)->ShiftDown_TONE_AD[(c)-(tbl)->Start_TONE_AD]) -#define shiftdownleft_tone_ad(c,tbl) \ - ((tbl)->ShiftDownLeft_TONE_AD[(c)-(tbl)->Start_TONE_AD]) -#define shiftleft_tone_ad(c,tbl) \ - ((tbl)->ShiftLeft_TONE_AD[(c)-(tbl)->Start_TONE_AD]) -#define shiftleft_av(c,tbl) \ - ((tbl)->ShiftLeft_AV[(c)-(tbl)->Start_AV]) -#define shiftdown_bv_bd(c,tbl) \ - ((tbl)->ShiftDown_BV_BD[(c)-(tbl)->Start_BV_BD]) -#define tailcutcons(c,tbl) \ - ((tbl)->TailCutCons[(c)-(tbl)->Start_TailCutCons]) - -/* No adjusted vowel/tonemark glyphs (tis620-0) - */ -static const ThaiShapeTable tis620_0_shape_table = { - 0xE7, 0xD1, 0xD8, 0xAD, - { 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE }, - { 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE }, - { 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE }, - { 0xD1, 0x00, 0x00, 0xD4, 0xD5, 0xD6, 0xD7 }, - { 0xD8, 0xD9, 0xDA }, - { 0xAD, 0x00, 0x00, 0xB0 }, - { 0xED, 0xD2 } -}; - -/* Macintosh - */ -static const ThaiShapeTable Mac_shape_table = { - 0xE7, 0xD1, 0xD8, 0xAD, - { 0xE7, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0xED, 0xEE }, - { 0x93, 0x83, 0x84, 0x85, 0x86, 0x87, 0x8F, 0xEE }, - { 0x93, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x8F, 0xEE }, - { 0x92, 0x00, 0x00, 0x94, 0x95, 0x96, 0x97 }, - { 0xFC, 0xFD, 0xFE }, - { 0x90, 0x00, 0x00, 0x80 }, - { 0xED, 0xD2 } -}; - -/* Microsoft Window - */ -static const ThaiShapeTable Win_shape_table = { - 0xE7, 0xD1, 0xD8, 0xAD, - { 0xE7, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0xED, 0xEE }, - { 0x9A, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x99, 0xEE }, - { 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0x99, 0xEE }, - { 0x98, 0x00, 0x00, 0x81, 0x82, 0x83, 0x84 }, - { 0xFC, 0xFD, 0xFE }, - { 0x90, 0x00, 0x00, 0x80 }, - { 0xED, 0xD2 } -}; - -static const ThaiShapeTable Lao_shape_table = { - 0x67, 0x51, 0x58, 0x2D, - { 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E }, - { 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E }, - { 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E }, - { 0x51, 0x00, 0x00, 0x54, 0x55, 0x56, 0x57 }, - { 0x58, 0x59, 0x00 }, - { 0x2D, 0x00, 0x00, 0x30 }, - { 0x6D, 0x52 } -}; - -static void -add_glyph (ThaiFontInfo *font_info, - PangoGlyphString *glyphs, - gint cluster_start, - PangoGlyph glyph, - gboolean combining) -{ - PangoRectangle ink_rect, logical_rect; - gint index = glyphs->num_glyphs; - - pango_glyph_string_set_size (glyphs, index + 1); - - glyphs->glyphs[index].glyph = glyph; - glyphs->glyphs[index].attr.is_cluster_start = combining ? 0 : 1; - - glyphs->log_clusters[index] = cluster_start; - - pango_font_get_glyph_extents (font_info->font, - glyphs->glyphs[index].glyph, &ink_rect, &logical_rect); - - if (combining || logical_rect.width > 0) - { - glyphs->glyphs[index].geometry.x_offset = 0; - glyphs->glyphs[index].geometry.width = logical_rect.width; - } - else - { - glyphs->glyphs[index].geometry.x_offset = ink_rect.width; - glyphs->glyphs[index].geometry.width = ink_rect.width; - } - glyphs->glyphs[index].geometry.y_offset = 0; -} - -static PangoGlyph -get_null_base_glyph (ThaiFontInfo *font_info) -{ - return thai_get_glyph_uni (font_info, 0x25cc); -} - -static gint -get_adjusted_glyphs_list (ThaiFontInfo *font_info, - gunichar *cluster, - gint num_chrs, - PangoGlyph *glyph_lists, - const ThaiShapeTable *shaping_table) -{ - switch (num_chrs) - { - case 1: - if (is_char_type (cluster[0], - BelowVowel|BelowDiac|AboveVowel|AboveDiac|Tone|SaraAm)) - { - gint n; - glyph_lists[0] = get_null_base_glyph (font_info); - n = glyph_lists[0] ? 1 : 0; - glyph_lists[n++] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - return n; - } - else - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - return 1; - } - break; - - case 2: - if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) && - is_char_type (cluster[1], SaraAm)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph_tis (font_info, shaping_table->AmComp[0]); - glyph_lists[2] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]); - return 3; - } - else if (is_char_type (cluster[0], UpTailCons) && - is_char_type (cluster[1], SaraAm)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph_tis (font_info, - shiftleft_tone_ad (shaping_table->AmComp[0], shaping_table)); - glyph_lists[2] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]); - return 3; - } - else if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) && - is_char_type (cluster[1], AboveVowel)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); - return 2; - } - else if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) && - is_char_type (cluster[1], AboveDiac|Tone)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph_tis (font_info, - shiftdown_tone_ad (ucs2tis (cluster[1]), shaping_table)); - return 2; - } - else if (is_char_type (cluster[0], UpTailCons) && - is_char_type (cluster[1], AboveVowel)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph_tis (font_info, - shiftleft_av (ucs2tis (cluster[1]), shaping_table)); - return 2; - } - else if (is_char_type (cluster[0], UpTailCons) && - is_char_type (cluster[1], AboveDiac|Tone)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph_tis (font_info, - shiftdownleft_tone_ad (ucs2tis (cluster[1]), shaping_table)); - return 2; - } - else if (is_char_type (cluster[0], NoTailCons|UpTailCons) && - is_char_type (cluster[1], BelowVowel|BelowDiac)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); - return 2; - } - else if (is_char_type (cluster[0], BotTailCons) && - is_char_type (cluster[1], BelowVowel|BelowDiac)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = - thai_make_glyph_tis (font_info, - shiftdown_bv_bd (ucs2tis (cluster[1]), shaping_table)); - return 2; - } - else if (is_char_type (cluster[0], SpltTailCons) && - is_char_type (cluster[1], BelowVowel|BelowDiac)) - { - glyph_lists[0] = thai_make_glyph_tis (font_info, - tailcutcons (ucs2tis (cluster[0]), shaping_table)); - glyph_lists[1] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); - return 2; - } - else - { - gint n; - glyph_lists[0] = get_null_base_glyph (font_info); - n = glyph_lists[0] ? 1 : 0; - glyph_lists[n++] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[n++] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); - return n; - } - break; - - case 3: - if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) && - is_char_type (cluster[1], Tone) && - is_char_type (cluster[2], SaraAm)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph_tis (font_info, shaping_table->AmComp[0]); - glyph_lists[2] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); - glyph_lists[3] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]); - return 4; - } - else if (is_char_type (cluster[0], UpTailCons) && - is_char_type (cluster[1], Tone) && - is_char_type (cluster[2], SaraAm)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph_tis (font_info, - shiftleft_tone_ad (shaping_table->AmComp[0], shaping_table)); - glyph_lists[2] = thai_make_glyph_tis (font_info, - shiftleft_tone_ad (ucs2tis (cluster[1]), shaping_table)); - glyph_lists[3] = thai_make_glyph_tis (font_info, shaping_table->AmComp[1]); - return 4; - } - else if (is_char_type (cluster[0], UpTailCons) && - is_char_type (cluster[1], AboveVowel) && - is_char_type (cluster[2], AboveDiac|Tone)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph_tis (font_info, - shiftleft_av (ucs2tis (cluster[1]), shaping_table)); - glyph_lists[2] = thai_make_glyph_tis (font_info, - shiftleft_tone_ad (ucs2tis (cluster[2]), shaping_table)); - return 3; - } - else if (is_char_type (cluster[0], UpTailCons) && - is_char_type (cluster[1], BelowVowel) && - is_char_type (cluster[2], AboveDiac|Tone)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); - glyph_lists[2] = thai_make_glyph_tis (font_info, - shiftdownleft_tone_ad (ucs2tis (cluster[2]), shaping_table)); - return 3; - } - else if (is_char_type (cluster[0], NoTailCons) && - is_char_type (cluster[1], BelowVowel) && - is_char_type (cluster[2], AboveDiac|Tone)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); - glyph_lists[2] = - thai_make_glyph_tis (font_info, - shiftdown_tone_ad (ucs2tis (cluster[2]), shaping_table)); - return 3; - } - else if (is_char_type (cluster[0], SpltTailCons) && - is_char_type (cluster[1], BelowVowel) && - is_char_type (cluster[2], AboveDiac|Tone)) - { - glyph_lists[0] = thai_make_glyph_tis (font_info, - tailcutcons (ucs2tis (cluster[0]), shaping_table)); - glyph_lists[1] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); - glyph_lists[2] = thai_make_glyph_tis (font_info, - shiftdown_tone_ad (ucs2tis (cluster[2]), shaping_table)); - return 3; - } - else if (is_char_type (cluster[0], BotTailCons) && - is_char_type (cluster[1], BelowVowel) && - is_char_type (cluster[2], AboveDiac|Tone)) - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph_tis (font_info, - shiftdown_bv_bd (ucs2tis (cluster[1]), shaping_table)); - glyph_lists[2] = thai_make_glyph_tis (font_info, - shiftdown_tone_ad (ucs2tis (cluster[2]), shaping_table)); - return 3; - } - else - { - glyph_lists[0] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); - glyph_lists[2] = - thai_make_glyph_tis (font_info, ucs2tis (cluster[2])); - return 3; - } - break; - - default: /* e.g. Lao cluster with below cons + upper/lower vowel + tone */ - { - gint i; - for (i = 0; i < num_chrs; i++) - glyph_lists[i] = thai_make_glyph_tis (font_info, ucs2tis (cluster[i])); - return num_chrs; - } - } - - return 0; -} - -static gint -get_glyphs_list (ThaiFontInfo *font_info, - PangoScript script, - gunichar *cluster, - gint num_chrs, - PangoGlyph *glyph_lists) -{ - gint i; - - switch ((int) script) - { - case PANGO_SCRIPT_THAI: - switch (font_info->font_set) - { - default: - case THAI_FONT_NONE: - for (i=0; i < num_chrs; i++) - glyph_lists[i] = thai_make_unknown_glyph (font_info, cluster[i]); - return num_chrs; - - case THAI_FONT_TIS: - /* TIS620-0 + Wtt2.0 Extension - */ - return get_adjusted_glyphs_list (font_info, cluster, - num_chrs, glyph_lists, &tis620_0_shape_table); - - case THAI_FONT_TIS_MAC: - /* MacIntosh Extension - */ - return get_adjusted_glyphs_list (font_info, cluster, - num_chrs, glyph_lists, &Mac_shape_table); - - case THAI_FONT_TIS_WIN: - /* Microsoft Extension - */ - return get_adjusted_glyphs_list (font_info, cluster, - num_chrs, glyph_lists, &Win_shape_table); - } - break; - - case PANGO_SCRIPT_LAO: - return get_adjusted_glyphs_list (font_info, cluster, - num_chrs, glyph_lists, &Lao_shape_table); - - default: - for (i=0; i < num_chrs; i++) - glyph_lists[i] = thai_make_unknown_glyph (font_info, cluster[i]); - return num_chrs; - } - - return 0; /* Quiet GCC */ -} - -static void -add_cluster (ThaiFontInfo *font_info, - PangoScript script, - PangoGlyphString *glyphs, - gint cluster_start, - gunichar *cluster, - gint num_chrs) -{ - PangoGlyph glyphs_list[MAX_GLYPHS]; - gint num_glyphs; - gint i; - - if (isthai (cluster[0])) - { - num_glyphs = get_glyphs_list(font_info, script, cluster, num_chrs, glyphs_list); - for (i=0; i<num_glyphs; i++) - add_glyph (font_info, glyphs, cluster_start, glyphs_list[i], - i == 0 ? FALSE : TRUE); - } - else if (islao (cluster[0])) - { - num_glyphs = get_glyphs_list(font_info, script, cluster, num_chrs, glyphs_list); - for (i=0; i<num_glyphs; i++) - add_glyph (font_info, glyphs, cluster_start, glyphs_list[i], - i == 0 ? FALSE : TRUE); - } - else - { - g_assert (num_chrs == 1); - add_glyph (font_info, glyphs, cluster_start, - thai_make_glyph_uni (font_info, cluster[0]), - FALSE); - } -} - -static gboolean -is_wtt_composible (gunichar cur_wc, gunichar nxt_wc) -{ - switch (TAC_compose_input(cur_wc, nxt_wc)) - { - case 'A': - case 'S': - case 'R': - case 'X': - return FALSE; - - case 'C': - return TRUE; - } - - g_assert_not_reached (); - return FALSE; -} - -static const char * -get_next_cluster(const char *text, - gint length, - gunichar *cluster, - gint *num_chrs) -{ - PangoScript cluster_script = PANGO_SCRIPT_INVALID_CODE, cur_script; - const char *p; - gint n_chars = 0; - gunichar current; - - for (p = text; p < text + length; p = g_utf8_next_char (p)) - { - current = g_utf8_get_char (p); - cur_script = pango_script_for_unichar (current); - if (cluster_script == PANGO_SCRIPT_INVALID_CODE) - cluster_script = cur_script; - if (cur_script != cluster_script || - (n_chars > 0 && - !is_wtt_composible (cluster[n_chars - 1], current))) - break; - cluster[n_chars++] = current; - } - - *num_chrs = n_chars; - return p; -} - -void -thai_set_glyphs (ThaiFontInfo *font_info, - const char *text, - gint length, - PangoScript script, - PangoGlyphString *glyphs) -{ - gint n_chars; - const char *p; - const char *log_cluster; - gunichar cluster[MAX_CLUSTER_CHRS]; - - pango_glyph_string_set_size (glyphs, 0); - - p = text; - while (p < text + length) - { - log_cluster = p; - p = get_next_cluster (p, text + length - p, cluster, &n_chars); - add_cluster (font_info, script, glyphs, log_cluster - text, cluster, n_chars); - } -} diff --git a/modules/thai/thai-shaper.h b/modules/thai/thai-shaper.h deleted file mode 100644 index cb2f7edc..00000000 --- a/modules/thai/thai-shaper.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Pango - * thai-shaper.h: - * - * Copyright (C) 1999 Red Hat Software - * Author: Owen Taylor <otaylor@redhat.com> - * - * Copyright (C) 2004 Theppitak Karoonboonyanan - * Copyright (C) 2002 Software and Language Engineering Laboratory, NECTEC - * Author: Theppitak Karoonboonyanan <thep@linux.thai.net> - * - * Copyright (c) 1996-2000 by Sun Microsystems, Inc. - * Author: Chookij Vanatham <Chookij.Vanatham@Eng.Sun.COM> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __THAI_SHAPER_H__ -#define __THAI_SHAPER_H__ - -typedef struct _ThaiFontInfo ThaiFontInfo; - -/* Font encodings we will use - */ -typedef enum { - THAI_FONT_NONE, - THAI_FONT_TIS, - THAI_FONT_TIS_MAC, - THAI_FONT_TIS_WIN -} ThaiFontSet; - -typedef enum { - THAI_FONTINFO_X, - THAI_FONTINFO_XFT -} ThaiFontInfoType; - -struct _ThaiFontInfo -{ - PangoFont *font; - ThaiFontSet font_set; -}; - -/* - * Abstract methods (implemented by each shaper module) - */ -PangoGlyph -thai_get_glyph_tis (ThaiFontInfo *font_info, guchar c); - -PangoGlyph -thai_make_glyph_tis (ThaiFontInfo *font_info, guchar c); - -PangoGlyph -thai_get_glyph_uni (ThaiFontInfo *font_info, gunichar uc); - -PangoGlyph -thai_make_glyph_uni (ThaiFontInfo *font_info, gunichar uc); - -PangoGlyph -thai_make_unknown_glyph (ThaiFontInfo *font_info, gunichar uc); - -void -thai_set_glyphs (ThaiFontInfo *font_info, - const char *text, - gint length, - PangoScript script, - PangoGlyphString *glyphs); - -#endif /* __THAI_SHAPER_H__ */ diff --git a/modules/tibetan/Makefile.am b/modules/tibetan/Makefile.am deleted file mode 100644 index 96ee4225..00000000 --- a/modules/tibetan/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -include $(top_srcdir)/modules/Module.mk - -if HAVE_FREETYPE -INCLUDES += $(FREETYPE_CFLAGS) -if INCLUDE_TIBETAN_FC -noinst_LTLIBRARIES += libpango-tibetan-fc.la -else -if DYNAMIC_TIBETAN_FC -module_LTLIBRARIES += pango-tibetan-fc.la -endif -endif -endif - -tibetan_fc_sources = $(common_sources) tibetan-fc.c - -pango_tibetan_fc_la_LDFLAGS = -module $(MODULE_LIBTOOL_OPTIONS) -pango_tibetan_fc_la_LIBADD = $(pangoft2libs) -pango_tibetan_fc_la_SOURCES = $(tibetan_fc_sources) -libpango_tibetan_fc_la_SOURCES = $(tibetan_fc_sources) -libpango_tibetan_fc_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_tibetan_fc - --include $(top_srcdir)/git.mk diff --git a/modules/tibetan/tibetan-fc.c b/modules/tibetan/tibetan-fc.c deleted file mode 100644 index 4e894165..00000000 --- a/modules/tibetan/tibetan-fc.c +++ /dev/null @@ -1,574 +0,0 @@ -/* Pango - * tibetan-fc.c: Shaper for Tibetan script - * - * Copyright (C) 2005 DIT, Government of Bhutan <http://www.dit.gov.bt> - * Contact person : Pema Geyleg <pema_geyleg@druknet.bt> - * - * Based on code from khmer shapers developed by Jens Herden - * <jens@tibetanos.inf > and Javier Sola <javier@tibetanos.info> - * - * Based on code from other shapers - * Copyright (C) 1999-2004 Red Hat Software - * Author: Owen Taylor <otaylor@redhat.com> - - * Partially based on Indic shaper - * Copyright (C) 2001, 2002 IBM Corporation - * Author: Eric Mader <mader@jtcsv.com> - * - * The first module for Tibetan shaper was developed by Mr. Karunakar under - * PanLocalization project. - * Mr. Chris Fynn, Mr.Javier Sola, Mr. Namgay Thinley were involved - * while developing this shaper. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * The license on the original Indic shaper code is as follows: - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished - * to do so, provided that the above copyright notice(s) and this - * permission notice appear in all copies of the Software and that - * both the above copyright notice(s) and this permission notice - * appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR - * ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written - * authorization of the copyright holder. - */ -#include "config.h" -#include <string.h> - -#include "pango-engine.h" -#include "pango-ot.h" -#include "pango-utils.h" -#include "pangofc-font.h" - - -#define SCRIPT_ENGINE_NAME "TibetanScriptEngineFc" -#define RENDER_TYPE PANGO_RENDER_TYPE_FC - - -typedef PangoEngineShape TibetanEngineFc; -typedef PangoEngineShapeClass TibetanEngineFcClass ; - - -static PangoEngineScriptInfo tibetan_scripts[] = -{ - { PANGO_SCRIPT_TIBETAN, "*" } -}; - -static PangoEngineInfo script_engines[] = -{ - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - RENDER_TYPE, - tibetan_scripts, G_N_ELEMENTS (tibetan_scripts) - } -}; - - -/* - * Vocabulary - * Base -> A consonant in its full (not subscript) form. It is the - * center of the syllable, it can be souranded by subjoined consonants, vowels, - * signs... but there is only one base in a stack, it has to be coded as - * the first character of the syllable.Included here are also groups of base + subjoined - * which are represented by one single code point in unicode (e.g. 0F43) Also other characters - * that might take subjoined consonants or other combining characters. - * Subjoined -> Subjoined consonants and groups of subjoined consonants which have a single code-point - * to repersent the group (even if each subjoined consonant is represented independently - * by anothe code-point - * Tsa Phru --> Tsa Phru character, Bhutanese people will always place it right after the base, but sometimes, due to - * "normalization" is placed after all the subjoined consonants, and it is also permitted there. - * A Chung Vowel lengthening mark --> . 0F71 It is placed after the base and any subjoined consonants but before any vowels - * Precomposed Sanskrit vowels --> The are combinations of subjoined consonants + vowels that have been assigned - * a given code-point (in spite of each single part of them having also a code-point - * They are avoided, and users are encouraged to use the combination of code-points that - * represents the same sound instead of using this combined characters. This is included here - * for compatibility with possible texts that use them (they are not in the Dzongkha keyboard). - * Halanta -> The Halanta or Virama character 0F84 indicates that a consonant should not use its inheernt vowel, - * in spite of not having other vowels present. It is usually placed immediatly after a base consonant, - * but in some special cases it can also be placed after a subjoined consonant, so this is also - * permitted in this algorithm. (Halanta is always displayed in Tibetan not used as a connecting char) - * - * Subjoined vowels -> Dependent vowels (matras) placed below the base and below all subjoined consonants. There - * might be as much as three subjoined vowels in a given stack (only one in general text, but up - * to three for abreviations, they have to be permitted). - * Superscript vowels -> There are three superscript vowels, and they can be repeated or combined (up to three - * times. They can combine with subjoined vowels, and are always coded after these. - * Anusvara --> Nasalisation sign. Traditioinally placed in absence of vowels, but also after vowels. In some - * special cases it can be placed before a vowel, so this is also permitted - * Candrabindu -> Forms of the Anusvara with different glyphs (and different in identity) which can be placed - * without vowel or after the vowel, but never before. Cannot combine with Anusvara. - * Stress marks -> Marks placed above or below a syllable, affecting the whole syllable. They are combining - * marks, so they have to be attached to a specific stack. The are using to emphasise a syllable. - * - * Digits -> Digits are not considered as non-combining characters because there are a few characters which - * combine with them, so they have to be considered independently. - * Digit combining marks -> dependent marks that combine with digits. - * - * TODO - * There are a number of characters in the CJK block that are used in Tibetan script, two of these are symbols - * are used as bases for combining glyphs, and have not been encoded in Tibetan. As these characters are outside - * of the tibetan block, they have not been treated in this program. -*/ - - -enum TibetanCharClassValues -{ - CC_RESERVED = 0, /* Non Combining Characters*/ - CC_BASE = 1, /* Base Consonants, Base Consonants with Subjoined attached in code point, Sanskrit base marks*/ - CC_SUBJOINED = 2, /* Subjoined Consonats, combination of more than Subjoined Consonants in the code point*/ - CC_TSA_PHRU = 3, /* Tsa-Phru character 0F39*/ - CC_A_CHUNG = 4, /* Vowel Lenthening a-chung mark 0F71*/ - CC_COMP_SANSKRIT = 5, /* Precomposed Sanskrit vowels including Subjoined characters and vowels*/ - CC_HALANTA = 6, /* Halanta Character 0F84*/ - CC_BELOW_VOWEL = 7, /* Subjoined vowels*/ - CC_ABOVE_VOWEL = 8, /* Superscript vowels*/ - CC_ANUSVARA = 9, /* Tibetan sign Rjes Su Nga Ro 0F7E*/ - CC_CANDRABINDU = 10, /* Tibetan sign Sna Ldan and Nyi Zla Naa Da 0F82, 0F83*/ - CC_VISARGA = 11, /* Tibetan sign Rnam Bcad (0F7F)*/ - CC_ABOVE_S_MARK = 12, /* Stress Marks placed above the text*/ - CC_BELOW_S_MARK = 13, /* Stress Marks placed below the text*/ - CC_DIGIT = 14, /* Dzongkha Digits*/ - CC_PRE_DIGIT_MARK = 15, /* Mark placed before the digit*/ - CC_POST_BELOW_DIGIT_M = 16, /* Mark placed below or after the digit*/ - CC_COUNT = 17 /* This is the number of character classes*/ -}; - - -enum TibetanCharClassFlags -{ - CF_CLASS_MASK = 0x0000FFFF, - - CF_DOTTED_CIRCLE = 0x04000000, /* add a dotted circle if a character with this flag is the first in a syllable*/ - CF_DIGIT = 0x01000000, /* flag to speed up comparaisson*/ - CF_PREDIGIT = 0x02000000, /* flag to detect pre-digit marks for reordering*/ - - /* position flags*/ - CF_POS_BEFORE = 0x00080000, - CF_POS_BELOW = 0x00040000, - CF_POS_ABOVE = 0x00020000, - CF_POS_AFTER = 0x00010000, - CF_POS_MASK = 0x000f0000 -}; - - -/* Characters that get refrered to by name */ -enum TibetanChar -{ - C_DOTTED_CIRCLE = 0x25CC, - C_PRE_NUMBER_MARK = 0x0F3F -}; - - -enum -{ - /* simple classes, they are used in the statetable (in this file) to control the length of a syllable - * they are also used to know where a character should be placed (location in reference to the base character) - * and also to know if a character, when independtly displayed, should be displayed with a dotted-circle to - * indicate error in syllable construction - */ - _xx = CC_RESERVED, - _ba = CC_BASE, - _sj = CC_SUBJOINED | CF_DOTTED_CIRCLE | CF_POS_BELOW, - _tp = CC_TSA_PHRU | CF_DOTTED_CIRCLE | CF_POS_ABOVE, - _ac = CC_A_CHUNG | CF_DOTTED_CIRCLE | CF_POS_BELOW, - _cs = CC_COMP_SANSKRIT | CF_DOTTED_CIRCLE | CF_POS_BELOW, - _ha = CC_HALANTA | CF_DOTTED_CIRCLE | CF_POS_BELOW, - _bv = CC_BELOW_VOWEL | CF_DOTTED_CIRCLE | CF_POS_BELOW, - _av = CC_ABOVE_VOWEL | CF_DOTTED_CIRCLE | CF_POS_ABOVE, - _an = CC_ANUSVARA | CF_DOTTED_CIRCLE | CF_POS_ABOVE, - _cb = CC_CANDRABINDU | CF_DOTTED_CIRCLE | CF_POS_ABOVE, - _vs = CC_VISARGA | CF_DOTTED_CIRCLE| CF_POS_AFTER, - _as = CC_ABOVE_S_MARK | CF_DOTTED_CIRCLE | CF_POS_ABOVE, - _bs = CC_BELOW_S_MARK | CF_DOTTED_CIRCLE | CF_POS_BELOW, - _di = CC_DIGIT | CF_DIGIT, - _pd = CC_PRE_DIGIT_MARK | CF_DOTTED_CIRCLE | CF_PREDIGIT | CF_POS_BEFORE , - _bd = CC_POST_BELOW_DIGIT_M | CF_DOTTED_CIRCLE | CF_POS_AFTER -}; - - -/* Character class: a character class value - * ORed with character class flags. - */ -typedef glong TibetanCharClass; -/*_xx Non Combining characters*/ -/*_ba Base Consonants*/ -/*_sj Subjoined consonants*/ -/*_tp Tsa - phru*/ -/*_ac A-chung, Vowel Lengthening mark*/ -/*_cs Precomposed Sanskrit vowel + subjoined consonants*/ -/*_ha Halanta/Virama*/ -/*_bv Below vowel*/ -/*_av above vowel*/ -/*_an Anusvara*/ -/*_cb Candrabindu*/ -/*_vs Visaraga/Post mark*/ -/*_as Upper Stress marks*/ -/*_bs Lower Stress marks*/ -/*_di Digit*/ -/*_pd Number pre combining, Needs reordering*/ -/*_bd Other number combining marks*/ - - -static const TibetanCharClass tibetanCharClasses[] = -{ - /* 0 1 2 3 4 5 6 7 8 9 a b c d e f*/ - _xx, _ba, _xx, _xx, _ba, _ba, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0F00 - 0F0F 0*/ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _bd, _bd, _xx, _xx, _xx, _xx, _xx, _xx, /* 0F10 - 0F1F 1*/ - _di, _di, _di, _di, _di, _di, _di, _di, _di, _di, _xx, _xx, _xx, _xx, _xx, _xx, /* 0F20 - 0F2F 2*/ - _xx, _xx, _xx, _xx, _xx, _bs, _xx, _bs, _xx, _tp, _xx, _xx, _xx, _xx, _bd, _pd, /* 0F30 - 0F3F 3*/ - _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _xx, _ba, _ba, _ba, _ba, _ba, _ba, _ba, /* 0F40 - 0F4F 4*/ - _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, /* 0F50 - 0F5F 5*/ - _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _ba, _xx, _xx, _xx, _xx, _xx, /* 0F60 - 0F6F 6*/ - _xx, _ac, _av, _cs, _bv, _bv, _cs, _cs, _cs, _cs, _av, _av, _av, _av, _an, _vs, /* 0F70 - 0F7F 7*/ - _av, _cs, _cb, _cb, _ha, _xx, _as, _as, _ba, _ba, _ba, _ba, _xx, _xx, _xx, _xx, /* 0F80 - 0F8F 8*/ - _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _xx, _sj, _sj, _sj, _sj, _sj, _sj, _sj, /* 0F90 - 0F9F 9*/ - _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, /* 0FA0 - 0FAF a*/ - _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _sj, _xx, _sj, _sj, /* 0FB0 - 0FBF b*/ - _xx, _xx, _xx, _xx, _xx, _xx, _bs, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0FC0 - 0FCF c*/ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0FD0 - 0FDF d*/ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0FE0 - 0FEF e*/ - _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0FF0 - 0FFF f*/ -}; - -/* this define must reflect the range of tibetanCharClasses */ -/*First Tibetan Character*/ -#define firstChar 0x0F00 -/*Last Tibetan Character*/ -#define lastChar 0x0FFF - -/* The stateTable is used to calculate the end (the length) of a well - * formed Tibetan Stack - * - * Each horizontal line is ordered exactly the same way as the values in TibetanClassTable - * CharClassValues.This coincidence of values allows the follow up of the table. - * - * Each line corresponds to a state, which does not necessarily need to be a type - * of component... for example, state 2 is a base, with is always a first character - * in the Stack but the state could be produced a consonant of any type when - * it is the first character that is analysed (in ground state). - */ - -static const gint8 tibetanStateTable[][CC_COUNT] = -{ - /*Dzongkha state table*/ - /*xx ba sj tp ac cs ha bv av an cb vs as bs di pd bd*/ - { 1, 2, 4, 3, 8, 7, 9, 10, 14, 13, 17, 18, 19, 19, 20, 21, 21,}, /* 0 - ground state*/ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, /* 1 - exit state (or sign to the right of the syllable)*/ - {-1, -1, 4, 3, 8, 7, 9, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 2 - Base consonant*/ - {-1, -1, 5, -1, 8, 7, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 3 - Tsa phru after base*/ - {-1, -1, 4, 6, 8, 7, 9, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 4 - Subjoined consonant after base*/ - {-1, -1, 5, -1, 8, 7, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 5 - Subjoined consonant after tsa phru*/ - {-1, -1, -1, -1, 8, 7, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 6 - Tsa phru after subjoined consonant*/ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 19, -1, -1, -1,}, /* 7 - Pre Composed Sanskrit*/ - {-1, -1, -1, -1, -1, -1, -1, 10, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 8 - A-chung*/ - {-1, -1, -1, -1, -1, -1, -1, -1, 14, 13, 17, -1, 19, 19, -1, -1, -1,}, /* 9 - Halanta*/ - {-1, -1, -1, -1, -1, -1, -1, 11, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 10 - below vowel 1*/ - {-1, -1, -1, -1, -1, -1, -1, 12, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 11 - below vowel 2*/ - {-1, -1, -1, -1, -1, -1, -1, -1, 14, 13, 17, 18, 19, 19, -1, -1, -1,}, /* 12 - below vowel 3*/ - {-1, -1, -1, -1, -1, -1, -1, -1, 14, 17, 17, 18, 19, 19, -1, -1, -1,}, /* 13 - Anusvara before vowel*/ - {-1, -1, -1, -1, -1, -1, -1, -1, 15, 17, 17, 18, 19, 19, -1, -1, -1,}, /* 14 - above vowel 1*/ - {-1, -1, -1, -1, -1, -1, -1, -1, 16, 17, 17, 18, 19, 19, -1, -1, -1,}, /* 15 - above vowel 2*/ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 17, 18, 19, 19, -1, -1, -1,}, /* 16 - above vowel 3*/ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, 19, 19, -1, -1, -1,}, /* 17 - Anusvara or Candrabindu after vowel*/ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 19, -1, -1, -1,}, /* 18 - Visarga*/ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, /* 19 - strss mark*/ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, 21,}, /* 20 - digit*/ - {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, /* 21 - digit mark*/ -}; - - -enum property_flags -{ - abvf = 0x0001, - pref = 0x0002, - pstf = 0x0004, - blwf = 0x0008, - - pres = 0x0010, - blws = 0x0020, - abvs = 0x0040, - psts = 0x0080, - clig = 0x0100, - - dist = 0x0200, - blwm = 0x0400, - abvm = 0x0800, -}; - - -enum properties -{ - blwf_p = /*(blwf | blws | clig | dist | blwm)*/ (abvf | pref | pstf | pres | abvs | psts | abvm), - pstf_p = /*(blwf | blws | pref | pres | pstf | psts | clig | dist | blwm)*/ (abvf | abvs | abvm), - abvf_p = /*(abvf | abvs | clig | dist | abvm)*/ (pref | pstf | blwf | pres | blws | psts | blwm), - pref_p = /*(pref | pres | clig | dist)*/ (abvf | pstf | blwf | blws | abvs | psts | blwm | abvm), - default_p = /*(pres | blws | clig | dist | abvm | blwm)*/ (pref | blwf |abvf | pstf | abvs | psts) -}; - - -/* Below we define how a character in the input string is either in the tibetanCharClasses table - * (in which case we get its type back), or an unknown object in which case we get _xx (CC_RESERVED) back - */ -static TibetanCharClass -get_char_class (gunichar ch) -{ - - if (ch < firstChar || ch > lastChar) - return CC_RESERVED; - - return tibetanCharClasses[ch - firstChar]; -} - - -/* Given an input string of characters and a location in which to start looking - * calculate, using the state table, which one is the last character of the syllable - * that starts in the starting position. - */ -static glong -find_syllable (const gunichar *chars, - glong start, - glong char_count) -{ - glong cursor = start; - gint8 state = 0; - TibetanCharClass charClass; - - while (cursor < char_count) - { - charClass = get_char_class (chars[cursor]) & CF_CLASS_MASK; - state = tibetanStateTable[state][charClass]; - - if (state < 0) - break; - - cursor += 1; - } - - return cursor; -} - -static const PangoOTFeatureMap gsub_features[] = -{ - {"ccmp", PANGO_OT_ALL_GLYPHS}, - {"locl", PANGO_OT_ALL_GLYPHS}, - {"blws", blws}, - {"abvs", abvs}, - {"psts", psts}, - {"clig", clig}, - {"calt", PANGO_OT_ALL_GLYPHS} -}; - -static const PangoOTFeatureMap gpos_features[] = -{ - {"dist", dist}, - {"blwm", blwm}, - {"abvm", abvm}, - {"kern", PANGO_OT_ALL_GLYPHS}, - {"mark", PANGO_OT_ALL_GLYPHS}, - {"mkmk", PANGO_OT_ALL_GLYPHS} -}; - -static PangoGlyph -get_index (PangoFcFont *fc_font, gunichar wc) -{ - PangoGlyph index = pango_fc_font_get_glyph (fc_font, wc); - if (!index) - index = PANGO_GET_UNKNOWN_GLYPH ( wc); - return index; -} - - -static void -tibetan_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED, - PangoFont *font, - const char *text, - int length, - const PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - PangoFcFont *fc_font; - FT_Face face; - PangoOTRulesetDescription desc; - const PangoOTRuleset *ruleset; - PangoOTBuffer *buffer; - glong n_chars; - gunichar *wcs; - const char *p; - int i; - glong syllable; - TibetanCharClass charClass; - glong cursor = 0; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - if (!face) - return; - - buffer = pango_ot_buffer_new (fc_font); - pango_ot_buffer_set_rtl (buffer, analysis->level % 2 != 0); - - wcs = g_utf8_to_ucs4_fast (text, length, &n_chars); - - p = text; - /* This loop only exits when we reach the end of a run, which may contain - * several syllables. - */ - while (cursor < n_chars) - { - syllable = find_syllable (wcs, cursor, n_chars); - - /* shall we add a dotted circle? - * If in the position in which the base should be (first char in the string) there is - * a character that has the Dotted circle flag (a character that cannot be a base) - * then write a dotted circle - */ - if (get_char_class (wcs[cursor]) & CF_DOTTED_CIRCLE) - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_DOTTED_CIRCLE), default_p, p - text); - } - - /* If it encounters a digit followed by number pre combining mark, then reorder the two characters - * coeng Ro if they are present - */ - for (i = cursor; i < syllable; i += 1) - { - charClass = get_char_class (wcs[i]); - - if ((charClass & CF_DIGIT ) - && ( get_char_class (wcs[i+1]) & CF_PREDIGIT)) - { - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, C_PRE_NUMBER_MARK), pref_p, p - text); - p = g_utf8_next_char (p); - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pref_p, p - text); - i += 1; - } else { - switch (charClass & CF_POS_MASK) - { - case CF_POS_ABOVE : - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), abvf_p, p - text); - break; - - case CF_POS_AFTER : - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), pstf_p, p - text); - break; - - case CF_POS_BELOW : - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), blwf_p, p - text); - break; - - default: - /* default - any other characters */ - pango_ot_buffer_add_glyph (buffer, get_index (fc_font, wcs[i]), default_p, p - text); - break; - } /* switch */ - } - - p = g_utf8_next_char (p); - } /* for */ - - cursor = syllable; /* move the pointer to the start of next syllable */ - } /* while */ - - desc.script = analysis->script; - desc.language = analysis->language; - - desc.n_static_gsub_features = G_N_ELEMENTS (gsub_features); - desc.static_gsub_features = gsub_features; - desc.n_static_gpos_features = G_N_ELEMENTS (gpos_features); - desc.static_gpos_features = gpos_features; - - /* TODO populate other_features from analysis->extra_attrs */ - desc.n_other_features = 0; - desc.other_features = NULL; - - ruleset = pango_ot_ruleset_get_for_description (pango_ot_info_get (face), &desc); - - pango_ot_ruleset_substitute (ruleset, buffer); - pango_ot_ruleset_position (ruleset, buffer); - pango_ot_buffer_output (buffer, glyphs); - - g_free (wcs); - pango_ot_buffer_destroy (buffer); - - pango_fc_font_unlock_face (fc_font); -} - - -static void -tibetan_engine_fc_class_init (PangoEngineShapeClass *class) -{ - class->script_shape = tibetan_engine_shape; -} - -PANGO_ENGINE_SHAPE_DEFINE_TYPE (TibetanEngineFc, tibetan_engine_fc, - tibetan_engine_fc_class_init, NULL) - - -void -PANGO_MODULE_ENTRY(init) (GTypeModule *module) -{ - tibetan_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 (tibetan_engine_fc_type, NULL); - else - return NULL; -} |