summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <pango@behdad.org>2005-07-23 19:24:48 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2005-07-23 19:24:48 +0000
commitd5142f02455703ea61bd11f308ef844e9b20ebbd (patch)
treeeee87660e4825754892fd64e65499bfc138aa78b
parent1470d761b0faf8de46ff38163272a9a6af6c5e64 (diff)
downloadpango-d5142f02455703ea61bd11f308ef844e9b20ebbd.tar.gz
New function added.
2005-07-23 Behdad Esfahbod <pango@behdad.org> * pango/pango-utils.c, pango/pango-utils.h (pango_is_zerowidth): New function added. * modules/basic/basic-common.h, modules/basic/basic-fc.c, modules/basic/basic-win32.c, modules/basic/basic-x.c, modules/hangul/hangul-fc.c, modules/arabic/arabic-fc.c, modules/indic/indic-fc.c, modules/indic/indic-ot.h, modules/syriac/syriac-fc.c: Use the new pango_is_zerowidth function. (#306639, Behnam Esfahbod)
-rw-r--r--ChangeLog12
-rw-r--r--ChangeLog.pre-1-1012
-rw-r--r--modules/arabic/arabic-fc.c2
-rw-r--r--modules/basic/basic-common.h18
-rw-r--r--modules/basic/basic-fc.c2
-rw-r--r--modules/basic/basic-win32.c2
-rw-r--r--modules/basic/basic-x.c2
-rw-r--r--modules/hangul/hangul-fc.c6
-rw-r--r--modules/indic/indic-fc.c2
-rw-r--r--modules/indic/indic-ot.h20
-rw-r--r--modules/syriac/syriac-fc.c2
-rw-r--r--pango/pango-utils.c34
-rw-r--r--pango/pango-utils.h8
13 files changed, 71 insertions, 51 deletions
diff --git a/ChangeLog b/ChangeLog
index b42b3daf..d0e16f06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-07-23 Behdad Esfahbod <pango@behdad.org>
+
+ * pango/pango-utils.c, pango/pango-utils.h (pango_is_zerowidth): New
+ function added.
+
+ * modules/basic/basic-common.h, modules/basic/basic-fc.c,
+ modules/basic/basic-win32.c, modules/basic/basic-x.c,
+ modules/hangul/hangul-fc.c, modules/arabic/arabic-fc.c,
+ modules/indic/indic-fc.c, modules/indic/indic-ot.h,
+ modules/syriac/syriac-fc.c: Use the new pango_is_zerowidth function.
+ (#306639, Behnam Esfahbod)
+
2005-07-22 Owen Taylor <otaylor@redhat.com>
* pango/pangofc-fontmap.c (get_context_matrix): Handle context == NULL.
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index b42b3daf..d0e16f06 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,15 @@
+2005-07-23 Behdad Esfahbod <pango@behdad.org>
+
+ * pango/pango-utils.c, pango/pango-utils.h (pango_is_zerowidth): New
+ function added.
+
+ * modules/basic/basic-common.h, modules/basic/basic-fc.c,
+ modules/basic/basic-win32.c, modules/basic/basic-x.c,
+ modules/hangul/hangul-fc.c, modules/arabic/arabic-fc.c,
+ modules/indic/indic-fc.c, modules/indic/indic-ot.h,
+ modules/syriac/syriac-fc.c: Use the new pango_is_zerowidth function.
+ (#306639, Behnam Esfahbod)
+
2005-07-22 Owen Taylor <otaylor@redhat.com>
* pango/pangofc-fontmap.c (get_context_matrix): Handle context == NULL.
diff --git a/modules/arabic/arabic-fc.c b/modules/arabic/arabic-fc.c
index 04ea2418..657eaf2a 100644
--- a/modules/arabic/arabic-fc.c
+++ b/modules/arabic/arabic-fc.c
@@ -197,7 +197,7 @@ fallback_shape (PangoEngineShape *engine,
input = buf;
}
- if (wc >= 0x200B && wc <= 0x200F) /* Zero-width characters */
+ if (pango_is_zero_width (wc))
{
set_glyph (font, glyphs, i, p - text, 0);
}
diff --git a/modules/basic/basic-common.h b/modules/basic/basic-common.h
index 3c140ad9..a3c0d16e 100644
--- a/modules/basic/basic-common.h
+++ b/modules/basic/basic-common.h
@@ -24,24 +24,6 @@
G_BEGIN_DECLS
-/* Zero Width characters:
- *
- * 200B ZERO WIDTH SPACE
- * 200C ZERO WIDTH NON-JOINER
- * 200D ZERO WIDTH JOINER
- * 200E LEFT-TO-RIGHT MARK
- * 200F RIGHT-TO-LEFT MARK
- * 2028 LINE SEPARATOR
- * 202A LEFT-TO-RIGHT EMBEDDING
- * 202B RIGHT-TO-LEFT EMBEDDING
- * 202C POP DIRECTIONAL FORMATTING
- * 202D LEFT-TO-RIGHT OVERRIDE
- * 202E RIGHT-TO-LEFT OVERRIDE
- * FEFF ZERO WIDTH NO-BREAK SPACE
- */
-
-#define ZERO_WIDTH_CHAR(wc)\
-(((wc) >= 0x200B && (wc) <= 0x200F) || (wc == 0x2028) || ((wc) >= 0x202A && (wc) <= 0x202E) || ((wc) == 0xFEFF))
G_END_DECLS
diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c
index 6fb28ecf..6d80d938 100644
--- a/modules/basic/basic-fc.c
+++ b/modules/basic/basic-fc.c
@@ -157,7 +157,7 @@ basic_engine_shape (PangoEngineShape *engine,
if (wc == 0xa0) /* non-break-space */
wc = 0x20;
- if (ZERO_WIDTH_CHAR (wc))
+ if (pango_is_zero_width (wc))
{
set_glyph (font, glyphs, i, p - text, 0);
}
diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c
index 2ffc090b..9e068409 100644
--- a/modules/basic/basic-win32.c
+++ b/modules/basic/basic-win32.c
@@ -1003,7 +1003,7 @@ basic_engine_shape (PangoEngineShape *engine,
if (wc == 0xa0) /* non-break-space */
wc = 0x20;
- if (ZERO_WIDTH_CHAR (wc))
+ if (pango_is_zero_width (wc))
{
set_glyph (font, glyphs, i, p - text, 0);
}
diff --git a/modules/basic/basic-x.c b/modules/basic/basic-x.c
index d0ba9c48..22dbb671 100644
--- a/modules/basic/basic-x.c
+++ b/modules/basic/basic-x.c
@@ -607,7 +607,7 @@ basic_engine_shape (PangoEngineShape *engine,
input = buf;
}
- if (ZERO_WIDTH_CHAR (wc))
+ if (pango_is_zero_width (wc))
{
set_glyph (font, glyphs, i, p - text, 0);
}
diff --git a/modules/hangul/hangul-fc.c b/modules/hangul/hangul-fc.c
index 75dfa7c9..ad7a239a 100644
--- a/modules/hangul/hangul-fc.c
+++ b/modules/hangul/hangul-fc.c
@@ -275,10 +275,6 @@ render_syllable (PangoFont *font, gunichar *text, int length,
render_tone(font, tone, glyphs, n_glyphs, cluster_offset);
}
-/* stolen from basic module */
-#define ZERO_WIDTH_CHAR(wc)\
-(((wc) >= 0x200B && (wc) <= 0x200F) || ((wc) >= 0x202A && (wc) <= 0x202E) || ((wc) == 0xFEFF))
-
static void
render_basic (PangoFont *font, gunichar wc,
PangoGlyphString *glyphs, int *n_glyphs, int cluster_offset)
@@ -294,7 +290,7 @@ render_basic (PangoFont *font, gunichar wc,
set_glyph (font, glyphs, *n_glyphs, cluster_offset, index);
else
{
- if (ZERO_WIDTH_CHAR (wc))
+ if (pango_is_zero_width (wc))
set_glyph (font, glyphs, *n_glyphs, cluster_offset, 0);
else
set_glyph (font, glyphs, *n_glyphs, cluster_offset,
diff --git a/modules/indic/indic-fc.c b/modules/indic/indic-fc.c
index c795a210..b1a8ba6e 100644
--- a/modules/indic/indic-fc.c
+++ b/modules/indic/indic-fc.c
@@ -260,7 +260,7 @@ set_glyphs (PangoFont *font, FT_Face face, const gunichar *wcs, gulong *tags, gl
{
guint glyph;
- if (ZERO_WIDTH_CHAR (wcs[i]) &&
+ if (pango_is_zero_width (wcs[i]) &&
(!process_zwj || wcs[i] != 0x200D))
glyph = 0;
else
diff --git a/modules/indic/indic-ot.h b/modules/indic/indic-ot.h
index 7d92b0c6..dd34144f 100644
--- a/modules/indic/indic-ot.h
+++ b/modules/indic/indic-ot.h
@@ -205,26 +205,6 @@ enum indic_glyph_property_
#define HAS_BELOW_BASE_FORM(charClass) ((charClass & CF_BELOW_BASE) != 0)
-/* This macro definition is shared with basic-common.h
- *
- * Zero Width characters:
- *
- * 200B ZERO WIDTH SPACE
- * 200C ZERO WIDTH NON-JOINER
- * 200D ZERO WIDTH JOINER
- * 200E LEFT-TO-RIGHT MARK
- * 200F RIGHT-TO-LEFT MARK
- * 2028 LINE SEPARATOR
- * 202A LEFT-TO-RIGHT EMBEDDING
- * 202B RIGHT-TO-LEFT EMBEDDING
- * 202C POP DIRECTIONAL FORMATTING
- * 202D LEFT-TO-RIGHT OVERRIDE
- * 202E RIGHT-TO-LEFT OVERRIDE
- * FEFF ZERO WIDTH NO-BREAK SPACE
- */
-#define ZERO_WIDTH_CHAR(wc) \
- (((wc) >= 0x200B && (wc) <= 0x200F) || (wc == 0x2028) || ((wc) >= 0x202A && (wc) <= 0x202E) || ((wc) == 0xFEFF))
-
struct _IndicOTClassTable
{
gunichar firstChar;
diff --git a/modules/syriac/syriac-fc.c b/modules/syriac/syriac-fc.c
index 4a78ab3d..8f054c55 100644
--- a/modules/syriac/syriac-fc.c
+++ b/modules/syriac/syriac-fc.c
@@ -196,7 +196,7 @@ fallback_shape (PangoEngineShape *engine,
pango_get_mirror_char (wc, &mirrored_ch))
wc = mirrored_ch;
- if (wc >= 0x200B && wc <= 0x200F) /* Zero-width characters */
+ if (pango_is_zero_width (wc))
{
set_glyph (font, glyphs, i, p - text, 0);
}
diff --git a/pango/pango-utils.c b/pango/pango-utils.c
index b8a367e8..18ef8924 100644
--- a/pango/pango-utils.c
+++ b/pango/pango-utils.c
@@ -1714,3 +1714,37 @@ pango_find_base_dir (const gchar *text,
return dir;
}
+
+/**
+ * pango_is_zero_width:
+ * @ch: a unicode character
+ *
+ * Checks @ch to see if it is a zero-width character that should not be
+ * normally rendered on the screen.
+ *
+ * Return value: %TRUE if @ch is a zero-width character, %FALSE otherwise
+ */
+gboolean
+pango_is_zero_width (gunichar ch)
+{
+/* Zero Width characters:
+ *
+ * 200B ZERO WIDTH SPACE
+ * 200C ZERO WIDTH NON-JOINER
+ * 200D ZERO WIDTH JOINER
+ * 200E LEFT-TO-RIGHT MARK
+ * 200F RIGHT-TO-LEFT MARK
+ * 2028 LINE SEPARATOR
+ * 202A LEFT-TO-RIGHT EMBEDDING
+ * 202B RIGHT-TO-LEFT EMBEDDING
+ * 202C POP DIRECTIONAL FORMATTING
+ * 202D LEFT-TO-RIGHT OVERRIDE
+ * 202E RIGHT-TO-LEFT OVERRIDE
+ * FEFF ZERO WIDTH NO-BREAK SPACE
+ */
+ return (ch & ~(gunichar)0x003F == 0x2000 && (
+ (ch >= 0x200B && ch <= 0x200F) ||
+ ch == 0x2028 ||
+ (ch >= 0x202A && ch <= 0x202E)
+ )) || ch == 0xFEFF;
+}
diff --git a/pango/pango-utils.h b/pango/pango-utils.h
index 20b828e4..4db1a23b 100644
--- a/pango/pango-utils.h
+++ b/pango/pango-utils.h
@@ -86,8 +86,7 @@ G_CONST_RETURN char * pango_get_lib_subdirectory (void);
#endif /* PANGO_ENABLE_BACKEND */
-/* A couple of routines from fribidi that we either wrap or
- * provide ourselves.
+/* A routine from fribidi that we either wrap or provide ourselves.
*/
gboolean pango_log2vis_get_embedding_levels (gunichar *str,
int len,
@@ -96,6 +95,11 @@ gboolean pango_log2vis_get_embedding_levels (gunichar *str,
G_CONST_RETURN char *pango_language_get_sample_string (PangoLanguage *language);
+/* Unicode characters that are zero-width and should not be rendered
+ * normally.
+ */
+G_GNUC_CONST gboolean pango_is_zero_width (gunichar ch);
+
G_END_DECLS
#endif /* __PANGO_UTILS_H__ */