summaryrefslogtreecommitdiff
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
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.
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.pre-1-07
-rw-r--r--ChangeLog.pre-1-107
-rw-r--r--ChangeLog.pre-1-27
-rw-r--r--ChangeLog.pre-1-47
-rw-r--r--ChangeLog.pre-1-67
-rw-r--r--ChangeLog.pre-1-87
-rw-r--r--examples/pango.modules4
-rw-r--r--examples/viewer.c5
-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
-rw-r--r--pango/pangox.c55
-rw-r--r--pango/pangox.h2
16 files changed, 315 insertions, 216 deletions
diff --git a/ChangeLog b/ChangeLog
index 646a3e3e..0f89bc13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
Mon Jan 17 18:29:39 2000 Owen Taylor <otaylor@redhat.com>
* libpango/pangox.[ch] modules/basic/basic.c: back away from
diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0
index 646a3e3e..0f89bc13 100644
--- a/ChangeLog.pre-1-0
+++ b/ChangeLog.pre-1-0
@@ -1,3 +1,10 @@
+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.
+
Mon Jan 17 18:29:39 2000 Owen Taylor <otaylor@redhat.com>
* libpango/pangox.[ch] modules/basic/basic.c: back away from
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 646a3e3e..0f89bc13 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,10 @@
+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.
+
Mon Jan 17 18:29:39 2000 Owen Taylor <otaylor@redhat.com>
* libpango/pangox.[ch] modules/basic/basic.c: back away from
diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2
index 646a3e3e..0f89bc13 100644
--- a/ChangeLog.pre-1-2
+++ b/ChangeLog.pre-1-2
@@ -1,3 +1,10 @@
+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.
+
Mon Jan 17 18:29:39 2000 Owen Taylor <otaylor@redhat.com>
* libpango/pangox.[ch] modules/basic/basic.c: back away from
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index 646a3e3e..0f89bc13 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,10 @@
+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.
+
Mon Jan 17 18:29:39 2000 Owen Taylor <otaylor@redhat.com>
* libpango/pangox.[ch] modules/basic/basic.c: back away from
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 646a3e3e..0f89bc13 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,10 @@
+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.
+
Mon Jan 17 18:29:39 2000 Owen Taylor <otaylor@redhat.com>
* libpango/pangox.[ch] modules/basic/basic.c: back away from
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 646a3e3e..0f89bc13 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,10 @@
+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.
+
Mon Jan 17 18:29:39 2000 Owen Taylor <otaylor@redhat.com>
* libpango/pangox.[ch] modules/basic/basic.c: back away from
diff --git a/examples/pango.modules b/examples/pango.modules
index 28d2cb73..e945bf29 100644
--- a/examples/pango.modules
+++ b/examples/pango.modules
@@ -1,2 +1,6 @@
/home/otaylor/devel/pango/modules/./basic/.libs/pango-basic.so BasicScriptEngineLang PangoEngineLang PangoRenderNone 0-687:* 688-767: 896-1423:* 1425-1641:* 7680-8191:* 8192-40959:* 44032-55203:kr 63744-64011:kr 65280-65507:*
/home/otaylor/devel/pango/modules/./basic/.libs/pango-basic.so BasicScriptEngineX PangoEngineShape PangoRenderX 0-687:* 688-767: 896-1423:* 1425-1641:* 7680-8191:* 8192-40959:* 44032-55203:kr 63744-64011:kr 65280-65507:*
+/home/otaylor/devel/pango/modules/./hangul/.libs/pango-hangul.so HangulScriptEngineLang PangoEngineLang PangoRenderNone 4352-4607:* 44032-55203:*
+/home/otaylor/devel/pango/modules/./hangul/.libs/pango-hangul.so HangulScriptEngineX PangoEngineShape PangoRenderX 4352-4607:* 44032-55203:*
+/home/otaylor/devel/pango/modules/./tamil/.libs/pango-tamil.so TamilScriptEngineLang PangoEngineLang PangoRenderNone 2944-3071:*
+/home/otaylor/devel/pango/modules/./tamil/.libs/pango-tamil.so TamilScriptEngineX PangoEngineShape PangoRenderX 2944-3071:*
diff --git a/examples/viewer.c b/examples/viewer.c
index 9a719e5d..c5411ab8 100644
--- a/examples/viewer.c
+++ b/examples/viewer.c
@@ -829,8 +829,9 @@ main (int argc, char **argv)
*/
font = pango_x_load_font (GDK_DISPLAY(),
/* "-misc-fixed-medium-r-semicondensed--13-*-*-*-c-*-iso10646-1," */
- "-gnu-unifont-medium-r-normal--16-*-*-*-c-*-iso10646-1,"
- "-*-*-medium-r-normal--16-*-*-*-*-*-*-*");
+ "-tamil-tscakaram-medium-r-normal--*-120-*-*-*-*-tscii-0,"
+ "-gnu-unifont-medium-r-normal--*-160-*-*-c-*-iso10646-1,"
+ "-*-*-medium-r-normal--*-160-*-*-*-*-*-*");
/* Create the user interface
*/
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);
}
diff --git a/pango/pangox.c b/pango/pangox.c
index 0bd1de72..7b4656c1 100644
--- a/pango/pangox.c
+++ b/pango/pangox.c
@@ -51,15 +51,18 @@ struct _PangoXFont {
gint max_subfonts;
};
-static PangoXSubfontInfo *pango_x_find_subfont (PangoFont *font,
- PangoXSubfont subfont_index);
-static XCharStruct * pango_x_get_per_char (PangoXSubfontInfo *subfont,
- guint16 char_index);
-static void pango_x_font_destroy (PangoFont *font);
-static gboolean pango_x_find_glyph (PangoFont *font,
- PangoGlyph glyph,
- PangoXSubfontInfo **subfont_return,
- XCharStruct **charstruct_return);
+static PangoXSubfontInfo * pango_x_find_subfont (PangoFont *font,
+ PangoXSubfont subfont_index);
+static XCharStruct * pango_x_get_per_char (PangoFont *font,
+ PangoXSubfontInfo *subfont,
+ guint16 char_index);
+static void pango_x_font_destroy (PangoFont *font);
+static gboolean pango_x_find_glyph (PangoFont *font,
+ PangoGlyph glyph,
+ PangoXSubfontInfo **subfont_return,
+ XCharStruct **charstruct_return);
+static XFontStruct * pango_x_get_font_struct (PangoFont *font,
+ PangoXSubfontInfo *info);
PangoFontClass pango_x_font_class = {
pango_x_font_destroy
@@ -150,7 +153,9 @@ pango_x_render (Display *display,
c.byte1 = index / 256;
c.byte2 = index % 256;
- fs = subfont->font_struct;
+ fs = pango_x_get_font_struct (font, subfont);
+ if (!fs)
+ continue;
if (fs->fid != old_fid)
{
@@ -537,6 +542,21 @@ pango_x_font_destroy (PangoFont *font)
/* Utility functions */
+static XFontStruct *
+pango_x_get_font_struct (PangoFont *font, PangoXSubfontInfo *info)
+{
+ PangoXFont *xfont = (PangoXFont *)font;
+
+ if (!info->font_struct)
+ {
+ info->font_struct = XLoadQueryFont (xfont->display, info->xlfd);
+ if (!info->font_struct)
+ g_warning ("Cannot load font for XLFD '%s\n", info->xlfd);
+ }
+
+ return info->font_struct;
+}
+
static PangoXSubfontInfo *
pango_x_find_subfont (PangoFont *font,
PangoXSubfont subfont_index)
@@ -553,7 +573,8 @@ pango_x_find_subfont (PangoFont *font,
}
static XCharStruct *
-pango_x_get_per_char (PangoXSubfontInfo *subfont,
+pango_x_get_per_char (PangoFont *font,
+ PangoXSubfontInfo *subfont,
guint16 char_index)
{
XFontStruct *fs;
@@ -565,9 +586,11 @@ pango_x_get_per_char (PangoXSubfontInfo *subfont,
byte1 = char_index / 256;
byte2 = char_index % 256;
- fs = subfont->font_struct;
-
- if ((fs->min_byte1 == 0) && (fs->min_byte1 == 0))
+ fs = pango_x_get_font_struct (font, subfont);
+ if (!fs)
+ return NULL;
+
+ if ((fs->min_byte1 == 0) && (fs->max_byte1 == 0))
{
if (byte2 < fs->min_char_or_byte2 || byte2 > fs->max_char_or_byte2)
return NULL;
@@ -607,9 +630,9 @@ pango_x_find_glyph (PangoFont *font,
if (!subfont)
return FALSE;
- cs = pango_x_get_per_char (subfont, char_index);
+ cs = pango_x_get_per_char (font, subfont, char_index);
- if (cs->width != 0)
+ if (cs && (cs->lbearing != cs->rbearing))
{
if (subfont_return)
*subfont_return = subfont;
diff --git a/pango/pangox.h b/pango/pangox.h
index 8847b363..6cde06bc 100644
--- a/pango/pangox.h
+++ b/pango/pangox.h
@@ -67,7 +67,7 @@ void pango_x_glyph_extents (PangoFont *font,
*/
typedef guint16 PangoXSubfont;
-#define PANGO_X_MAKE_GLYPH(charset,index) (charset<<16 | index)
+#define PANGO_X_MAKE_GLYPH(subfont,index) (subfont<<16 | index)
#define PANGO_X_GLYPH_SUBFONT(glyph) (glyph>>16)
#define PANGO_X_GLYPH_INDEX(glyph) (glyph & 0xffff)