diff options
author | Owen Taylor <otaylor@redhat.com> | 2000-12-15 01:10:13 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2000-12-15 01:10:13 +0000 |
commit | f2bb9b92d5cebe5594e73e2eeea8a1a606da9005 (patch) | |
tree | 0eb5ddbd7f3c77b799603fcc21e444f6d9941d6c /modules | |
parent | 016c4d7047fd3ac2f76667f4ffe3b3a22ad0b902 (diff) | |
download | pango-f2bb9b92d5cebe5594e73e2eeea8a1a606da9005.tar.gz |
Fix macro breakage.
Thu Dec 14 19:00:46 2000 Owen Taylor <otaylor@redhat.com>
* modules/indic/pango-indic-script.h: Fix macro breakage.
* modules/basic/tables-big.i: Remove extra copy of basic_ranges.
* modules/thai/thai.c: Fix various warnings.
* configure.in Makefile.am pangoxft.pc.in pango-config.in
modules/basic/Makefile.am modules/basic/basic-xft.c
pango/Makefile.am pango/pangoxft-font.[ch] pango/pangoxft-fontmap.c
pango/pangoxft.h pango/pangoxft-private.h: Initial support
for rendering via Xft and the Xrender extension.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/basic/Makefile.am | 23 | ||||
-rw-r--r-- | modules/basic/basic-fc.c | 284 | ||||
-rw-r--r-- | modules/basic/basic-x.c | 17 | ||||
-rw-r--r-- | modules/basic/basic-xft.c | 284 | ||||
-rw-r--r-- | modules/basic/basic.c | 17 | ||||
-rw-r--r-- | modules/basic/tables-big.i | 17 | ||||
-rw-r--r-- | modules/indic/pango-indic-script.h | 2 | ||||
-rw-r--r-- | modules/thai/thai-x.c | 96 | ||||
-rw-r--r-- | modules/thai/thai.c | 96 |
9 files changed, 714 insertions, 122 deletions
diff --git a/modules/basic/Makefile.am b/modules/basic/Makefile.am index b2cc5f33..f0daa7ae 100644 --- a/modules/basic/Makefile.am +++ b/modules/basic/Makefile.am @@ -1,6 +1,12 @@ ## Process this file with automake to create Makefile.in. -sources = basic.c +basic_sources = basic.c + +if HAVE_XFT +XFT_MODULES=pango-basic-xft.la +else +XFT_MODULES= +endif if INCLUDE_BASIC noinst_LTLIBRARIES = libpango-basic.la @@ -8,17 +14,21 @@ moddefine = -DMODULE_PREFIX else moduledir = $(libdir)/pango/modules -module_LTLIBRARIES = pango-basic.la +module_LTLIBRARIES = $(XFT_MODULES) pango-basic.la moduleflags=-rpath $(libdir) endif -INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/pango/ $(moddefine) +INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/pango/ $(X_CFLAGS) $(moddefine) pango_basic_la_LDFLAGS = $(moduleflags) -export-dynamic -avoid-version -module pango_basic_la_LIBADD = -pango_basic_la_SOURCES = $(sources) +pango_basic_la_SOURCES = $(basic_sources) -libpango_basic_la_SOURCES = $(sources) +libpango_basic_la_SOURCES = $(basic_sources) + +pango_basic_xft_la_LDFLAGS = -rpath $(libdir) -export-dynamic -avoid-version -module +pango_basic_xft_la_LIBADD = +pango_basic_xft_la_SOURCES = basic-xft.c EXTRA_DIST = \ tables-big.i \ @@ -27,6 +37,3 @@ EXTRA_DIST = \ basic-ft2.c \ makefile.mingw \ makefile.mingw.in - -makefile.mingw: $(top_builddir)/config.status $(top_srcdir)/modules/basic/makefile.mingw.in - cd $(top_builddir) && CONFIG_FILES=modules/basic/$@ CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c new file mode 100644 index 00000000..979a3772 --- /dev/null +++ b/modules/basic/basic-fc.c @@ -0,0 +1,284 @@ +/* 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-utils.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 (Display *display, PangoFont *font, gunichar wc) +{ + XftFont *xft_font = pango_xft_font_get_font (font); + + if (XftGlyphExists (display, xft_font, wc)) + return wc; + 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; + Display *display; + + g_return_if_fail (font != NULL); + g_return_if_fail (text != NULL); + g_return_if_fail (length >= 0); + g_return_if_fail (analysis != NULL); + + display = pango_xft_font_get_display (font); + + 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; + 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 == 0x200E || wc == 0x200F) /* Zero-width characters */ + { + set_glyph (font, glyphs, i, p - text, 0); + } + else + { + index = find_char (display, 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 (display, 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, + const char *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_ + */ +#ifdef MODULE_PREFIX +#define MODULE_ENTRY(func) _pango_basic_##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/basic/basic-x.c b/modules/basic/basic-x.c index ab54aa9b..4169fe6c 100644 --- a/modules/basic/basic-x.c +++ b/modules/basic/basic-x.c @@ -77,6 +77,23 @@ static PangoGlyph conv_ucs4 (CharCache *cache, #include "tables-big.i" +static PangoEngineRange basic_ranges[] = { + /* Language characters */ + { 0x0000, 0x02af, "*" }, + { 0x02b0, 0x02ff, "" }, + { 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, "*" } +}; + static PangoEngineInfo script_engines[] = { { "BasicScriptEngineX", diff --git a/modules/basic/basic-xft.c b/modules/basic/basic-xft.c new file mode 100644 index 00000000..979a3772 --- /dev/null +++ b/modules/basic/basic-xft.c @@ -0,0 +1,284 @@ +/* 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-utils.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 (Display *display, PangoFont *font, gunichar wc) +{ + XftFont *xft_font = pango_xft_font_get_font (font); + + if (XftGlyphExists (display, xft_font, wc)) + return wc; + 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; + Display *display; + + g_return_if_fail (font != NULL); + g_return_if_fail (text != NULL); + g_return_if_fail (length >= 0); + g_return_if_fail (analysis != NULL); + + display = pango_xft_font_get_display (font); + + 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; + 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 == 0x200E || wc == 0x200F) /* Zero-width characters */ + { + set_glyph (font, glyphs, i, p - text, 0); + } + else + { + index = find_char (display, 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 (display, 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, + const char *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_ + */ +#ifdef MODULE_PREFIX +#define MODULE_ENTRY(func) _pango_basic_##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/basic/basic.c b/modules/basic/basic.c index ab54aa9b..4169fe6c 100644 --- a/modules/basic/basic.c +++ b/modules/basic/basic.c @@ -77,6 +77,23 @@ static PangoGlyph conv_ucs4 (CharCache *cache, #include "tables-big.i" +static PangoEngineRange basic_ranges[] = { + /* Language characters */ + { 0x0000, 0x02af, "*" }, + { 0x02b0, 0x02ff, "" }, + { 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, "*" } +}; + static PangoEngineInfo script_engines[] = { { "BasicScriptEngineX", diff --git a/modules/basic/tables-big.i b/modules/basic/tables-big.i index 0e7bf27f..2de955b9 100644 --- a/modules/basic/tables-big.i +++ b/modules/basic/tables-big.i @@ -42,23 +42,6 @@ Charset charsets[] = { { 18, "ISO-10646", "iso10646-1", conv_ucs4 } }; -static PangoEngineRange basic_ranges[] = { - /* Language characters */ - { 0x0000, 0x02af, "*" }, - { 0x02b0, 0x02ff, "" }, - { 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, "*" } -}; - const guint32 char_mask_map[] = { 0, ENC_ISO_8859_10|ENC_ISO_8859_1|ENC_ISO_8859_13|ENC_ISO_8859_14|ENC_ISO_8859_15|ENC_ISO_8859_2|ENC_ISO_8859_3|ENC_ISO_8859_4|ENC_ISO_8859_5|ENC_ISO_8859_6|ENC_ISO_8859_7|ENC_ISO_8859_8|ENC_ISO_8859_9|ENC_KOI8_R, diff --git a/modules/indic/pango-indic-script.h b/modules/indic/pango-indic-script.h index 8a4c40a3..c041c845 100644 --- a/modules/indic/pango-indic-script.h +++ b/modules/indic/pango-indic-script.h @@ -22,6 +22,6 @@ }; \ static gint n_script_engines = G_N_ELEMENTS (script_engines); -#define pango_indic_get_char ( (chars) >= (end) ? 0 : *(chars) ) +#define pango_indic_get_char(chars,end) ( (chars) >= (end) ? 0 : *(chars) ) #endif diff --git a/modules/thai/thai-x.c b/modules/thai/thai-x.c index c6c2a6cc..b32721b4 100644 --- a/modules/thai/thai-x.c +++ b/modules/thai/thai-x.c @@ -1,4 +1,4 @@ -/* pANGO +/* Pango * thai.c: * * Copyright (C) 1999 Red Hat Software @@ -27,6 +27,8 @@ */ +#include <string.h> + #include <glib.h> #include <string.h> #include "pango.h" @@ -238,40 +240,40 @@ static const gint TAC_char_class[256] = { static const gchar TAC_compose_and_input_check_type_table[17][17] = { /* Cn */ /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F */ - /* Cn-1 00 */ 'X', 'A', 'A', 'A', 'A', 'A', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 10 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 20 */ 'X', 'A', 'A', 'A', 'A', 'S', 'A', 'C', - 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', - /* 30 */ 'X', 'S', 'A', 'S', 'S', 'S', 'S', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 40 */ 'X', 'S', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 50 */ 'X', 'A', 'A', 'A', 'A', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 60 */ 'X', 'A', 'A', 'A', 'S', 'A', 'S', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 70 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'C', 'C', 'R', 'R', 'R', 'R', 'R', - /* 80 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'C', 'R', 'R', 'R', 'R', 'R', 'R', - /* 90 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* A0 */ 'X', 'A', 'A', 'A', 'A', 'A', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* B0 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* C0 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* D0 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* E0 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'C', 'C', 'R', 'R', 'R', 'R', 'R', - /* F0 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'C', 'R', 'R', 'R', 'R', 'R', 'R', - 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'C', 'R', 'C', 'R', 'R', 'R', 'R' + /* Cn-1 00 */ { 'X', 'A', 'A', 'A', 'A', 'A', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 10 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 20 */ { 'X', 'A', 'A', 'A', 'A', 'S', 'A', 'C', + 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C' }, + /* 30 */ {'X', 'S', 'A', 'S', 'S', 'S', 'S', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 40 */ { 'X', 'S', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 50 */ { 'X', 'A', 'A', 'A', 'A', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 60 */ { 'X', 'A', 'A', 'A', 'S', 'A', 'S', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 70 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'C', 'C', 'R', 'R', 'R', 'R', 'R' }, + /* 80 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'C', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 90 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* A0 */ { 'X', 'A', 'A', 'A', 'A', 'A', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* B0 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* C0 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* D0 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* E0 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'C', 'C', 'R', 'R', 'R', 'R', 'R' }, + /* F0 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'C', 'R', 'R', 'R', 'R', 'R', 'R' }, + { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'C', 'R', 'C', 'R', 'R', 'R', 'R' } }; typedef struct { @@ -439,10 +441,10 @@ add_glyph (ThaiFontInfo *font_info, static gint get_adjusted_glyphs_list (ThaiFontInfo *font_info, - gunichar *cluster, - gint num_chrs, - PangoGlyph **glyph_lists, - const ThaiShapeTable *shaping_table) + gunichar *cluster, + gint num_chrs, + PangoGlyph *glyph_lists, + const ThaiShapeTable *shaping_table) { switch (num_chrs) { @@ -665,7 +667,7 @@ static gint get_glyphs_list (ThaiFontInfo *font_info, gunichar *cluster, gint num_chrs, - PangoGlyph **glyph_lists) + PangoGlyph *glyph_lists) { PangoGlyph glyph; gint xtis_index; @@ -737,7 +739,7 @@ add_cluster (ThaiFontInfo *font_info, gint num_glyphs; gint i; - num_glyphs = get_glyphs_list(font_info, cluster, num_chrs, &glyphs_list); + num_glyphs = get_glyphs_list(font_info, 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); @@ -758,12 +760,15 @@ is_wtt_composible (gunichar cur_wc, gunichar nxt_wc) case 'C': return TRUE; } + + g_assert_not_reached (); + return FALSE; } static const char * get_next_cluster(const char *text, gint length, - gunichar **cluster, + gunichar *cluster, gint *num_chrs) { const char *p; @@ -808,11 +813,6 @@ thai_engine_shape (PangoFont *font, gunichar cluster[MAX_CLUSTER_CHRS]; gint num_chrs; - gunichar base = 0; - gunichar group1 = 0; - gunichar group2 = 0; - int cluster_start = 0; - pango_glyph_string_set_size (glyphs, 0); font_info = get_font_info (font); @@ -821,7 +821,7 @@ thai_engine_shape (PangoFont *font, while (p < text + length) { log_cluster = p; - p = get_next_cluster (p, text + length - p, &cluster, &num_chrs); + p = get_next_cluster (p, text + length - p, cluster, &num_chrs); add_cluster (font_info, glyphs, log_cluster - text, cluster, num_chrs); } } diff --git a/modules/thai/thai.c b/modules/thai/thai.c index c6c2a6cc..b32721b4 100644 --- a/modules/thai/thai.c +++ b/modules/thai/thai.c @@ -1,4 +1,4 @@ -/* pANGO +/* Pango * thai.c: * * Copyright (C) 1999 Red Hat Software @@ -27,6 +27,8 @@ */ +#include <string.h> + #include <glib.h> #include <string.h> #include "pango.h" @@ -238,40 +240,40 @@ static const gint TAC_char_class[256] = { static const gchar TAC_compose_and_input_check_type_table[17][17] = { /* Cn */ /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F */ - /* Cn-1 00 */ 'X', 'A', 'A', 'A', 'A', 'A', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 10 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 20 */ 'X', 'A', 'A', 'A', 'A', 'S', 'A', 'C', - 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', - /* 30 */ 'X', 'S', 'A', 'S', 'S', 'S', 'S', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 40 */ 'X', 'S', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 50 */ 'X', 'A', 'A', 'A', 'A', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 60 */ 'X', 'A', 'A', 'A', 'S', 'A', 'S', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* 70 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'C', 'C', 'R', 'R', 'R', 'R', 'R', - /* 80 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'C', 'R', 'R', 'R', 'R', 'R', 'R', - /* 90 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* A0 */ 'X', 'A', 'A', 'A', 'A', 'A', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* B0 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* C0 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* D0 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', - /* E0 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'C', 'C', 'R', 'R', 'R', 'R', 'R', - /* F0 */ 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'C', 'R', 'R', 'R', 'R', 'R', 'R', - 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', - 'R', 'R', 'C', 'R', 'C', 'R', 'R', 'R', 'R' + /* Cn-1 00 */ { 'X', 'A', 'A', 'A', 'A', 'A', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 10 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 20 */ { 'X', 'A', 'A', 'A', 'A', 'S', 'A', 'C', + 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C' }, + /* 30 */ {'X', 'S', 'A', 'S', 'S', 'S', 'S', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 40 */ { 'X', 'S', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 50 */ { 'X', 'A', 'A', 'A', 'A', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 60 */ { 'X', 'A', 'A', 'A', 'S', 'A', 'S', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 70 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'C', 'C', 'R', 'R', 'R', 'R', 'R' }, + /* 80 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'C', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* 90 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* A0 */ { 'X', 'A', 'A', 'A', 'A', 'A', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* B0 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* C0 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* D0 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + /* E0 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'C', 'C', 'R', 'R', 'R', 'R', 'R' }, + /* F0 */ { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'C', 'R', 'R', 'R', 'R', 'R', 'R' }, + { 'X', 'A', 'A', 'A', 'S', 'S', 'A', 'R', + 'R', 'R', 'C', 'R', 'C', 'R', 'R', 'R', 'R' } }; typedef struct { @@ -439,10 +441,10 @@ add_glyph (ThaiFontInfo *font_info, static gint get_adjusted_glyphs_list (ThaiFontInfo *font_info, - gunichar *cluster, - gint num_chrs, - PangoGlyph **glyph_lists, - const ThaiShapeTable *shaping_table) + gunichar *cluster, + gint num_chrs, + PangoGlyph *glyph_lists, + const ThaiShapeTable *shaping_table) { switch (num_chrs) { @@ -665,7 +667,7 @@ static gint get_glyphs_list (ThaiFontInfo *font_info, gunichar *cluster, gint num_chrs, - PangoGlyph **glyph_lists) + PangoGlyph *glyph_lists) { PangoGlyph glyph; gint xtis_index; @@ -737,7 +739,7 @@ add_cluster (ThaiFontInfo *font_info, gint num_glyphs; gint i; - num_glyphs = get_glyphs_list(font_info, cluster, num_chrs, &glyphs_list); + num_glyphs = get_glyphs_list(font_info, 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); @@ -758,12 +760,15 @@ is_wtt_composible (gunichar cur_wc, gunichar nxt_wc) case 'C': return TRUE; } + + g_assert_not_reached (); + return FALSE; } static const char * get_next_cluster(const char *text, gint length, - gunichar **cluster, + gunichar *cluster, gint *num_chrs) { const char *p; @@ -808,11 +813,6 @@ thai_engine_shape (PangoFont *font, gunichar cluster[MAX_CLUSTER_CHRS]; gint num_chrs; - gunichar base = 0; - gunichar group1 = 0; - gunichar group2 = 0; - int cluster_start = 0; - pango_glyph_string_set_size (glyphs, 0); font_info = get_font_info (font); @@ -821,7 +821,7 @@ thai_engine_shape (PangoFont *font, while (p < text + length) { log_cluster = p; - p = get_next_cluster (p, text + length - p, &cluster, &num_chrs); + p = get_next_cluster (p, text + length - p, cluster, &num_chrs); add_cluster (font_info, glyphs, log_cluster - text, cluster, num_chrs); } } |