summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-04-04 16:05:02 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-04-04 16:05:02 +0000
commit52f2e805bf993f711d09ba6fe4972c7f7ee33eae (patch)
tree15e89d657b3f582fd2e8051c198c808b0756a682 /pango
parent2149bad49c6b0603daa2ee90d66a9f37d75f1eb9 (diff)
downloadpango-52f2e805bf993f711d09ba6fe4972c7f7ee33eae.tar.gz
fribidi-0.1.9 wants UCS-4 not UCS2; switch accordingly.
Tue Apr 4 12:01:37 2000 Owen Taylor <otaylor@redhat.com> * pango/utils.[ch] pango/pango-context.c: fribidi-0.1.9 wants UCS-4 not UCS2; switch accordingly.
Diffstat (limited to 'pango')
-rw-r--r--pango/pango-context.c10
-rw-r--r--pango/utils.c52
-rw-r--r--pango/utils.h2
3 files changed, 59 insertions, 5 deletions
diff --git a/pango/pango-context.c b/pango/pango-context.c
index 5343ab27..95c5bab2 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -473,7 +473,7 @@ pango_itemize (PangoContext *context,
int length,
PangoAttrList *attrs)
{
- guint16 *text_ucs2;
+ GUChar4 *text_ucs4;
gint n_chars;
guint8 *embedding_levels;
FriBidiCharType base_dir;
@@ -506,8 +506,8 @@ pango_itemize (PangoContext *context,
/* First, apply the bidirectional algorithm to break
* the text into directional runs.
*/
- text_ucs2 = _pango_utf8_to_ucs2 (text, length);
- if (!text_ucs2)
+ text_ucs4 = _pango_utf8_to_ucs4 (text, length);
+ if (!text_ucs4)
return NULL;
n_chars = unicode_strlen (text, length);
@@ -522,7 +522,7 @@ pango_itemize (PangoContext *context,
fonts = g_new0 (PangoFont *, n_chars);
extra_attr_lists = g_new0 (GSList *, n_chars);
- fribidi_log2vis_get_embedding_levels (text_ucs2, n_chars, &base_dir,
+ fribidi_log2vis_get_embedding_levels (text_ucs4, n_chars, &base_dir,
embedding_levels);
/* Now, fill in the appropriate shapers, language engines and fonts for
@@ -595,7 +595,7 @@ pango_itemize (PangoContext *context,
g_free (fonts);
g_free (extra_attr_lists);
- g_free (text_ucs2);
+ g_free (text_ucs4);
return g_list_reverse (result);
}
diff --git a/pango/utils.c b/pango/utils.c
index b9795ffb..5a04ccc7 100644
--- a/pango/utils.c
+++ b/pango/utils.c
@@ -153,6 +153,58 @@ _pango_utf8_to_ucs2 (const char *str, int len)
}
+#ifdef __GLIBC__
+# define UCS4_CHARSET "UNICODELITTLE"
+#else
+# if G_BYTE_ORDER == G_LITTLE_ENDIAN
+# define UCS4_CHARSET "UCS-4-LE"
+# else
+# define UCS4_CHARSET "UCS-4-BE"
+# endif
+#endif
+
+GUChar4 *
+_pango_utf8_to_ucs4 (const char *str, int len)
+{
+ iconv_t cd;
+ char *outbuf, *result;
+ const char *inbuf;
+ size_t inbytesleft;
+ size_t outbytesleft;
+ gint outlen;
+
+ gint count;
+
+ cd = iconv_open (UCS4_CHARSET, "UTF-8");
+
+ if (cd == (iconv_t)-1)
+ g_error ("No converter from UTF-8 to " UCS4_CHARSET);
+
+ if (len < 0)
+ len = strlen (str);
+
+ outlen = unicode_strlen (str, len) * sizeof(GUChar4);
+ result = g_malloc (outlen);
+
+ inbuf = str;
+ inbytesleft = len;
+ outbuf = result;
+ outbytesleft = outlen;
+
+ count = iconv (cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
+
+ if (count < 0 && (errno != E2BIG))
+ {
+ g_free (result);
+ result = NULL;
+ }
+
+ iconv_close (cd);
+
+ return (GUChar4 *)result;
+
+}
+
/**
* _pango_guchar4_to_utf8:
* @ch: a ISO10646 character code
diff --git a/pango/utils.h b/pango/utils.h
index d46d44ba..9cf40dbb 100644
--- a/pango/utils.h
+++ b/pango/utils.h
@@ -32,6 +32,8 @@ gboolean _pango_utf8_iterate (const char *cur,
GUChar4 *wc_out);
GUChar2 *_pango_utf8_to_ucs2 (const char *str,
gint len);
+GUChar4 *_pango_utf8_to_ucs4 (const char *str,
+ int len);
int _pango_guchar4_to_utf8 (GUChar4 c,
char *outbuf);
int _pango_utf8_len (const char *str,