summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--ChangeLog.pre-1-010
-rw-r--r--ChangeLog.pre-1-1010
-rw-r--r--ChangeLog.pre-1-210
-rw-r--r--ChangeLog.pre-1-410
-rw-r--r--ChangeLog.pre-1-610
-rw-r--r--ChangeLog.pre-1-810
-rw-r--r--configure.in22
-rw-r--r--examples/viewer-qt.cc15
-rw-r--r--examples/viewer-qt.h3
-rw-r--r--examples/viewer.c13
-rw-r--r--modules/arabic/arabic-x.c42
-rw-r--r--modules/arabic/arabic.c42
-rw-r--r--modules/arabic/arconv.c36
-rw-r--r--modules/arabic/arconv.h7
-rw-r--r--modules/arabic/langboxfont.c4
-rw-r--r--modules/arabic/mulefont.c4
-rw-r--r--modules/basic/basic-x.c34
-rw-r--r--modules/basic/basic.c34
-rw-r--r--modules/devanagari/devanagari.c71
-rw-r--r--modules/hangul/hangul-x.c32
-rw-r--r--modules/hangul/hangul.c32
-rw-r--r--modules/tamil/tamil-x.c35
-rw-r--r--modules/tamil/tamil.c35
-rw-r--r--modules/thai/thai-x.c26
-rw-r--r--modules/thai/thai.c26
-rw-r--r--pango/Makefile.am4
-rw-r--r--pango/break.c17
-rw-r--r--pango/glyphstring.c7
-rw-r--r--pango/gunicode.h21
-rw-r--r--pango/itemize.c11
-rw-r--r--pango/mapping.c7
-rw-r--r--pango/modules.c5
-rw-r--r--pango/pango-context.c21
-rw-r--r--pango/pango-layout.c50
-rw-r--r--pango/pangox.c15
-rw-r--r--pango/shape.c1
-rw-r--r--pango/utils.c228
-rw-r--r--pango/utils.h42
39 files changed, 353 insertions, 659 deletions
diff --git a/ChangeLog b/ChangeLog
index c6df1336..a8e1c5ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Wed Jun 21 12:11:56 2000 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in: Remove tests for libunicode
+
+ * pango/utils.[ch]: Removed. The functions from here are now in
+ GLib.
+
+ * **.[ch]: Removed use of libunicode and utils.c in favor of
+ Unicode functions in GLib. Requires latest GLib from CVS.
+
2000-06-14 Havoc Pennington <hp@redhat.com>
* pango/pango-attributes.c (pango_attr_list_copy): Function to
diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0
index c6df1336..a8e1c5ea 100644
--- a/ChangeLog.pre-1-0
+++ b/ChangeLog.pre-1-0
@@ -1,3 +1,13 @@
+Wed Jun 21 12:11:56 2000 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in: Remove tests for libunicode
+
+ * pango/utils.[ch]: Removed. The functions from here are now in
+ GLib.
+
+ * **.[ch]: Removed use of libunicode and utils.c in favor of
+ Unicode functions in GLib. Requires latest GLib from CVS.
+
2000-06-14 Havoc Pennington <hp@redhat.com>
* pango/pango-attributes.c (pango_attr_list_copy): Function to
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index c6df1336..a8e1c5ea 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,13 @@
+Wed Jun 21 12:11:56 2000 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in: Remove tests for libunicode
+
+ * pango/utils.[ch]: Removed. The functions from here are now in
+ GLib.
+
+ * **.[ch]: Removed use of libunicode and utils.c in favor of
+ Unicode functions in GLib. Requires latest GLib from CVS.
+
2000-06-14 Havoc Pennington <hp@redhat.com>
* pango/pango-attributes.c (pango_attr_list_copy): Function to
diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2
index c6df1336..a8e1c5ea 100644
--- a/ChangeLog.pre-1-2
+++ b/ChangeLog.pre-1-2
@@ -1,3 +1,13 @@
+Wed Jun 21 12:11:56 2000 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in: Remove tests for libunicode
+
+ * pango/utils.[ch]: Removed. The functions from here are now in
+ GLib.
+
+ * **.[ch]: Removed use of libunicode and utils.c in favor of
+ Unicode functions in GLib. Requires latest GLib from CVS.
+
2000-06-14 Havoc Pennington <hp@redhat.com>
* pango/pango-attributes.c (pango_attr_list_copy): Function to
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index c6df1336..a8e1c5ea 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,13 @@
+Wed Jun 21 12:11:56 2000 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in: Remove tests for libunicode
+
+ * pango/utils.[ch]: Removed. The functions from here are now in
+ GLib.
+
+ * **.[ch]: Removed use of libunicode and utils.c in favor of
+ Unicode functions in GLib. Requires latest GLib from CVS.
+
2000-06-14 Havoc Pennington <hp@redhat.com>
* pango/pango-attributes.c (pango_attr_list_copy): Function to
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index c6df1336..a8e1c5ea 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,13 @@
+Wed Jun 21 12:11:56 2000 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in: Remove tests for libunicode
+
+ * pango/utils.[ch]: Removed. The functions from here are now in
+ GLib.
+
+ * **.[ch]: Removed use of libunicode and utils.c in favor of
+ Unicode functions in GLib. Requires latest GLib from CVS.
+
2000-06-14 Havoc Pennington <hp@redhat.com>
* pango/pango-attributes.c (pango_attr_list_copy): Function to
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index c6df1336..a8e1c5ea 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,13 @@
+Wed Jun 21 12:11:56 2000 Owen Taylor <otaylor@redhat.com>
+
+ * configure.in: Remove tests for libunicode
+
+ * pango/utils.[ch]: Removed. The functions from here are now in
+ GLib.
+
+ * **.[ch]: Removed use of libunicode and utils.c in favor of
+ Unicode functions in GLib. Requires latest GLib from CVS.
+
2000-06-14 Havoc Pennington <hp@redhat.com>
* pango/pango-attributes.c (pango_attr_list_copy): Function to
diff --git a/configure.in b/configure.in
index 29ec4dca..1019c79a 100644
--- a/configure.in
+++ b/configure.in
@@ -33,7 +33,7 @@ if test x$FRIBIDI_CONFIG = xno ; then
AC_MSG_ERROR([*** fribidi-config not found])
fi
FRIBIDI_CFLAGS="`$FRIBIDI_CONFIG --cflags`"
-CFLAGS="$CFLAGS $UNICODE_CFLAGS"
+CFLAGS="$CFLAGS $FRIBIDI_CFLAGS"
FRIBIDI_LIBS="`$FRIBIDI_CONFIG --libs`"
AC_SUBST(FRIBIDI_LIBS)
AC_SUBST(FRIBIDI_CFLAGS)
@@ -53,20 +53,6 @@ AC_SUBST(GLIB_LIBS)
AC_SUBST(GLIB_CFLAGS)
-AC_PATH_PROG(UNICODE_CONFIG, unicode-config, no)
-if test x$UNICODE_CONFIG = xno ; then
- AC_MSG_ERROR([*** unicode-config not found])
-fi
-UNICODE_CFLAGS="`$UNICODE_CONFIG --cflags`"
-CFLAGS="$CFLAGS $UNICODE_CFLAGS"
-UNICODE_LIBS="`$UNICODE_CONFIG --libs`"
-AC_SUBST(UNICODE_LIBS)
-AC_SUBST(UNICODE_CFLAGS)
-
-AC_CHECK_LIB(unicode, unicode_type, :,
- AC_MSG_ERROR([*** libunicode not found.]), $UNICODE_LIBS)
-
-
#
# Checks for iconv
#
@@ -92,9 +78,13 @@ if test "x$found_iconv" = "xno" ; then
AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
fi
+UNICODE_CFLAGS=
+UNICODE_LIBS=
if test "x$with_libiconv" = "xyes" ; then
- UNICODE_LIBS="$UNICODE_LIBS -liconv"
+ UNICODE_LIBS="-liconv"
fi
+AC_SUBST(UNICODE_CFLAGS)
+AC_SUBST(UNICODE_LIBS)
#
# Allow building some or all modules included
diff --git a/examples/viewer-qt.cc b/examples/viewer-qt.cc
index ff078e21..b2522063 100644
--- a/examples/viewer-qt.cc
+++ b/examples/viewer-qt.cc
@@ -104,15 +104,12 @@ ViewerPara::draw (QPainter *painter, GC gc, int y)
gc, layout_, 0, devicePt.y());
}
-unicode_char_t
+gunichar
ViewerPara::getChar (int index)
{
- unicode_char_t result;
-
- if (unicode_get_utf8 (((const char *)text_) + index, &result))
- return result;
- else
- return 0;
+ gunichar result;
+
+ return g_utf8_get_char ((const char *)text_ + index);
}
QRect
@@ -319,9 +316,9 @@ ViewerView::contentsMousePressEvent (QMouseEvent *event)
if (y <= event->y() && event->y() < y_end)
{
int index = para->findPoint (event->x(), event->y() - y);
- unicode_char_t wc = para->getChar (index);
+ gunichar wc = para->getChar (index);
- if (index >= 0 && wc)
+ if (index >= 0 && wc != (gunichar)-1)
{
highlight_para_ = para;
highlight_index_ = index;
diff --git a/examples/viewer-qt.h b/examples/viewer-qt.h
index 75261ebb..c03a543d 100644
--- a/examples/viewer-qt.h
+++ b/examples/viewer-qt.h
@@ -24,7 +24,6 @@
#include <qlist.h>
#include <qmainwindow.h>
#include <pango/pango.h>
-#include <unicode.h>
class QComboBox;
class QSpinBox;
@@ -40,7 +39,7 @@ class ViewerPara
int height ();
void draw (QPainter *painter, GC gc, int y);
QRect charBounds (int index);
- unicode_char_t getChar (int index);
+ gunichar getChar (int index);
int findPoint (int x, int y);
private:
diff --git a/examples/viewer.c b/examples/viewer.c
index 84b7b25d..65a251e7 100644
--- a/examples/viewer.c
+++ b/examples/viewer.c
@@ -26,7 +26,6 @@
#include <pango/pango.h>
#include <pango/pangox.h>
-#include <unicode.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
@@ -113,14 +112,16 @@ static GList *
split_paragraphs (char *text)
{
char *p = text;
- unicode_char_t wc;
+ char *next;
+ gunichar wc;
GList *result = NULL;
char *last_para = text;
while (*p)
{
- char *next = unicode_get_utf8 (p, &wc);
- if (!next)
+ wc = g_utf8_get_char (p);
+ next = g_utf8_next_char (p);
+ if (wc == (gunichar)-1)
{
fprintf (stderr, "gscript-viewer: Invalid character in input\n");
g_list_foreach (result, (GFunc)g_free, NULL);
@@ -344,9 +345,9 @@ button_press (GtkWidget *layout, GdkEventButton *event)
if (para)
{
- unicode_char_t wc;
+ gunichar wc;
- unicode_get_utf8 (para->text + offset, &wc);
+ wc = g_utf8_get_char (para->text + offset);
message = g_strdup_printf ("Current char: U%04x", wc);
xor_char (layout, NULL, highlight_para, highlight_offset);
diff --git a/modules/arabic/arabic-x.c b/modules/arabic/arabic-x.c
index 05df83f9..807ce793 100644
--- a/modules/arabic/arabic-x.c
+++ b/modules/arabic/arabic-x.c
@@ -10,8 +10,6 @@
#include <glib.h>
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
-#include <unicode.h>
#include "arconv.h"
#include "mulefont.h"
@@ -62,27 +60,24 @@ arabic_engine_break (const char *text,
*/
const char *cur = text;
- const char *next;
gint i = 0;
- GUChar4 wc;
+ gunichar wc;
- while (*cur)
- {
- if (!_pango_utf8_iterate (cur, &next, &wc))
- return;
- if (cur == next)
- break;
- if ((next - text) > len)
- break;
- cur = next;
+ while (*cur && cur - text < len)
+ {
+ wc = g_utf8_get_char (cur);
+ if (wc == (gunichar)-1)
+ break; /* FIXME: ERROR */
attrs[i].is_white = (wc == ' ' || wc == '\t' || wc == 'n') ? 1 : 0;
attrs[i].is_break = (i > 0 && attrs[i-1].is_white) || attrs[i].is_white;
attrs[i].is_char_stop = 1;
attrs[i].is_word_stop = (i == 0) || attrs[i-1].is_white;
/* actually, is_word_stop in not correct, but simple and good enough. */
+
i++;
- }
+ cur = g_utf8_next_char (cur);
+ }
}
static PangoEngine *
@@ -222,8 +217,7 @@ arabic_engine_shape (PangoFont *font,
int i;
const char *p;
const char *pold;
- const char *next;
- GUChar4 *wc;
+ gunichar *wc;
int lvl = 1;
g_return_if_fail (font != NULL);
@@ -235,7 +229,7 @@ arabic_engine_shape (PangoFont *font,
** the needed chars -- or tree mulearabic-coded fonts ...
*/
- n_chars = n_glyph = unicode_strlen (text, length);
+ n_chars = n_glyph = g_utf8_strlen (text, length);
if (!(lvl = find_unic_font (font, default_charset,arfonts)))
{
@@ -250,19 +244,19 @@ arabic_engine_shape (PangoFont *font,
set_glyph (glyphs, font,
PANGO_X_GLYPH_SUBFONT (unknown_glyph), i,
p - text, PANGO_X_GLYPH_INDEX (unknown_glyph),0);
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
}
return;
}
subfont = arfonts[0];
- wc = (GUChar4 *)g_malloc(sizeof(GUChar4)*n_chars);
+ wc = (gunichar *)g_malloc(sizeof(gunichar)*n_chars);
p = text;
for (i=0; i < n_chars; i++)
{
- _pango_utf8_iterate (p, &next, &wc[n_chars - i - 1]);
- p = next;
+ wc[n_chars - i - 1] = g_utf8_get_char (p);
+ p = g_utf8_next_char (p);
}
@@ -290,7 +284,7 @@ arabic_engine_shape (PangoFont *font,
{
if (wc[i] == 0)
{
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
i--;
}
else
@@ -323,7 +317,7 @@ arabic_engine_shape (PangoFont *font,
cluster_start, wc[i], is_vowel);
pold = p;
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
n_glyph--;
i--;
}
@@ -337,7 +331,7 @@ static PangoCoverage *
arabic_engine_get_coverage (PangoFont *font,
const char *lang)
{
- GUChar4 i;
+ gunichar i;
PangoCoverage *result = pango_coverage_new ();
for (i = 0x60B; i <= 0x66D; i++)
diff --git a/modules/arabic/arabic.c b/modules/arabic/arabic.c
index 05df83f9..807ce793 100644
--- a/modules/arabic/arabic.c
+++ b/modules/arabic/arabic.c
@@ -10,8 +10,6 @@
#include <glib.h>
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
-#include <unicode.h>
#include "arconv.h"
#include "mulefont.h"
@@ -62,27 +60,24 @@ arabic_engine_break (const char *text,
*/
const char *cur = text;
- const char *next;
gint i = 0;
- GUChar4 wc;
+ gunichar wc;
- while (*cur)
- {
- if (!_pango_utf8_iterate (cur, &next, &wc))
- return;
- if (cur == next)
- break;
- if ((next - text) > len)
- break;
- cur = next;
+ while (*cur && cur - text < len)
+ {
+ wc = g_utf8_get_char (cur);
+ if (wc == (gunichar)-1)
+ break; /* FIXME: ERROR */
attrs[i].is_white = (wc == ' ' || wc == '\t' || wc == 'n') ? 1 : 0;
attrs[i].is_break = (i > 0 && attrs[i-1].is_white) || attrs[i].is_white;
attrs[i].is_char_stop = 1;
attrs[i].is_word_stop = (i == 0) || attrs[i-1].is_white;
/* actually, is_word_stop in not correct, but simple and good enough. */
+
i++;
- }
+ cur = g_utf8_next_char (cur);
+ }
}
static PangoEngine *
@@ -222,8 +217,7 @@ arabic_engine_shape (PangoFont *font,
int i;
const char *p;
const char *pold;
- const char *next;
- GUChar4 *wc;
+ gunichar *wc;
int lvl = 1;
g_return_if_fail (font != NULL);
@@ -235,7 +229,7 @@ arabic_engine_shape (PangoFont *font,
** the needed chars -- or tree mulearabic-coded fonts ...
*/
- n_chars = n_glyph = unicode_strlen (text, length);
+ n_chars = n_glyph = g_utf8_strlen (text, length);
if (!(lvl = find_unic_font (font, default_charset,arfonts)))
{
@@ -250,19 +244,19 @@ arabic_engine_shape (PangoFont *font,
set_glyph (glyphs, font,
PANGO_X_GLYPH_SUBFONT (unknown_glyph), i,
p - text, PANGO_X_GLYPH_INDEX (unknown_glyph),0);
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
}
return;
}
subfont = arfonts[0];
- wc = (GUChar4 *)g_malloc(sizeof(GUChar4)*n_chars);
+ wc = (gunichar *)g_malloc(sizeof(gunichar)*n_chars);
p = text;
for (i=0; i < n_chars; i++)
{
- _pango_utf8_iterate (p, &next, &wc[n_chars - i - 1]);
- p = next;
+ wc[n_chars - i - 1] = g_utf8_get_char (p);
+ p = g_utf8_next_char (p);
}
@@ -290,7 +284,7 @@ arabic_engine_shape (PangoFont *font,
{
if (wc[i] == 0)
{
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
i--;
}
else
@@ -323,7 +317,7 @@ arabic_engine_shape (PangoFont *font,
cluster_start, wc[i], is_vowel);
pold = p;
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
n_glyph--;
i--;
}
@@ -337,7 +331,7 @@ static PangoCoverage *
arabic_engine_get_coverage (PangoFont *font,
const char *lang)
{
- GUChar4 i;
+ gunichar i;
PangoCoverage *result = pango_coverage_new ();
for (i = 0x60B; i <= 0x66D; i++)
diff --git a/modules/arabic/arconv.c b/modules/arabic/arconv.c
index 94da5a4c..e722a86d 100644
--- a/modules/arabic/arconv.c
+++ b/modules/arabic/arconv.c
@@ -18,15 +18,15 @@
#endif
typedef struct {
- GUChar4 basechar;
- GUChar4 charstart;
+ gunichar basechar;
+ gunichar charstart;
int count;
} shapestruct;
typedef struct {
- GUChar4 basechar;
- GUChar4 mark1; /* has to be initialized to zero */
- GUChar4 vowel; /* */
+ gunichar basechar;
+ gunichar mark1; /* has to be initialized to zero */
+ gunichar vowel; /* */
char connecttoleft;
signed char lignum; /* is a ligature with lignum aditional characters */
char numshapes;
@@ -155,7 +155,7 @@ charstruct_init(charstruct* s)
}
void
-copycstostring(GUChar4* string,int* i,charstruct* s,int level)
+copycstostring(gunichar* string,int* i,charstruct* s,int level)
{ /* s is a shaped charstruct; i is the index into the string */
if (s->basechar == 0) return;
@@ -189,7 +189,7 @@ copycstostring(GUChar4* string,int* i,charstruct* s,int level)
}
int
-arabic_isvowel(GUChar4 s)
+arabic_isvowel(gunichar s)
{ /* is this 'joining HAMZA' ( strange but has to be handled like a vowel )
* Kasra, Fatha, Damma, Sukun ?
*/
@@ -199,8 +199,8 @@ arabic_isvowel(GUChar4 s)
return 0;
}
-static GUChar4
-unshape(GUChar4 s)
+static gunichar
+unshape(gunichar s)
{
int j = 0;
if ( (s > 0xFE80) && ( s < 0xFEFF ))
@@ -218,8 +218,8 @@ unshape(GUChar4 s)
}
}
-static GUChar4
-charshape(GUChar4 s,short which)
+static gunichar
+charshape(gunichar s,short which)
{ /* which 0=alone 1=end 2=start 3=middle */
int j = 0;
if ((s >= chartable[1].basechar) && (s <= 0x64A) && ( s != TATWEEL))
@@ -245,7 +245,7 @@ charshape(GUChar4 s,short which)
static short
-shapecount(GUChar4 s)
+shapecount(gunichar s)
{
int j = 0;
if (arabic_isvowel(s))
@@ -269,10 +269,10 @@ shapecount(GUChar4 s)
}
int
-ligature(GUChar4* string,int si,int len,charstruct* oldchar)
+ligature(gunichar* string,int si,int len,charstruct* oldchar)
{ /* no ligature possible --> return 0; 1 == vowel; 2 = two chars */
int retval = 0;
- GUChar4 newchar = string[si];
+ gunichar newchar = string[si];
if (arabic_isvowel(newchar))
{
retval = 1;
@@ -395,7 +395,7 @@ ligature(GUChar4* string,int si,int len,charstruct* oldchar)
}
static void
-shape(int olen,int* len,GUChar4* string,int level)
+shape(int olen,int* len,gunichar* string,int level)
{
/* The string must be in visual order already.
** This routine does the basic arabic reshaping.
@@ -468,10 +468,10 @@ shape(int olen,int* len,GUChar4* string,int level)
}
static void
-doublelig(int olen,int* len,GUChar4* string,int level)
+doublelig(int olen,int* len,gunichar* string,int level)
{ /* Ok. We have presentation ligatures in our font. */
int si = (olen)-1;
- GUChar4 lapresult;
+ gunichar lapresult;
while (si > 0)
{
@@ -550,7 +550,7 @@ doublelig(int olen,int* len,GUChar4* string,int level)
}
void
-arabic_reshape(int* len,GUChar4* string,int level)
+arabic_reshape(int* len,gunichar* string,int level)
{
int i;
int olen = *len;
diff --git a/modules/arabic/arconv.h b/modules/arabic/arconv.h
index d266b9d7..2e3416d9 100644
--- a/modules/arabic/arconv.h
+++ b/modules/arabic/arconv.h
@@ -7,7 +7,8 @@
#ifndef __arconv_h_
#define __arconv_h_
-#include "utils.h"
+
+#include <glib.h>
/*
* arabic_reshape: reshapes string ( ordered left-to right visual order )
@@ -19,7 +20,7 @@
* 4 : with some extra Ligatures
*
*/
-void arabic_reshape(int* len,GUChar4* string,int level);
-int arabic_isvowel(GUChar4 s);
+void arabic_reshape(int* len,gunichar* string,int level);
+int arabic_isvowel(gunichar s);
#endif
diff --git a/modules/arabic/langboxfont.c b/modules/arabic/langboxfont.c
index 3073b539..784fdd0b 100644
--- a/modules/arabic/langboxfont.c
+++ b/modules/arabic/langboxfont.c
@@ -10,8 +10,6 @@
#include <glib.h>
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
-#include <unicode.h>
/* #define DEBUG */
#ifdef DEBUG
@@ -50,7 +48,7 @@ arabic_lboxinit(PangoFont *font,PangoXSubfont* lboxfonts)
typedef struct {
- GUChar4 unicodechar;
+ gunichar unicodechar;
int charindex;
} fontentry;
diff --git a/modules/arabic/mulefont.c b/modules/arabic/mulefont.c
index e087ce0d..6766b7c1 100644
--- a/modules/arabic/mulefont.c
+++ b/modules/arabic/mulefont.c
@@ -10,8 +10,6 @@
#include <glib.h>
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
-#include <unicode.h>
/* #define DEBUG */
#ifdef DEBUG
@@ -80,7 +78,7 @@ arabic_muleinit(PangoFont *font,PangoXSubfont* mulefonts)
typedef struct {
- GUChar4 unicodechar;
+ gunichar unicodechar;
int fontindex;
int charindex;
} fontentry;
diff --git a/modules/basic/basic-x.c b/modules/basic/basic-x.c
index 8f639a2b..944ec41c 100644
--- a/modules/basic/basic-x.c
+++ b/modules/basic/basic-x.c
@@ -24,8 +24,6 @@
#include <glib.h>
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
-#include <unicode.h>
#include <fribidi/fribidi.h>
typedef struct _CharRange CharRange;
@@ -164,7 +162,7 @@ char_cache_free (CharCache *cache)
}
PangoGlyph
-find_char (CharCache *cache, PangoFont *font, GUChar4 wc, const char *input)
+find_char (CharCache *cache, PangoFont *font, gunichar wc, const char *input)
{
int mask_index;
MaskTable *mask_table;
@@ -267,15 +265,13 @@ conv_8bit (CharCache *cache,
{
iconv_t cd;
char outbuf;
- const char *p;
const char *inptr = input;
size_t inbytesleft;
char *outptr = &outbuf;
size_t outbytesleft = 1;
- _pango_utf8_iterate (input, &p, NULL);
- inbytesleft = p - input;
+ inbytesleft = g_utf8_next_char (input) - input;
cd = find_converter (cache, charset);
@@ -291,15 +287,13 @@ conv_euc (CharCache *cache,
{
iconv_t cd;
char outbuf[2];
- const char *p;
const char *inptr = input;
size_t inbytesleft;
char *outptr = outbuf;
size_t outbytesleft = 2;
- _pango_utf8_iterate (input, &p, NULL);
- inbytesleft = p - input;
+ inbytesleft = g_utf8_next_char (input) - input;
cd = find_converter (cache, charset);
@@ -316,10 +310,7 @@ conv_ucs4 (CharCache *cache,
Charset *charset,
const char *input)
{
- GUChar4 wc;
-
- unicode_get_utf8 (input, &wc);
- return wc;
+ return g_utf8_get_char (input);
}
static void
@@ -368,7 +359,6 @@ basic_engine_shape (PangoFont *font,
int n_chars;
int i;
const char *p;
- const char *next;
CharCache *cache;
@@ -379,19 +369,19 @@ basic_engine_shape (PangoFont *font,
cache = get_char_cache (font);
- n_chars = unicode_strlen (text, length);
+ n_chars = g_utf8_strlen (text, length);
pango_glyph_string_set_size (glyphs, n_chars);
p = text;
for (i=0; i < n_chars; i++)
{
- GUChar4 wc;
+ gunichar wc;
FriBidiChar mirrored_ch;
PangoGlyph index;
char buf[6];
const char *input;
- _pango_utf8_iterate (p, &next, &wc);
+ wc = g_utf8_get_char (p);
input = p;
if (analysis->level % 2)
@@ -399,7 +389,7 @@ basic_engine_shape (PangoFont *font,
{
wc = mirrored_ch;
- _pango_guchar4_to_utf8 (wc, buf);
+ g_unichar_to_utf8 (wc, buf);
input = buf;
}
@@ -414,7 +404,7 @@ basic_engine_shape (PangoFont *font,
{
set_glyph (font, glyphs, i, p - text, index);
- if (unicode_type (wc) == UNICODE_NON_SPACING_MARK)
+ if (g_unichar_type (wc) == G_UNICODE_NON_SPACING_MARK)
{
if (i > 0)
{
@@ -438,7 +428,7 @@ basic_engine_shape (PangoFont *font,
set_glyph (font, glyphs, i, p - text, pango_x_get_unknown_glyph (font));
}
- p = next;
+ p = g_utf8_next_char (p);
}
/* Simple bidi support... may have separate modules later */
@@ -470,13 +460,13 @@ basic_engine_get_coverage (PangoFont *font,
{
CharCache *cache = get_char_cache (font);
PangoCoverage *result = pango_coverage_new ();
- GUChar4 wc;
+ gunichar wc;
for (wc = 0; wc < 65536; wc++)
{
char buf[6];
- _pango_guchar4_to_utf8 (wc, buf);
+ g_unichar_to_utf8 (wc, buf);
if (find_char (cache, font, wc, buf))
pango_coverage_set (result, wc, PANGO_COVERAGE_EXACT);
}
diff --git a/modules/basic/basic.c b/modules/basic/basic.c
index 8f639a2b..944ec41c 100644
--- a/modules/basic/basic.c
+++ b/modules/basic/basic.c
@@ -24,8 +24,6 @@
#include <glib.h>
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
-#include <unicode.h>
#include <fribidi/fribidi.h>
typedef struct _CharRange CharRange;
@@ -164,7 +162,7 @@ char_cache_free (CharCache *cache)
}
PangoGlyph
-find_char (CharCache *cache, PangoFont *font, GUChar4 wc, const char *input)
+find_char (CharCache *cache, PangoFont *font, gunichar wc, const char *input)
{
int mask_index;
MaskTable *mask_table;
@@ -267,15 +265,13 @@ conv_8bit (CharCache *cache,
{
iconv_t cd;
char outbuf;
- const char *p;
const char *inptr = input;
size_t inbytesleft;
char *outptr = &outbuf;
size_t outbytesleft = 1;
- _pango_utf8_iterate (input, &p, NULL);
- inbytesleft = p - input;
+ inbytesleft = g_utf8_next_char (input) - input;
cd = find_converter (cache, charset);
@@ -291,15 +287,13 @@ conv_euc (CharCache *cache,
{
iconv_t cd;
char outbuf[2];
- const char *p;
const char *inptr = input;
size_t inbytesleft;
char *outptr = outbuf;
size_t outbytesleft = 2;
- _pango_utf8_iterate (input, &p, NULL);
- inbytesleft = p - input;
+ inbytesleft = g_utf8_next_char (input) - input;
cd = find_converter (cache, charset);
@@ -316,10 +310,7 @@ conv_ucs4 (CharCache *cache,
Charset *charset,
const char *input)
{
- GUChar4 wc;
-
- unicode_get_utf8 (input, &wc);
- return wc;
+ return g_utf8_get_char (input);
}
static void
@@ -368,7 +359,6 @@ basic_engine_shape (PangoFont *font,
int n_chars;
int i;
const char *p;
- const char *next;
CharCache *cache;
@@ -379,19 +369,19 @@ basic_engine_shape (PangoFont *font,
cache = get_char_cache (font);
- n_chars = unicode_strlen (text, length);
+ n_chars = g_utf8_strlen (text, length);
pango_glyph_string_set_size (glyphs, n_chars);
p = text;
for (i=0; i < n_chars; i++)
{
- GUChar4 wc;
+ gunichar wc;
FriBidiChar mirrored_ch;
PangoGlyph index;
char buf[6];
const char *input;
- _pango_utf8_iterate (p, &next, &wc);
+ wc = g_utf8_get_char (p);
input = p;
if (analysis->level % 2)
@@ -399,7 +389,7 @@ basic_engine_shape (PangoFont *font,
{
wc = mirrored_ch;
- _pango_guchar4_to_utf8 (wc, buf);
+ g_unichar_to_utf8 (wc, buf);
input = buf;
}
@@ -414,7 +404,7 @@ basic_engine_shape (PangoFont *font,
{
set_glyph (font, glyphs, i, p - text, index);
- if (unicode_type (wc) == UNICODE_NON_SPACING_MARK)
+ if (g_unichar_type (wc) == G_UNICODE_NON_SPACING_MARK)
{
if (i > 0)
{
@@ -438,7 +428,7 @@ basic_engine_shape (PangoFont *font,
set_glyph (font, glyphs, i, p - text, pango_x_get_unknown_glyph (font));
}
- p = next;
+ p = g_utf8_next_char (p);
}
/* Simple bidi support... may have separate modules later */
@@ -470,13 +460,13 @@ basic_engine_get_coverage (PangoFont *font,
{
CharCache *cache = get_char_cache (font);
PangoCoverage *result = pango_coverage_new ();
- GUChar4 wc;
+ gunichar wc;
for (wc = 0; wc < 65536; wc++)
{
char buf[6];
- _pango_guchar4_to_utf8 (wc, buf);
+ g_unichar_to_utf8 (wc, buf);
if (find_char (cache, font, wc, buf))
pango_coverage_set (result, wc, PANGO_COVERAGE_EXACT);
}
diff --git a/modules/devanagari/devanagari.c b/modules/devanagari/devanagari.c
index 0fe59422..7f3c1528 100644
--- a/modules/devanagari/devanagari.c
+++ b/modules/devanagari/devanagari.c
@@ -20,10 +20,8 @@
*/
#include <glib.h>
-#include <unicode.h>
#include <stdio.h>
-#include "utils.h"
#include "pango.h"
#include "pangox.h"
@@ -94,7 +92,7 @@ static gboolean
static PangoCoverage *
devanagari_engine_get_coverage (PangoFont * font, const char *lang)
{
- GUChar4 i;
+ gunichar i;
PangoCoverage *result = pango_coverage_new ();
PangoXSubfont subfont;
@@ -171,14 +169,14 @@ is_ind_vowel (int i)
}
static int
-is_nonspacing_vowel (GUChar4 c)
+is_nonspacing_vowel (gunichar c)
{
/* one that doesn't space. ie 93f and 940 don't count */
return (c >= 0x941 && c <= 0x948) || (c >= 0x962 && c <= 0x963);
}
static int
-get_char (GUChar4 * chars, GUChar4 * end)
+get_char (gunichar * chars, gunichar * end)
{
if (chars >= end)
return 0;
@@ -186,15 +184,15 @@ get_char (GUChar4 * chars, GUChar4 * end)
}
static void
-devanagari_shift_vowels (GUChar4 * chars, GUChar4 * end)
+devanagari_shift_vowels (gunichar * chars, gunichar * end)
{
/* moves 0x93f (I) before consonant clusters where appropriate. */
- GUChar4 *strt = chars;
+ gunichar *strt = chars;
while (chars < end)
{
if (*chars == 0x93f && chars > strt)
{
- GUChar4 *bubble = chars;
+ gunichar *bubble = chars;
int i = 1;
/* move back TO START! */
@@ -212,12 +210,12 @@ devanagari_shift_vowels (GUChar4 * chars, GUChar4 * end)
}
void
-devanagari_convert_vowels (int *num, GUChar4 * chars)
+devanagari_convert_vowels (int *num, gunichar * chars)
{
/* goes along and converts matras to vowel letters if needed.
* this is only currently done at the beginning of the string. */
- GUChar4 *end = chars + *num;
- GUChar4 *start = chars;
+ gunichar *end = chars + *num;
+ gunichar *start = chars;
while (chars < end)
{
if ((chars == start && is_comb_vowel (chars[0])) ||
@@ -231,11 +229,11 @@ devanagari_convert_vowels (int *num, GUChar4 * chars)
}
static void
-devanagari_compact (int *num, GUChar4 * chars, gint * cluster)
+devanagari_compact (int *num, gunichar * chars, gint * cluster)
{
/* shuffle stuff up into the blanked out elements. */
- GUChar4 *dest = chars;
- GUChar4 *end = chars + *num;
+ gunichar *dest = chars;
+ gunichar *end = chars + *num;
gint *cluster_dest = cluster;
while (chars < end)
{
@@ -296,12 +294,12 @@ const char *bar[] =
#endif
static void
-devanagari_make_ligs (GUChar4 * start, GUChar4 * end, int *cluster)
+devanagari_make_ligs (gunichar * start, gunichar * end, int *cluster)
{
- GUChar4 t0 = get_char (start, end);
- GUChar4 t1 = get_char (start + 1, end);
- GUChar4 t2 = get_char (start + 2, end);
- GUChar4 t3 = get_char (start + 3, end);
+ gunichar t0 = get_char (start, end);
+ gunichar t1 = get_char (start + 1, end);
+ gunichar t2 = get_char (start + 2, end);
+ gunichar t3 = get_char (start + 3, end);
int i, j;
int repha = 0, ligature = 0;
@@ -425,19 +423,19 @@ devanagari_engine_shape (PangoFont * font,
int n_chars, n_glyph;
int lvl;
- const char *p, *next;
+ const char *p;
int i;
- GUChar4 *wc;
+ gunichar *wc;
int sb;
int n_syls;
- GUChar4 **syls = g_malloc (sizeof (GUChar4 **));
+ gunichar **syls = g_malloc (sizeof (gunichar **));
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
g_return_if_fail (length >= 0);
g_return_if_fail (analysis != NULL);
- n_chars = n_glyph = unicode_strlen (text, length);
+ n_chars = n_glyph = g_utf8_strlen (text, length);
lvl = find_unic_font (font, default_charset, &subfont);
if (!lvl)
{
@@ -454,18 +452,18 @@ devanagari_engine_shape (PangoFont * font,
glyphs->glyphs[i].geometry.width = logical_rect.width;
glyphs->log_clusters[i] = 0;
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
}
return;
}
p = text;
- wc = (GUChar4 *) g_malloc (sizeof (GUChar4) * n_chars);
+ wc = (gunichar *) g_malloc (sizeof (gunichar) * n_chars);
pango_glyph_string_set_size (glyphs, n_glyph);
for (i = 0; i < n_chars; i++)
{
- _pango_utf8_iterate (p, &next, &wc[i]);
+ wc[i] = g_utf8_get_char (p);
glyphs->log_clusters[i] = p - text;
- p = next;
+ p = g_utf8_next_char (p);
}
devanagari_convert_vowels (&n_glyph, wc);
@@ -478,7 +476,7 @@ devanagari_engine_shape (PangoFont * font,
if (i && (is_consonant (wc[i]) | is_ind_vowel (wc[i]))
&& wc[i - 1] != 0x94d)
{
- syls = g_realloc (syls, ((n_syls + 2) * sizeof (GUChar4 **)));
+ syls = g_realloc (syls, ((n_syls + 2) * sizeof (gunichar **)));
syls[n_syls] = wc + i;
n_syls++;
sb = glyphs->log_clusters[i];
@@ -550,19 +548,14 @@ devanagari_engine_break (const char *text,
PangoAnalysis * analysis, PangoLogAttr * attrs)
{
const char *cur = text;
- const char *next;
gint i = 0;
- GUChar4 wc;
+ gunichar wc;
- while (*cur)
+ while (*cur && cur - text < len)
{
- if (!_pango_utf8_iterate (cur, &next, &wc))
- return;
- if (cur == next)
- break;
- if ((next - text) > len)
- break;
- cur = next;
+ wc = g_utf8_get_char (cur);
+ if (wc == (gunichar)-1)
+ break; /* FIXME: ERROR */
attrs[i].is_white = (wc == ' ' || wc == '\t' || wc == 'n') ? 1 : 0;
attrs[i].is_break = (i > 0 && attrs[i - 1].is_white) ||
@@ -570,7 +563,9 @@ devanagari_engine_break (const char *text,
attrs[i].is_char_stop = 1;
attrs[i].is_word_stop = (i == 0) || attrs[i - 1].is_white;
/* actually, is_word_stop in not correct, but simple and good enough. */
+
i++;
+ cur = g_utf8_next_char (cur);
}
}
diff --git a/modules/hangul/hangul-x.c b/modules/hangul/hangul-x.c
index 6265b77b..8df658ed 100644
--- a/modules/hangul/hangul-x.c
+++ b/modules/hangul/hangul-x.c
@@ -23,8 +23,6 @@
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
-#include <unicode.h>
static PangoEngineRange hangul_ranges[] = {
@@ -134,7 +132,7 @@ set_glyph (PangoGlyphString *glyphs,
typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
- GUChar2 *text, int length,
+ gunichar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int cluster_offset);
@@ -171,7 +169,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
\
if (n_cho <= 1 && n_jung <= 1 && n_jong <= 1) \
{ \
- GUChar2 l, v, t; \
+ gunichar2 l, v, t; \
\
if (n_cho > 0) \
l = text[0]; \
@@ -260,7 +258,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
static void
render_syllable_with_johabs (PangoFont *font, PangoXSubfont subfont,
- GUChar2 *text, int length,
+ gunichar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int cluster_offset)
{
@@ -302,7 +300,7 @@ JOHAB_COMMON
static void
render_syllable_with_johab (PangoFont *font, PangoXSubfont subfont,
- GUChar2 *text, int length,
+ gunichar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int cluster_offset)
{
@@ -312,7 +310,7 @@ JOHAB_COMMON
for (i = 0; i < length; i++)
{
int j;
- GUChar2 wc;
+ gunichar2 wc;
wc = text[i];
for (j = 0; (j < 3) && (__jamo_to_johabfont[wc-LBASE][j] != 0); j++)
@@ -335,7 +333,7 @@ JOHAB_COMMON
static void
render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
- GUChar2 *text, int length,
+ gunichar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int cluster_offset)
{
@@ -403,7 +401,7 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
static void
render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
- GUChar2 *text, int length,
+ gunichar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int cluster_offset)
{
@@ -588,7 +586,7 @@ hangul_engine_shape (PangoFont *font,
const char *ptr;
const char *next;
int i, n_chars;
- GUChar2 jamos[4];
+ gunichar2 jamos[4];
int n_jamos = 0;
int n_glyphs = 0, cluster_offset = 0;
@@ -608,7 +606,7 @@ hangul_engine_shape (PangoFont *font,
{
PangoGlyph unknown_glyph = pango_x_get_unknown_glyph (font);
- n_chars = unicode_strlen (text, length);
+ n_chars = g_utf8_strlen (text, length);
pango_glyph_string_set_size (glyphs, n_chars);
for (i=0; i<n_chars; i++)
@@ -619,16 +617,18 @@ hangul_engine_shape (PangoFont *font,
return;
}
- n_chars = unicode_strlen (text, length);
+ n_chars = g_utf8_strlen (text, length);
ptr = text;
for (i = 0; i < n_chars; i++)
{
- GUChar4 wc4;
- GUChar2 wcs[4], wc;
+ gunichar wc4;
+ gunichar2 wcs[4], wc;
int n_code = 0;
- _pango_utf8_iterate (ptr, &next, &wc4);
+ wc4 = g_utf8_get_char (ptr);
+ next = g_utf8_next_char (ptr);
+
if (wc4 >= SBASE && wc4 < (SBASE + SCOUNT))
{
/* decompose the syllable. */
@@ -656,7 +656,7 @@ hangul_engine_shape (PangoFont *font,
}
else if (wc4 >= 0x1100 && wc4 <= 0x11ff)
{
- wc = (GUChar2) wc4;
+ wc = (gunichar2) wc4;
if (n_jamos == 0)
{
diff --git a/modules/hangul/hangul.c b/modules/hangul/hangul.c
index 6265b77b..8df658ed 100644
--- a/modules/hangul/hangul.c
+++ b/modules/hangul/hangul.c
@@ -23,8 +23,6 @@
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
-#include <unicode.h>
static PangoEngineRange hangul_ranges[] = {
@@ -134,7 +132,7 @@ set_glyph (PangoGlyphString *glyphs,
typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
- GUChar2 *text, int length,
+ gunichar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int cluster_offset);
@@ -171,7 +169,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
\
if (n_cho <= 1 && n_jung <= 1 && n_jong <= 1) \
{ \
- GUChar2 l, v, t; \
+ gunichar2 l, v, t; \
\
if (n_cho > 0) \
l = text[0]; \
@@ -260,7 +258,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
static void
render_syllable_with_johabs (PangoFont *font, PangoXSubfont subfont,
- GUChar2 *text, int length,
+ gunichar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int cluster_offset)
{
@@ -302,7 +300,7 @@ JOHAB_COMMON
static void
render_syllable_with_johab (PangoFont *font, PangoXSubfont subfont,
- GUChar2 *text, int length,
+ gunichar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int cluster_offset)
{
@@ -312,7 +310,7 @@ JOHAB_COMMON
for (i = 0; i < length; i++)
{
int j;
- GUChar2 wc;
+ gunichar2 wc;
wc = text[i];
for (j = 0; (j < 3) && (__jamo_to_johabfont[wc-LBASE][j] != 0); j++)
@@ -335,7 +333,7 @@ JOHAB_COMMON
static void
render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
- GUChar2 *text, int length,
+ gunichar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int cluster_offset)
{
@@ -403,7 +401,7 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
static void
render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
- GUChar2 *text, int length,
+ gunichar2 *text, int length,
PangoGlyphString *glyphs,
int *n_glyphs, int cluster_offset)
{
@@ -588,7 +586,7 @@ hangul_engine_shape (PangoFont *font,
const char *ptr;
const char *next;
int i, n_chars;
- GUChar2 jamos[4];
+ gunichar2 jamos[4];
int n_jamos = 0;
int n_glyphs = 0, cluster_offset = 0;
@@ -608,7 +606,7 @@ hangul_engine_shape (PangoFont *font,
{
PangoGlyph unknown_glyph = pango_x_get_unknown_glyph (font);
- n_chars = unicode_strlen (text, length);
+ n_chars = g_utf8_strlen (text, length);
pango_glyph_string_set_size (glyphs, n_chars);
for (i=0; i<n_chars; i++)
@@ -619,16 +617,18 @@ hangul_engine_shape (PangoFont *font,
return;
}
- n_chars = unicode_strlen (text, length);
+ n_chars = g_utf8_strlen (text, length);
ptr = text;
for (i = 0; i < n_chars; i++)
{
- GUChar4 wc4;
- GUChar2 wcs[4], wc;
+ gunichar wc4;
+ gunichar2 wcs[4], wc;
int n_code = 0;
- _pango_utf8_iterate (ptr, &next, &wc4);
+ wc4 = g_utf8_get_char (ptr);
+ next = g_utf8_next_char (ptr);
+
if (wc4 >= SBASE && wc4 < (SBASE + SCOUNT))
{
/* decompose the syllable. */
@@ -656,7 +656,7 @@ hangul_engine_shape (PangoFont *font,
}
else if (wc4 >= 0x1100 && wc4 <= 0x11ff)
{
- wc = (GUChar2) wc4;
+ wc = (gunichar2) wc4;
if (n_jamos == 0)
{
diff --git a/modules/tamil/tamil-x.c b/modules/tamil/tamil-x.c
index e55362b8..98c31548 100644
--- a/modules/tamil/tamil-x.c
+++ b/modules/tamil/tamil-x.c
@@ -9,9 +9,7 @@
#include <glib.h>
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
#include "taconv.h"
-#include <unicode.h>
static PangoEngineRange tamil_range[] = {
{ 0x0b80, 0x0bff, "*" },
@@ -49,19 +47,14 @@ tamil_engine_break (const char *text,
*/
const char *cur = text;
- const char *next;
gint i = 0;
- GUChar4 wc;
+ gunichar wc;
- while (*cur)
+ while (*cur && cur - text < len)
{
- if (!_pango_utf8_iterate (cur, &next, &wc))
- return;
- if (cur == next)
- break;
- if ((next - text) > len)
- break;
- cur = next;
+ wc = g_utf8_get_char (cur);
+ if (wc == (gunichar)-1)
+ break; /* FIXME: ERROR */
attrs[i].is_white = (wc == ' ' || wc == '\t' || wc == 'n') ? 1 : 0;
attrs[i].is_break = (i > 0 && attrs[i-1].is_white) || attrs[i].is_white;
@@ -69,6 +62,7 @@ tamil_engine_break (const char *text,
attrs[i].is_word_stop = (i == 0) || attrs[i-1].is_white;
i++;
+ cur = g_utf8_next_char (cur);
}
}
@@ -98,7 +92,6 @@ static void
set_glyph (PangoGlyphString *glyphs, int i, int cluster_start,
PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
- int width;
PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
@@ -143,8 +136,7 @@ tamil_engine_shape (PangoFont *font,
int i, j;
const char *cluster_start;
const char *p;
- const char *next;
- GUChar4 *wc, *uni_str;
+ gunichar *wc, *uni_str;
int res;
unsigned char tsc_str[6];
int ntsc, nuni;
@@ -163,17 +155,18 @@ tamil_engine_shape (PangoFont *font,
return;
}
- n_chars = _pango_utf8_len (text, length);
+ n_chars = g_utf8_strlen (text, length);
/* temporarily set the size to 3 times the number of unicode chars */
pango_glyph_string_set_size (glyphs, n_chars * 3);
- wc = (GUChar4 *)g_malloc(sizeof(GUChar4)*n_chars);
+
+ wc = (gunichar *)g_malloc(sizeof(gunichar)*n_chars);
p = text;
for (i=0; i < n_chars; i++)
{
- _pango_utf8_iterate (p, &next, &wc[i]);
- p = next;
+ wc[i] = g_utf8_get_char (p);
+ p = g_utf8_next_char (p);
}
n_glyph = 0;
@@ -201,7 +194,7 @@ tamil_engine_shape (PangoFont *font,
}
j = j + nuni;
while (nuni--)
- cluster_start = unicode_next_utf8 (cluster_start);
+ cluster_start = g_utf8_next_char (cluster_start);
}
pango_glyph_string_set_size (glyphs, n_glyph);
@@ -218,7 +211,7 @@ tamil_engine_get_coverage (PangoFont *font,
PangoXSubfont tscii_font = find_tscii_font (font);
if (tscii_font)
{
- GUChar4 i;
+ gunichar i;
for (i = 0xb80; i <= 0xbff; i++)
pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
diff --git a/modules/tamil/tamil.c b/modules/tamil/tamil.c
index e55362b8..98c31548 100644
--- a/modules/tamil/tamil.c
+++ b/modules/tamil/tamil.c
@@ -9,9 +9,7 @@
#include <glib.h>
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
#include "taconv.h"
-#include <unicode.h>
static PangoEngineRange tamil_range[] = {
{ 0x0b80, 0x0bff, "*" },
@@ -49,19 +47,14 @@ tamil_engine_break (const char *text,
*/
const char *cur = text;
- const char *next;
gint i = 0;
- GUChar4 wc;
+ gunichar wc;
- while (*cur)
+ while (*cur && cur - text < len)
{
- if (!_pango_utf8_iterate (cur, &next, &wc))
- return;
- if (cur == next)
- break;
- if ((next - text) > len)
- break;
- cur = next;
+ wc = g_utf8_get_char (cur);
+ if (wc == (gunichar)-1)
+ break; /* FIXME: ERROR */
attrs[i].is_white = (wc == ' ' || wc == '\t' || wc == 'n') ? 1 : 0;
attrs[i].is_break = (i > 0 && attrs[i-1].is_white) || attrs[i].is_white;
@@ -69,6 +62,7 @@ tamil_engine_break (const char *text,
attrs[i].is_word_stop = (i == 0) || attrs[i-1].is_white;
i++;
+ cur = g_utf8_next_char (cur);
}
}
@@ -98,7 +92,6 @@ static void
set_glyph (PangoGlyphString *glyphs, int i, int cluster_start,
PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
- int width;
PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
@@ -143,8 +136,7 @@ tamil_engine_shape (PangoFont *font,
int i, j;
const char *cluster_start;
const char *p;
- const char *next;
- GUChar4 *wc, *uni_str;
+ gunichar *wc, *uni_str;
int res;
unsigned char tsc_str[6];
int ntsc, nuni;
@@ -163,17 +155,18 @@ tamil_engine_shape (PangoFont *font,
return;
}
- n_chars = _pango_utf8_len (text, length);
+ n_chars = g_utf8_strlen (text, length);
/* temporarily set the size to 3 times the number of unicode chars */
pango_glyph_string_set_size (glyphs, n_chars * 3);
- wc = (GUChar4 *)g_malloc(sizeof(GUChar4)*n_chars);
+
+ wc = (gunichar *)g_malloc(sizeof(gunichar)*n_chars);
p = text;
for (i=0; i < n_chars; i++)
{
- _pango_utf8_iterate (p, &next, &wc[i]);
- p = next;
+ wc[i] = g_utf8_get_char (p);
+ p = g_utf8_next_char (p);
}
n_glyph = 0;
@@ -201,7 +194,7 @@ tamil_engine_shape (PangoFont *font,
}
j = j + nuni;
while (nuni--)
- cluster_start = unicode_next_utf8 (cluster_start);
+ cluster_start = g_utf8_next_char (cluster_start);
}
pango_glyph_string_set_size (glyphs, n_glyph);
@@ -218,7 +211,7 @@ tamil_engine_get_coverage (PangoFont *font,
PangoXSubfont tscii_font = find_tscii_font (font);
if (tscii_font)
{
- GUChar4 i;
+ gunichar i;
for (i = 0xb80; i <= 0xbff; i++)
pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
diff --git a/modules/thai/thai-x.c b/modules/thai/thai-x.c
index 0882f75e..aaa52140 100644
--- a/modules/thai/thai-x.c
+++ b/modules/thai/thai-x.c
@@ -24,8 +24,6 @@
#include <glib.h>
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
-#include <unicode.h>
#include <fribidi/fribidi.h>
/* We handle the range U+0e01 to U+0e5b exactly
@@ -240,7 +238,7 @@ add_glyph (ThaiFontInfo *font_info,
* code pointer
*/
static int
-get_glyph (ThaiFontInfo *font_info, unicode_char_t wc)
+get_glyph (ThaiFontInfo *font_info, gunichar wc)
{
switch (font_info->type)
{
@@ -260,9 +258,9 @@ static void
add_cluster (ThaiFontInfo *font_info,
PangoGlyphString *glyphs,
int cluster_start,
- unicode_char_t base,
- unicode_char_t group1,
- unicode_char_t group2)
+ gunichar base,
+ gunichar group1,
+ gunichar group2)
{
/* If we are rendering with an XTIS font, we try to find a precomposed
* glyph for the cluster.
@@ -303,11 +301,11 @@ thai_engine_shape (PangoFont *font,
PangoGlyphString *glyphs)
{
ThaiFontInfo *font_info;
- const char *p, *next;
+ const char *p;
- unicode_char_t base = 0;
- unicode_char_t group1 = 0;
- unicode_char_t group2 = 0;
+ gunichar base = 0;
+ gunichar group1 = 0;
+ gunichar group2 = 0;
int cluster_start = 0;
pango_glyph_string_set_size (glyphs, 0);
@@ -318,9 +316,9 @@ thai_engine_shape (PangoFont *font,
while (p < text + length)
{
int group;
- unicode_char_t wc;
+ gunichar wc;
- next = unicode_get_utf8 (p, &wc);
+ wc = g_utf8_get_char (p);
if (wc >= 0xe30 && wc < 0xe50)
group = groups[wc - 0xe30];
@@ -347,7 +345,7 @@ thai_engine_shape (PangoFont *font,
break;
}
- p = next;
+ p = g_utf8_next_char (p);
}
if (base)
@@ -364,7 +362,7 @@ thai_engine_get_coverage (PangoFont *font,
if (font_info->type != THAI_FONT_NONE)
{
- unicode_char_t wc;
+ gunichar wc;
for (wc = 0xe01; wc <= 0xe3a; wc++)
pango_coverage_set (result, wc, PANGO_COVERAGE_EXACT);
diff --git a/modules/thai/thai.c b/modules/thai/thai.c
index 0882f75e..aaa52140 100644
--- a/modules/thai/thai.c
+++ b/modules/thai/thai.c
@@ -24,8 +24,6 @@
#include <glib.h>
#include "pango.h"
#include "pangox.h"
-#include "utils.h"
-#include <unicode.h>
#include <fribidi/fribidi.h>
/* We handle the range U+0e01 to U+0e5b exactly
@@ -240,7 +238,7 @@ add_glyph (ThaiFontInfo *font_info,
* code pointer
*/
static int
-get_glyph (ThaiFontInfo *font_info, unicode_char_t wc)
+get_glyph (ThaiFontInfo *font_info, gunichar wc)
{
switch (font_info->type)
{
@@ -260,9 +258,9 @@ static void
add_cluster (ThaiFontInfo *font_info,
PangoGlyphString *glyphs,
int cluster_start,
- unicode_char_t base,
- unicode_char_t group1,
- unicode_char_t group2)
+ gunichar base,
+ gunichar group1,
+ gunichar group2)
{
/* If we are rendering with an XTIS font, we try to find a precomposed
* glyph for the cluster.
@@ -303,11 +301,11 @@ thai_engine_shape (PangoFont *font,
PangoGlyphString *glyphs)
{
ThaiFontInfo *font_info;
- const char *p, *next;
+ const char *p;
- unicode_char_t base = 0;
- unicode_char_t group1 = 0;
- unicode_char_t group2 = 0;
+ gunichar base = 0;
+ gunichar group1 = 0;
+ gunichar group2 = 0;
int cluster_start = 0;
pango_glyph_string_set_size (glyphs, 0);
@@ -318,9 +316,9 @@ thai_engine_shape (PangoFont *font,
while (p < text + length)
{
int group;
- unicode_char_t wc;
+ gunichar wc;
- next = unicode_get_utf8 (p, &wc);
+ wc = g_utf8_get_char (p);
if (wc >= 0xe30 && wc < 0xe50)
group = groups[wc - 0xe30];
@@ -347,7 +345,7 @@ thai_engine_shape (PangoFont *font,
break;
}
- p = next;
+ p = g_utf8_next_char (p);
}
if (base)
@@ -364,7 +362,7 @@ thai_engine_get_coverage (PangoFont *font,
if (font_info->type != THAI_FONT_NONE)
{
- unicode_char_t wc;
+ gunichar wc;
for (wc = 0xe01; wc <= 0xe3a; wc++)
pango_coverage_set (result, wc, PANGO_COVERAGE_EXACT);
diff --git a/pango/Makefile.am b/pango/Makefile.am
index 5cd9e019..ea86de71 100644
--- a/pango/Makefile.am
+++ b/pango/Makefile.am
@@ -21,9 +21,7 @@ libpango_la_SOURCES = \
pango-item.c \
pango-layout.c \
reorder-items.c \
- shape.c \
- utils.c \
- utils.h
+ shape.c
libpangox_la_SOURCES = \
pangox.c \
diff --git a/pango/break.c b/pango/break.c
index 70de69ce..93ffecf2 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -20,8 +20,6 @@
*/
#include "pango.h"
-#include <unicode.h>
-#include "utils.h"
/**
* pango_break:
@@ -41,20 +39,14 @@ void pango_break (const gchar *text,
/* Pseudo-implementation */
const gchar *cur = text;
- const gchar *next;
gint i = 0;
- GUChar4 wc;
+ gunichar wc;
- while (*cur)
+ while (*cur && cur - text < length)
{
- next = unicode_get_utf8 (cur, &wc);
- if (!next)
+ wc = g_utf8_get_char (cur);
+ if (wc == (gunichar)-1)
break; /* FIXME: ERROR */
- if (cur == next)
- break;
- if ((next - text) > length)
- break;
- cur = next;
attrs[i].is_white = (wc == ' ' || wc == '\t' || wc == '\n' || wc == 0x200b) ? 1 : 0;
attrs[i].is_break = i == 0 || attrs[i-1].is_white || attrs[i].is_white;
@@ -62,5 +54,6 @@ void pango_break (const gchar *text,
attrs[i].is_word_stop = (i == 0) || attrs[i-1].is_white;
i++;
+ cur = g_utf8_next_char (cur);
}
}
diff --git a/pango/glyphstring.c b/pango/glyphstring.c
index d9d7c87b..b8d9eaa7 100644
--- a/pango/glyphstring.c
+++ b/pango/glyphstring.c
@@ -22,7 +22,6 @@
#include <glib.h>
#include <pango/pango-glyph.h>
#include <pango/pango-font.h>
-#include <unicode.h>
/**
* pango_glyph_string_new:
@@ -188,7 +187,7 @@ pango_glyph_string_extents (PangoGlyphString *glyphs,
* @text: the text corresponding to the glyphs
* @length: the length of @text, in bytes
* @embedding_level: the embedding level of the string
- * @logical_widths: an array whose length is unicode_strlen (text, length)
+ * @logical_widths: an array whose length is g_utf8_strlen (text, length)
* to be filled in with the resulting character widths.
*
* Given a #PangoGlyphString resulting from pango_shape() and the corresponding
@@ -222,7 +221,7 @@ pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs,
while (p < text + glyphs->log_clusters[glyph_index])
{
next_cluster++;
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
}
}
else
@@ -230,7 +229,7 @@ pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs,
while (p < text + length)
{
next_cluster++;
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
}
}
diff --git a/pango/gunicode.h b/pango/gunicode.h
deleted file mode 100644
index 6d089880..00000000
--- a/pango/gunicode.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Pango
- * gunicode.h:
- *
- * Copyright (C) 1999 Red Hat Software
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
diff --git a/pango/itemize.c b/pango/itemize.c
index ed877fc0..da8b0fbc 100644
--- a/pango/itemize.c
+++ b/pango/itemize.c
@@ -20,10 +20,8 @@
*/
#include <fribidi/fribidi.h>
-#include <unicode.h>
#include "pango.h"
#include "iconv.h"
-#include "utils.h"
#include "modules.h"
static void add_engines (PangoContext *context,
@@ -90,7 +88,7 @@ pango_itemize (PangoContext *context,
if (!text_ucs2)
return NULL;
- n_chars = unicode_strlen (text, length);
+ n_chars = g_utf8_strlen (text, length);
embedding_levels = g_new (guint8, n_chars);
/* Storing these as ranges would be a lot more efficient,
@@ -126,7 +124,7 @@ pango_itemize (PangoContext *context,
p = text;
for (i=0; i<n_chars; i++)
{
- next = unicode_next_utf8 (p);
+ next = g_utf8_next_char (p);
if (i == 0 ||
embedding_levels[i] != embedding_levels[i-1] ||
@@ -182,7 +180,7 @@ add_engines (PangoContext *context,
GUChar4 wc;
int i, j;
- n_chars = unicode_strlen (text, length);
+ n_chars = g_utf8_strlen (text, length);
pos = text;
last_lang = NULL;
@@ -211,7 +209,8 @@ add_engines (PangoContext *context,
last_lang = lang;
}
- pos = unicode_get_utf8 (pos, &wc);
+ wc = g_utf8_get_char (pos);
+ pos = g_utf8_next_char (pos);
if (!lang_engines[i])
{
diff --git a/pango/mapping.c b/pango/mapping.c
index 57a438d9..251cda64 100644
--- a/pango/mapping.c
+++ b/pango/mapping.c
@@ -29,7 +29,6 @@
*/
#include <pango/pango.h>
-#include <unicode.h>
/**
* pango_glyph_string_index_to_x:
@@ -143,7 +142,7 @@ pango_glyph_string_index_to_x (PangoGlyphString *glyphs,
if (p < text + index)
cluster_offset++;
cluster_chars++;
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
}
/* Now interpolate the result. For South Asian languages
@@ -265,7 +264,7 @@ pango_glyph_string_x_to_index (PangoGlyphString *glyphs,
p = text + start_index;
while (p < text + end_index)
{
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
cluster_chars++;
}
@@ -287,7 +286,7 @@ pango_glyph_string_x_to_index (PangoGlyphString *glyphs,
while (i + 1 <= cp)
{
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
i++;
}
diff --git a/pango/modules.c b/pango/modules.c
index 66a75c2c..fcd42813 100644
--- a/pango/modules.c
+++ b/pango/modules.c
@@ -29,7 +29,6 @@
#include "pango-modules.h"
#include "modules.h"
-#include "utils.h"
typedef struct _PangoMapInfo PangoMapInfo;
typedef struct _PangoEnginePair PangoEnginePair;
@@ -464,8 +463,8 @@ build_map (PangoMapInfo *info)
submap <= pair->info.ranges[i].end / 256;
submap ++)
{
- GUChar4 start;
- GUChar4 end;
+ gunichar start;
+ gunichar end;
if (submap == pair->info.ranges[i].start / 256)
start = pair->info.ranges[i].start % 256;
diff --git a/pango/pango-context.c b/pango/pango-context.c
index b967000b..11e1ecbc 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -21,10 +21,8 @@
#include <pango/pango-context.h>
#include <fribidi/fribidi.h>
-#include <unicode.h>
#include "iconv.h"
-#include "utils.h"
#include "pango-modules.h"
struct _PangoContext
@@ -511,7 +509,7 @@ pango_itemize (PangoContext *context,
int length,
PangoAttrList *attrs)
{
- GUChar4 *text_ucs4;
+ gunichar *text_ucs4;
int n_chars, i;
guint8 *embedding_levels;
FriBidiCharType base_dir;
@@ -543,11 +541,11 @@ pango_itemize (PangoContext *context,
/* First, apply the bidirectional algorithm to break
* the text into directional runs.
*/
- text_ucs4 = _pango_utf8_to_ucs4 (text, length);
+ text_ucs4 = g_utf8_to_ucs4 (text, length);
if (!text_ucs4)
return NULL;
- n_chars = unicode_strlen (text, length);
+ n_chars = g_utf8_strlen (text, length);
embedding_levels = g_new (guint8, n_chars);
fribidi_log2vis_get_embedding_levels (text_ucs4, n_chars, &base_dir,
@@ -577,7 +575,7 @@ pango_itemize (PangoContext *context,
p = text;
for (i=0; i<n_chars; i++)
{
- next = unicode_next_utf8 (p);
+ next = g_utf8_next_char (p);
if (i == 0 ||
text_ucs4[i] == '\t' || text_ucs4[i-1] == '\t' ||
@@ -637,8 +635,8 @@ pango_itemize (PangoContext *context,
static PangoFont *
get_font (PangoFont **fonts,
PangoCoverage **coverages,
- int n_families,
- GUChar4 wc)
+ int n_families,
+ gunichar wc)
{
PangoFont *result = NULL;
PangoCoverageLevel best_level = PANGO_COVERAGE_NONE;
@@ -693,10 +691,10 @@ add_engines (PangoContext *context,
PangoAttrIterator *iterator;
PangoAttribute *attr;
- GUChar4 wc;
+ gunichar wc;
int i, j;
- n_chars = unicode_strlen (text, length);
+ n_chars = g_utf8_strlen (text, length);
iterator = pango_attr_list_get_iterator (attrs);
@@ -775,7 +773,8 @@ add_engines (PangoContext *context,
pango_attr_iterator_next (iterator);
}
- pos = unicode_get_utf8 (pos, &wc);
+ wc = g_utf8_get_char (pos);
+ pos = g_utf8_next_char (pos);
lang_engines[i] = (PangoEngineLang *)pango_map_get_engine (lang_map, wc);
fonts[i] = get_font (current_fonts, current_coverages, n_families, wc);
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index c1b1e514..a876c069 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -22,7 +22,6 @@
#include <pango/pango-layout.h>
#include <pango/pango.h> /* For pango_shape() */
#include <string.h>
-#include <unicode.h>
#define LINE_IS_VALID(line) ((line)->layout != NULL)
@@ -431,18 +430,17 @@ pango_layout_set_text (PangoLayout *layout,
}
else
{
- unicode_char_t junk;
const char *p = text;
int n_chars = 0;
while (*p && (length < 0 || p < text + length))
{
- p = unicode_get_utf8 (p, &junk);
- if (!p)
+ if (g_utf8_get_char (p) == (gunichar)-1)
{
g_warning ("Invalid UTF8 string passed to pango_layout_set_text()");
return;
}
+ p = g_utf8_next_char (p);
n_chars++;
}
@@ -454,8 +452,7 @@ pango_layout_set_text (PangoLayout *layout,
length = p - text;
- /* NULL-terminate the text, since we currently use unicode_next_utf8()
- * in quite a few places, and for convenience.
+ /* NULL-terminate the text for convenience.
*/
layout->text = g_malloc (length + 1);
@@ -761,10 +758,10 @@ pango_layout_move_cursor_visually (PangoLayout *layout,
next_line = NULL;
if (old_trailing)
- old_index = unicode_next_utf8 (layout->text + old_index) - layout->text;
+ old_index = g_utf8_next_char (layout->text + old_index) - layout->text;
log2vis_map = pango_layout_line_get_log2vis_map (line, TRUE);
- n_vis = unicode_strlen (layout->text + bytes_seen, line->length);
+ n_vis = g_utf8_strlen (layout->text + bytes_seen, line->length);
vis_pos = log2vis_map[old_index - bytes_seen];
g_free (log2vis_map);
@@ -794,7 +791,7 @@ pango_layout_move_cursor_visually (PangoLayout *layout,
line = next_line;
}
- vis_pos = unicode_strlen (layout->text + bytes_seen, line->length);
+ vis_pos = g_utf8_strlen (layout->text + bytes_seen, line->length);
}
else if (vis_pos == n_vis && direction > 0)
{
@@ -830,9 +827,9 @@ pango_layout_move_cursor_visually (PangoLayout *layout,
*new_index = bytes_seen + vis2log_map[vis_pos];
g_free (vis2log_map);
- if (*new_index == bytes_seen + line->length)
+ if (*new_index == bytes_seen + line->length && line->length > 0)
{
- *new_index = unicode_previous_utf8 (layout->text, layout->text + *new_index) - layout->text;
+ *new_index = g_utf8_prev_char (layout->text + *new_index) - layout->text;
*new_trailing = 1;
}
else
@@ -1023,7 +1020,7 @@ pango_layout_line_get_vis2log_map (PangoLayoutLine *line,
int n_chars;
pango_layout_line_get_range (line, &start, &end);
- n_chars = unicode_strlen (start, end - start);
+ n_chars = g_utf8_strlen (start, end - start);
result = g_new (int, n_chars + 1);
@@ -1057,12 +1054,12 @@ pango_layout_line_get_vis2log_map (PangoLayoutLine *line,
(prev_dir == run_dir))
result[pos] = p - start;
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
for (i = 1; i < run_n_chars; i++)
{
result[pos + i] = p - start;
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
}
if ((strong && base_dir == run_dir) ||
@@ -1075,12 +1072,12 @@ pango_layout_line_get_vis2log_map (PangoLayoutLine *line,
(!strong && base_dir != run_dir))
result[pos + run_n_chars] = p - start;
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
for (i = 1; i < run_n_chars; i++)
{
result[pos + run_n_chars - i] = p - start;
- p = unicode_next_utf8 (p);
+ p = g_utf8_next_char (p);
}
if ((strong && base_dir == run_dir) ||
@@ -1108,7 +1105,7 @@ pango_layout_line_get_log2vis_map (PangoLayoutLine *line,
int n_chars;
pango_layout_line_get_range (line, &start, &end);
- n_chars = unicode_strlen (start, end - start);
+ n_chars = g_utf8_strlen (start, end - start);
result = g_new0 (int, end - start + 1);
reverse_map = pango_layout_line_get_vis2log_map (line, strong);
@@ -1220,7 +1217,7 @@ pango_layout_get_cursor_pos (PangoLayout *layout,
}
else
{
- gint prev_index = unicode_previous_utf8 (layout->text, layout->text + index) - layout->text;
+ gint prev_index = g_utf8_prev_char (layout->text + index) - layout->text;
dir1 = pango_layout_line_get_char_direction (layout_line, prev_index);
pango_layout_line_index_to_x (layout_line, prev_index, TRUE, &x1_trailing);
}
@@ -1565,7 +1562,7 @@ process_item (PangoLayoutLine *line,
{
PangoItem *new_item = pango_item_copy (item);
- length = unicode_offset_to_index (text + item->offset, num_chars);
+ length = g_utf8_offset_to_pointer (text + item->offset, num_chars) - (text + item->offset);
new_item->length = length;
new_item->num_chars = num_chars;
@@ -1679,7 +1676,7 @@ pango_layout_check_lines (PangoLayout *layout)
while (end != layout->text + layout->length && *end != '\n')
{
- end = unicode_next_utf8 (end);
+ end = g_utf8_next_char (end);
para_chars++;
}
@@ -1911,8 +1908,13 @@ pango_layout_line_x_to_index (PangoLayoutLine *line,
return;
}
- last_index = first_index + line->length;
- last_index = unicode_previous_utf8 (line->layout->text + first_index, line->layout->text + last_index) - line->layout->text;
+ if (line->length > 0)
+ {
+ last_index = first_index + line->length;
+ last_index = g_utf8_prev_char (line->layout->text + last_index) - line->layout->text;
+ }
+ else
+ last_index = first_index; /* FIXME - does this make sense at all? */
/* This is a HACK. If a program only keeps track if cursor (etc)
* indices and not the trailing flag, then the trailing index of the
@@ -2072,9 +2074,11 @@ pango_layout_line_get_x_ranges (PangoLayoutLine *line,
int run_end_index = MIN (end_index, run->item->offset + run->item->length);
int run_start_x, run_end_x;
+ g_assert (run_end_index > 0);
+
/* Back the end_index off one since we want to find the trailing edge of the preceding character */
- run_end_index = unicode_previous_utf8 (line->layout->text, line->layout->text + run_end_index) - line->layout->text;
+ run_end_index = g_utf8_prev_char (line->layout->text + run_end_index) - line->layout->text;
pango_glyph_string_index_to_x (run->glyphs,
line->layout->text + run->item->offset,
diff --git a/pango/pangox.c b/pango/pangox.c
index b2f3ca0d..c9388fef 100644
--- a/pango/pangox.c
+++ b/pango/pangox.c
@@ -24,12 +24,9 @@
#include <X11/Xlib.h>
#include <fribidi/fribidi.h>
-#include <unicode.h>
#include "pangox.h"
#include "pangox-private.h"
-#include "utils.h"
-
#include <config.h>
#define PANGO_TYPE_X_FONT (pango_x_font_get_type ())
@@ -487,15 +484,15 @@ get_font_metrics_from_string (PangoFont *font,
PangoGlyphString *glyph_str = pango_glyph_string_new ();
PangoEngineShape *shaper, *last_shaper;
int last_level;
- GUChar4 *text_ucs4;
+ gunichar *text_ucs4;
int n_chars, i;
guint8 *embedding_levels;
FriBidiCharType base_dir = PANGO_DIRECTION_LTR;
GSList *subfonts = NULL;
- n_chars = unicode_strlen (str, -1);
+ n_chars = g_utf8_strlen (str, -1);
- text_ucs4 = _pango_utf8_to_ucs4 (str, strlen (str));
+ text_ucs4 = g_utf8_to_ucs4 (str, strlen (str));
if (!text_ucs4)
return;
@@ -511,9 +508,9 @@ get_font_metrics_from_string (PangoFont *font,
p = start = str;
while (*p)
{
- unicode_char_t wc;
- p = unicode_get_utf8 (p, &wc);
-
+ gunichar wc = g_utf8_get_char (p);
+ p = g_utf8_next_char (p);
+
shaper = pango_font_find_shaper (font, lang, wc);
if (p > start &&
(shaper != last_shaper || last_level != embedding_levels[i]))
diff --git a/pango/shape.c b/pango/shape.c
index 7209d97a..c7ec405c 100644
--- a/pango/shape.c
+++ b/pango/shape.c
@@ -20,7 +20,6 @@
*/
#include <pango/pango.h>
-#include "utils.h"
/**
* pango_shape:
diff --git a/pango/utils.c b/pango/utils.c
deleted file mode 100644
index 6f7ff8ca..00000000
--- a/pango/utils.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/* Pango
- * utils.c:
- *
- * Copyright (C) 1999 Red Hat Software
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "utils.h"
-#include <iconv.h>
-#include <errno.h>
-#include <unicode.h>
-
-gboolean
-_pango_utf8_iterate (const char *cur, const char **next, GUChar4 *wc_out)
-{
- const guchar *p = (guchar *)cur;
- guchar c = *p;
- GUChar4 wc;
- gint length;
-
- if ((c & 0x80) == 0)
- {
- length = 1;
- wc = c;
- }
- else if ((c & 0xc0) == 0x80)
- {
- return FALSE;
- }
- else if ((c & 0xe0) == 0xc0)
- {
- length = 2;
- wc = c & 0x1f;
- }
- else if ((c & 0xf0) == 0xe0)
- {
- length = 3;
- wc = c & 0x0f;
- }
- else
- return FALSE;
-
- p++;
- while (--length > 0)
- {
- if (*p == 0) /* Incomplete character */
- {
- if (next)
- *next = cur;
- if (wc_out)
- *wc_out = 0;
- return TRUE;
- }
-
- if ((*p & 0xc0) != 0x80)
- return FALSE;
-
- wc <<= 6;
- wc |= (*p) & 0x3f;
-
- p++;
- }
-
- if (wc_out)
- *wc_out = wc;
- if (next)
- *next = (const char *)p;
-
- return TRUE;
-}
-
-int
-_pango_utf8_len (const char *str, int limit)
-{
- const char *cur = str;
- const char *next;
- int len = 0;
-
- while (*cur)
- {
- if (!_pango_utf8_iterate (cur, &next, NULL))
- return -1;
- if (cur == next)
- break;
- if (limit >= 0 && (next - str) > limit)
- return len;
- cur = next;
- len++;
- }
-
- return len;
-}
-
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define UCS2_CHARSET "UNICODELITTLE"
-#else
-#define UCS2_CHARSET "UNICODE"
-#endif
-
-GUChar2 *
-_pango_utf8_to_ucs2 (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 (UCS2_CHARSET, "UTF-8");
-
- if (cd == (iconv_t)-1)
- g_error ("No converter from UTF-8 to " UCS2_CHARSET);
-
- if (len < 0)
- len = strlen (str);
-
- outlen = unicode_strlen (str, len) * sizeof(GUChar2);
- 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 (GUChar2 *)result;
-
-}
-
-GUChar4 *
-_pango_utf8_to_ucs4 (const char *str, int len)
-{
- GUChar4 *result;
- int n_chars, i;
- const char *p;
-
- n_chars = unicode_strlen (str, len);
- result = g_new (GUChar4, n_chars);
-
- p = str;
- for (i=0; i < n_chars; i++)
- p = unicode_get_utf8 (p, &result[i]);
-
- return result;
-}
-
-/**
- * _pango_guchar4_to_utf8:
- * @ch: a ISO10646 character code
- * @out: output buffer, must have at least 6 bytes of space.
- *
- * Convert a single character to utf8
- *
- * Return value: number of bytes written
- **/
-int
-_pango_guchar4_to_utf8 (GUChar4 c, char *outbuf)
-{
- size_t len = 0;
- int first;
- int i;
-
- if (c < 0x80)
- {
- first = 0;
- len = 1;
- }
- else if (c < 0x800)
- {
- first = 0xc0;
- len = 2;
- }
- else if (c < 0x10000)
- {
- first = 0xe0;
- len = 3;
- }
- else if (c < 0x200000)
- {
- first = 0xf0;
- len = 4;
- }
- else if (c < 0x4000000)
- {
- first = 0xf8;
- len = 5;
- }
- else
- {
- first = 0xfc;
- len = 6;
- }
-
- for (i = len - 1; i > 0; --i)
- {
- outbuf[i] = (c & 0x3f) | 0x80;
- c >>= 6;
- }
- outbuf[0] = c | first;
-
- return len;
-}
diff --git a/pango/utils.h b/pango/utils.h
deleted file mode 100644
index 9cf40dbb..00000000
--- a/pango/utils.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Pango
- * utils.h:
- *
- * Copyright (C) 1999 Red Hat Software
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __UTILS_H__
-#define __UTILS_H__
-
-#include <glib.h>
-
-typedef guint16 GUChar2;
-typedef guint32 GUChar4;
-
-gboolean _pango_utf8_iterate (const char *cur,
- const char **next,
- 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,
- gint limit);
-
-#endif /* __UTILS_H__ */