diff options
author | Owen Taylor <otaylor@redhat.com> | 2003-04-14 23:48:34 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2003-04-14 23:48:34 +0000 |
commit | 402f2625c2c779df20470ed0f758999db494e4dc (patch) | |
tree | 6667e384ed0c39a22a6e3f731c062311fa7b3e9a /modules | |
parent | f6fdd34661bd9fe23452b5eb98ece8488a12ce8f (diff) | |
download | pango-402f2625c2c779df20470ed0f758999db494e4dc.tar.gz |
Switch over the way that module entry points work, taking advantage of the
Mon Apr 14 06:02:34 2003 Owen Taylor <otaylor@redhat.com>
* modules/thai/{thai-fc.c,thai-shaper.c,thai-x.c}:
* modules/*/*-{xft,x,win32.c} pango/pango-engine.h
modules/*/Makefile.am: Switch over the way that
module entry points work, taking advantage of the
new automake capability for per-target CFLAGS for
shared sources.
* pango/pangofc-font.[ch] pango/pangoxft-font.c
pango/pangoft2.c: Add a base class for
PangoXft and PangoFT2 font classes so code can
be shared between FT2 and Xft backends.
* configure.in modules/*/Makefile.am
modules/{arabic,basic,hangul,hebrew,indic,thai}: Move
*-xft.c to *-fc.c and share between Xft and FT2 backends;
adds FT2 backend capabilities for hangul/indic/thai.
* pango/pangoxft.h pango/pangoft2.h: Deprecate
APIs that moved into PangoFcFont
* modules/basic/basic-fc.c (set_glyph): Add kerning
handling from FT2 backend.
Diffstat (limited to 'modules')
36 files changed, 356 insertions, 3369 deletions
diff --git a/modules/arabic/Makefile.am b/modules/arabic/Makefile.am index 3aeafb90..683ac140 100644 --- a/modules/arabic/Makefile.am +++ b/modules/arabic/Makefile.am @@ -26,7 +26,6 @@ if HAVE_X INCLUDES += $(X_CFLAGS) if INCLUDE_ARABIC_X noinst_LTLIBRARIES += libpango-arabic-x.la -INCLUDES += -DX_MODULE_PREFIX else module_LTLIBRARIES += pango-arabic-x.la endif @@ -47,48 +46,51 @@ pango_arabic_x_la_LDFLAGS = -export-dynamic -avoid-version -module pango_arabic_x_la_LIBADD = $(pangoxlibs) pango_arabic_x_la_SOURCES = $(x_sources) libpango_arabic_x_la_SOURCES = $(x_sources) +libpango_arabic_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_arabic_x if HAVE_XFT INCLUDES += $(XFT_CFLAGS) if INCLUDE_ARABIC_XFT noinst_LTLIBRARIES += libpango-arabic-xft.la -INCLUDES += -DXFT_MODULE_PREFIX else module_LTLIBRARIES += pango-arabic-xft.la endif endif xft_sources = \ - arabic-xft.c \ + arabic-fc.c \ arabic-ot.c \ arabic-ot.h pango_arabic_xft_la_LDFLAGS = -export-dynamic -avoid-version -module pango_arabic_xft_la_LIBADD = $(pangoxftlibs) pango_arabic_xft_la_SOURCES = $(xft_sources) +pango_arabic_xft_la_CFLAGS = -DBUILD_XFT libpango_arabic_xft_la_SOURCES = $(xft_sources) +libpango_arabic_xft_la_CFLAGS = -DBUILD_XFT -DPANGO_MODULE_PREFIX=_pango_arabic_xft if HAVE_FREETYPE INCLUDES += $(FREETYPE_CFLAGS) if INCLUDE_ARABIC_FT2 noinst_LTLIBRARIES += libpango-arabic-ft2.la -INCLUDES += -DFT2_MODULE_PREFIX else module_LTLIBRARIES += pango-arabic-ft2.la endif endif ft2_sources = \ - arabic-ft2.c \ + arabic-fc.c \ arabic-ot.c \ arabic-ot.h pango_arabic_ft2_la_LDFLAGS = -export-dynamic -avoid-version -module $(no_undefined) pango_arabic_ft2_la_LIBADD = $(pangoft2libs) pango_arabic_ft2_la_SOURCES = $(ft2_sources) +pango_arabic_ft2_la_CFLAGS = -DBUILD_FT2 libpango_arabic_ft2_la_SOURCES = $(ft2_sources) +libpango_arabic_ft2_la_CFLAGS = -DBUILD_FT2 -DPANGO_MODULE_PREFIX=_pango_arabic_ft2 included-modules: $(noinst_LTLIBRARIES) diff --git a/modules/arabic/arabic-fc.c b/modules/arabic/arabic-fc.c index f4a63c0a..c94b2626 100644 --- a/modules/arabic/arabic-fc.c +++ b/modules/arabic/arabic-fc.c @@ -1,7 +1,7 @@ /* Pango - * arabic-xft.h: + * arabic-fc.h: * - * Copyright (C) 2000 Red Hat Software + * Copyright (C) 2000, 2003 Red Hat Software * Author: Owen Taylor <otaylor@redhat.com> * * This library is free software; you can redistribute it and/or @@ -24,11 +24,18 @@ #include "arabic-ot.h" -#include "pangoxft.h" #include "pango-engine.h" #include "pango-utils.h" +#ifdef BUILD_XFT +#include "pangoxft.h" #define SCRIPT_ENGINE_NAME "ArabicScriptEngineXft" +#define RENDER_TYPE PANGO_RENDER_TYPE_XFT +#else +#include "pangoft2.h" +#define SCRIPT_ENGINE_NAME "ArabicScriptEngineFt2" +#define RENDER_TYPE PANGO_RENDER_TYPE_FT2 +#endif static PangoEngineRange arabic_ranges[] = { /* Language characters */ @@ -39,7 +46,7 @@ static PangoEngineInfo script_engines[] = { { SCRIPT_ENGINE_NAME, PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_XFT, + RENDER_TYPE, arabic_ranges, G_N_ELEMENTS(arabic_ranges) } }; @@ -129,10 +136,10 @@ set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGl static void arabic_engine_shape (PangoFont *font, - const char *text, - gint length, - PangoAnalysis *analysis, - PangoGlyphString *glyphs) + const char *text, + gint length, + PangoAnalysis *analysis, + PangoGlyphString *glyphs) { int n_chars; int i; @@ -141,13 +148,16 @@ arabic_engine_shape (PangoFont *font, gunichar *wcs = NULL; FT_Face face; PangoOTRuleset *ruleset; + PangoFcFont *fc_font; 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_lock_face (font); + fc_font = PANGO_FC_FONT (font); + + face = pango_fc_font_lock_face (fc_font); g_assert (face); n_chars = g_utf8_strlen (text, length); @@ -198,12 +208,12 @@ arabic_engine_shape (PangoFont *font, ((properties[i] & (initial | medial)) != (initial | medial))) wc = 0x64a; - index = pango_xft_font_get_glyph (font, wc); + index = pango_fc_font_get_glyph (fc_font, wc); if (!index) { set_glyph (font, glyphs, i, p - text, - pango_xft_font_get_unknown_glyph (font, wc)); + pango_fc_font_get_unknown_glyph (fc_font, wc)); } else { @@ -287,18 +297,18 @@ arabic_engine_shape (PangoFont *font, } } - pango_xft_font_unlock_face (font); + pango_fc_font_unlock_face (fc_font); } static PangoCoverage * -arabic_engine_get_coverage (PangoFont *font, - PangoLanguage *lang) +arabic_engine_get_coverage (PangoFont *font, + PangoLanguage *lang) { return pango_font_get_coverage (font, lang); } static PangoEngine * -arabic_engine_xft_new () +arabic_engine_fc_new () { PangoEngineShape *result; @@ -313,23 +323,11 @@ arabic_engine_xft_new () 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) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = G_N_ELEMENTS (script_engines); @@ -338,15 +336,15 @@ MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) /* Load a particular engine given the ID for the engine */ PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) - return arabic_engine_xft_new (); + return arabic_engine_fc_new (); else return NULL; } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/arabic/arabic-ft2.c b/modules/arabic/arabic-ft2.c deleted file mode 100644 index cb817e33..00000000 --- a/modules/arabic/arabic-ft2.c +++ /dev/null @@ -1,408 +0,0 @@ -/* Pango - * arabic-ft2.c: - * - * Copyright (C) 2001 convergence integrated media GmbH - * Author: Andreas Bogk <andreas@convergence.de> - * - * Based on xft code for arabic: - * - * 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 "pangoft2.h" -#include "pango-engine.h" -#include "pango-utils.h" - -#define SCRIPT_ENGINE_NAME "ArabicScriptEngineFt2" - -static PangoEngineRange arabic_ranges[] = { - /* Language characters */ - { 0x060c, 0x06f9, "*" }, /* Arabic */ -}; - -static PangoEngineInfo script_engines[] = { - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_FT2, - 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; - - if (!ruleset_quark) - ruleset_quark = g_quark_from_string ("pango-arabic-ruleset"); - - 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; - FT_Face face; - - face = pango_ft2_font_get_face (font); - if (!face) - { - g_warning ("Couldn't get face for font"); - return NULL; - } - - info = pango_ot_info_get (face); - ruleset = pango_ot_ruleset_new (info); - - if (!info) - return NULL; - - 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); - } - else - { - g_object_unref (ruleset); - ruleset = NULL; - } - } - - return ruleset; -} - -/* - * FT2 system script engine portion - */ - -static PangoGlyph -find_char (PangoFont *font, - gunichar wc) -{ - FT_Face face; - FT_UInt index; - - face = pango_ft2_font_get_face (font); - index = FT_Get_Char_Index (face, wc); - if (index && index <= face->num_glyphs) - return index; - - return 0; -} - -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; - - if (i > 0) - { - glyphs->glyphs[i-1].geometry.width += - pango_ft2_font_get_kerning (font, - glyphs->glyphs[i-1].glyph, - glyphs->glyphs[i].glyph); - } -} - -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; - 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); - - 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 (font, wc); - - if (!index) - { - set_glyph (font, glyphs, i, p - text, - pango_ft2_get_unknown_glyph (font)); - } - 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_ft2_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 FT2_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_arabic_ft2_##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_ft2_new (); - else - return NULL; -} - -void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) -{ -} diff --git a/modules/arabic/arabic-x.c b/modules/arabic/arabic-x.c index ccd84a91..3c3b9689 100644 --- a/modules/arabic/arabic-x.c +++ b/modules/arabic/arabic-x.c @@ -331,24 +331,16 @@ arabic_engine_x_new () -/* The following three functions provide the public module API for - * Pango - */ -#ifdef X_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_arabic_x_##func -#else -#define MODULE_ENTRY(func) func -#endif - void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, int *n_engines) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = n_script_engines; } PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return arabic_engine_x_new (); @@ -357,6 +349,6 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/arabic/arabic-xft.c b/modules/arabic/arabic-xft.c deleted file mode 100644 index f4a63c0a..00000000 --- a/modules/arabic/arabic-xft.c +++ /dev/null @@ -1,352 +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 (FT_Face face) -{ - PangoOTRuleset *ruleset; - static GQuark ruleset_quark = 0; - - PangoOTInfo *info = pango_ot_info_get (face); - - if (!ruleset_quark) - ruleset_quark = g_quark_from_string ("pango-arabic-ruleset"); - - if (!info) - return NULL; - - ruleset = g_object_get_qdata (G_OBJECT (info), 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 (info), 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 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_lock_face (font); - g_assert (face); - - n_chars = g_utf8_strlen (text, length); - pango_glyph_string_set_size (glyphs, n_chars); - - ruleset = get_ruleset (face); - 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 = pango_xft_font_get_glyph (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 (face); - - 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; - } - } - - pango_xft_font_unlock_face (font); -} - -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/Makefile.am b/modules/basic/Makefile.am index f9ed1bf6..a655db71 100644 --- a/modules/basic/Makefile.am +++ b/modules/basic/Makefile.am @@ -14,8 +14,7 @@ INCLUDES = \ $(PANGO_DEBUG_FLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/pango/ \ - $(GLIB_CFLAGS) \ - $(moddefine) + $(GLIB_CFLAGS) if PLATFORM_WIN32 no_undefined = -no-undefined @@ -25,13 +24,10 @@ moduledir = $(libdir)/pango/$(PANGO_MODULE_VERSION)/modules module_LTLIBRARIES = noinst_LTLIBRARIES = -moddefine = - if HAVE_X INCLUDES += $(X_CFLAGS) if INCLUDE_BASIC_X noinst_LTLIBRARIES += libpango-basic-x.la -INCLUDES += -DX_MODULE_PREFIX else module_LTLIBRARIES += pango-basic-x.la endif @@ -41,13 +37,13 @@ pango_basic_x_la_LDFLAGS = -export-dynamic -avoid-version -module pango_basic_x_la_LIBADD = $(pangoxlibs) pango_basic_x_la_SOURCES = basic-x.c libpango_basic_x_la_SOURCES = basic-x.c +libpango_basic_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_basic_x if HAVE_XFT INCLUDES += $(XFT_CFLAGS) if INCLUDE_BASIC_XFT noinst_LTLIBRARIES += libpango-basic-xft.la -INCLUDES += -DXFT_MODULE_PREFIX else module_LTLIBRARIES += pango-basic-xft.la endif @@ -55,15 +51,16 @@ endif pango_basic_xft_la_LDFLAGS = -export-dynamic -avoid-version -module pango_basic_xft_la_LIBADD = $(pangoxftlibs) -pango_basic_xft_la_SOURCES = basic-xft.c -libpango_basic_xft_la_SOURCES = basic-xft.c +pango_basic_xft_la_SOURCES = basic-fc.c +pango_basic_xft_la_CFLAGS = -DBUILD_XFT +libpango_basic_xft_la_SOURCES = basic-fc.c +libpango_basic_xft_la_CFLAGS = -DBUILD_XFT -DPANGO_MODULE_PREFIX=_pango_basic_xft if HAVE_FREETYPE INCLUDES += $(FREETYPE_CFLAGS) if INCLUDE_BASIC_FT2 noinst_LTLIBRARIES += libpango-basic-ft2.la -INCLUDES += -DFT2_MODULE_PREFIX else module_LTLIBRARIES += pango-basic-ft2.la endif @@ -71,14 +68,15 @@ endif pango_basic_ft2_la_LDFLAGS = -export-dynamic -avoid-version -module $(no_undefined) pango_basic_ft2_la_LIBADD = $(pangoft2libs) -pango_basic_ft2_la_SOURCES = basic-ft2.c -libpango_basic_ft2_la_SOURCES = basic-ft2.c +pango_basic_ft2_la_SOURCES = basic-fc.c +pango_basic_ft2_la_CFLAGS = -DBUILD_FT2 +libpango_basic_ft2_la_SOURCES = basic-fc.c +libpango_basic_ft2_la_CFLAGS = -DBUILD_FT2 -DPANGO_MODULE_PREFIX=_pango_basic_ft2 if HAVE_WIN32 if INCLUDE_BASIC_WIN32 noinst_LTLIBRARIES += libpango-basic-win32.la -moddefine += -DWIN32_MODULE_PREFIX else module_LTLIBRARIES += pango-basic-win32.la endif @@ -88,6 +86,7 @@ pango_basic_win32_la_LDFLAGS = -export-dynamic -avoid-version -module $(no_undef pango_basic_win32_la_LIBADD = $(pangowin32libs) -lgdi32 pango_basic_win32_la_SOURCES = basic-win32.c libpango_basic_win32_la_SOURCES = basic-win32.c +libpango_basic_win32_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_basic_win32 if HAVE_USP10_H basic-win32.lo: usp10.h diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c index cdc0db36..c9d64c9e 100644 --- a/modules/basic/basic-fc.c +++ b/modules/basic/basic-fc.c @@ -1,5 +1,5 @@ /* Pango - * basic-xft.h: + * basic-fc.c: Basic shaper for FreeType-based backends * * Copyright (C) 2000 Red Hat Software * Author: Owen Taylor <otaylor@redhat.com> @@ -23,39 +23,65 @@ #include <string.h> #include <glib/gprintf.h> -#include "pangoxft.h" #include "pango-engine.h" #include "pango-utils.h" #include "basic-common.h" +#ifdef BUILD_XFT +#include "pangoxft.h" +#define SCRIPT_ENGINE_NAME "BasicScriptEngineXft" +#define RENDER_TYPE PANGO_RENDER_TYPE_XFT +#else /* FT2 */ +#include "pangoft2.h" +#define SCRIPT_ENGINE_NAME "BasicScriptEngineFt2" +#define RENDER_TYPE PANGO_RENDER_TYPE_FT2 +#endif + static PangoEngineRange basic_ranges[] = { - /* Language characters */ - { 0x0380, 0x058f, "*" }, + /* Basic Latin, Latin-1 Supplement, Latin Extended-A, Latin Extended-B, + * IPA Extensions + */ + { 0x0000, 0x02af, "*" }, + { 0x0380, 0x058f, "*" }, /* Greek, Cyrillic, Armenian */ { 0x10a0, 0x10ff, "*" }, /* Georgian */ { 0x1200, 0x16ff, "*" }, /* Ethiopic,Cherokee,Canadian,Ogham,Runic */ - { 0x1e00, 0x1fff, "*" }, - { 0x2000, 0x302d, "*" }, + { 0x1e00, 0x1fff, "*" }, /* Latin Extended Additional, Greek Extended */ + + /* General Punctuation, Superscripts and Subscripts, Currency Symbols, + * Combining Marks for Symbols, Letterlike Symbols, Number Forms, + * Arrows, Mathematical Operators, Miscellaneous Technical, + * Control Pictures, Optical Character Recognition, Enclosed Alphanumerics, + * Box Drawing, Block Elements, Geometric Shapes, Miscellaneous Symbols, + * Dingbats, Braille Patterns, CJK Radicals Supplement, Kangxi Radicals, + * Ideographic Description Characters, CJK Symbols and Punctuation, + * Hiragana, Katakana, Bopomofo, Hangul Compatibility Jamo, Kanbun, + * Bopomofo Extended, Enclosed CJK Letters and Months, CJK Compatibility, + * CJK Unified Ideographs Extension A, CJK Unified Ideographs + */ + { 0x2000, 0x3029, "*" }, /* Gap for Hangul diacritics */ { 0x3030, 0x9fff, "*" }, { 0xa000, 0xa4c6, "*" }, /* Yi */ { 0xe000, 0xf7ee, "*" }, /* HKSCS-1999 */ { 0xf900, 0xfa2d, "*" }, /* CJK Compatibility Ideographs */ { 0xfe30, 0xfe6b, "*" }, /* CJK Compatibility Forms and Small Form Variants */ - { 0xff00, 0xffe3, "*" }, + { 0xff00, 0xffe3, "*" }, /* Halfwidth and Fullwidth Forms (partly) */ { 0x0000, 0xffff, "" }, }; static PangoEngineInfo script_engines[] = { { - "BasicScriptEngineXft", + SCRIPT_ENGINE_NAME, PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_XFT, + RENDER_TYPE, basic_ranges, G_N_ELEMENTS(basic_ranges) } }; static void -swap_range (PangoGlyphString *glyphs, int start, int end) +swap_range (PangoGlyphString *glyphs, + int start, + int end) { int i, j; @@ -75,7 +101,11 @@ swap_range (PangoGlyphString *glyphs, int start, int end) } static void -set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGlyph glyph) +set_glyph (PangoFont *font, + PangoGlyphString *glyphs, + int i, + int offset, + PangoGlyph glyph) { PangoRectangle logical_rect; @@ -88,6 +118,12 @@ set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGl pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect); glyphs->glyphs[i].geometry.width = logical_rect.width; + + if (i > 0) + glyphs->glyphs[i-1].geometry.width += + pango_fc_font_get_kerning ((PangoFcFont *)font, + glyphs->glyphs[i-1].glyph, + glyphs->glyphs[i].glyph); } static void @@ -97,6 +133,7 @@ basic_engine_shape (PangoFont *font, PangoAnalysis *analysis, PangoGlyphString *glyphs) { + PangoFcFont *fc_font = PANGO_FC_FONT (font); int n_chars; int i; const char *p; @@ -109,8 +146,10 @@ basic_engine_shape (PangoFont *font, n_chars = g_utf8_strlen (text, length); pango_glyph_string_set_size (glyphs, n_chars); + pango_fc_font_lock_face (fc_font); + p = text; - for (i=0; i < n_chars; i++) + for (i = 0; i < n_chars; i++) { gunichar wc; gunichar mirrored_ch; @@ -131,29 +170,12 @@ basic_engine_shape (PangoFont *font, } else { - index = pango_xft_font_get_glyph (font, wc); + index = pango_fc_font_get_glyph (fc_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; - - g_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 + pango_fc_font_get_unknown_glyph (fc_font, wc)); } else { @@ -184,8 +206,9 @@ basic_engine_shape (PangoFont *font, p = g_utf8_next_char (p); } - /* Simple bidi support... may have separate modules later */ - + /* Simple bidi support; most bidi languages (Arabic, Hebrew, Syriac) + * are in fact handled in other modules. + */ if (analysis->level % 2) { int start, end; @@ -194,7 +217,7 @@ basic_engine_shape (PangoFont *font, swap_range (glyphs, 0, n_chars); /* Now reorder glyphs within each cluster back to LTR */ - for (start=0; start<n_chars;) + for (start = 0; start < n_chars;) { end = start; while (end < n_chars && @@ -205,6 +228,8 @@ basic_engine_shape (PangoFont *font, start = end; } } + + pango_fc_font_unlock_face (fc_font); } static PangoCoverage * @@ -215,13 +240,13 @@ basic_engine_get_coverage (PangoFont *font, } static PangoEngine * -basic_engine_xft_new () +basic_engine_fc_new () { PangoEngineShape *result; result = g_new (PangoEngineShape, 1); - result->engine.id = PANGO_RENDER_TYPE_XFT; + result->engine.id = SCRIPT_ENGINE_NAME; result->engine.type = PANGO_ENGINE_TYPE_SHAPE; result->engine.length = sizeof (result); result->script_shape = basic_engine_shape; @@ -230,23 +255,11 @@ basic_engine_xft_new () 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) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = G_N_ELEMENTS (script_engines); @@ -255,15 +268,15 @@ MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) /* Load a particular engine given the ID for the engine */ PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { - if (!strcmp (id, "BasicScriptEngineXft")) - return basic_engine_xft_new (); + if (!strcmp (id, SCRIPT_ENGINE_NAME)) + return basic_engine_fc_new (); else return NULL; } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/basic/basic-ft2.c b/modules/basic/basic-ft2.c deleted file mode 100644 index e1f65a42..00000000 --- a/modules/basic/basic-ft2.c +++ /dev/null @@ -1,335 +0,0 @@ -/* Pango - * basic-ft2.c: - * - * Copyright (C) 1999 Red Hat Software - * - * 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 <glib.h> -#include <string.h> - -#include "pango-layout.h" -#include "pango-engine.h" -#include "pangoft2.h" -#include "pango-utils.h" - -#include "basic-common.h" - -#define SCRIPT_ENGINE_NAME "BasicScriptEngineFT2" - - -static PangoEngineRange basic_ranges[] = { - /* Basic Latin, Latin-1 Supplement, Latin Extended-A, Latin Extended-B, - * IPA Extensions - */ - { 0x0000, 0x02af, "*" }, - - /* Spacing Modifier Letters */ - { 0x02b0, 0x02ff, "" }, - - /* Not covered: Combining Diacritical Marks */ - - /* Greek, Cyrillic, Armenian */ - { 0x0380, 0x058f, "*" }, - - /* Hebrew */ - { 0x0591, 0x05f4, "" }, - - /* Arabic */ - { 0x060c, 0x06f9, "" }, - - /* Not covered: Syriac, Thaana, Devanagari, Bengali, Gurmukhi, Gujarati, - * Oriya, Tamil, Telugu, Kannada, Malayalam, Sinhala - */ - - /* Thai */ - { 0x0e01, 0x0e5b, "" }, - - /* Not covered: Lao, Tibetan, Myanmar, Georgian, Hangul Jamo, Ethiopic, - * Cherokee, Unified Canadian Aboriginal Syllabics, Ogham, Runic, - * Khmer, Mongolian - */ - - /* Latin Extended Additional, Greek Extended */ - { 0x1e00, 0x1fff, "*" }, - - /* General Punctuation, Superscripts and Subscripts, Currency Symbols, - * Combining Marks for Symbols, Letterlike Symbols, Number Forms, - * Arrows, Mathematical Operators, Miscellaneous Technical, - * Control Pictures, Optical Character Recognition, Enclosed Alphanumerics, - * Box Drawing, Block Elements, Geometric Shapes, Miscellaneous Symbols, - * Dingbats, Braille Patterns, CJK Radicals Supplement, Kangxi Radicals, - * Ideographic Description Characters, CJK Symbols and Punctuation, - * Hiragana, Katakana, Bopomofo, Hangul Compatibility Jamo, Kanbun, - * Bopomofo Extended, Enclosed CJK Letters and Months, CJK Compatibility, - * CJK Unified Ideographs Extension A, CJK Unified Ideographs - */ - { 0x2000, 0x9fff, "*" }, - - /* Not covered: Yi Syllables, Yi Radicals */ - - /* Hangul Syllables */ - { 0xac00, 0xd7a3, "kr" }, - - /* Not covered: Private Use */ - - /* CJK Compatibility Ideographs (partly) */ - { 0xf900, 0xfa0b, "kr" }, - - /* Not covered: CJK Compatibility Ideographs (partly), - * Alphabetic Presentation Forms, Arabic Presentation Forms-A, - * Combining Half Marks, CJK Compatibility Forms, - * Small Form Variants, Arabic Presentation Forms-B, - * Specials - */ - - /* Halfwidth and Fullwidth Forms (partly) */ - { 0xff00, 0xffe3, "*" } - - /* Not covered: Halfwidth and Fullwidth Forms, Specials */ -}; - -static PangoEngineInfo script_engines[] = { - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_FT2, - basic_ranges, G_N_ELEMENTS(basic_ranges) - } -}; - -static gint n_script_engines = G_N_ELEMENTS (script_engines); - -/* - * FT2 system script engine portion - */ - -static PangoGlyph -find_char (PangoFont *font, - gunichar wc) -{ - FT_Face face; - FT_UInt index; - - face = pango_ft2_font_get_face (font); - index = FT_Get_Char_Index (face, wc); - if (index && index <= face->num_glyphs) - return index; - - return 0; -} - -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; - - if (i > 0) - { - glyphs->glyphs[i-1].geometry.width += - pango_ft2_font_get_kerning (font, - glyphs->glyphs[i-1].glyph, - glyphs->glyphs[i].glyph); - } -} - -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 -basic_engine_shape (PangoFont *font, - const char *text, - gint length, - PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - int n_chars; - int i; - const char *p; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - 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 (font, wc); - if (index) - { - 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; - } - } - } - else - set_glyph (font, glyphs, i, p - text, pango_ft2_get_unknown_glyph (font)); - } - - 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_ft2_new (void) -{ - 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 = basic_engine_shape; - result->get_coverage = basic_engine_get_coverage; - - return (PangoEngine *)result; -} - -/* The following three functions provide the public module API for - * Pango - */ -#ifdef FT2_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_basic_ft2_##func -#else -#define MODULE_ENTRY(func) func -#endif - -void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, - gint *n_engines) -{ - *engines = script_engines; - *n_engines = n_script_engines; -} - -PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) -{ - if (!strcmp (id, SCRIPT_ENGINE_NAME)) - return basic_engine_ft2_new (); - else - return NULL; -} - -void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) -{ -} - diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c index 1b5cf8b2..83fa12ca 100644 --- a/modules/basic/basic-win32.c +++ b/modules/basic/basic-win32.c @@ -1067,18 +1067,9 @@ init_uniscribe (void) #endif } -/* The following three functions provide the public module API for - * Pango - */ -#ifdef WIN32_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_basic_win32_##func -#else -#define MODULE_ENTRY(func) func -#endif - void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, - gint *n_engines) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + gint *n_engines) { init_uniscribe (); @@ -1115,7 +1106,7 @@ MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, } PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { init_uniscribe (); @@ -1129,6 +1120,6 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/basic/basic-x.c b/modules/basic/basic-x.c index 2cce3046..686b85e7 100644 --- a/modules/basic/basic-x.c +++ b/modules/basic/basic-x.c @@ -715,24 +715,16 @@ basic_engine_x_new () return (PangoEngine *)result; } -/* The following three functions provide the public module API for - * Pango - */ -#ifdef X_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_basic_x_##func -#else -#define MODULE_ENTRY(func) func -#endif - void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = n_script_engines; } PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return basic_engine_x_new (); @@ -741,7 +733,7 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/basic/basic-xft.c b/modules/basic/basic-xft.c deleted file mode 100644 index cdc0db36..00000000 --- a/modules/basic/basic-xft.c +++ /dev/null @@ -1,269 +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 <glib/gprintf.h> -#include "pangoxft.h" -#include "pango-engine.h" -#include "pango-utils.h" - -#include "basic-common.h" - -static PangoEngineRange basic_ranges[] = { - /* Language characters */ - { 0x0380, 0x058f, "*" }, - { 0x10a0, 0x10ff, "*" }, /* Georgian */ - { 0x1200, 0x16ff, "*" }, /* Ethiopic,Cherokee,Canadian,Ogham,Runic */ - { 0x1e00, 0x1fff, "*" }, - { 0x2000, 0x302d, "*" }, - { 0x3030, 0x9fff, "*" }, - { 0xa000, 0xa4c6, "*" }, /* Yi */ - { 0xe000, 0xf7ee, "*" }, /* HKSCS-1999 */ - { 0xf900, 0xfa2d, "*" }, /* CJK Compatibility Ideographs */ - { 0xfe30, 0xfe6b, "*" }, /* CJK Compatibility Forms and Small Form Variants */ - { 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 void -basic_engine_shape (PangoFont *font, - const char *text, - gint length, - PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - int n_chars; - int i; - const char *p; - - g_return_if_fail (font != NULL); - g_return_if_fail (text != NULL); - g_return_if_fail (length >= 0); - g_return_if_fail (analysis != NULL); - - 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 = pango_xft_font_get_glyph (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; - - g_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/hangul/Makefile.am b/modules/hangul/Makefile.am index c90b9e0a..a4047f3b 100644 --- a/modules/hangul/Makefile.am +++ b/modules/hangul/Makefile.am @@ -21,7 +21,6 @@ if HAVE_X INCLUDES += $(X_CFLAGS) if INCLUDE_HANGUL_X noinst_LTLIBRARIES += libpango-hangul-x.la -INCLUDES += -DX_MODULE_PREFIX else module_LTLIBRARIES += pango-hangul-x.la endif @@ -33,24 +32,45 @@ pango_hangul_x_la_LDFLAGS = -export-dynamic -avoid-version -module pango_hangul_x_la_LIBADD = $(pangoxlibs) pango_hangul_x_la_SOURCES = $(x_sources) libpango_hangul_x_la_SOURCES = $(x_sources) +libpango_hangul_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_hangul_x if HAVE_XFT INCLUDES += $(XFT_CFLAGS) if INCLUDE_HANGUL_XFT noinst_LTLIBRARIES += libpango-hangul-xft.la -INCLUDES += -DXFT_MODULE_PREFIX else module_LTLIBRARIES += pango-hangul-xft.la endif endif -xft_sources = hangul-xft.c hangul-defs.h +xft_sources = hangul-fc.c hangul-defs.h pango_hangul_xft_la_LDFLAGS = -export-dynamic -avoid-version -module pango_hangul_xft_la_LIBADD = $(pangoxftlibs) pango_hangul_xft_la_SOURCES = $(xft_sources) +pango_hangul_xft_la_CFLAGS = -DBUILD_XFT libpango_hangul_xft_la_SOURCES = $(xft_sources) +libpango_hangul_xft_la_CFLAGS = -DBUILD_XFT -DPANGO_MODULE_PREFIX=_pango_hangul_xft + + +if HAVE_FREETYPE +INCLUDES += $(FREETYPE_CFLAGS) +if INCLUDE_HANGUL_FT2 +noinst_LTLIBRARIES += libpango-hangul-ft2.la +else +module_LTLIBRARIES += pango-hangul-ft2.la +endif +endif + +ft2_sources = hangul-fc.c hangul-defs.h + +pango_hangul_ft2_la_LDFLAGS = -export-dynamic -avoid-version -module +pango_hangul_ft2_la_LIBADD = $(pangoft2libs) +pango_hangul_ft2_la_SOURCES = $(ft2_sources) +pango_hangul_ft2_la_CFLAGS = -DBUILD_FT2 +libpango_hangul_ft2_la_SOURCES = $(ft2_sources) +libpango_hangul_ft2_la_CFLAGS = -DBUILD_FT2 -DPANGO_MODULE_PREFIX=_pango_hangul_ft2 EXTRA_DIST = \ diff --git a/modules/hangul/hangul-fc.c b/modules/hangul/hangul-fc.c index be796693..7300f897 100644 --- a/modules/hangul/hangul-fc.c +++ b/modules/hangul/hangul-fc.c @@ -1,5 +1,5 @@ /* Pango - * hangul-xft.c: + * hangul-fc.c: Hangul shaper for FreeType based backends * * Copyright (C) 2002 Changwoo Ryu * Author: Changwoo Ryu <cwryu@debian.org> @@ -22,14 +22,21 @@ #include <string.h> -#include "pangoxft.h" #include "pango-engine.h" #include "pango-utils.h" #include "hangul-defs.h" #include "tables-jamos.i" +#ifdef BUILD_XFT +#include "pangoxft.h" #define SCRIPT_ENGINE_NAME "HangulScriptEngineXft" +#define RENDER_TYPE PANGO_RENDER_TYPE_XFT +#else +#include "pangoft2.h" +#define SCRIPT_ENGINE_NAME "HangulScriptEngineFT2" +#define RENDER_TYPE PANGO_RENDER_TYPE_FT2 +#endif static PangoEngineRange hangul_ranges[] = { /* Language characters */ @@ -42,7 +49,7 @@ static PangoEngineInfo script_engines[] = { { SCRIPT_ENGINE_NAME, PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_XFT, + RENDER_TYPE, hangul_ranges, G_N_ELEMENTS(hangul_ranges) } }; @@ -122,8 +129,10 @@ set_glyph_tone (PangoFont *font, PangoGlyphString *glyphs, int i, } -#define find_char pango_xft_font_get_glyph - +#define find_char(font,wc) \ + pango_fc_font_get_glyph((PangoFcFont *)font, wc) +#define get_unknown_glyph(font,wc) \ + pango_fc_font_get_unknown_glyph((PangoFcFont *)font, wc) static void render_tone (PangoFont *font, gunichar tone, PangoGlyphString *glyphs, @@ -147,7 +156,7 @@ render_tone (PangoFont *font, gunichar tone, PangoGlyphString *glyphs, } else set_glyph (font, glyphs, *n_glyphs, cluster_offset, - pango_xft_font_get_unknown_glyph (font, tone)); + get_unknown_glyph (font, tone)); } (*n_glyphs)++; } @@ -167,7 +176,7 @@ render_isolated_tone (PangoFont *font, gunichar tone, PangoGlyphString *glyphs, if (!index) index = find_char (font, ' '); /* Space */ if (!index) /* Unknown glyph box with 0000 in it */ - index = find_char (font, pango_xft_font_get_unknown_glyph (font, 0)); + index = find_char (font, get_unknown_glyph (font, 0)); /* Add the base character */ @@ -214,7 +223,7 @@ render_syllable (PangoFont *font, gunichar *text, int length, pango_glyph_string_set_size (glyphs, *n_glyphs + 1); if (!index) set_glyph (font, glyphs, *n_glyphs, cluster_offset, - pango_xft_font_get_unknown_glyph (font, wc)); + get_unknown_glyph (font, wc)); else set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); (*n_glyphs)++; @@ -249,7 +258,7 @@ render_syllable (PangoFont *font, gunichar *text, int length, pango_glyph_string_set_size (glyphs, *n_glyphs + 1); if (!index) set_glyph (font, glyphs, *n_glyphs, cluster_offset, - pango_xft_font_get_unknown_glyph (font, index)); + get_unknown_glyph (font, index)); else set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); (*n_glyphs)++; @@ -261,7 +270,7 @@ render_syllable (PangoFont *font, gunichar *text, int length, pango_glyph_string_set_size (glyphs, *n_glyphs + 1); if (!index) set_glyph (font, glyphs, *n_glyphs, cluster_offset, - pango_xft_font_get_unknown_glyph (font, index)); + get_unknown_glyph (font, index)); else set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); glyphs->log_clusters[*n_glyphs] = cluster_offset; @@ -386,23 +395,11 @@ hangul_engine_xft_new () 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_hangul_xft__ - */ -#ifdef XFT_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_hangul_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) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = G_N_ELEMENTS (script_engines); @@ -411,7 +408,7 @@ MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) /* Load a particular engine given the ID for the engine */ PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return hangul_engine_xft_new (); @@ -420,6 +417,6 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/hangul/hangul-x.c b/modules/hangul/hangul-x.c index 1cf5c91c..3ec4aa7e 100644 --- a/modules/hangul/hangul-x.c +++ b/modules/hangul/hangul-x.c @@ -872,25 +872,18 @@ hangul_engine_x_new () -/* The following three functions provide the public module API for - * Pango +/* The following three functions provide the public module API for Pango */ - -#ifdef X_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_hangul_x_##func -#else -#define MODULE_ENTRY(func) func -#endif - void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, int *n_engines) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = n_script_engines; } PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return hangul_engine_x_new (); @@ -899,7 +892,6 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } - diff --git a/modules/hangul/hangul-xft.c b/modules/hangul/hangul-xft.c deleted file mode 100644 index be796693..00000000 --- a/modules/hangul/hangul-xft.c +++ /dev/null @@ -1,425 +0,0 @@ -/* Pango - * hangul-xft.c: - * - * Copyright (C) 2002 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 <string.h> - -#include "pangoxft.h" -#include "pango-engine.h" -#include "pango-utils.h" - -#include "hangul-defs.h" -#include "tables-jamos.i" - -#define SCRIPT_ENGINE_NAME "HangulScriptEngineXft" - -static PangoEngineRange hangul_ranges[] = { - /* Language characters */ - { 0x1100, 0x11ff, "*" }, /* Hangul Jamo */ - { 0x302e, 0x302f, "*" }, /* Hangul Tone Marks */ - { 0xac00, 0xd7a3, "*" }, /* Hangul Syllables */ -}; - -static PangoEngineInfo script_engines[] = { - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_XFT, - hangul_ranges, G_N_ELEMENTS(hangul_ranges) - } -}; - -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 pango_xft_font_get_glyph - - -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_xft_font_get_unknown_glyph (font, 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) -{ - /* 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_xft_font_get_unknown_glyph (font, 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)++; - - /* And the tone mrak - */ - render_tone(font, tone, glyphs, n_glyphs, cluster_offset); -} - -static void -render_syllable (PangoFont *font, gunichar *text, int length, - PangoGlyphString *glyphs, int *n_glyphs, int cluster_offset) -{ - int n_prev_glyphs = *n_glyphs; - int index; - gunichar wc, tone; - int i, j, composed; - - if (IS_M (text[length - 1])) - { - tone = text[length - 1]; - length--; - } - else - tone = 0; - - if (length >= 3 && IS_L_S(text[0]) && IS_V_S(text[1]) && IS_T_S(text[2])) - composed = 3; - else if (length >= 2 && IS_L_S(text[0]) && IS_V_S(text[1])) - composed = 2; - else - composed = 0; - - if (composed) - { - if (composed == 3) - wc = S_FROM_LVT(text[0], text[1], text[2]); - else - wc = S_FROM_LV(text[0], text[1]); - 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_xft_font_get_unknown_glyph (font, wc)); - else - set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); - (*n_glyphs)++; - text += composed; - length -= composed; - } - - /* Render the remaining text as uncomposed forms as a fallback. */ - for (i = 0; i < length; i++) - { - int jindex; - - if (text[i] == LFILL || text[i] == VFILL) - continue; - - index = find_char (font, text[i]); - if (index) - { - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); - (*n_glyphs)++; - continue; - } - - /* This font has no glyphs on the Hangul Jamo area! Find a - fallback from the Hangul Compatibility Jamo area. */ - jindex = text[i] - LBASE; - for (j = 0; j < 3 && (__jamo_to_ksc5601[jindex][j] != 0); j++) - { - wc = __jamo_to_ksc5601[jindex][j] - KSC_JAMOBASE + UNI_JAMOBASE; - index = (wc >= 0x3131) ? find_char (font, wc) : 0; - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - if (!index) - set_glyph (font, glyphs, *n_glyphs, cluster_offset, - pango_xft_font_get_unknown_glyph (font, index)); - else - set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); - (*n_glyphs)++; - } - } - if (n_prev_glyphs == *n_glyphs) - { - index = find_char (font, 0x3164); - pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - if (!index) - set_glyph (font, glyphs, *n_glyphs, cluster_offset, - pango_xft_font_get_unknown_glyph (font, 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 -hangul_engine_shape (PangoFont *font, - const char *text, - gint length, - PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - int n_chars, n_glyphs; - int i; - const char *p, *start; - - gunichar jamos_static[8]; - guint max_jamos = G_N_ELEMENTS (jamos_static); - gunichar *jamos = jamos_static; - int n_jamos; - - n_chars = g_utf8_strlen (text, length); - n_glyphs = 0; - start = p = text; - n_jamos = 0; - - for (i = 0; i < n_chars; i++) - { - gunichar prev = jamos[n_jamos - 1]; - gunichar wc; - - wc = g_utf8_get_char (p); - - /* Check syllable boundaries. */ - if (n_jamos && - ((!IS_L (prev) && IS_S (wc)) || - (IS_T (prev) && IS_L (wc)) || - (IS_V (prev) && IS_L (wc)) || - (IS_T (prev) && IS_V (wc)) || - IS_M(prev))) - { - /* Draw a syllable. */ - render_syllable (font, jamos, n_jamos, glyphs, - &n_glyphs, start - text); - n_jamos = 0; - start = p; - } - - if (n_jamos == max_jamos) - { - max_jamos += 3; /* at most 3 for each syllable code (L+V+T) */ - if (jamos == jamos_static) - { - jamos = g_new (gunichar, max_jamos); - memcpy (jamos, jamos_static, n_jamos*sizeof(gunichar)); - } - else - jamos = g_renew (gunichar, jamos, max_jamos); - } - - if (IS_S (wc)) - { - jamos[n_jamos++] = L_FROM_S (wc); - jamos[n_jamos++] = V_FROM_S (wc); - if (S_HAS_T (wc)) - jamos[n_jamos++] = T_FROM_S (wc); - } - 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 - jamos[n_jamos++] = wc; - p = g_utf8_next_char (p); - } - - if (n_jamos != 0) - render_syllable (font, jamos, n_jamos, glyphs, &n_glyphs, - start - text); - - if (jamos != jamos_static) - g_free(jamos); -} - -static PangoCoverage * -hangul_engine_get_coverage (PangoFont *font, - PangoLanguage *lang) -{ - PangoCoverage *result = pango_coverage_new (); - int i; - - /* Well, no unicode rendering engine could render Hangul Jamo area - _exactly_, I sure. */ - for (i = 0x1100; i <= 0x11ff; i++) - pango_coverage_set (result, i, PANGO_COVERAGE_FALLBACK); - pango_coverage_set (result, 0x302e, PANGO_COVERAGE_FALLBACK); - pango_coverage_set (result, 0x302f, PANGO_COVERAGE_FALLBACK); - for (i = 0xac00; i <= 0xd7a3; i++) - pango_coverage_set (result, i, PANGO_COVERAGE_EXACT); - return result; -} - -static PangoEngine * -hangul_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 = hangul_engine_shape; - result->get_coverage = hangul_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_hangul_xft__ - */ -#ifdef XFT_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_hangul_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 hangul_engine_xft_new (); - else - return NULL; -} - -void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) -{ -} diff --git a/modules/hebrew/Makefile.am b/modules/hebrew/Makefile.am index 8cc7fa7c..b486afd7 100644 --- a/modules/hebrew/Makefile.am +++ b/modules/hebrew/Makefile.am @@ -23,7 +23,6 @@ if HAVE_X INCLUDES += $(X_CFLAGS) if INCLUDE_HEBREW_X noinst_LTLIBRARIES += libpango-hebrew-x.la -INCLUDES += -DX_MODULE_PREFIX else module_LTLIBRARIES += pango-hebrew-x.la endif @@ -35,31 +34,32 @@ pango_hebrew_x_la_LDFLAGS = -export-dynamic -avoid-version -module pango_hebrew_x_la_LIBADD = $(pangoxlibs) pango_hebrew_x_la_SOURCES = $(hebrew_x_sources) libpango_hebrew_x_la_SOURCES = $(hebrew_x_sources) +libpango_hebrew_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_hebrew_x if HAVE_XFT INCLUDES += $(XFT_CFLAGS) if INCLUDE_HEBREW_XFT noinst_LTLIBRARIES += libpango-hebrew-xft.la -INCLUDES += -DXFT_MODULE_PREFIX else module_LTLIBRARIES += pango-hebrew-xft.la endif endif -hebrew_xft_sources = $(common_sources) hebrew-xft.c +hebrew_xft_sources = $(common_sources) hebrew-fc.c pango_hebrew_xft_la_LDFLAGS = -export-dynamic -avoid-version -module pango_hebrew_xft_la_LIBADD = $(pangoxftlibs) pango_hebrew_xft_la_SOURCES = $(hebrew_xft_sources) +pango_hebrew_xft_la_CFLAGS = -DBUILD_XFT libpango_hebrew_xft_la_SOURCES = $(hebrew_xft_sources) +libpango_hebrew_xft_la_CFLAGS = -DBUILD_XFT -DPANGO_MODULE_PREFIX=_pango_hebrew_xft if HAVE_FREETYPE INCLUDES += $(FREETYPE_CFLAGS) if INCLUDE_HEBREW_FT2 noinst_LTLIBRARIES += libpango-hebrew-ft2.la -INCLUDES += -DFT2_MODULE_PREFIX else module_LTLIBRARIES += pango-hebrew-ft2.la endif @@ -69,12 +69,14 @@ if PLATFORM_WIN32 no_undefined = -no-undefined endif -hebrew_ft2_sources = $(common_sources) hebrew-ft2.c +hebrew_ft2_sources = $(common_sources) hebrew-fc.c pango_hebrew_ft2_la_LDFLAGS = -export-dynamic -avoid-version -module $(no_undefined) pango_hebrew_ft2_la_LIBADD = $(pangoft2libs) pango_hebrew_ft2_la_SOURCES = $(hebrew_ft2_sources) +pango_hebrew_ft2_la_CFLAGS = -DBUILD_FT2 libpango_hebrew_ft2_la_SOURCES = $(hebrew_ft2_sources) +libpango_hebrew_ft2_la_CFLAGS = -DBUILD_FT2 -DPANGO_MODULE_PREFIX=_pango_hebrew_ft2 included-modules: $(noinst_LTLIBRARIES) diff --git a/modules/hebrew/hebrew-fc.c b/modules/hebrew/hebrew-fc.c index 7615e0b0..a18e3d09 100644 --- a/modules/hebrew/hebrew-fc.c +++ b/modules/hebrew/hebrew-fc.c @@ -1,5 +1,5 @@ /* Pango - * hebrew-xft.h: + * hebrew-fc.h: Hebrew shaper for FreeType-based backends * * Copyright (C) 2000 Red Hat Software * Author: Owen Taylor <otaylor@redhat.com> @@ -22,7 +22,6 @@ #include <string.h> -#include "pangoxft.h" #include "pango-engine.h" #include "pango-utils.h" #include "hebrew-shaper.h" @@ -35,11 +34,21 @@ static PangoEngineRange hebrew_ranges[] = { { 0xfb1d, 0xfb4f, "*" } /* Hebrew presentation forms */ }; +#ifdef BUILD_XFT2 +#include "pangoxft.h" +#define SCRIPT_ENGINE_NAME "HebrewScriptEngineXft" +#define RENDER_TYPE PANGO_RENDER_TYPE_XFT +#else +#include "pangoft2.h" +#define SCRIPT_ENGINE_NAME "HebrewScriptEngineFt2" +#define RENDER_TYPE PANGO_RENDER_TYPE_FT2 +#endif + static PangoEngineInfo script_engines[] = { { - "HebrewScriptEngineXft", + SCRIPT_ENGINE_NAME, PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_XFT, + RENDER_TYPE, hebrew_ranges, G_N_ELEMENTS(hebrew_ranges) } }; @@ -58,7 +67,7 @@ get_cluster_glyphs(PangoFont *font, for (i=0; i<cluster_size; i++) { PangoRectangle logical_rect; - glyph_num[i] = pango_xft_font_get_glyph (font, cluster[i]); + glyph_num[i] = pango_fc_font_get_glyph ((PangoFcFont *)font, cluster[i]); glyph[i] = glyph_num[i]; pango_font_get_glyph_extents (font, @@ -194,13 +203,13 @@ hebrew_engine_get_coverage (PangoFont *font, } static PangoEngine * -hebrew_engine_xft_new () +hebrew_engine_fc_new () { PangoEngineShape *result; result = g_new (PangoEngineShape, 1); - result->engine.id = PANGO_RENDER_TYPE_XFT; + result->engine.id = SCRIPT_ENGINE_NAME; result->engine.type = PANGO_ENGINE_TYPE_SHAPE; result->engine.length = sizeof (result); result->script_shape = hebrew_engine_shape; @@ -209,23 +218,11 @@ hebrew_engine_xft_new () 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) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = G_N_ELEMENTS (script_engines); @@ -234,15 +231,15 @@ MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) /* Load a particular engine given the ID for the engine */ PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { - if (!strcmp (id, "HebrewScriptEngineXft")) - return hebrew_engine_xft_new (); + if (!strcmp (id, SCRIPT_ENGINE_NAME)) + return hebrew_engine_fc_new (); else return NULL; } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/hebrew/hebrew-ft2.c b/modules/hebrew/hebrew-ft2.c deleted file mode 100644 index ef84f1b7..00000000 --- a/modules/hebrew/hebrew-ft2.c +++ /dev/null @@ -1,273 +0,0 @@ -/* Pango - * hebrew-ft2.c: - * - * Copyright (C) 1999 Red Hat Software - * - * 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 <glib.h> -#include <string.h> - -#include "pango-layout.h" -#include "pango-engine.h" -#include "pangoft2.h" -#include "pango-utils.h" -#include "hebrew-shaper.h" - -#define SCRIPT_ENGINE_NAME "HebrewScriptEngineFT2" -#define MAX_CLUSTER_CHRS 20 - -static PangoEngineRange hebrew_ranges[] = { - /* Hebrew */ - { 0x0591, 0x05f4, "*" }, - { 0xfb1d, 0xfb4f, "*" } /* Hebrew presentation forms */ -}; - -static PangoEngineInfo script_engines[] = { - { - SCRIPT_ENGINE_NAME, - PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_FT2, - hebrew_ranges, G_N_ELEMENTS(hebrew_ranges) - } -}; - -static gint n_script_engines = G_N_ELEMENTS (script_engines); - -/* - * FT2 system script engine portion - */ - -static PangoGlyph -get_glyph (PangoFont *font, - gunichar wc) -{ - FT_Face face; - FT_UInt index; - - face = pango_ft2_font_get_face (font); - index = FT_Get_Char_Index (face, wc); - if (index && index <= face->num_glyphs) - return index; - - return 0; -} - -/* This should be extended to support various encodings... */ -static gint -get_glyph_num(PangoFont *font, - gunichar uch) -{ - return uch; -} - -static void -get_cluster_glyphs(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(font, cluster[i]); - glyph[i] = get_glyph(font, 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, - /* output */ - 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]; - - 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); - - 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, - /* 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_ft2_new (void) -{ - 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 = hebrew_engine_shape; - result->get_coverage = hebrew_engine_get_coverage; - - return (PangoEngine *)result; -} - -/* The following three functions provide the public module API for - * Pango - */ -#ifdef FT2_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_hebrew_ft2_##func -#else -#define MODULE_ENTRY(func) func -#endif - -void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, - gint *n_engines) -{ - *engines = script_engines; - *n_engines = n_script_engines; -} - -PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) -{ - if (!strcmp (id, SCRIPT_ENGINE_NAME)) - return hebrew_engine_ft2_new (); - else - return NULL; -} - -void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) -{ -} - diff --git a/modules/hebrew/hebrew-x.c b/modules/hebrew/hebrew-x.c index dba246e0..70c5e95d 100644 --- a/modules/hebrew/hebrew-x.c +++ b/modules/hebrew/hebrew-x.c @@ -419,24 +419,11 @@ hebrew_engine_x_new () 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_x_ - */ -#ifdef X_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_hebrew_x_##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) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = G_N_ELEMENTS (script_engines); @@ -445,7 +432,7 @@ MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) /* Load a particular engine given the ID for the engine */ PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return hebrew_engine_x_new (); @@ -454,7 +441,6 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } - diff --git a/modules/hebrew/hebrew-xft.c b/modules/hebrew/hebrew-xft.c deleted file mode 100644 index 7615e0b0..00000000 --- a/modules/hebrew/hebrew-xft.c +++ /dev/null @@ -1,248 +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 */ - { 0xfb1d, 0xfb4f, "*" } /* Hebrew presentation forms */ -}; - -static PangoEngineInfo script_engines[] = { - { - "HebrewScriptEngineXft", - PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_XFT, - hebrew_ranges, G_N_ELEMENTS(hebrew_ranges) - } -}; - -static void -get_cluster_glyphs(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] = pango_xft_font_get_glyph (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); - - 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, - /* 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/indic/Makefile.am b/modules/indic/Makefile.am index 4df9443f..42912836 100644 --- a/modules/indic/Makefile.am +++ b/modules/indic/Makefile.am @@ -22,35 +22,30 @@ if HAVE_X INCLUDES += $(X_CFLAGS) if INCLUDE_MYANMAR_X noinst_LTLIBRARIES += libpango-myanmar-x.la -INCLUDES += -DMYANMAR_X_MODULE_PREFIX else module_LTLIBRARIES += pango-myanmar-x.la endif if INCLUDE_GURMUKHI_X noinst_LTLIBRARIES += libpango-gurmukhi-x.la -INCLUDES += -DGURMUKHI_X_MODULE_PREFIX else module_LTLIBRARIES += pango-gurmukhi-x.la endif if INCLUDE_BENGALI_X noinst_LTLIBRARIES += libpango-bengali-x.la -INCLUDES += -DBENGALI_X_MODULE_PREFIX else module_LTLIBRARIES += pango-bengali-x.la endif if INCLUDE_DEVANAGARI_X noinst_LTLIBRARIES += libpango-devanagari-x.la -INCLUDES += -DDEVANAGARI_X_MODULE_PREFIX else module_LTLIBRARIES += pango-devanagari-x.la endif if INCLUDE_GUJARATI_X noinst_LTLIBRARIES += libpango-gujarati-x.la -INCLUDES += -DGUJARATI_X_MODULE_PREFIX else module_LTLIBRARIES += pango-gujarati-x.la endif @@ -60,40 +55,44 @@ pango_devanagari_x_la_LDFLAGS = -export-dynamic -avoid-version -module pango_devanagari_x_la_LIBADD = $(pangoxlibs) pango_devanagari_x_la_SOURCES = devanagari-x.c pango-indic-script.h libpango_devanagari_x_la_SOURCES = devanagari-x.c pango-indic-script.h +libpango_devanagari_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_devanagari_x pango_myanmar_x_la_LDFLAGS = -export-dynamic -avoid-version -module pango_myanmar_x_la_LIBADD = $(pangoxlibs) pango_myanmar_x_la_SOURCES = myanmar-x.c pango-indic-script.h libpango_myanmar_x_la_SOURCES = myanmar-x.c pango-indic-script.h +libpango_myanmar_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_myanmar_x pango_gurmukhi_x_la_LDFLAGS = -export-dynamic -avoid-version -module pango_gurmukhi_x_la_LIBADD = $(pangoxlibs) pango_gurmukhi_x_la_SOURCES = gurmukhi-x.c pango-indic-script.h libpango_gurmukhi_x_la_SOURCES = gurmukhi-x.c pango-indic-script.h +libpango_gurmukhi_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_gurmukhi_x pango_bengali_x_la_LDFLAGS = -export-dynamic -avoid-version -module pango_bengali_x_la_LIBADD = $(pangoxlibs) pango_bengali_x_la_SOURCES = bengali-x.c pango-indic-script.h libpango_bengali_x_la_SOURCES = bengali-x.c pango-indic-script.h +libpango_bengali_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_bengali_x pango_gujarati_x_la_LDFLAGS = -export-dynamic -avoid-version -module pango_gujarati_x_la_LIBADD = $(pangoxlibs) pango_gujarati_x_la_SOURCES = gujarati-x.c pango-indic-script.h libpango_gujarati_x_la_SOURCES = gujarati-x.c pango-indic-script.h +libpango_gujarati_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_gujarati_x if HAVE_XFT INCLUDES += $(XFT_CFLAGS) if INCLUDE_INDIC_XFT noinst_LTLIBRARIES += libpango-indic-xft.la -INCLUDES += -DXFT_MODULE_PREFIX else module_LTLIBRARIES += pango-indic-xft.la endif endif xft_sources = \ - indic-xft.c \ + indic-fc.c \ indic-ot-class-tables.c \ indic-ot.c \ indic-ot.h @@ -101,7 +100,32 @@ xft_sources = \ pango_indic_xft_la_LDFLAGS = -export-dynamic -avoid-version -module pango_indic_xft_la_LIBADD = $(pangoxftlibs) pango_indic_xft_la_SOURCES = $(xft_sources) +pango_indic_xft_la_CFLAGS = -DBUILD_XFT libpango_indic_xft_la_SOURCES = $(xft_sources) +libpango_indic_xft_la_CFLAGS = -DBUILD_FT2 -DPANGO_MODULE_PREFIX=_pango_indic_xft + + +if HAVE_FREETYPE +INCLUDES += $(FREETYPE_CFLAGS) +if INCLUDE_INDIC_FT2 +noinst_LTLIBRARIES += libpango-indic-ft2.la +else +module_LTLIBRARIES += pango-indic-ft2.la +endif +endif + +ft2_sources = \ + indic-fc.c \ + indic-ot-class-tables.c \ + indic-ot.c \ + indic-ot.h + +pango_indic_ft2_la_LDFLAGS = -export-dynamic -avoid-version -module +pango_indic_ft2_la_LIBADD = $(pangoft2libs) +pango_indic_ft2_la_SOURCES = $(ft2_sources) +pango_indic_ft2_la_CFLAGS = -DBUILD_FT2 +libpango_indic_ft2_la_SOURCES = $(ft2_sources) +libpango_indic_ft2_la_CFLAGS = -DBUILD_FT2 -DPANGO_MODULE_PREFIX=_pango_indic_ft2 included-modules: $(noinst_LTLIBRARIES) diff --git a/modules/indic/bengali-x.c b/modules/indic/bengali-x.c index ee66c9a0..7f74abe8 100644 --- a/modules/indic/bengali-x.c +++ b/modules/indic/bengali-x.c @@ -285,21 +285,16 @@ pango_indic_engine_x_new () return (PangoEngine *) result; } -#ifdef BENGALI_X_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_bengali_x_##func -#else -#define MODULE_ENTRY(func) func -#endif - void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo ** engines, int *n_engines) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = n_script_engines; } PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return pango_indic_engine_x_new (); @@ -308,7 +303,7 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine * engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/indic/devanagari-x.c b/modules/indic/devanagari-x.c index e81e600a..865124e3 100644 --- a/modules/indic/devanagari-x.c +++ b/modules/indic/devanagari-x.c @@ -338,21 +338,16 @@ pango_indic_engine_x_new () return (PangoEngine *) result; } -#ifdef DEVANAGARI_X_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_devanagari_x_##func -#else -#define MODULE_ENTRY(func) func -#endif - void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo ** engines, int *n_engines) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = n_script_engines; } PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return pango_indic_engine_x_new (); @@ -361,6 +356,6 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine * engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/indic/gujarati-x.c b/modules/indic/gujarati-x.c index 1a998b88..f414a38a 100644 --- a/modules/indic/gujarati-x.c +++ b/modules/indic/gujarati-x.c @@ -314,21 +314,16 @@ pango_indic_engine_x_new () return (PangoEngine *) result; } -#ifdef GUJARATI_X_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_gujarati_x_##func -#else -#define MODULE_ENTRY(func) func -#endif - void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo ** engines, int *n_engines) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = n_script_engines; } PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return pango_indic_engine_x_new (); @@ -337,6 +332,6 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine * engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine * engine) { } diff --git a/modules/indic/gurmukhi-x.c b/modules/indic/gurmukhi-x.c index 89ae5e69..6187f937 100644 --- a/modules/indic/gurmukhi-x.c +++ b/modules/indic/gurmukhi-x.c @@ -229,21 +229,16 @@ pango_indic_engine_x_new () return (PangoEngine *) result; } -#ifdef GURMUKHI_X_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_gurmukhi_x_##func -#else -#define MODULE_ENTRY(func) func -#endif - void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo ** engines, int *n_engines) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = n_script_engines; } PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return pango_indic_engine_x_new (); @@ -252,6 +247,6 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine * engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine * engine) { } diff --git a/modules/indic/indic-fc.c b/modules/indic/indic-fc.c index 390b2871..ffe7424c 100644 --- a/modules/indic/indic-fc.c +++ b/modules/indic/indic-fc.c @@ -25,8 +25,8 @@ #include "indic-ot.h" -#include "pangoxft.h" #include "pango-engine.h" +#include "pango-ot.h" #include "pango-utils.h" typedef struct _PangoEngineShapeIndic PangoEngineShapeIndic; @@ -46,7 +46,17 @@ struct _PangoIndicInfo gchar *gposQuarkName; }; -#define INDIC_ENGINE_INFO(script) {#script "ScriptEngineXft", PANGO_ENGINE_TYPE_SHAPE, PANGO_RENDER_TYPE_XFT, script##_ranges, G_N_ELEMENTS(script##_ranges)} +#ifdef BUILD_XFT +#include "pangoxft.h" +#define ENGINE_SUFFIX "ScriptEngineXft" +#define RENDER_TYPE PANGO_RENDER_TYPE_XFT +#else +#include "pangoft2.h" +#define ENGINE_SUFFIX "ScriptEngineFT2" +#define RENDER_TYPE PANGO_RENDER_TYPE_FT2 +#endif + +#define INDIC_ENGINE_INFO(script) {#script ENGINE_SUFFIX, PANGO_ENGINE_TYPE_SHAPE, RENDER_TYPE, script##_ranges, G_N_ELEMENTS(script##_ranges)} #define PANGO_INDIC_INFO(script) {OT_TAG_##script, &script##_class_table, "pango-indic-" #script "-GSUB-ruleset", "pango-indic-" #script "-GPOS-rulsest"} @@ -302,13 +312,15 @@ indic_engine_shape (PangoFont *font, PangoOTRuleset *gsub_ruleset = NULL, *gpos_ruleset = NULL; PangoEngineShapeIndic *indic_shape_engine = NULL; PangoIndicInfo *indic_info = NULL; + PangoFcFont *fc_font; 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_lock_face (font); + fc_font = PANGO_FC_FONT (font); + face = pango_fc_font_lock_face (fc_font); g_assert (face != NULL); indic_shape_engine = (PangoEngineShapeIndic *) analysis->shape_engine; @@ -366,7 +378,7 @@ indic_engine_shape (PangoFont *font, } #endif - pango_xft_font_unlock_face (font); + pango_fc_font_unlock_face (fc_font); g_free (tags); g_free (indices); @@ -383,7 +395,7 @@ indic_engine_get_coverage (PangoFont *font, } static PangoEngine * -indic_engine_xft_new (gint index) +indic_engine_fc_new (gint index) { PangoEngineShapeIndic *result; @@ -400,23 +412,11 @@ indic_engine_xft_new (gint index) return (PangoEngine *)result; } -/* The following three functions provide the public module API for - * Pango. If we are compiling it as 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_indic_xft_ - */ -#ifdef XFT_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_indic_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) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = G_N_ELEMENTS (script_engines); @@ -425,7 +425,7 @@ MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) /* Load a particular engine given the ID for the engine */ PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { gint i; @@ -433,7 +433,7 @@ MODULE_ENTRY(script_engine_load) (const char *id) { if (!strcmp(id, script_engines[i].id)) { - return indic_engine_xft_new(i); + return indic_engine_fc_new(i); } } @@ -441,6 +441,6 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/indic/indic-xft.c b/modules/indic/indic-xft.c deleted file mode 100644 index 390b2871..00000000 --- a/modules/indic/indic-xft.c +++ /dev/null @@ -1,446 +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 <string.h> - -#include "indic-ot.h" - -#include "pangoxft.h" -#include "pango-engine.h" -#include "pango-utils.h" - -typedef struct _PangoEngineShapeIndic PangoEngineShapeIndic; -typedef struct _PangoIndicInfo PangoIndicInfo; - -struct _PangoEngineShapeIndic -{ - PangoEngineShape shapeEngine; - PangoIndicInfo *indicInfo; -}; - -struct _PangoIndicInfo -{ - PangoOTTag scriptTag; - IndicOTClassTable *classTable; - gchar *gsubQuarkName; - gchar *gposQuarkName; -}; - -#define INDIC_ENGINE_INFO(script) {#script "ScriptEngineXft", PANGO_ENGINE_TYPE_SHAPE, PANGO_RENDER_TYPE_XFT, script##_ranges, G_N_ELEMENTS(script##_ranges)} - -#define PANGO_INDIC_INFO(script) {OT_TAG_##script, &script##_class_table, "pango-indic-" #script "-GSUB-ruleset", "pango-indic-" #script "-GPOS-rulsest"} - -#define INDIC_SCRIPT_RANGE(script) {SCRIPT_RANGE_##script, "*"} - -#define OT_TAG_deva FT_MAKE_TAG('d','e','v','a') -#define OT_TAG_beng FT_MAKE_TAG('b','e','n','g') -#define OT_TAG_guru FT_MAKE_TAG('g','u','r','u') -#define OT_TAG_gujr FT_MAKE_TAG('g','u','j','r') -#define OT_TAG_orya FT_MAKE_TAG('o','r','y','a') -#define OT_TAG_taml FT_MAKE_TAG('t','a','m','l') -#define OT_TAG_telu FT_MAKE_TAG('t','e','l','u') -#define OT_TAG_knda FT_MAKE_TAG('k','n','d','a') -#define OT_TAG_mlym FT_MAKE_TAG('m','l','y','m') - -static PangoEngineRange deva_ranges[] = { - INDIC_SCRIPT_RANGE(deva), /* Devanagari */ -}; - -static PangoEngineRange beng_ranges[] = { - INDIC_SCRIPT_RANGE(beng), /* Bengali */ -}; - -static PangoEngineRange guru_ranges[] = { - INDIC_SCRIPT_RANGE(guru), /* Gurmukhi */ -}; - -static PangoEngineRange gujr_ranges[] = { - INDIC_SCRIPT_RANGE(gujr), /* Gujarati */ -}; - -static PangoEngineRange orya_ranges[] = { - INDIC_SCRIPT_RANGE(orya), /* Oriya */ -}; - -static PangoEngineRange taml_ranges[] = { - INDIC_SCRIPT_RANGE(taml), /* Tamil */ -}; - -static PangoEngineRange telu_ranges[] = { - INDIC_SCRIPT_RANGE(telu), /* Telugu */ -}; - -static PangoEngineRange knda_ranges[] = { - INDIC_SCRIPT_RANGE(knda), /* Kannada */ -}; - -static PangoEngineRange mlym_ranges[] = { - INDIC_SCRIPT_RANGE(mlym), /* Malayalam */ -}; - -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) -}; - -/* - * 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 PangoIndicInfo indic_info[] = { - PANGO_INDIC_INFO(deva), PANGO_INDIC_INFO(beng), PANGO_INDIC_INFO(guru), - PANGO_INDIC_INFO(gujr), PANGO_INDIC_INFO(orya), PANGO_INDIC_INFO(taml), - PANGO_INDIC_INFO(telu), PANGO_INDIC_INFO(knda), PANGO_INDIC_INFO(mlym) -}; - -static void -maybe_add_GSUB_feature (PangoOTRuleset *ruleset, - PangoOTInfo *info, - guint script_index, - PangoOTTag feature_tag, - gulong property_bit) -{ - guint feature_index; - - /* 0xffff == default language system */ - if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GSUB, - feature_tag, script_index, 0xffff, &feature_index)) - { - /* - printf("Added GSUB feature '%c%c%c%c' = %8.8X\n", feature_tag>>24, feature_tag>>16&0xFF, feature_tag>>8&0xFF, feature_tag&0xFF, property_bit); - */ - - pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GSUB, feature_index, - property_bit); - } -} - -static void -maybe_add_GPOS_feature (PangoOTRuleset *ruleset, - PangoOTInfo *info, - guint script_index, - PangoOTTag feature_tag, - gulong property_bit) -{ - guint feature_index; - - if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GPOS, - feature_tag,script_index, 0xffff, &feature_index)) - { - /* - printf("Added GPOS feature '%c%c%c%c' = %8.8X\n", feature_tag>>24, feature_tag>>16&0xFF, feature_tag>>8&0xFF, feature_tag&0xFF, property_bit); - */ - - pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GPOS, feature_index, - property_bit); - } -} - -static PangoOTRuleset * -get_gsub_ruleset (FT_Face face, PangoIndicInfo *indic_info) -{ - PangoOTInfo *info = pango_ot_info_get (face); - GQuark ruleset_quark = g_quark_from_string (indic_info->gsubQuarkName); - PangoOTRuleset *ruleset; - - if (!info) - return NULL; - - ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark); - - if (!ruleset) - { - guint script_index; - - ruleset = pango_ot_ruleset_new (info); - - if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB, - indic_info->scriptTag, &script_index)) - { - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('n','u','k','t'), nukt); - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','k','h','n'), akhn); - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('r','p','h','f'), rphf); - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','f'), blwf); - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('h','a','l','f'), half); - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','s','t','f'), pstf); - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('v','a','t','u'), vatu); - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','r','e','s'), pres); - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','s'), blws); - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','s'), abvs); - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','s','t','s'), psts); - maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('h','a','l','n'), haln); - } - - g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset, - (GDestroyNotify)g_object_unref); - } - - return ruleset; -} - - -static PangoOTRuleset * -get_gpos_ruleset (FT_Face face, PangoIndicInfo *indic_info) -{ - PangoOTInfo *info = pango_ot_info_get (face); - GQuark ruleset_quark = g_quark_from_string (indic_info->gposQuarkName); - PangoOTRuleset *ruleset; - - if (!info) - return NULL; - - ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark); - - if (!ruleset) - { - guint script_index; - - ruleset = pango_ot_ruleset_new (info); - - if (1 && pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS, - indic_info->scriptTag, &script_index)) - { - maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','m'), blwm); - maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','m'), abvm); - maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('d','i','s','t'), dist); - } - - g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset, - (GDestroyNotify)g_object_unref); - } - - return ruleset; -} -static void -set_glyphs (PangoFont *font, FT_Face face, const gunichar *wcs, const glong *indices, glong n_glyphs, PangoGlyphString *glyphs) -{ - gint i; - - g_assert (face); - - pango_glyph_string_set_size (glyphs, n_glyphs); - - for (i = 0; i < n_glyphs; i += 1) - { - PangoGlyph glyph = FT_Get_Char_Index (face, wcs[i]); - - glyphs->glyphs[i].glyph = glyph; - glyphs->log_clusters[i] = indices[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 += 1) - { - *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 (PangoFont *font, - const char *text, - gint length, - PangoAnalysis *analysis, - PangoGlyphString *glyphs) -{ - glong i, n_chars, n_glyphs; - gulong *tags = NULL; - gunichar *wc_in = NULL, *wc_out = NULL; - glong *utf8_offsets = NULL; - glong *indices = NULL; - FT_Face face; - PangoOTRuleset *gsub_ruleset = NULL, *gpos_ruleset = NULL; - PangoEngineShapeIndic *indic_shape_engine = NULL; - PangoIndicInfo *indic_info = NULL; - - 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_lock_face (font); - g_assert (face != NULL); - - indic_shape_engine = (PangoEngineShapeIndic *) analysis->shape_engine; - -#if 1 - g_assert (indic_shape_engine->shapeEngine.engine.length == sizeof (PangoEngineShapeIndic)); -#endif - - indic_info = indic_shape_engine->indicInfo; - - wc_in = expand_text (text, length, &utf8_offsets, &n_chars); - n_glyphs = indic_ot_reorder (wc_in, utf8_offsets, n_chars, indic_info->classTable, 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_info->classTable, wc_out, indices, tags); - - pango_glyph_string_set_size (glyphs, n_glyphs); - set_glyphs(font, face, wc_out, indices, n_glyphs, glyphs); - - /* do gsub processing */ - gsub_ruleset = get_gsub_ruleset (face, indic_info); - if (gsub_ruleset != NULL) - { - pango_ot_ruleset_shape (gsub_ruleset, glyphs, tags); - } - - /* apply default positioning */ - for (i = 0; i < glyphs->num_glyphs; i += 1) - { - if (glyphs->glyphs[i].glyph != 0) - { - 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; - } - -#if 1 - /* do gpos processing */ - gpos_ruleset = get_gpos_ruleset (face, indic_info); - if (gpos_ruleset != NULL) - { - pango_ot_ruleset_shape (gpos_ruleset, glyphs, tags); - } -#endif - - pango_xft_font_unlock_face (font); - - g_free (tags); - g_free (indices); - g_free (wc_out); - g_free (wc_in); - g_free (utf8_offsets); -} - -static PangoCoverage * -indic_engine_get_coverage (PangoFont *font, - PangoLanguage *lang) -{ - return pango_font_get_coverage (font, lang); -} - -static PangoEngine * -indic_engine_xft_new (gint index) -{ - PangoEngineShapeIndic *result; - - result = g_new (PangoEngineShapeIndic, 1); - - result->shapeEngine.engine.id = script_engines[index].id; - result->shapeEngine.engine.type = PANGO_ENGINE_TYPE_SHAPE; - result->shapeEngine.engine.length = sizeof (*result); - result->shapeEngine.script_shape = indic_engine_shape; - result->shapeEngine.get_coverage = indic_engine_get_coverage; - - result->indicInfo = &indic_info[index]; - - return (PangoEngine *)result; -} - -/* The following three functions provide the public module API for - * Pango. If we are compiling it as 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_indic_xft_ - */ -#ifdef XFT_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_indic_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) -{ - gint i; - - for (i = 0; i < G_N_ELEMENTS(script_engines); i += 1) - { - if (!strcmp(id, script_engines[i].id)) - { - return indic_engine_xft_new(i); - } - } - - return NULL; -} - -void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) -{ -} diff --git a/modules/indic/myanmar-x.c b/modules/indic/myanmar-x.c index 140e2026..76dd5c18 100644 --- a/modules/indic/myanmar-x.c +++ b/modules/indic/myanmar-x.c @@ -209,21 +209,16 @@ pango_engine_x_new () return (PangoEngine *) result; } -#ifdef MYANMAR_X_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_myanmar_x_##func -#else -#define MODULE_ENTRY(func) func -#endif - void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo ** engines, int *n_engines) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = n_script_engines; } PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return pango_engine_x_new (); @@ -232,6 +227,6 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine * engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine * engine) { } diff --git a/modules/tamil/Makefile.am b/modules/tamil/Makefile.am index c3ecaf25..84bcee83 100644 --- a/modules/tamil/Makefile.am +++ b/modules/tamil/Makefile.am @@ -20,7 +20,6 @@ if HAVE_X INCLUDES += $(X_CFLAGS) if INCLUDE_TAMIL_X noinst_LTLIBRARIES += libpango-tamil-x.la -INCLUDES += -DX_MODULE_PREFIX else module_LTLIBRARIES += pango-tamil-x.la endif @@ -34,6 +33,7 @@ pango_tamil_x_la_LDFLAGS = -export-dynamic -avoid-version -module pango_tamil_x_la_LIBADD = $(pangoxlibs) pango_tamil_x_la_SOURCES = $(x_sources) libpango_tamil_x_la_SOURCES = $(x_sources) +libpango_tamil_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_tamil_x included-modules: $(noinst_LTLIBRARIES) diff --git a/modules/tamil/tamil-x.c b/modules/tamil/tamil-x.c index fe164acc..119bf9bc 100644 --- a/modules/tamil/tamil-x.c +++ b/modules/tamil/tamil-x.c @@ -397,25 +397,18 @@ tamil_engine_x_new () return (PangoEngine *)result; } -/* The following three functions provide the public module API for - * Pango +/* The following three functions provide the public module API for Pango */ - -#ifdef X_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_tamil_x_##func -#else -#define MODULE_ENTRY(func) func -#endif - void -MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, int *n_engines) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = n_script_engines; } PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return tamil_engine_x_new (); @@ -424,6 +417,6 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/thai/Makefile.am b/modules/thai/Makefile.am index 7b66a756..82918faf 100644 --- a/modules/thai/Makefile.am +++ b/modules/thai/Makefile.am @@ -24,7 +24,6 @@ if HAVE_X INCLUDES += $(X_CFLAGS) if INCLUDE_THAI_X noinst_LTLIBRARIES += libpango-thai-x.la -INCLUDES += -DX_MODULE_PREFIX else module_LTLIBRARIES += pango-thai-x.la endif @@ -36,24 +35,45 @@ pango_thai_x_la_LDFLAGS = -export-dynamic -avoid-version -module pango_thai_x_la_LIBADD = $(pangoxlibs) pango_thai_x_la_SOURCES = $(thai_x_sources) libpango_thai_x_la_SOURCES = $(thai_x_sources) +libpango_thai_x_la_CFLAGS = -DPANGO_MODULE_PREFIX=_pango_thai_x if HAVE_XFT INCLUDES += $(XFT_CFLAGS) if INCLUDE_THAI_XFT noinst_LTLIBRARIES += libpango-thai-xft.la -INCLUDES += -DXFT_MODULE_PREFIX else module_LTLIBRARIES += pango-thai-xft.la endif endif -thai_xft_sources = $(common_sources) thai-xft.c +thai_xft_sources = $(common_sources) thai-fc.c pango_thai_xft_la_LDFLAGS = -export-dynamic -avoid-version -module pango_thai_xft_la_LIBADD = $(pangoxftlibs) pango_thai_xft_la_SOURCES = $(thai_xft_sources) +pango_thai_xft_la_CFLAGS = -DBUILD_XFT libpango_thai_xft_la_SOURCES = $(thai_xft_sources) +libpango_thai_xft_la_CFLAGS = -DBUILD_XFT -DPANGO_MODULE_PREFIX=_pango_thai_xft + + +if HAVE_FREETYPE +INCLUDES += $(FREETYPE_CFLAGS) +if INCLUDE_THAI_FT2 +noinst_LTLIBRARIES += libpango-thai-ft2.la +else +module_LTLIBRARIES += pango-thai-ft2.la +endif +endif + +thai_ft2_sources = $(common_sources) thai-fc.c + +pango_thai_ft2_la_LDFLAGS = -export-dynamic -avoid-version -module +pango_thai_ft2_la_LIBADD = $(pangoft2libs) +pango_thai_ft2_la_SOURCES = $(thai_ft2_sources) +pango_thai_ft2_la_CFLAGS = -DBUILD_FT2 +libpango_thai_ft2_la_SOURCES = $(thai_ft2_sources) +libpango_thai_ft2_la_CFLAGS = -DBUILD_FT2 -DPANGO_MODULE_PREFIX=_pango_thai_ft2 included-modules: $(noinst_LTLIBRARIES) diff --git a/modules/thai/thai-fc.c b/modules/thai/thai-fc.c index a6ec0c15..a8e3ef3a 100644 --- a/modules/thai/thai-fc.c +++ b/modules/thai/thai-fc.c @@ -31,10 +31,17 @@ #include <glib.h> #include "pango-engine.h" -#include "pangoxft.h" #include "thai-shaper.h" +#ifdef BUILD_XFT +#include "pangoxft.h" #define SCRIPT_ENGINE_NAME "ThaiScriptEngineXft" +#define RENDER_TYPE PANGO_RENDER_TYPE_XFT +#else +#include "pangoft2.h" +#define SCRIPT_ENGINE_NAME "ThaiScriptEngineFT2" +#define RENDER_TYPE PANGO_RENDER_TYPE_FT2 +#endif /* We handle the range U+0e01 to U+0e5b exactly */ @@ -46,7 +53,7 @@ static PangoEngineInfo script_engines[] = { { SCRIPT_ENGINE_NAME, PANGO_ENGINE_TYPE_SHAPE, - PANGO_RENDER_TYPE_XFT, + RENDER_TYPE, thai_ranges, G_N_ELEMENTS(thai_ranges) } }; @@ -113,13 +120,14 @@ static int tis620_2[128] = { 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_xft_font_has_char (font, glyph_map[c])) + if (!pango_fc_font_has_char (fc_font, glyph_map[c])) return 0; } } @@ -166,6 +174,7 @@ thai_make_glyph (ThaiFontInfo *font_info, unsigned int c) { int index; PangoGlyph result; + PangoFcFont *fc_font = (PangoFcFont *)font_info->font; switch (font_info->font_set) { case THAI_FONT_ISO10646:index = c; break; @@ -175,17 +184,25 @@ thai_make_glyph (ThaiFontInfo *font_info, unsigned int c) default: index = 0; break; } - result = pango_xft_font_get_glyph (font_info->font, index); + result = pango_fc_font_get_glyph (fc_font, index); if (result) return result; else - return pango_xft_font_get_unknown_glyph (font_info->font, index); + return pango_fc_font_get_unknown_glyph (fc_font, index); } PangoGlyph thai_make_unknown_glyph (ThaiFontInfo *font_info, unsigned int c) { - return pango_xft_font_get_unknown_glyph (font_info->font, c); + return pango_fc_font_get_unknown_glyph ((PangoFcFont *)font_info->font, c); +} + +/* Unused; used only for X backend and XTIS encoding + */ +gboolean +thai_has_glyph (ThaiFontInfo *font_info, PangoGlyph glyph) +{ + return TRUE; } static PangoCoverage * @@ -196,7 +213,7 @@ thai_engine_get_coverage (PangoFont *font, } static PangoEngine * -thai_engine_xft_new () +thai_engine_fc_new () { PangoEngineShape *result; @@ -211,23 +228,11 @@ thai_engine_xft_new () 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) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = G_N_ELEMENTS (script_engines); @@ -236,16 +241,15 @@ MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) /* Load a particular engine given the ID for the engine */ PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) - return thai_engine_xft_new (); + return thai_engine_fc_new (); else return NULL; } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } - diff --git a/modules/thai/thai-shaper.c b/modules/thai/thai-shaper.c index 9822c28b..39e3ee14 100644 --- a/modules/thai/thai-shaper.c +++ b/modules/thai/thai-shaper.c @@ -582,7 +582,7 @@ get_glyphs_list (ThaiFontInfo *font_info, if (cluster[2]) xtis_index += group2_map[cluster[2] - 0xe30]; glyph = thai_make_glyph (font_info, xtis_index); - if (pango_x_has_glyph (font_info->font, glyph)) { + if (thai_has_glyph (font_info, glyph)) { glyph_lists[0] = glyph; return 1; } diff --git a/modules/thai/thai-shaper.h b/modules/thai/thai-shaper.h index c9f487fa..401a4f78 100644 --- a/modules/thai/thai-shaper.h +++ b/modules/thai/thai-shaper.h @@ -43,6 +43,9 @@ thai_make_glyph (ThaiFontInfo *font_info, unsigned int c); PangoGlyph thai_make_unknown_glyph (ThaiFontInfo *font_info, unsigned int c); +gboolean +thai_has_glyph (ThaiFontInfo *font_info, PangoGlyph glyph); + /* * Public functions */ diff --git a/modules/thai/thai-x.c b/modules/thai/thai-x.c index 5bfd0b09..246fd688 100644 --- a/modules/thai/thai-x.c +++ b/modules/thai/thai-x.c @@ -137,6 +137,12 @@ thai_make_unknown_glyph (ThaiFontInfo *font_info, unsigned int c) return pango_x_get_unknown_glyph (font_info->font); } +gboolean +thai_has_glyph (ThaiFontInfo *font_info, PangoGlyph glyph) +{ + return pango_x_has_glyph (font_info->font, glyph); +} + static PangoCoverage * thai_engine_get_coverage (PangoFont *font, PangoLanguage *lang) @@ -174,23 +180,11 @@ thai_engine_x_new () 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_x_ - */ -#ifdef X_MODULE_PREFIX -#define MODULE_ENTRY(func) _pango_thai_x_##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) +PANGO_MODULE_ENTRY(list) (PangoEngineInfo **engines, + int *n_engines) { *engines = script_engines; *n_engines = G_N_ELEMENTS (script_engines); @@ -199,7 +193,7 @@ MODULE_ENTRY(script_engine_list) (PangoEngineInfo **engines, gint *n_engines) /* Load a particular engine given the ID for the engine */ PangoEngine * -MODULE_ENTRY(script_engine_load) (const char *id) +PANGO_MODULE_ENTRY(load) (const char *id) { if (!strcmp (id, SCRIPT_ENGINE_NAME)) return thai_engine_x_new (); @@ -208,7 +202,7 @@ MODULE_ENTRY(script_engine_load) (const char *id) } void -MODULE_ENTRY(script_engine_unload) (PangoEngine *engine) +PANGO_MODULE_ENTRY(unload) (PangoEngine *engine) { } diff --git a/modules/thai/thai-xft.c b/modules/thai/thai-xft.c deleted file mode 100644 index a6ec0c15..00000000 --- a/modules/thai/thai-xft.c +++ /dev/null @@ -1,251 +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(PangoFont *font, const int glyph_map[128]) -{ - unsigned char c; - - for (c = 0; c < 0x80; c++) - { - if (glyph_map[c]) - { - if (!pango_xft_font_has_char (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. - */ -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 - */ - font_info = g_new (ThaiFontInfo, 1); - font_info->font = font; - - /* detect font set by determining availibility of glyphs */ - 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 if (contain_glyphs(font, tis620_0)) - font_info->font_set = THAI_FONT_TIS; - else - font_info->font_set = THAI_FONT_ISO10646; - - 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 = pango_xft_font_get_glyph (font_info->font, index); - if (result) - 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) -{ -} - |