summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/basic/basic-x.c147
-rw-r--r--modules/basic/basic.c147
-rw-r--r--modules/hangul/hangul-x.c111
-rw-r--r--modules/hangul/hangul.c111
-rw-r--r--modules/tamil/tamil-x.c54
-rw-r--r--modules/tamil/tamil.c54
6 files changed, 424 insertions, 200 deletions
diff --git a/modules/basic/basic-x.c b/modules/basic/basic-x.c
index e82d15bf..7f62ebcb 100644
--- a/modules/basic/basic-x.c
+++ b/modules/basic/basic-x.c
@@ -28,21 +28,19 @@
#include <unicode.h>
#include <fribidi/fribidi.h>
-#define MEMBERS(strct) sizeof(strct) / sizeof(strct[1])
-
typedef struct _CharRange CharRange;
typedef struct _Charset Charset;
typedef struct _CharCache CharCache;
typedef struct _MaskTable MaskTable;
-typedef PangoGlyph (*ConvFunc) (CharCache *cache,
- gchar *id,
- gchar *input);
+typedef PangoGlyph (*ConvFunc) (CharCache *cache,
+ const char *id,
+ const gchar *input);
struct _Charset
{
- gchar *id;
- gchar *x_charset;
+ char *id;
+ char *x_charset;
ConvFunc conv_func;
};
@@ -70,14 +68,14 @@ struct _CharCache
};
static PangoGlyph conv_8bit (CharCache *cache,
- gchar *id,
- char *input);
-static PangoGlyph conv_euc (CharCache *cache,
- gchar *id,
- char *input);
-static PangoGlyph conv_ucs4 (CharCache *cache,
- gchar *id,
- char *input);
+ const char *id,
+ const char *input);
+static PangoGlyph conv_euc (CharCache *cache,
+ const char *id,
+ const char *input);
+static PangoGlyph conv_ucs4 (CharCache *cache,
+ const char *id,
+ const char *input);
#include "tables-big.i"
@@ -86,27 +84,27 @@ static PangoEngineInfo script_engines[] = {
"BasicScriptEngineLang",
PANGO_ENGINE_TYPE_LANG,
PANGO_RENDER_TYPE_NONE,
- basic_ranges, MEMBERS(basic_ranges)
+ basic_ranges, G_N_ELEMENTS(basic_ranges)
},
{
"BasicScriptEngineX",
PANGO_ENGINE_TYPE_SHAPE,
PANGO_RENDER_TYPE_X,
- basic_ranges, MEMBERS(basic_ranges)
+ basic_ranges, G_N_ELEMENTS(basic_ranges)
}
};
-static gint n_script_engines = MEMBERS (script_engines);
+static gint n_script_engines = G_N_ELEMENTS (script_engines);
/*
* Language script engine
*/
static void
-basic_engine_break (gchar *text,
- gint len,
- PangoAnalysis *analysis,
- PangoLogAttr *attrs)
+basic_engine_break (const char *text,
+ gint len,
+ PangoAnalysis *analysis,
+ PangoLogAttr *attrs)
{
}
@@ -135,7 +133,7 @@ find_char_mask (GUChar4 wc)
int start, end, middle;
start = 0;
- end = MEMBERS(ranges) - 1;
+ end = G_N_ELEMENTS(ranges) - 1;
if (ranges[start].start > wc || ranges[end].end < wc)
return 0;
@@ -207,7 +205,7 @@ char_cache_free (CharCache *cache)
}
PangoGlyph
-find_char (CharCache *cache, PangoFont *font, GUChar4 wc, char *input)
+find_char (CharCache *cache, PangoFont *font, GUChar4 wc, const char *input)
{
guint mask = find_char_mask (wc);
GSList *tmp_list;
@@ -227,8 +225,8 @@ find_char (CharCache *cache, PangoFont *font, GUChar4 wc, char *input)
if (!tmp_list)
{
- char *charset_names[MEMBERS(charsets)];
- Charset *charsets_map[MEMBERS(charsets)];
+ char *charset_names[G_N_ELEMENTS(charsets)];
+ Charset *charsets_map[G_N_ELEMENTS(charsets)];
int n_charsets = 0;
@@ -241,7 +239,7 @@ find_char (CharCache *cache, PangoFont *font, GUChar4 wc, char *input)
/* Find the character sets that are included in this mask
*/
- for (i=0; i<MEMBERS(charsets); i++)
+ for (i=0; i<G_N_ELEMENTS(charsets); i++)
{
if (mask & (1 << i))
{
@@ -297,7 +295,7 @@ set_glyph (PangoFont *font, PangoGlyphString *glyphs, gint i, PangoGlyph glyph)
}
static iconv_t
-find_converter (CharCache *cache, gchar *id)
+find_converter (CharCache *cache, const char *id)
{
iconv_t cd = g_hash_table_lookup (cache->converters, id);
if (!cd)
@@ -310,15 +308,15 @@ find_converter (CharCache *cache, gchar *id)
}
static PangoGlyph
-conv_8bit (CharCache *cache,
- gchar *id,
- char *input)
+conv_8bit (CharCache *cache,
+ const char *id,
+ const char *input)
{
iconv_t cd;
char outbuf;
- char *p;
+ const char *p;
- char *inptr = input;
+ const char *inptr = input;
int inbytesleft;
char *outptr = &outbuf;
int outbytesleft = 1;
@@ -335,15 +333,15 @@ conv_8bit (CharCache *cache,
}
static PangoGlyph
-conv_euc (CharCache *cache,
- gchar *id,
- char *input)
+conv_euc (CharCache *cache,
+ const char *id,
+ const char *input)
{
iconv_t cd;
char outbuf[2];
- char *p;
+ const char *p;
- char *inptr = input;
+ const char *inptr = input;
int inbytesleft;
char *outptr = outbuf;
int outbytesleft = 2;
@@ -354,7 +352,7 @@ conv_euc (CharCache *cache,
cd = find_converter (cache, id);
g_assert (cd != (iconv_t)-1);
- iconv (cd, (const char **)&inptr, &inbytesleft, &outptr, &outbytesleft);
+ iconv (cd, &inptr, &inbytesleft, &outptr, &outbytesleft);
if ((guchar)outbuf[0] < 128)
return outbuf[0];
@@ -363,9 +361,9 @@ conv_euc (CharCache *cache,
}
static PangoGlyph
-conv_ucs4 (CharCache *cache,
- gchar *id,
- char *input)
+conv_ucs4 (CharCache *cache,
+ const char *id,
+ const char *input)
{
GUChar4 wc;
@@ -393,16 +391,31 @@ swap_range (PangoGlyphString *glyphs, int start, int end)
}
}
+static CharCache *
+get_char_cache (PangoFont *font)
+{
+ CharCache *cache = pango_font_get_data (font, "basic-char-cache");
+ if (!cache)
+ {
+ cache = char_cache_new ();
+ pango_font_set_data (font, "basic-char-cache",
+ cache, (GDestroyNotify)char_cache_free);
+ }
+
+ return cache;
+}
+
static void
basic_engine_shape (PangoFont *font,
- gchar *text,
+ const char *text,
gint length,
PangoAnalysis *analysis,
PangoGlyphString *glyphs)
{
int n_chars;
int i;
- char *p, *next;
+ const char *p;
+ const char *next;
PangoXSubfont fallback_subfont = 0;
CharCache *cache;
@@ -412,14 +425,8 @@ basic_engine_shape (PangoFont *font,
g_return_if_fail (length >= 0);
g_return_if_fail (analysis != NULL);
- cache = pango_font_get_data (font, "basic-char-cache");
- if (!cache)
- {
- cache = char_cache_new ();
- pango_font_set_data (font, "basic-char-cache",
- cache, (GDestroyNotify)char_cache_free);
- }
-
+ cache = get_char_cache (font);
+
n_chars = unicode_strlen (text, length);
pango_glyph_string_set_size (glyphs, n_chars);
@@ -504,6 +511,41 @@ basic_engine_shape (PangoFont *font,
}
}
+static PangoCoverage *
+basic_engine_get_coverage (PangoFont *font,
+ const char *lang)
+{
+ CharCache *cache = get_char_cache (font);
+ PangoCoverage *result = pango_coverage_new ();
+ GUChar4 wc;
+
+ iconv_t utf8_conv = (iconv_t)-1;
+
+ if (utf8_conv == (iconv_t)-1)
+ {
+ utf8_conv = iconv_open ("utf-8", "ucs-4");
+ if (utf8_conv == (iconv_t)-1)
+ g_error ("Could not open coverter from ucs-4 to utf-8!");
+ }
+
+ for (wc = 0; wc < 65536; wc++)
+ {
+ char buf[4];
+ const char *inbuf = (const char *)&wc;
+ size_t inbytes_left = 4;
+ char *outbuf = buf;
+ size_t outbytes_left = 4;
+
+ iconv (utf8_conv, &inbuf, &inbytes_left, &outbuf, &outbytes_left);
+
+ if (find_char (cache, font, wc, buf))
+ pango_coverage_set (result, wc, PANGO_COVERAGE_EXACT);
+
+ }
+
+ return result;
+}
+
static PangoEngine *
basic_engine_x_new ()
{
@@ -515,6 +557,7 @@ basic_engine_x_new ()
result->engine.type = PANGO_ENGINE_TYPE_LANG;
result->engine.length = sizeof (result);
result->script_shape = basic_engine_shape;
+ result->get_coverage = basic_engine_get_coverage;
return (PangoEngine *)result;
}
diff --git a/modules/basic/basic.c b/modules/basic/basic.c
index e82d15bf..7f62ebcb 100644
--- a/modules/basic/basic.c
+++ b/modules/basic/basic.c
@@ -28,21 +28,19 @@
#include <unicode.h>
#include <fribidi/fribidi.h>
-#define MEMBERS(strct) sizeof(strct) / sizeof(strct[1])
-
typedef struct _CharRange CharRange;
typedef struct _Charset Charset;
typedef struct _CharCache CharCache;
typedef struct _MaskTable MaskTable;
-typedef PangoGlyph (*ConvFunc) (CharCache *cache,
- gchar *id,
- gchar *input);
+typedef PangoGlyph (*ConvFunc) (CharCache *cache,
+ const char *id,
+ const gchar *input);
struct _Charset
{
- gchar *id;
- gchar *x_charset;
+ char *id;
+ char *x_charset;
ConvFunc conv_func;
};
@@ -70,14 +68,14 @@ struct _CharCache
};
static PangoGlyph conv_8bit (CharCache *cache,
- gchar *id,
- char *input);
-static PangoGlyph conv_euc (CharCache *cache,
- gchar *id,
- char *input);
-static PangoGlyph conv_ucs4 (CharCache *cache,
- gchar *id,
- char *input);
+ const char *id,
+ const char *input);
+static PangoGlyph conv_euc (CharCache *cache,
+ const char *id,
+ const char *input);
+static PangoGlyph conv_ucs4 (CharCache *cache,
+ const char *id,
+ const char *input);
#include "tables-big.i"
@@ -86,27 +84,27 @@ static PangoEngineInfo script_engines[] = {
"BasicScriptEngineLang",
PANGO_ENGINE_TYPE_LANG,
PANGO_RENDER_TYPE_NONE,
- basic_ranges, MEMBERS(basic_ranges)
+ basic_ranges, G_N_ELEMENTS(basic_ranges)
},
{
"BasicScriptEngineX",
PANGO_ENGINE_TYPE_SHAPE,
PANGO_RENDER_TYPE_X,
- basic_ranges, MEMBERS(basic_ranges)
+ basic_ranges, G_N_ELEMENTS(basic_ranges)
}
};
-static gint n_script_engines = MEMBERS (script_engines);
+static gint n_script_engines = G_N_ELEMENTS (script_engines);
/*
* Language script engine
*/
static void
-basic_engine_break (gchar *text,
- gint len,
- PangoAnalysis *analysis,
- PangoLogAttr *attrs)
+basic_engine_break (const char *text,
+ gint len,
+ PangoAnalysis *analysis,
+ PangoLogAttr *attrs)
{
}
@@ -135,7 +133,7 @@ find_char_mask (GUChar4 wc)
int start, end, middle;
start = 0;
- end = MEMBERS(ranges) - 1;
+ end = G_N_ELEMENTS(ranges) - 1;
if (ranges[start].start > wc || ranges[end].end < wc)
return 0;
@@ -207,7 +205,7 @@ char_cache_free (CharCache *cache)
}
PangoGlyph
-find_char (CharCache *cache, PangoFont *font, GUChar4 wc, char *input)
+find_char (CharCache *cache, PangoFont *font, GUChar4 wc, const char *input)
{
guint mask = find_char_mask (wc);
GSList *tmp_list;
@@ -227,8 +225,8 @@ find_char (CharCache *cache, PangoFont *font, GUChar4 wc, char *input)
if (!tmp_list)
{
- char *charset_names[MEMBERS(charsets)];
- Charset *charsets_map[MEMBERS(charsets)];
+ char *charset_names[G_N_ELEMENTS(charsets)];
+ Charset *charsets_map[G_N_ELEMENTS(charsets)];
int n_charsets = 0;
@@ -241,7 +239,7 @@ find_char (CharCache *cache, PangoFont *font, GUChar4 wc, char *input)
/* Find the character sets that are included in this mask
*/
- for (i=0; i<MEMBERS(charsets); i++)
+ for (i=0; i<G_N_ELEMENTS(charsets); i++)
{
if (mask & (1 << i))
{
@@ -297,7 +295,7 @@ set_glyph (PangoFont *font, PangoGlyphString *glyphs, gint i, PangoGlyph glyph)
}
static iconv_t
-find_converter (CharCache *cache, gchar *id)
+find_converter (CharCache *cache, const char *id)
{
iconv_t cd = g_hash_table_lookup (cache->converters, id);
if (!cd)
@@ -310,15 +308,15 @@ find_converter (CharCache *cache, gchar *id)
}
static PangoGlyph
-conv_8bit (CharCache *cache,
- gchar *id,
- char *input)
+conv_8bit (CharCache *cache,
+ const char *id,
+ const char *input)
{
iconv_t cd;
char outbuf;
- char *p;
+ const char *p;
- char *inptr = input;
+ const char *inptr = input;
int inbytesleft;
char *outptr = &outbuf;
int outbytesleft = 1;
@@ -335,15 +333,15 @@ conv_8bit (CharCache *cache,
}
static PangoGlyph
-conv_euc (CharCache *cache,
- gchar *id,
- char *input)
+conv_euc (CharCache *cache,
+ const char *id,
+ const char *input)
{
iconv_t cd;
char outbuf[2];
- char *p;
+ const char *p;
- char *inptr = input;
+ const char *inptr = input;
int inbytesleft;
char *outptr = outbuf;
int outbytesleft = 2;
@@ -354,7 +352,7 @@ conv_euc (CharCache *cache,
cd = find_converter (cache, id);
g_assert (cd != (iconv_t)-1);
- iconv (cd, (const char **)&inptr, &inbytesleft, &outptr, &outbytesleft);
+ iconv (cd, &inptr, &inbytesleft, &outptr, &outbytesleft);
if ((guchar)outbuf[0] < 128)
return outbuf[0];
@@ -363,9 +361,9 @@ conv_euc (CharCache *cache,
}
static PangoGlyph
-conv_ucs4 (CharCache *cache,
- gchar *id,
- char *input)
+conv_ucs4 (CharCache *cache,
+ const char *id,
+ const char *input)
{
GUChar4 wc;
@@ -393,16 +391,31 @@ swap_range (PangoGlyphString *glyphs, int start, int end)
}
}
+static CharCache *
+get_char_cache (PangoFont *font)
+{
+ CharCache *cache = pango_font_get_data (font, "basic-char-cache");
+ if (!cache)
+ {
+ cache = char_cache_new ();
+ pango_font_set_data (font, "basic-char-cache",
+ cache, (GDestroyNotify)char_cache_free);
+ }
+
+ return cache;
+}
+
static void
basic_engine_shape (PangoFont *font,
- gchar *text,
+ const char *text,
gint length,
PangoAnalysis *analysis,
PangoGlyphString *glyphs)
{
int n_chars;
int i;
- char *p, *next;
+ const char *p;
+ const char *next;
PangoXSubfont fallback_subfont = 0;
CharCache *cache;
@@ -412,14 +425,8 @@ basic_engine_shape (PangoFont *font,
g_return_if_fail (length >= 0);
g_return_if_fail (analysis != NULL);
- cache = pango_font_get_data (font, "basic-char-cache");
- if (!cache)
- {
- cache = char_cache_new ();
- pango_font_set_data (font, "basic-char-cache",
- cache, (GDestroyNotify)char_cache_free);
- }
-
+ cache = get_char_cache (font);
+
n_chars = unicode_strlen (text, length);
pango_glyph_string_set_size (glyphs, n_chars);
@@ -504,6 +511,41 @@ basic_engine_shape (PangoFont *font,
}
}
+static PangoCoverage *
+basic_engine_get_coverage (PangoFont *font,
+ const char *lang)
+{
+ CharCache *cache = get_char_cache (font);
+ PangoCoverage *result = pango_coverage_new ();
+ GUChar4 wc;
+
+ iconv_t utf8_conv = (iconv_t)-1;
+
+ if (utf8_conv == (iconv_t)-1)
+ {
+ utf8_conv = iconv_open ("utf-8", "ucs-4");
+ if (utf8_conv == (iconv_t)-1)
+ g_error ("Could not open coverter from ucs-4 to utf-8!");
+ }
+
+ for (wc = 0; wc < 65536; wc++)
+ {
+ char buf[4];
+ const char *inbuf = (const char *)&wc;
+ size_t inbytes_left = 4;
+ char *outbuf = buf;
+ size_t outbytes_left = 4;
+
+ iconv (utf8_conv, &inbuf, &inbytes_left, &outbuf, &outbytes_left);
+
+ if (find_char (cache, font, wc, buf))
+ pango_coverage_set (result, wc, PANGO_COVERAGE_EXACT);
+
+ }
+
+ return result;
+}
+
static PangoEngine *
basic_engine_x_new ()
{
@@ -515,6 +557,7 @@ basic_engine_x_new ()
result->engine.type = PANGO_ENGINE_TYPE_LANG;
result->engine.length = sizeof (result);
result->script_shape = basic_engine_shape;
+ result->get_coverage = basic_engine_get_coverage;
return (PangoEngine *)result;
}
diff --git a/modules/hangul/hangul-x.c b/modules/hangul/hangul-x.c
index 74a9208a..65e9faf3 100644
--- a/modules/hangul/hangul-x.c
+++ b/modules/hangul/hangul-x.c
@@ -26,8 +26,6 @@
#include "utils.h"
#include <unicode.h>
-#define MEMBERS(strct) sizeof(strct) / sizeof(strct[1])
-
static PangoEngineRange hangul_ranges[] = {
/* Hangul Jamo U+1100 -- U+11FF */
@@ -44,25 +42,25 @@ static PangoEngineInfo script_engines[] = {
"HangulScriptEngineLang",
PANGO_ENGINE_TYPE_LANG,
PANGO_RENDER_TYPE_NONE,
- hangul_ranges, MEMBERS(hangul_ranges)
+ hangul_ranges, G_N_ELEMENTS(hangul_ranges)
},
{
"HangulScriptEngineX",
PANGO_ENGINE_TYPE_SHAPE,
PANGO_RENDER_TYPE_X,
- hangul_ranges, MEMBERS(hangul_ranges)
+ hangul_ranges, G_N_ELEMENTS(hangul_ranges)
}
};
-static gint n_script_engines = MEMBERS (script_engines);
+static int n_script_engines = G_N_ELEMENTS (script_engines);
/*
* Language script engine
*/
static void
-hangul_engine_break (gchar *text,
- gint len,
+hangul_engine_break (const char *text,
+ int len,
PangoAnalysis *analysis,
PangoLogAttr *attrs)
{
@@ -89,10 +87,10 @@ hangul_engine_lang_new ()
*/
static void
-set_glyph (PangoGlyphString *glyphs, gint i,
+set_glyph (PangoGlyphString *glyphs, int i,
PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
- gint width;
+ int width;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
@@ -513,7 +511,7 @@ subfont_has_korean (PangoFont *font,
}
static gboolean
-find_subfont (PangoFont *font, gchar **charsets, gint n_charsets,
+find_subfont (PangoFont *font, char **charsets, int n_charsets,
PangoXSubfont *subfont, RenderSyllableFunc *render_func)
{
int i;
@@ -562,36 +560,37 @@ find_subfont (PangoFont *font, gchar **charsets, gint n_charsets,
return (*subfont != 0);
}
+static char *default_charset[] = {
+ "johabs-1"
+};
+
+static char *secondary_charset[] = {
+ "johab-1"
+};
+
+static char *fallback_charsets[] = {
+ "iso10646-1",
+ "ksc5601.1987-0"
+};
+
static void
hangul_engine_shape (PangoFont *font,
- gchar *text,
- gint length,
+ const char *text,
+ int length,
PangoAnalysis *analysis,
PangoGlyphString *glyphs)
{
PangoXSubfont subfont;
RenderSyllableFunc render_func = NULL;
- char *ptr, *next;
+ const char *ptr;
+ const char *next;
int i, n_chars;
GUChar2 jamos[4];
int n_jamos = 0;
int n_glyphs = 0, n_clusters = 0;
- static char *default_charset[] = {
- "johabs-1"
- };
-
- static char *secondary_charset[] = {
- "johab-1"
- };
-
- static char *fallback_charsets[] = {
- "iso10646-1",
- "ksc5601.1987-0"
- };
-
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
g_return_if_fail (length >= 0);
@@ -601,9 +600,9 @@ hangul_engine_shape (PangoFont *font,
* otherwise use iso-10646 or KSC font depending on the ordering
* of the fontlist.
*/
- if (!find_subfont (font, default_charset, 1, &subfont, &render_func))
- if (!find_subfont (font, secondary_charset, 1, &subfont, &render_func))
- if (!find_subfont (font, fallback_charsets, 2, &subfont, &render_func))
+ if (!find_subfont (font, default_charset, G_N_ELEMENTS (default_charset), &subfont, &render_func))
+ if (!find_subfont (font, secondary_charset, G_N_ELEMENTS (secondary_charset), &subfont, &render_func))
+ if (!find_subfont (font, fallback_charsets, G_N_ELEMENTS (fallback_charsets), &subfont, &render_func))
{
g_warning ("No available Hangul fonts.");
return;
@@ -688,6 +687,57 @@ hangul_engine_shape (PangoFont *font,
}
}
+static PangoCoverage *
+hangul_engine_get_coverage (PangoFont *font,
+ const char *lang)
+{
+ PangoCoverage *result = pango_coverage_new ();
+ PangoXSubfont subfont;
+ RenderSyllableFunc render_func = NULL;
+ int i;
+
+ /* An approximate implementation, please check and fix as necessary!
+ * OWT 2 Feb 2000
+ */
+ if (find_subfont (font, default_charset, G_N_ELEMENTS (default_charset), &subfont, &render_func) ||
+ find_subfont (font, secondary_charset, G_N_ELEMENTS (secondary_charset), &subfont, &render_func) ||
+ find_subfont (font, fallback_charsets, G_N_ELEMENTS (fallback_charsets), &subfont, &render_func))
+ {
+ if (render_func == render_syllable_with_johabs ||
+ render_func == render_syllable_with_johab)
+ {
+ for (i = 0x1100; i <= 0x11ff; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
+
+ for (i = 0xac00; i <= 0xd7a3; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
+
+ }
+ else if (render_func == render_syllable_with_iso10646)
+ {
+ for (i = 0x1100; i <= 0x11ff; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_FALLBACK);
+
+ for (i = 0xac00; i <= 0xd7a3; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
+ }
+ else if (render_func == render_syllable_with_ksc5601)
+ {
+ for (i = 0x1100; i <= 0x11ff; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_FALLBACK);
+
+ for (i = 0xac00; i <= 0xd7a3; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_FALLBACK);
+
+ for (i=0; i<KSC5601_HANGUL; i++)
+ pango_coverage_set (result, __ksc5601_hangul_to_ucs[i], PANGO_COVERAGE_EXACT);
+ }
+ else
+ g_assert_not_reached();
+ }
+
+ return result;
+}
static PangoEngine *
hangul_engine_x_new ()
@@ -700,6 +750,7 @@ hangul_engine_x_new ()
result->engine.type = PANGO_ENGINE_TYPE_LANG;
result->engine.length = sizeof (result);
result->script_shape = hangul_engine_shape;
+ result->get_coverage = hangul_engine_get_coverage;
return (PangoEngine *)result;
}
@@ -711,7 +762,7 @@ hangul_engine_x_new ()
*/
void
-script_engine_list (PangoEngineInfo **engines, gint *n_engines)
+script_engine_list (PangoEngineInfo **engines, int *n_engines)
{
*engines = script_engines;
*n_engines = n_script_engines;
diff --git a/modules/hangul/hangul.c b/modules/hangul/hangul.c
index 74a9208a..65e9faf3 100644
--- a/modules/hangul/hangul.c
+++ b/modules/hangul/hangul.c
@@ -26,8 +26,6 @@
#include "utils.h"
#include <unicode.h>
-#define MEMBERS(strct) sizeof(strct) / sizeof(strct[1])
-
static PangoEngineRange hangul_ranges[] = {
/* Hangul Jamo U+1100 -- U+11FF */
@@ -44,25 +42,25 @@ static PangoEngineInfo script_engines[] = {
"HangulScriptEngineLang",
PANGO_ENGINE_TYPE_LANG,
PANGO_RENDER_TYPE_NONE,
- hangul_ranges, MEMBERS(hangul_ranges)
+ hangul_ranges, G_N_ELEMENTS(hangul_ranges)
},
{
"HangulScriptEngineX",
PANGO_ENGINE_TYPE_SHAPE,
PANGO_RENDER_TYPE_X,
- hangul_ranges, MEMBERS(hangul_ranges)
+ hangul_ranges, G_N_ELEMENTS(hangul_ranges)
}
};
-static gint n_script_engines = MEMBERS (script_engines);
+static int n_script_engines = G_N_ELEMENTS (script_engines);
/*
* Language script engine
*/
static void
-hangul_engine_break (gchar *text,
- gint len,
+hangul_engine_break (const char *text,
+ int len,
PangoAnalysis *analysis,
PangoLogAttr *attrs)
{
@@ -89,10 +87,10 @@ hangul_engine_lang_new ()
*/
static void
-set_glyph (PangoGlyphString *glyphs, gint i,
+set_glyph (PangoGlyphString *glyphs, int i,
PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
- gint width;
+ int width;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
@@ -513,7 +511,7 @@ subfont_has_korean (PangoFont *font,
}
static gboolean
-find_subfont (PangoFont *font, gchar **charsets, gint n_charsets,
+find_subfont (PangoFont *font, char **charsets, int n_charsets,
PangoXSubfont *subfont, RenderSyllableFunc *render_func)
{
int i;
@@ -562,36 +560,37 @@ find_subfont (PangoFont *font, gchar **charsets, gint n_charsets,
return (*subfont != 0);
}
+static char *default_charset[] = {
+ "johabs-1"
+};
+
+static char *secondary_charset[] = {
+ "johab-1"
+};
+
+static char *fallback_charsets[] = {
+ "iso10646-1",
+ "ksc5601.1987-0"
+};
+
static void
hangul_engine_shape (PangoFont *font,
- gchar *text,
- gint length,
+ const char *text,
+ int length,
PangoAnalysis *analysis,
PangoGlyphString *glyphs)
{
PangoXSubfont subfont;
RenderSyllableFunc render_func = NULL;
- char *ptr, *next;
+ const char *ptr;
+ const char *next;
int i, n_chars;
GUChar2 jamos[4];
int n_jamos = 0;
int n_glyphs = 0, n_clusters = 0;
- static char *default_charset[] = {
- "johabs-1"
- };
-
- static char *secondary_charset[] = {
- "johab-1"
- };
-
- static char *fallback_charsets[] = {
- "iso10646-1",
- "ksc5601.1987-0"
- };
-
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
g_return_if_fail (length >= 0);
@@ -601,9 +600,9 @@ hangul_engine_shape (PangoFont *font,
* otherwise use iso-10646 or KSC font depending on the ordering
* of the fontlist.
*/
- if (!find_subfont (font, default_charset, 1, &subfont, &render_func))
- if (!find_subfont (font, secondary_charset, 1, &subfont, &render_func))
- if (!find_subfont (font, fallback_charsets, 2, &subfont, &render_func))
+ if (!find_subfont (font, default_charset, G_N_ELEMENTS (default_charset), &subfont, &render_func))
+ if (!find_subfont (font, secondary_charset, G_N_ELEMENTS (secondary_charset), &subfont, &render_func))
+ if (!find_subfont (font, fallback_charsets, G_N_ELEMENTS (fallback_charsets), &subfont, &render_func))
{
g_warning ("No available Hangul fonts.");
return;
@@ -688,6 +687,57 @@ hangul_engine_shape (PangoFont *font,
}
}
+static PangoCoverage *
+hangul_engine_get_coverage (PangoFont *font,
+ const char *lang)
+{
+ PangoCoverage *result = pango_coverage_new ();
+ PangoXSubfont subfont;
+ RenderSyllableFunc render_func = NULL;
+ int i;
+
+ /* An approximate implementation, please check and fix as necessary!
+ * OWT 2 Feb 2000
+ */
+ if (find_subfont (font, default_charset, G_N_ELEMENTS (default_charset), &subfont, &render_func) ||
+ find_subfont (font, secondary_charset, G_N_ELEMENTS (secondary_charset), &subfont, &render_func) ||
+ find_subfont (font, fallback_charsets, G_N_ELEMENTS (fallback_charsets), &subfont, &render_func))
+ {
+ if (render_func == render_syllable_with_johabs ||
+ render_func == render_syllable_with_johab)
+ {
+ for (i = 0x1100; i <= 0x11ff; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
+
+ for (i = 0xac00; i <= 0xd7a3; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
+
+ }
+ else if (render_func == render_syllable_with_iso10646)
+ {
+ for (i = 0x1100; i <= 0x11ff; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_FALLBACK);
+
+ for (i = 0xac00; i <= 0xd7a3; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
+ }
+ else if (render_func == render_syllable_with_ksc5601)
+ {
+ for (i = 0x1100; i <= 0x11ff; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_FALLBACK);
+
+ for (i = 0xac00; i <= 0xd7a3; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_FALLBACK);
+
+ for (i=0; i<KSC5601_HANGUL; i++)
+ pango_coverage_set (result, __ksc5601_hangul_to_ucs[i], PANGO_COVERAGE_EXACT);
+ }
+ else
+ g_assert_not_reached();
+ }
+
+ return result;
+}
static PangoEngine *
hangul_engine_x_new ()
@@ -700,6 +750,7 @@ hangul_engine_x_new ()
result->engine.type = PANGO_ENGINE_TYPE_LANG;
result->engine.length = sizeof (result);
result->script_shape = hangul_engine_shape;
+ result->get_coverage = hangul_engine_get_coverage;
return (PangoEngine *)result;
}
@@ -711,7 +762,7 @@ hangul_engine_x_new ()
*/
void
-script_engine_list (PangoEngineInfo **engines, gint *n_engines)
+script_engine_list (PangoEngineInfo **engines, int *n_engines)
{
*engines = script_engines;
*n_engines = n_script_engines;
diff --git a/modules/tamil/tamil-x.c b/modules/tamil/tamil-x.c
index f31a0e9b..908aaa94 100644
--- a/modules/tamil/tamil-x.c
+++ b/modules/tamil/tamil-x.c
@@ -12,8 +12,6 @@
#include "utils.h"
#include "taconv.h"
-#define MEMBERS(strct) sizeof(strct) / sizeof(strct[1])
-
static PangoEngineRange tamil_range[] = {
{ 0x0b80, 0x0bff, "*" },
};
@@ -23,25 +21,25 @@ static PangoEngineInfo script_engines[] = {
"TamilScriptEngineLang",
PANGO_ENGINE_TYPE_LANG,
PANGO_RENDER_TYPE_NONE,
- tamil_range, MEMBERS(tamil_range)
+ tamil_range, G_N_ELEMENTS(tamil_range)
},
{
"TamilScriptEngineX",
PANGO_ENGINE_TYPE_SHAPE,
PANGO_RENDER_TYPE_X,
- tamil_range, MEMBERS(tamil_range)
+ tamil_range, G_N_ELEMENTS(tamil_range)
}
};
-static gint n_script_engines = MEMBERS (script_engines);
+static gint n_script_engines = G_N_ELEMENTS (script_engines);
/*
* Language script engine
*/
static void
-tamil_engine_break (gchar *text,
- gint len,
+tamil_engine_break (const char *text,
+ int len,
PangoAnalysis *analysis,
PangoLogAttr *attrs)
{
@@ -49,8 +47,8 @@ tamil_engine_break (gchar *text,
* only difference is char stop based on modifiers
*/
- gchar *cur = text;
- gchar *next;
+ const char *cur = text;
+ const char *next;
gint i = 0;
GUChar4 wc;
@@ -96,10 +94,10 @@ tamil_engine_lang_new ()
* But we can live with this for time being
*/
static void
-set_glyph (PangoGlyphString *glyphs, gint i,
+set_glyph (PangoGlyphString *glyphs, int i,
PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
- gint width;
+ int width;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
@@ -134,15 +132,16 @@ find_tscii_font (PangoFont *font)
}
static void
-tamil_engine_shape (PangoFont *font,
- gchar *text,
- gint length,
- PangoAnalysis *analysis,
- PangoGlyphString *glyphs)
+tamil_engine_shape (PangoFont *font,
+ const char *text,
+ int length,
+ PangoAnalysis *analysis,
+ PangoGlyphString *glyphs)
{
int n_chars, n_glyph;
int i, j;
- char *p, *next;
+ const char *p;
+ const char *next;
GUChar4 *wc, *uni_str;
int res;
unsigned char tsc_str[6];
@@ -205,6 +204,24 @@ tamil_engine_shape (PangoFont *font,
g_free(wc);
}
+static PangoCoverage *
+tamil_engine_get_coverage (PangoFont *font,
+ const char *lang)
+{
+ PangoCoverage *result = pango_coverage_new ();
+
+ PangoXSubfont tscii_font = find_tscii_font (font);
+ if (tscii_font)
+ {
+ GUChar4 i;
+
+ for (i = 0xb80; i <= 0xbff; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
+ }
+
+ return result;
+}
+
static PangoEngine *
tamil_engine_x_new ()
{
@@ -216,6 +233,7 @@ tamil_engine_x_new ()
result->engine.type = PANGO_ENGINE_TYPE_LANG;
result->engine.length = sizeof (result);
result->script_shape = tamil_engine_shape;
+ result->get_coverage = tamil_engine_get_coverage;
return (PangoEngine *)result;
}
@@ -224,7 +242,7 @@ tamil_engine_x_new ()
* Pango
*/
void
-script_engine_list (PangoEngineInfo **engines, gint *n_engines)
+script_engine_list (PangoEngineInfo **engines, int *n_engines)
{
*engines = script_engines;
*n_engines = n_script_engines;
diff --git a/modules/tamil/tamil.c b/modules/tamil/tamil.c
index f31a0e9b..908aaa94 100644
--- a/modules/tamil/tamil.c
+++ b/modules/tamil/tamil.c
@@ -12,8 +12,6 @@
#include "utils.h"
#include "taconv.h"
-#define MEMBERS(strct) sizeof(strct) / sizeof(strct[1])
-
static PangoEngineRange tamil_range[] = {
{ 0x0b80, 0x0bff, "*" },
};
@@ -23,25 +21,25 @@ static PangoEngineInfo script_engines[] = {
"TamilScriptEngineLang",
PANGO_ENGINE_TYPE_LANG,
PANGO_RENDER_TYPE_NONE,
- tamil_range, MEMBERS(tamil_range)
+ tamil_range, G_N_ELEMENTS(tamil_range)
},
{
"TamilScriptEngineX",
PANGO_ENGINE_TYPE_SHAPE,
PANGO_RENDER_TYPE_X,
- tamil_range, MEMBERS(tamil_range)
+ tamil_range, G_N_ELEMENTS(tamil_range)
}
};
-static gint n_script_engines = MEMBERS (script_engines);
+static gint n_script_engines = G_N_ELEMENTS (script_engines);
/*
* Language script engine
*/
static void
-tamil_engine_break (gchar *text,
- gint len,
+tamil_engine_break (const char *text,
+ int len,
PangoAnalysis *analysis,
PangoLogAttr *attrs)
{
@@ -49,8 +47,8 @@ tamil_engine_break (gchar *text,
* only difference is char stop based on modifiers
*/
- gchar *cur = text;
- gchar *next;
+ const char *cur = text;
+ const char *next;
gint i = 0;
GUChar4 wc;
@@ -96,10 +94,10 @@ tamil_engine_lang_new ()
* But we can live with this for time being
*/
static void
-set_glyph (PangoGlyphString *glyphs, gint i,
+set_glyph (PangoGlyphString *glyphs, int i,
PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
- gint width;
+ int width;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
@@ -134,15 +132,16 @@ find_tscii_font (PangoFont *font)
}
static void
-tamil_engine_shape (PangoFont *font,
- gchar *text,
- gint length,
- PangoAnalysis *analysis,
- PangoGlyphString *glyphs)
+tamil_engine_shape (PangoFont *font,
+ const char *text,
+ int length,
+ PangoAnalysis *analysis,
+ PangoGlyphString *glyphs)
{
int n_chars, n_glyph;
int i, j;
- char *p, *next;
+ const char *p;
+ const char *next;
GUChar4 *wc, *uni_str;
int res;
unsigned char tsc_str[6];
@@ -205,6 +204,24 @@ tamil_engine_shape (PangoFont *font,
g_free(wc);
}
+static PangoCoverage *
+tamil_engine_get_coverage (PangoFont *font,
+ const char *lang)
+{
+ PangoCoverage *result = pango_coverage_new ();
+
+ PangoXSubfont tscii_font = find_tscii_font (font);
+ if (tscii_font)
+ {
+ GUChar4 i;
+
+ for (i = 0xb80; i <= 0xbff; i++)
+ pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
+ }
+
+ return result;
+}
+
static PangoEngine *
tamil_engine_x_new ()
{
@@ -216,6 +233,7 @@ tamil_engine_x_new ()
result->engine.type = PANGO_ENGINE_TYPE_LANG;
result->engine.length = sizeof (result);
result->script_shape = tamil_engine_shape;
+ result->get_coverage = tamil_engine_get_coverage;
return (PangoEngine *)result;
}
@@ -224,7 +242,7 @@ tamil_engine_x_new ()
* Pango
*/
void
-script_engine_list (PangoEngineInfo **engines, gint *n_engines)
+script_engine_list (PangoEngineInfo **engines, int *n_engines)
{
*engines = script_engines;
*n_engines = n_script_engines;