summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-01-18 03:03:07 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-01-18 03:03:07 +0000
commitdc428426c9c618412eae117d7cc542e64b7babe3 (patch)
tree267db5934b4dbdb7c7bc288aea55ab3f5cf38326 /modules
parent4f4abbdc8fc0cd0547b0df81eb6f7bb3c77dee7e (diff)
downloadpango-dc428426c9c618412eae117d7cc542e64b7babe3.tar.gz
Updated to use new X font mechanism.
Mon Jan 17 22:03:24 2000 Owen Taylor <otaylor@redhat.com> * modules/hangul/hangul.c modules/tamil/tamil.c: Updated to use new X font mechanism. * libpango/pangox.[ch]: Misc bugfixes, no longer segfaults.
Diffstat (limited to 'modules')
-rw-r--r--modules/Makefile.am2
-rw-r--r--modules/hangul/hangul-x.c155
-rw-r--r--modules/hangul/hangul.c155
-rw-r--r--modules/tamil/tamil-x.c52
-rw-r--r--modules/tamil/tamil.c52
5 files changed, 219 insertions, 197 deletions
diff --git a/modules/Makefile.am b/modules/Makefile.am
index 33fc1857..f51d2bd6 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -1,3 +1,3 @@
## Process this file with automake to create Makefile.in.
-SUBDIRS=basic # hangul tamil \ No newline at end of file
+SUBDIRS=basic hangul tamil \ No newline at end of file
diff --git a/modules/hangul/hangul-x.c b/modules/hangul/hangul-x.c
index 6198972e..74a9208a 100644
--- a/modules/hangul/hangul-x.c
+++ b/modules/hangul/hangul-x.c
@@ -89,20 +89,19 @@ hangul_engine_lang_new ()
*/
static void
-set_glyph (PangoGlyphString *glyphs, gint i, PangoCFont *cfont,
- PangoGlyph glyph)
+set_glyph (PangoGlyphString *glyphs, gint i,
+ PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
gint width;
- glyphs->glyphs[i].font = cfont;
- glyphs->glyphs[i].glyph = glyph;
+ glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
- glyphs->geometry[i].x_offset = 0;
- glyphs->geometry[i].y_offset = 0;
+ glyphs->glyphs[i].geometry.x_offset = 0;
+ glyphs->glyphs[i].geometry.y_offset = 0;
- pango_x_glyph_extents (&glyphs->glyphs[i],
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->geometry[i].width = width * 72;
+ pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
+ NULL, NULL, &width, NULL, NULL, NULL, NULL);
+ glyphs->glyphs[i].geometry.width = width * 72;
}
@@ -134,7 +133,7 @@ set_glyph (PangoGlyphString *glyphs, gint i, PangoCFont *cfont,
#define IS_T(wc) (wc >= 0x11A7 && wc < 0x11F9)
-typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
+typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int n_clusters);
@@ -146,7 +145,7 @@ typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
#define JOHAB_COMMON \
int i; \
- PangoGlyph gindex; \
+ guint16 gindex; \
\
/* \
* Check if there are one CHOSEONG, one JUNGSEONG, and no more \
@@ -211,8 +210,8 @@ typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
else \
gindex += __choseong_map_2[v - VBASE]; \
} \
- pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
- set_glyph (glyphs, *n_glyphs, cfont, gindex); \
+ pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
glyphs->log_clusters[*n_glyphs] = n_clusters; \
(*n_glyphs)++; \
} \
@@ -231,8 +230,8 @@ typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
break; \
} \
\
- pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
- set_glyph (glyphs, *n_glyphs, cfont, gindex); \
+ pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
glyphs->log_clusters[*n_glyphs] = n_clusters; \
(*n_glyphs)++; \
} \
@@ -241,16 +240,16 @@ typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
{ \
gindex = __jongseong_johabfont_base[t - TBASE] + \
__jongseong_map[v - VBASE]; \
- pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
- set_glyph (glyphs, *n_glyphs, cfont, gindex); \
+ pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
glyphs->log_clusters[*n_glyphs] = n_clusters; \
(*n_glyphs)++; \
} \
\
if (v == VFILL && t == TFILL) /* dummy for no zero width */ \
{ \
- pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
- set_glyph (glyphs, *n_glyphs, cfont, JOHAB_FILLER); \
+ pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
+ set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER); \
glyphs->log_clusters[*n_glyphs] = n_clusters; \
(*n_glyphs)++; \
} \
@@ -260,7 +259,7 @@ typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
}
static void
-render_syllable_with_johabs (PangoCFont *cfont,
+render_syllable_with_johabs (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int n_clusters)
@@ -291,7 +290,7 @@ JOHAB_COMMON
break;
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont, gindex);
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
}
@@ -302,7 +301,7 @@ JOHAB_COMMON
}
static void
-render_syllable_with_johab (PangoCFont *cfont,
+render_syllable_with_johab (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int n_clusters)
@@ -319,14 +318,14 @@ JOHAB_COMMON
for (j = 0; (j < 3) && (__jamo_to_johabfont[wc-LBASE][j] != 0); j++)
{
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont,
+ set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_johabfont[wc - LBASE][j]);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
if (IS_L (wc))
{
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont, JOHAB_FILLER);
+ set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
}
@@ -335,12 +334,12 @@ JOHAB_COMMON
}
static void
-render_syllable_with_iso10646 (PangoCFont *cfont,
+render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int n_clusters)
{
- PangoGlyph gindex;
+ guint16 gindex;
int i;
/*
@@ -384,7 +383,7 @@ render_syllable_with_iso10646 (PangoCFont *cfont,
gindex = (lindex * VCOUNT + vindex) * TCOUNT + tindex + SBASE;
/* easy for composed syllables. */
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont, gindex);
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
return;
@@ -396,20 +395,20 @@ render_syllable_with_iso10646 (PangoCFont *cfont,
{
gindex = text[i];
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont, gindex);
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
}
}
static void
-render_syllable_with_ksc5601 (PangoCFont *cfont,
+render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int n_clusters)
{
guint16 sindex;
- PangoGlyph gindex;
+ guint16 gindex;
int i;
/*
@@ -470,7 +469,7 @@ render_syllable_with_ksc5601 (PangoCFont *cfont,
gindex = (((m / 94) + 0x30) << 8) | ((m % 94) + 0x21);
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont, gindex);
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
return;
@@ -487,7 +486,7 @@ render_syllable_with_ksc5601 (PangoCFont *cfont,
for (j = 0; (j < 3) && (__jamo_to_ksc5601[gindex - LBASE][j] != 0); j++)
{
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont,
+ set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_ksc5601[gindex - LBASE][j]);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
@@ -496,81 +495,71 @@ render_syllable_with_ksc5601 (PangoCFont *cfont,
}
static gboolean
-ranges_include_korean (int *ranges,
- int n_ranges)
+subfont_has_korean (PangoFont *font,
+ PangoXSubfont subfont)
{
- gboolean have_syllables = FALSE;
- gboolean have_jamos = FALSE;
- gint i;
-
- /* Check for syllables and for uncomposed jamos */
+ /* Check for syllables and for uncomposed jamos. We do this
+ * very unscientifically - if we have the first glyph, we
+ * assume we have them all. It might be better to try
+ * for the last one, to account for lazy font designers.
+ */
- for (i=0; i<n_ranges; i++)
- {
- if (ranges[2*i] <= 0xac00 && ranges[2*i+1] >= 0xd7a3)
- have_syllables = 1;
- if (ranges[2*i] <= 0x1100 && ranges[2*i+1] >= 0x11ff)
- have_jamos = 1;
- }
+ if (!pango_x_has_glyph (font, PANGO_X_MAKE_GLYPH (subfont, 0xac00)))
+ return FALSE;
+ if (!pango_x_has_glyph (font, PANGO_X_MAKE_GLYPH (subfont, 0x1100)))
+ return FALSE;
- return have_syllables && have_jamos;
+ return TRUE;
}
static gboolean
-find_charset (PangoFont *font, gchar **charsets, gint n_charsets,
- PangoXCharset *charset, RenderSyllableFunc *render_func)
+find_subfont (PangoFont *font, gchar **charsets, gint n_charsets,
+ PangoXSubfont *subfont, RenderSyllableFunc *render_func)
{
int i;
- char **xlfds;
- int n_xlfds;
+ int n_subfonts;
+ PangoXSubfont *subfonts;
+ int *subfont_charsets;
- pango_x_list_cfonts (font, charsets, n_charsets, &xlfds, &n_xlfds);
+ n_subfonts = pango_x_list_subfonts (font, charsets, n_charsets, &subfonts, &subfont_charsets);
- *cfont = NULL;
- for (i=0; i<n_xlfds; i++)
+ *subfont = 0;
+
+ for (i=0; i<n_subfonts; i++)
{
- if (match_end (xlfds[i], "johabs-1"))
+ if (strcmp (charsets[subfont_charsets[i]], "johabs-1") == 0)
{
- *cfont = pango_x_load_xlfd (font, xlfds[i]);
+ *subfont = subfonts[i];
*render_func = render_syllable_with_johabs;
break;
}
- if (match_end (xlfds[i], "johab-1"))
+ else if (strcmp (charsets[subfont_charsets[i]], "johab-1") == 0)
{
- *cfont = pango_x_load_xlfd (font, xlfds[i]);
+ *subfont = subfonts[i];
*render_func = render_syllable_with_johab;
break;
}
- else if (match_end (xlfds[i], "iso10646-1"))
+ else if (strcmp (charsets[subfont_charsets[i]], "iso10646-1") == 0)
{
- gint *ranges;
- int n_ranges;
-
- pango_x_xlfd_get_ranges (font, xlfds[i], &ranges, &n_ranges);
-
- if (ranges_include_korean (ranges, n_ranges))
+ if (subfont_has_korean (font, subfonts[i]))
{
- *cfont = pango_x_load_xlfd (font, xlfds[i]);
+ *subfont = subfonts[i];
*render_func = render_syllable_with_iso10646;
- g_free (ranges);
break;
}
-
- g_free (ranges);
}
- else if (match_end (xlfds[i], "ksc5601.1987-0"))
+ else if (strcmp (charsets[subfont_charsets[i]], "ksc5601.1987-0") == 0)
{
- *cfont = pango_x_load_xlfd (font, xlfds[i]);
+ *subfont = subfonts[i];
*render_func = render_syllable_with_ksc5601;
break;
}
}
- for (i=0; i<n_xlfds; i++)
- g_free (xlfds[i]);
- g_free (xlfds);
+ g_free (subfonts);
+ g_free (subfont_charsets);
- return (*cfont != NULL);
+ return (*subfont != 0);
}
static void
@@ -580,7 +569,7 @@ hangul_engine_shape (PangoFont *font,
PangoAnalysis *analysis,
PangoGlyphString *glyphs)
{
- PangoXCharset *charset_id;
+ PangoXSubfont subfont;
RenderSyllableFunc render_func = NULL;
char *ptr, *next;
@@ -612,9 +601,9 @@ hangul_engine_shape (PangoFont *font,
* otherwise use iso-10646 or KSC font depending on the ordering
* of the fontlist.
*/
- if (!find_charset (font, default_charset, 1, &cfont, &render_func))
- if (!find_charset (font, secondary_charset, 1, &cfont, &render_func))
- if (!find_charset (font, fallback_charsets, 2, &cfont, &render_func))
+ 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))
{
g_warning ("No available Hangul fonts.");
return;
@@ -643,14 +632,14 @@ hangul_engine_shape (PangoFont *font,
if (n_jamos > 0)
{
- (*render_func) (cfont, jamos, n_jamos,
+ (*render_func) (font, subfont, jamos, n_jamos,
glyphs, &n_glyphs, n_clusters);
n_clusters++;
n_jamos = 0;
}
/* Draw a syllable. */
- (*render_func) (cfont, wcs, 3,
+ (*render_func) (font, subfont, wcs, 3,
glyphs, &n_glyphs, n_clusters);
n_clusters++;
/* Clear. */
@@ -671,7 +660,7 @@ hangul_engine_shape (PangoFont *font,
(IS_T (jamos[n_jamos - 1]) && IS_V (wc)))
{
/* Draw a syllable. */
- (*render_func) (cfont, jamos, n_jamos,
+ (*render_func) (font, subfont, jamos, n_jamos,
glyphs, &n_glyphs, n_clusters);
n_clusters++;
/* Clear. */
@@ -692,7 +681,7 @@ hangul_engine_shape (PangoFont *font,
/* Draw the remaining Jamos. */
if (n_jamos > 0)
{
- (*render_func) (cfont, jamos, n_jamos,
+ (*render_func) (font, subfont, jamos, n_jamos,
glyphs, &n_glyphs, n_clusters);
n_clusters++;
n_jamos = 0;
diff --git a/modules/hangul/hangul.c b/modules/hangul/hangul.c
index 6198972e..74a9208a 100644
--- a/modules/hangul/hangul.c
+++ b/modules/hangul/hangul.c
@@ -89,20 +89,19 @@ hangul_engine_lang_new ()
*/
static void
-set_glyph (PangoGlyphString *glyphs, gint i, PangoCFont *cfont,
- PangoGlyph glyph)
+set_glyph (PangoGlyphString *glyphs, gint i,
+ PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
gint width;
- glyphs->glyphs[i].font = cfont;
- glyphs->glyphs[i].glyph = glyph;
+ glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
- glyphs->geometry[i].x_offset = 0;
- glyphs->geometry[i].y_offset = 0;
+ glyphs->glyphs[i].geometry.x_offset = 0;
+ glyphs->glyphs[i].geometry.y_offset = 0;
- pango_x_glyph_extents (&glyphs->glyphs[i],
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->geometry[i].width = width * 72;
+ pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
+ NULL, NULL, &width, NULL, NULL, NULL, NULL);
+ glyphs->glyphs[i].geometry.width = width * 72;
}
@@ -134,7 +133,7 @@ set_glyph (PangoGlyphString *glyphs, gint i, PangoCFont *cfont,
#define IS_T(wc) (wc >= 0x11A7 && wc < 0x11F9)
-typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
+typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int n_clusters);
@@ -146,7 +145,7 @@ typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
#define JOHAB_COMMON \
int i; \
- PangoGlyph gindex; \
+ guint16 gindex; \
\
/* \
* Check if there are one CHOSEONG, one JUNGSEONG, and no more \
@@ -211,8 +210,8 @@ typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
else \
gindex += __choseong_map_2[v - VBASE]; \
} \
- pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
- set_glyph (glyphs, *n_glyphs, cfont, gindex); \
+ pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
glyphs->log_clusters[*n_glyphs] = n_clusters; \
(*n_glyphs)++; \
} \
@@ -231,8 +230,8 @@ typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
break; \
} \
\
- pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
- set_glyph (glyphs, *n_glyphs, cfont, gindex); \
+ pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
glyphs->log_clusters[*n_glyphs] = n_clusters; \
(*n_glyphs)++; \
} \
@@ -241,16 +240,16 @@ typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
{ \
gindex = __jongseong_johabfont_base[t - TBASE] + \
__jongseong_map[v - VBASE]; \
- pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
- set_glyph (glyphs, *n_glyphs, cfont, gindex); \
+ pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
glyphs->log_clusters[*n_glyphs] = n_clusters; \
(*n_glyphs)++; \
} \
\
if (v == VFILL && t == TFILL) /* dummy for no zero width */ \
{ \
- pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
- set_glyph (glyphs, *n_glyphs, cfont, JOHAB_FILLER); \
+ pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
+ set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER); \
glyphs->log_clusters[*n_glyphs] = n_clusters; \
(*n_glyphs)++; \
} \
@@ -260,7 +259,7 @@ typedef void (* RenderSyllableFunc) (PangoCFont *cfont,
}
static void
-render_syllable_with_johabs (PangoCFont *cfont,
+render_syllable_with_johabs (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int n_clusters)
@@ -291,7 +290,7 @@ JOHAB_COMMON
break;
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont, gindex);
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
}
@@ -302,7 +301,7 @@ JOHAB_COMMON
}
static void
-render_syllable_with_johab (PangoCFont *cfont,
+render_syllable_with_johab (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int n_clusters)
@@ -319,14 +318,14 @@ JOHAB_COMMON
for (j = 0; (j < 3) && (__jamo_to_johabfont[wc-LBASE][j] != 0); j++)
{
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont,
+ set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_johabfont[wc - LBASE][j]);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
if (IS_L (wc))
{
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont, JOHAB_FILLER);
+ set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
}
@@ -335,12 +334,12 @@ JOHAB_COMMON
}
static void
-render_syllable_with_iso10646 (PangoCFont *cfont,
+render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int n_clusters)
{
- PangoGlyph gindex;
+ guint16 gindex;
int i;
/*
@@ -384,7 +383,7 @@ render_syllable_with_iso10646 (PangoCFont *cfont,
gindex = (lindex * VCOUNT + vindex) * TCOUNT + tindex + SBASE;
/* easy for composed syllables. */
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont, gindex);
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
return;
@@ -396,20 +395,20 @@ render_syllable_with_iso10646 (PangoCFont *cfont,
{
gindex = text[i];
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont, gindex);
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
}
}
static void
-render_syllable_with_ksc5601 (PangoCFont *cfont,
+render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int n_clusters)
{
guint16 sindex;
- PangoGlyph gindex;
+ guint16 gindex;
int i;
/*
@@ -470,7 +469,7 @@ render_syllable_with_ksc5601 (PangoCFont *cfont,
gindex = (((m / 94) + 0x30) << 8) | ((m % 94) + 0x21);
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont, gindex);
+ set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
return;
@@ -487,7 +486,7 @@ render_syllable_with_ksc5601 (PangoCFont *cfont,
for (j = 0; (j < 3) && (__jamo_to_ksc5601[gindex - LBASE][j] != 0); j++)
{
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
- set_glyph (glyphs, *n_glyphs, cfont,
+ set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_ksc5601[gindex - LBASE][j]);
glyphs->log_clusters[*n_glyphs] = n_clusters;
(*n_glyphs)++;
@@ -496,81 +495,71 @@ render_syllable_with_ksc5601 (PangoCFont *cfont,
}
static gboolean
-ranges_include_korean (int *ranges,
- int n_ranges)
+subfont_has_korean (PangoFont *font,
+ PangoXSubfont subfont)
{
- gboolean have_syllables = FALSE;
- gboolean have_jamos = FALSE;
- gint i;
-
- /* Check for syllables and for uncomposed jamos */
+ /* Check for syllables and for uncomposed jamos. We do this
+ * very unscientifically - if we have the first glyph, we
+ * assume we have them all. It might be better to try
+ * for the last one, to account for lazy font designers.
+ */
- for (i=0; i<n_ranges; i++)
- {
- if (ranges[2*i] <= 0xac00 && ranges[2*i+1] >= 0xd7a3)
- have_syllables = 1;
- if (ranges[2*i] <= 0x1100 && ranges[2*i+1] >= 0x11ff)
- have_jamos = 1;
- }
+ if (!pango_x_has_glyph (font, PANGO_X_MAKE_GLYPH (subfont, 0xac00)))
+ return FALSE;
+ if (!pango_x_has_glyph (font, PANGO_X_MAKE_GLYPH (subfont, 0x1100)))
+ return FALSE;
- return have_syllables && have_jamos;
+ return TRUE;
}
static gboolean
-find_charset (PangoFont *font, gchar **charsets, gint n_charsets,
- PangoXCharset *charset, RenderSyllableFunc *render_func)
+find_subfont (PangoFont *font, gchar **charsets, gint n_charsets,
+ PangoXSubfont *subfont, RenderSyllableFunc *render_func)
{
int i;
- char **xlfds;
- int n_xlfds;
+ int n_subfonts;
+ PangoXSubfont *subfonts;
+ int *subfont_charsets;
- pango_x_list_cfonts (font, charsets, n_charsets, &xlfds, &n_xlfds);
+ n_subfonts = pango_x_list_subfonts (font, charsets, n_charsets, &subfonts, &subfont_charsets);
- *cfont = NULL;
- for (i=0; i<n_xlfds; i++)
+ *subfont = 0;
+
+ for (i=0; i<n_subfonts; i++)
{
- if (match_end (xlfds[i], "johabs-1"))
+ if (strcmp (charsets[subfont_charsets[i]], "johabs-1") == 0)
{
- *cfont = pango_x_load_xlfd (font, xlfds[i]);
+ *subfont = subfonts[i];
*render_func = render_syllable_with_johabs;
break;
}
- if (match_end (xlfds[i], "johab-1"))
+ else if (strcmp (charsets[subfont_charsets[i]], "johab-1") == 0)
{
- *cfont = pango_x_load_xlfd (font, xlfds[i]);
+ *subfont = subfonts[i];
*render_func = render_syllable_with_johab;
break;
}
- else if (match_end (xlfds[i], "iso10646-1"))
+ else if (strcmp (charsets[subfont_charsets[i]], "iso10646-1") == 0)
{
- gint *ranges;
- int n_ranges;
-
- pango_x_xlfd_get_ranges (font, xlfds[i], &ranges, &n_ranges);
-
- if (ranges_include_korean (ranges, n_ranges))
+ if (subfont_has_korean (font, subfonts[i]))
{
- *cfont = pango_x_load_xlfd (font, xlfds[i]);
+ *subfont = subfonts[i];
*render_func = render_syllable_with_iso10646;
- g_free (ranges);
break;
}
-
- g_free (ranges);
}
- else if (match_end (xlfds[i], "ksc5601.1987-0"))
+ else if (strcmp (charsets[subfont_charsets[i]], "ksc5601.1987-0") == 0)
{
- *cfont = pango_x_load_xlfd (font, xlfds[i]);
+ *subfont = subfonts[i];
*render_func = render_syllable_with_ksc5601;
break;
}
}
- for (i=0; i<n_xlfds; i++)
- g_free (xlfds[i]);
- g_free (xlfds);
+ g_free (subfonts);
+ g_free (subfont_charsets);
- return (*cfont != NULL);
+ return (*subfont != 0);
}
static void
@@ -580,7 +569,7 @@ hangul_engine_shape (PangoFont *font,
PangoAnalysis *analysis,
PangoGlyphString *glyphs)
{
- PangoXCharset *charset_id;
+ PangoXSubfont subfont;
RenderSyllableFunc render_func = NULL;
char *ptr, *next;
@@ -612,9 +601,9 @@ hangul_engine_shape (PangoFont *font,
* otherwise use iso-10646 or KSC font depending on the ordering
* of the fontlist.
*/
- if (!find_charset (font, default_charset, 1, &cfont, &render_func))
- if (!find_charset (font, secondary_charset, 1, &cfont, &render_func))
- if (!find_charset (font, fallback_charsets, 2, &cfont, &render_func))
+ 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))
{
g_warning ("No available Hangul fonts.");
return;
@@ -643,14 +632,14 @@ hangul_engine_shape (PangoFont *font,
if (n_jamos > 0)
{
- (*render_func) (cfont, jamos, n_jamos,
+ (*render_func) (font, subfont, jamos, n_jamos,
glyphs, &n_glyphs, n_clusters);
n_clusters++;
n_jamos = 0;
}
/* Draw a syllable. */
- (*render_func) (cfont, wcs, 3,
+ (*render_func) (font, subfont, wcs, 3,
glyphs, &n_glyphs, n_clusters);
n_clusters++;
/* Clear. */
@@ -671,7 +660,7 @@ hangul_engine_shape (PangoFont *font,
(IS_T (jamos[n_jamos - 1]) && IS_V (wc)))
{
/* Draw a syllable. */
- (*render_func) (cfont, jamos, n_jamos,
+ (*render_func) (font, subfont, jamos, n_jamos,
glyphs, &n_glyphs, n_clusters);
n_clusters++;
/* Clear. */
@@ -692,7 +681,7 @@ hangul_engine_shape (PangoFont *font,
/* Draw the remaining Jamos. */
if (n_jamos > 0)
{
- (*render_func) (cfont, jamos, n_jamos,
+ (*render_func) (font, subfont, jamos, n_jamos,
glyphs, &n_glyphs, n_clusters);
n_clusters++;
n_jamos = 0;
diff --git a/modules/tamil/tamil-x.c b/modules/tamil/tamil-x.c
index 4d0d5d9a..f31a0e9b 100644
--- a/modules/tamil/tamil-x.c
+++ b/modules/tamil/tamil-x.c
@@ -96,21 +96,41 @@ tamil_engine_lang_new ()
* But we can live with this for time being
*/
static void
-set_glyph (PangoGlyphString *glyphs, gint i, PangoCFont *cfont, PangoGlyph glyph)
+set_glyph (PangoGlyphString *glyphs, gint i,
+ PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
gint width;
- glyphs->glyphs[i].font = cfont;
- glyphs->glyphs[i].glyph = glyph;
+ glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
- glyphs->geometry[i].x_offset = 0;
- glyphs->geometry[i].y_offset = 0;
+ glyphs->glyphs[i].geometry.x_offset = 0;
+ glyphs->glyphs[i].geometry.y_offset = 0;
glyphs->log_clusters[i] = i;
- pango_x_glyph_extents (&glyphs->glyphs[i],
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->geometry[i].width = width * 72;
+ pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
+ NULL, NULL, &width, NULL, NULL, NULL, NULL);
+ glyphs->glyphs[i].geometry.width = width * 72;
+}
+
+static PangoXSubfont
+find_tscii_font (PangoFont *font)
+{
+ char *charsets[] = { "tscii-0" };
+ PangoXSubfont *subfonts;
+ int *subfont_charsets;
+ int n_subfonts;
+ PangoXSubfont result = 0;
+
+ n_subfonts = pango_x_list_subfonts (font, charsets, 1, &subfonts, &subfont_charsets);
+
+ if (n_subfonts > 0)
+ result = subfonts[0];
+
+ g_free (subfonts);
+ g_free (subfont_charsets);
+
+ return result;
}
static void
@@ -128,15 +148,19 @@ tamil_engine_shape (PangoFont *font,
unsigned char tsc_str[6];
int ntsc, nuni;
- PangoCFont *tscii_font = NULL;
+ PangoXSubfont tscii_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);
- tscii_font = pango_x_find_cfont (font, "tscii-0");
- pango_cfont_ref (tscii_font);
+ tscii_font = find_tscii_font (font);
+ if (!tscii_font)
+ {
+ g_warning ("Cannot find a tscii font!\n");
+ return;
+ }
n_chars = _pango_utf8_len (text, length);
@@ -163,14 +187,14 @@ tamil_engine_shape (PangoFont *font,
/* We need to differentiate between different return codes later */
if (res != TA_SUCCESS)
{
- set_glyph (glyphs, n_glyph, tscii_font, ' ');
+ set_glyph (glyphs, n_glyph, font, tscii_font, ' ');
n_glyph++;
j = j + nuni;
continue;
}
for (i = 0; i < ntsc; i++)
{
- set_glyph (glyphs, n_glyph, tscii_font, (PangoGlyph) tsc_str[i]);
+ set_glyph (glyphs, n_glyph, font, tscii_font, (PangoGlyph) tsc_str[i]);
n_glyph++;
}
j = j + nuni;
@@ -178,8 +202,6 @@ tamil_engine_shape (PangoFont *font,
pango_glyph_string_set_size (glyphs, n_glyph);
- if (tscii_font)
- pango_cfont_unref (tscii_font);
g_free(wc);
}
diff --git a/modules/tamil/tamil.c b/modules/tamil/tamil.c
index 4d0d5d9a..f31a0e9b 100644
--- a/modules/tamil/tamil.c
+++ b/modules/tamil/tamil.c
@@ -96,21 +96,41 @@ tamil_engine_lang_new ()
* But we can live with this for time being
*/
static void
-set_glyph (PangoGlyphString *glyphs, gint i, PangoCFont *cfont, PangoGlyph glyph)
+set_glyph (PangoGlyphString *glyphs, gint i,
+ PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
gint width;
- glyphs->glyphs[i].font = cfont;
- glyphs->glyphs[i].glyph = glyph;
+ glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
- glyphs->geometry[i].x_offset = 0;
- glyphs->geometry[i].y_offset = 0;
+ glyphs->glyphs[i].geometry.x_offset = 0;
+ glyphs->glyphs[i].geometry.y_offset = 0;
glyphs->log_clusters[i] = i;
- pango_x_glyph_extents (&glyphs->glyphs[i],
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->geometry[i].width = width * 72;
+ pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
+ NULL, NULL, &width, NULL, NULL, NULL, NULL);
+ glyphs->glyphs[i].geometry.width = width * 72;
+}
+
+static PangoXSubfont
+find_tscii_font (PangoFont *font)
+{
+ char *charsets[] = { "tscii-0" };
+ PangoXSubfont *subfonts;
+ int *subfont_charsets;
+ int n_subfonts;
+ PangoXSubfont result = 0;
+
+ n_subfonts = pango_x_list_subfonts (font, charsets, 1, &subfonts, &subfont_charsets);
+
+ if (n_subfonts > 0)
+ result = subfonts[0];
+
+ g_free (subfonts);
+ g_free (subfont_charsets);
+
+ return result;
}
static void
@@ -128,15 +148,19 @@ tamil_engine_shape (PangoFont *font,
unsigned char tsc_str[6];
int ntsc, nuni;
- PangoCFont *tscii_font = NULL;
+ PangoXSubfont tscii_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);
- tscii_font = pango_x_find_cfont (font, "tscii-0");
- pango_cfont_ref (tscii_font);
+ tscii_font = find_tscii_font (font);
+ if (!tscii_font)
+ {
+ g_warning ("Cannot find a tscii font!\n");
+ return;
+ }
n_chars = _pango_utf8_len (text, length);
@@ -163,14 +187,14 @@ tamil_engine_shape (PangoFont *font,
/* We need to differentiate between different return codes later */
if (res != TA_SUCCESS)
{
- set_glyph (glyphs, n_glyph, tscii_font, ' ');
+ set_glyph (glyphs, n_glyph, font, tscii_font, ' ');
n_glyph++;
j = j + nuni;
continue;
}
for (i = 0; i < ntsc; i++)
{
- set_glyph (glyphs, n_glyph, tscii_font, (PangoGlyph) tsc_str[i]);
+ set_glyph (glyphs, n_glyph, font, tscii_font, (PangoGlyph) tsc_str[i]);
n_glyph++;
}
j = j + nuni;
@@ -178,8 +202,6 @@ tamil_engine_shape (PangoFont *font,
pango_glyph_string_set_size (glyphs, n_glyph);
- if (tscii_font)
- pango_cfont_unref (tscii_font);
g_free(wc);
}