diff options
-rw-r--r-- | modules/arabic/arabic-fc.c | 361 | ||||
-rw-r--r-- | modules/basic/basic-fc.c | 283 | ||||
-rw-r--r-- | modules/hebrew/hebrew-fc.c | 262 | ||||
-rw-r--r-- | modules/thai/thai-fc.c | 259 |
4 files changed, 0 insertions, 1165 deletions
diff --git a/modules/arabic/arabic-fc.c b/modules/arabic/arabic-fc.c deleted file mode 100644 index 71b5bd50..00000000 --- a/modules/arabic/arabic-fc.c +++ /dev/null @@ -1,361 +0,0 @@ -/* Pango - * arabic-xft.h: - * - * Copyright (C) 2000 Red Hat Software - * Author: 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 <string.h> - -#include "arabic-ot.h" - -#include "pangoxft.h" -#include "pango-engine.h" -#include "pango-utils.h" - -#define SCRIPT_ENGINE_NAME "ArabicScriptEngineXft" - -static PangoEngineRange arabic_ranges[] = { - /* Language characters */ - { 0x060c, 0x06f9, "*" }, /* Arabic */ -}; - -static PangoEngineInfo script_engines[] = { - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_XFT, - arabic_ranges, G_N_ELEMENTS(arabic_ranges) - } -}; - -static void -maybe_add_feature (PangoOTRuleset *ruleset, - PangoOTInfo *info, - guint script_index, - PangoOTTag tag, - gulong property_bit) -{ - guint feature_index; - - /* 0xffff == default language system */ - if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GSUB, - tag, script_index, 0xffff, &feature_index)) - pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GSUB, feature_index, - property_bit); -} - -static PangoOTRuleset * -get_ruleset (PangoFont *font) -{ - PangoOTRuleset *ruleset; - static GQuark ruleset_quark = 0; - - PangoOTInfo *info = pango_xft_font_get_ot_info (font); - - if (!ruleset_quark) - ruleset_quark = g_quark_from_string ("pango-arabic-ruleset"); - - if (!info) - return NULL; - - ruleset = g_object_get_qdata (G_OBJECT (font), ruleset_quark); - - if (!ruleset) - { - PangoOTTag arab_tag = FT_MAKE_TAG ('a', 'r', 'a', 'b'); - guint script_index; - - ruleset = pango_ot_ruleset_new (info); - - if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB, - arab_tag, &script_index)) - { - maybe_add_feature (ruleset, info, script_index, FT_MAKE_TAG ('i','s','o','l'), isolated); - maybe_add_feature (ruleset, info, script_index, FT_MAKE_TAG ('i','n','i','t'), initial); - maybe_add_feature (ruleset, info, script_index, FT_MAKE_TAG ('m','e','d','i'), medial); - maybe_add_feature (ruleset, info, script_index, FT_MAKE_TAG ('f','i','n','a'), final); - maybe_add_feature (ruleset, info, script_index, FT_MAKE_TAG ('l','i','g','a'), 0xFFFF); - } - - g_object_set_qdata_full (G_OBJECT (font), ruleset_quark, ruleset, - (GDestroyNotify)g_object_unref); - } - - return ruleset; -} - -static void -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; - } -} - -static void -set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGlyph glyph) -{ - glyphs->glyphs[i].glyph = glyph; - glyphs->log_clusters[i] = offset; -} - -static guint -find_char (FT_Face face, PangoFont *font, gunichar wc) -{ - int index = FT_Get_Char_Index (face, wc); - - if (index && index <= face->num_glyphs) - return index; - else - return 0; -} - -static void -arabic_engine_shape (PangoFont *font, - const char *text, - gint length, - PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - int n_chars; - int i; - const char *p; - gulong *properties = NULL; - gunichar *wcs = NULL; - FT_Face face; - PangoOTRuleset *ruleset; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - face = pango_xft_font_get_face (font); - g_assert (face); - - n_chars = g_utf8_strlen (text, length); - pango_glyph_string_set_size (glyphs, n_chars); - - ruleset = get_ruleset (font); - if (ruleset) - { - wcs = g_utf8_to_ucs4_fast (text, length, NULL); - properties = g_new0 (gulong, n_chars); - - Arabic_Assign_Properties (wcs, properties, n_chars); - } - - p = text; - for (i=0; i < n_chars; i++) - { - gunichar wc; - gunichar mirrored_ch; - PangoGlyph index; - char buf[6]; - const char *input; - - wc = g_utf8_get_char (p); - - input = p; - if (analysis->level % 2) - if (pango_get_mirror_char (wc, &mirrored_ch)) - { - wc = mirrored_ch; - - g_unichar_to_utf8 (wc, buf); - input = buf; - } - - if (wc >= 0x200B && wc <= 0x200F) /* Zero-width characters */ - { - set_glyph (font, glyphs, i, p - text, 0); - } - else - { - /* 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 (wc == 0x6cc && ruleset && - ((properties[i] & (initial | medial)) != (initial | medial))) - wc = 0x64a; - - index = find_char (face, font, wc); - - if (!index) - { - set_glyph (font, glyphs, i, p - text, - pango_xft_font_get_unknown_glyph (font, wc)); - } - else - { - set_glyph (font, glyphs, i, p - text, index); - - if (g_unichar_type (wc) == G_UNICODE_NON_SPACING_MARK) - { - if (i > 0) - { - glyphs->log_clusters[i] = glyphs->log_clusters[i-1]; -#if 0 - PangoRectangle logical_rect, ink_rect; - - glyphs->glyphs[i].geometry.width = MAX (glyphs->glyphs[i-1].geometry.width, - glyphs->glyphs[i].geometry.width); - glyphs->glyphs[i-1].geometry.width = 0; - - /* Some heuristics to try to guess how overstrike glyphs are - * done and compensate - */ - pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, &ink_rect, &logical_rect); - if (logical_rect.width == 0 && ink_rect.x == 0) - glyphs->glyphs[i].geometry.x_offset = (glyphs->glyphs[i].geometry.width - ink_rect.width) / 2; -#endif - } - } - } - } - - p = g_utf8_next_char (p); - } - - ruleset = get_ruleset (font); - - if (ruleset) - { - pango_ot_ruleset_shape (ruleset, glyphs, properties); - - g_free (wcs); - g_free (properties); - - } - - for (i = 0; i < glyphs->num_glyphs; i++) - { - - if (glyphs->glyphs[i].glyph) - { - PangoRectangle logical_rect; - - pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect); - glyphs->glyphs[i].geometry.width = logical_rect.width; - } - else - glyphs->glyphs[i].geometry.width = 0; - - glyphs->glyphs[i].geometry.x_offset = 0; - glyphs->glyphs[i].geometry.y_offset = 0; - } - - /* Simple bidi support */ - - if (analysis->level % 2) - { - int start, end; - - /* Swap all glyphs */ - 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++; - - if (end > start + 1) - swap_range (glyphs, start, end); - start = end; - } - } -} - -static PangoCoverage * -arabic_engine_get_coverage (PangoFont *font, - PangoLanguage *lang) -{ - return pango_font_get_coverage (font, lang); -} - -static PangoEngine * -arabic_engine_xft_new () -{ - PangoEngineShape *result; - - result = g_new (PangoEngineShape, 1); - - result->engine.id = SCRIPT_ENGINE_NAME; - result->engine.type = PANGO_ENGINE_TYPE_SHAPE; - result->engine.length = sizeof (result); - result->script_shape = arabic_engine_shape; - result->get_coverage = arabic_engine_get_coverage; - - return (PangoEngine *)result; -} - -/* The following three functions provide the public module API for - * Pango. If we are compiling it is a module, then we name the - * entry points script_engine_list, etc. But if we are compiling - * it for inclusion directly in Pango, then we need them to - * to have distinct names for this module, so we prepend - * _pango_arabic_ - */ -#ifdef XFT_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_arabic_xft_##func -#else -#define MODULE_ENTRY(func) func -#endif - -/* List the engines contained within this module - */ -void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) -{ - *engines = script_engines; - *n_engines = G_N_ELEMENTS (script_engines); -} - -/* Load a particular engine given the ID for the engine - */ -PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) -{ - if (!strcmp (id, SCRIPT_ENGINE_NAME)) - return arabic_engine_xft_new (); - else - return NULL; -} - -void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) -{ -} diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c deleted file mode 100644 index f72ae195..00000000 --- a/modules/basic/basic-fc.c +++ /dev/null @@ -1,283 +0,0 @@ -/* Pango - * basic-xft.h: - * - * Copyright (C) 2000 Red Hat Software - * Author: 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 <string.h> - -#include "pangoxft.h" -#include "pango-engine.h" -#include "pango-utils.h" - -#include "basic-common.h" - -static PangoEngineRange basic_ranges[] = { - /* Language characters */ - { 0x0380, 0x058f, "*" }, - { 0x0591, 0x05f4, "" }, /* Hebrew */ - { 0x060c, 0x06f9, "" }, /* Arabic */ - { 0x0e01, 0x0e5b, "" }, /* Thai */ - { 0x10a0, 0x10ff, "*" }, /* Georgian */ - { 0x1200, 0x16ff, "*" }, /* Ethiopic,Cherokee,Canadian,Ogham,Runic */ - { 0x1e00, 0x1fff, "*" }, - { 0x2000, 0x9fff, "*" }, - { 0xac00, 0xd7a3, "kr" }, - { 0xf900, 0xfa0b, "kr" }, - { 0xff00, 0xffe3, "*" }, - { 0x0000, 0xffff, "" }, -}; - -static PangoEngineInfo script_engines[] = { - { - "BasicScriptEngineXft", - PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_XFT, - basic_ranges, G_N_ELEMENTS(basic_ranges) - } -}; - -static void -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; - } -} - -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; -} - -static guint -find_char (FT_Face face, PangoFont *font, gunichar wc) -{ - int index = FT_Get_Char_Index (face, wc); - - if (index && index <= face->num_glyphs) - return index; - else - return 0; -} - -static void -basic_engine_shape (PangoFont *font, - const char *text, - gint length, - PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - int n_chars; - int i; - const char *p; - FT_Face face; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - face = pango_xft_font_get_face (font); - g_assert (face); - - n_chars = g_utf8_strlen (text, length); - pango_glyph_string_set_size (glyphs, n_chars); - - p = text; - for (i=0; i < n_chars; i++) - { - gunichar wc; - gunichar mirrored_ch; - PangoGlyph index; - - wc = g_utf8_get_char (p); - - if (analysis->level % 2) - if (pango_get_mirror_char (wc, &mirrored_ch)) - wc = mirrored_ch; - - if (wc == 0xa0) /* non-break-space */ - wc = 0x20; - - if (ZERO_WIDTH_CHAR (wc)) - { - set_glyph (font, glyphs, i, p - text, 0); - } - else - { - index = find_char (face, font, wc); - - if (!index) - { - set_glyph (font, glyphs, i, p - text, - pango_xft_font_get_unknown_glyph (font, wc)); - -#if 0 - gint j; - char buf[9]; - int len = (wc < 65536) ? 6 : 8; - - sprintf(buf, "[%0*X]", len - 2, wc); - - n_chars += len - 1; - pango_glyph_string_set_size (glyphs, n_chars); - for (j=0; j < len; j++) - { - set_glyph (font, glyphs, i + j, - p - text, find_char (face, font, buf[j])); - } - i += len - 1; -#endif - } - else - { - set_glyph (font, glyphs, i, p - text, index); - - if (g_unichar_type (wc) == G_UNICODE_NON_SPACING_MARK) - { - if (i > 0) - { - PangoRectangle logical_rect, ink_rect; - - glyphs->glyphs[i].geometry.width = MAX (glyphs->glyphs[i-1].geometry.width, - glyphs->glyphs[i].geometry.width); - glyphs->glyphs[i-1].geometry.width = 0; - glyphs->log_clusters[i] = glyphs->log_clusters[i-1]; - - /* Some heuristics to try to guess how overstrike glyphs are - * done and compensate - */ - pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, &ink_rect, &logical_rect); - if (logical_rect.width == 0 && ink_rect.x == 0) - glyphs->glyphs[i].geometry.x_offset = (glyphs->glyphs[i].geometry.width - ink_rect.width) / 2; - } - } - } - } - - p = g_utf8_next_char (p); - } - - /* Simple bidi support... may have separate modules later */ - - if (analysis->level % 2) - { - int start, end; - - /* Swap all glyphs */ - swap_range (glyphs, 0, n_chars); - - /* Now reorder glyphs within each cluster back to LTR */ - for (start=0; start<n_chars;) - { - end = start; - while (end < n_chars && - glyphs->log_clusters[end] == glyphs->log_clusters[start]) - end++; - - swap_range (glyphs, start, end); - start = end; - } - } -} - -static PangoCoverage * -basic_engine_get_coverage (PangoFont *font, - PangoLanguage *lang) -{ - return pango_font_get_coverage (font, lang); -} - -static PangoEngine * -basic_engine_xft_new () -{ - PangoEngineShape *result; - - result = g_new (PangoEngineShape, 1); - - result->engine.id = PANGO_RENDER_TYPE_XFT; - result->engine.type = PANGO_ENGINE_TYPE_SHAPE; - result->engine.length = sizeof (result); - result->script_shape = basic_engine_shape; - result->get_coverage = basic_engine_get_coverage; - - return (PangoEngine *)result; -} - -/* The following three functions provide the public module API for - * Pango. If we are compiling it is a module, then we name the - * entry points script_engine_list, etc. But if we are compiling - * it for inclusion directly in Pango, then we need them to - * to have distinct names for this module, so we prepend - * _pango_basic_xft_ - */ -#ifdef XFT_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_basic_xft_##func -#else -#define MODULE_ENTRY(func) func -#endif - -/* List the engines contained within this module - */ -void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) -{ - *engines = script_engines; - *n_engines = G_N_ELEMENTS (script_engines); -} - -/* Load a particular engine given the ID for the engine - */ -PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) -{ - if (!strcmp (id, "BasicScriptEngineXft")) - return basic_engine_xft_new (); - else - return NULL; -} - -void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) -{ -} diff --git a/modules/hebrew/hebrew-fc.c b/modules/hebrew/hebrew-fc.c deleted file mode 100644 index 365d34fb..00000000 --- a/modules/hebrew/hebrew-fc.c +++ /dev/null @@ -1,262 +0,0 @@ -/* Pango - * hebrew-xft.h: - * - * Copyright (C) 2000 Red Hat Software - * Author: 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 <string.h> - -#include "pangoxft.h" -#include "pango-engine.h" -#include "pango-utils.h" -#include "hebrew-shaper.h" - -#define MAX_CLUSTER_CHRS 20 - -static PangoEngineRange hebrew_ranges[] = { - /* Language characters */ - { 0x0591, 0x05f4, "*" }, /* Hebrew */ -}; - -static PangoEngineInfo script_engines[] = { - { - "HebrewScriptEngineXft", - PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_XFT, - hebrew_ranges, G_N_ELEMENTS(hebrew_ranges) - } -}; - -static guint -get_glyph_num (FT_Face face, PangoFont *font, gunichar wc) -{ - int index = FT_Get_Char_Index (face, wc); - - if (index && index <= face->num_glyphs) - return index; - else - return 0; -} - -static void -get_cluster_glyphs(FT_Face face, - PangoFont *font, - gunichar cluster[], - gint cluster_size, - /* output */ - gint glyph_num[], - PangoGlyph glyph[], - gint widths[], - PangoRectangle ink_rects[]) -{ - int i; - for (i=0; i<cluster_size; i++) - { - PangoRectangle logical_rect; - glyph_num[i] = get_glyph_num(face, font, cluster[i]); - 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(PangoFont *font, - PangoGlyphString *glyphs, - int cluster_size, - int cluster_start, - int glyph_num[], - 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 -hebrew_engine_shape (PangoFont *font, - const char *text, - gint length, - 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]; - FT_Face face; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - pango_glyph_string_set_size (glyphs, 0); - face = pango_xft_font_get_face (font); - g_assert (face); - - 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(face, - font, - cluster, - cluster_size, - /* 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(font, - glyphs, - cluster_size, - log_cluster - text, - glyph_num, - glyph, - glyph_width, - x_offset, - y_offset); - - } - - if (analysis->level % 2) - hebrew_shaper_bidi_reorder(glyphs); -} - -static PangoCoverage * -hebrew_engine_get_coverage (PangoFont *font, - PangoLanguage *lang) -{ - return pango_font_get_coverage (font, lang); -} - -static PangoEngine * -hebrew_engine_xft_new () -{ - PangoEngineShape *result; - - result = g_new (PangoEngineShape, 1); - - result->engine.id = PANGO_RENDER_TYPE_XFT; - result->engine.type = PANGO_ENGINE_TYPE_SHAPE; - result->engine.length = sizeof (result); - result->script_shape = hebrew_engine_shape; - result->get_coverage = hebrew_engine_get_coverage; - - return (PangoEngine *)result; -} - -/* The following three functions provide the public module API for - * Pango. If we are compiling it is a module, then we name the - * entry points script_engine_list, etc. But if we are compiling - * it for inclusion directly in Pango, then we need them to - * to have distinct names for this module, so we prepend - * _pango_hebrew_xft_ - */ -#ifdef XFT_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_hebrew_xft_##func -#else -#define MODULE_ENTRY(func) func -#endif - -/* List the engines contained within this module - */ -void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) -{ - *engines = script_engines; - *n_engines = G_N_ELEMENTS (script_engines); -} - -/* Load a particular engine given the ID for the engine - */ -PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) -{ - if (!strcmp (id, "HebrewScriptEngineXft")) - return hebrew_engine_xft_new (); - else - return NULL; -} - -void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) -{ -} diff --git a/modules/thai/thai-fc.c b/modules/thai/thai-fc.c deleted file mode 100644 index 3466bf2a..00000000 --- a/modules/thai/thai-fc.c +++ /dev/null @@ -1,259 +0,0 @@ -/* Pango - * thai-xft.c: - * - * Copyright (C) 1999 Red Hat Software - * Author: Owen Taylor <otaylor@redhat.com> - * - * Copyright (C) 2002 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 <string.h> - -#include <glib.h> -#include "pango-engine.h" -#include "pangoxft.h" -#include "thai-shaper.h" - -#define SCRIPT_ENGINE_NAME "ThaiScriptEngineXft" - -/* We handle the range U+0e01 to U+0e5b exactly - */ -static PangoEngineRange thai_ranges[] = { - { 0x0e01, 0x0e5b, "*" }, /* Thai */ -}; - -static PangoEngineInfo script_engines[] = { - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_XFT, - thai_ranges, G_N_ELEMENTS(thai_ranges) - } -}; - -/* TIS-to-Unicode glyph maps for characters 0x80-0xff - */ -static 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 int tis620_1[128] = { - 0x00ab, 0x00bb, 0x2026, 0xf88c, 0xf88f, 0xf892, 0xf895, 0xf898, - 0xf88b, 0xf88e, 0xf891, 0xf894, 0xf897, 0x201c, 0x201d, 0xf899, - /**/ 0, 0x2022, 0xf884, 0xf889, 0xf885, 0xf886, 0xf887, 0xf888, - 0xf88a, 0xf88d, 0xf890, 0xf893, 0xf896, 0x2018, 0x2019, 0, - 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, 0xfeff, 0x200b, 0x2013, 0x2014, 0x0e3f, - 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, - 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x2122, 0x0e4f, - 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, - 0x0e58, 0x0e59, 0x00ae, 0x00a9, 0, 0, 0, 0 -}; - -static 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 int -contain_glyphs(FT_Face face, const int glyph_map[128]) -{ - unsigned char c; - int index; - - for (c = 0; c < 0x80; c++) - { - if (glyph_map[c]) - { - index = FT_Get_Char_Index (face, glyph_map[c]); - if (!index || index > face->num_glyphs) - 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. - */ -ThaiFontInfo * -thai_get_font_info (PangoFont *font) -{ - ThaiFontInfo *font_info; - GQuark info_id = g_quark_from_string ("thai-font-info"); - - font_info = g_object_get_qdata (G_OBJECT (font), info_id); - - if (!font_info) - { - /* No cached information not found, so we need to compute it - * from scratch - */ - FT_Face face; - - font_info = g_new (ThaiFontInfo, 1); - font_info->font = font; - - /* detect font set by determining availibility of glyphs */ - face = pango_xft_font_get_face(font); - if (contain_glyphs(face, tis620_2)) - font_info->font_set = THAI_FONT_TIS_WIN; - else if (contain_glyphs(face, tis620_1)) - font_info->font_set = THAI_FONT_TIS_MAC; - else if (contain_glyphs(face, tis620_0)) - font_info->font_set = THAI_FONT_TIS; - else - font_info->font_set = THAI_FONT_ISO10646; - - font_info->info_type = THAI_FONTINFO_XFT; - font_info->info.face = face; - - g_object_set_qdata_full (G_OBJECT (font), info_id, font_info, (GDestroyNotify)g_free); - } - - return font_info; -} - -PangoGlyph -thai_make_glyph (ThaiFontInfo *font_info, unsigned int c) -{ - int index; - PangoGlyph result; - - switch (font_info->font_set) { - case THAI_FONT_ISO10646:index = c; break; - case THAI_FONT_TIS: index = (c & 0x80) ? tis620_0[c & 0x7f] : c; break; - case THAI_FONT_TIS_MAC: index = (c & 0x80) ? tis620_1[c & 0x7f] : c; break; - case THAI_FONT_TIS_WIN: index = (c & 0x80) ? tis620_2[c & 0x7f] : c; break; - default: index = 0; break; - } - - result = FT_Get_Char_Index (font_info->info.face, index); - if (result && result <= ((FT_Face) font_info->info.face)->num_glyphs) - return result; - else - return pango_xft_font_get_unknown_glyph (font_info->font, index); -} - -PangoGlyph -thai_make_unknown_glyph (ThaiFontInfo *font_info, unsigned int c) -{ - return pango_xft_font_get_unknown_glyph (font_info->font, c); -} - -static PangoCoverage * -thai_engine_get_coverage (PangoFont *font, - PangoLanguage *lang) -{ - return pango_font_get_coverage (font, lang); -} - -static PangoEngine * -thai_engine_xft_new () -{ - PangoEngineShape *result; - - result = g_new (PangoEngineShape, 1); - - result->engine.id = SCRIPT_ENGINE_NAME; - result->engine.type = PANGO_ENGINE_TYPE_SHAPE; - result->engine.length = sizeof (result); - result->script_shape = thai_engine_shape; - result->get_coverage = thai_engine_get_coverage; - - return (PangoEngine *)result; -} - -/* The following three functions provide the public module API for - * Pango. If we are compiling it is a module, then we name the - * entry points script_engine_list, etc. But if we are compiling - * it for inclusion directly in Pango, then we need them to - * to have distinct names for this module, so we prepend - * _pango_thai_xft_ - */ -#ifdef XFT_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_thai_xft_##func -#else -#define MODULE_ENTRY(func) func -#endif - -/* List the engines contained within this module - */ -void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) -{ - *engines = script_engines; - *n_engines = G_N_ELEMENTS (script_engines); -} - -/* Load a particular engine given the ID for the engine - */ -PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) -{ - if (!strcmp (id, SCRIPT_ENGINE_NAME)) - return thai_engine_xft_new (); - else - return NULL; -} - -void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) -{ -} - |