summaryrefslogtreecommitdiff
path: root/pango/pangox.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2003-08-02 18:18:30 +0000
committerOwen Taylor <otaylor@src.gnome.org>2003-08-02 18:18:30 +0000
commit61b8f962174f41685a12d850632da094a4dd1bc6 (patch)
tree67faa7cce4cbeb289defc9fed024b7616baa5a26 /pango/pangox.c
parent85cb529088899889a65a99d3a00f6035eecb4c98 (diff)
downloadpango-61b8f962174f41685a12d850632da094a4dd1bc6.tar.gz
Remove.
Sat Aug 2 14:10:31 2003 Owen Taylor <otaylor@redhat.com> * pango/Makefile.am pango/pango-intset.[ch] pango/pango-indic.[ch]: Remove. * pango/pangox.c (pango_x_apply_ligatures): Make a noop, remove associated code. * pango/pangox-fontmap.c pango/pangox.[ch]: Deprecate everything.
Diffstat (limited to 'pango/pangox.c')
-rw-r--r--pango/pangox.c473
1 files changed, 14 insertions, 459 deletions
diff --git a/pango/pangox.c b/pango/pangox.c
index e3036d5b..91c3c75e 100644
--- a/pango/pangox.c
+++ b/pango/pangox.c
@@ -24,15 +24,15 @@
#include <math.h>
#include <X11/Xlib.h>
-#include "pangox.h"
#include "pango-utils.h"
-#include "pangox-private.h"
-#include "pango-intset.h"
#include "modules.h"
-#define PANGO_X_UNKNOWN_FLAG 0x10000000
+#undef PANGO_DISABLE_DEPRECATED
-#define PANGO_LIGATURE_HACK_DEBUG
+#include "pangox.h"
+#include "pangox-private.h"
+
+#define PANGO_X_UNKNOWN_FLAG 0x10000000
#include "config.h"
@@ -46,97 +46,6 @@
typedef struct _PangoXFontClass PangoXFontClass;
typedef struct _PangoXMetricsInfo PangoXMetricsInfo;
typedef struct _PangoXContextInfo PangoXContextInfo;
-typedef struct _PangoXLigatureInfo PangoXLigatureInfo;
-typedef struct _PangoXLigatureSource PangoXLigatureSource;
-
-#ifndef HAVE_STRTOK_R
-/* This implementation of strtok_r comes from the GNU C library.
- * Copyright (C) 1991, 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
- */
-static char *
-my_strtok_r (char *s,
- const char *delim,
- char **save_ptr)
-{
- char *token;
-
- if (s == NULL)
- s = *save_ptr;
-
- /* Scan leading delimiters. */
- s += strspn (s, delim);
- if (*s == '\0')
- {
- *save_ptr = s;
- return NULL;
- }
-
- /* Find the end of the token. */
- token = s;
- s = strpbrk (token, delim);
- if (s == NULL)
- /* This token finishes the string. */
- *save_ptr = token + strlen (token);
- else
- {
- /* Terminate the token and make *SAVE_PTR point past it. */
- *s = '\0';
- *save_ptr = s + 1;
- }
- return token;
-}
-#else
-#define my_strtok_r strtok_r
-#endif /* HAVE_STRTOK_R */
-
-static int
-hex_to_integer (const char *s)
-{
- int a;
- char *end_ptr;
-
- if (!*s)
- return (gunichar)-1;
-
- a = strtol (s, &end_ptr, 16);
- if (*end_ptr)
- return (gunichar)-1; /* Invalid characters in string */
-
- if (a <= 0 || a >= 0xffff)
- return (gunichar)-1; /* Character out of range */
-
- return a;
-}
-
-static PangoIntSet *
-parse_gintset_spec (char *s)
-{
- char *m = NULL;
- PangoIntSet *set = pango_int_set_new ();
- s = my_strtok_r (s, ",", &m);
- while (s)
- {
- char *p = strchr (s, '-');
- if (!p)
- {
- int i = hex_to_integer (s);
- if (i != -1)
- pango_int_set_add (set, i);
- }
- else
- {
- int start, end;
- *p = 0;
- p++;
- start = hex_to_integer (s);
- end = hex_to_integer (p);
- if (start != -1 && end != -1)
- pango_int_set_add_range (set, start, end);
- }
- s = my_strtok_r (NULL, ",", &m);
- }
- return set;
-}
struct _PangoXSubfontInfo
{
@@ -145,12 +54,6 @@ struct _PangoXSubfontInfo
gboolean is_1byte;
int range_byte1;
int range_byte2;
-
- /* hash table mapping setnames to PangoIntSets */
- GHashTable *ligature_sets;
-
- PangoXLigatureInfo *ligs;
- int n_ligs;
};
struct _PangoXMetricsInfo
@@ -170,24 +73,6 @@ struct _PangoXFontClass
PangoFontClass parent_class;
};
-struct _PangoXLigatureSource
-{
- gboolean is_set;
- union {
- PangoIntSet *set;
- gunichar glyph;
- } data;
-};
-
-struct _PangoXLigatureInfo
-{
- int n_source;
- PangoXLigatureSource *source;
-
- gunichar *dest;
- int n_dest;
-};
-
static PangoFontClass *parent_class; /* Parent class structure for PangoXFont */
static void pango_x_font_class_init (PangoXFontClass *class);
@@ -227,11 +112,6 @@ static void pango_x_get_item_properties (PangoItem *item,
PangoAttrColor *bg_color,
gboolean *bg_set);
-static void font_struct_get_ligatures (PangoFontMap *map,
- Display *display,
- XFontStruct *fs,
- PangoXSubfontInfo *info);
-
static inline PangoXSubfontInfo *
pango_x_find_subfont (PangoFont *font,
PangoXSubfont subfont_index)
@@ -267,7 +147,6 @@ pango_x_make_font_struct (PangoFont *font, PangoXSubfontInfo *info)
info->is_1byte = (info->font_struct->min_byte1 == 0 && info->font_struct->max_byte1 == 0);
info->range_byte1 = info->font_struct->max_byte1 - info->font_struct->min_byte1 + 1;
info->range_byte2 = info->font_struct->max_char_or_byte2 - info->font_struct->min_char_or_byte2 + 1;
- font_struct_get_ligatures (xfont->fontmap, xfont->display, info->font_struct, info);
}
static inline XFontStruct *
@@ -1142,9 +1021,6 @@ pango_x_insert_subfont (PangoFont *font, const char *xlfd)
info->xlfd = g_strdup (xlfd);
info->font_struct = NULL;
- info->n_ligs = 0;
- info->ligs = 0;
- info->ligature_sets = 0;
xfont->n_subfonts++;
@@ -1348,13 +1224,6 @@ subfonts_foreach (gpointer key, gpointer value, gpointer data)
}
static void
-free_sets_foreach (gpointer key, gpointer value, gpointer data)
-{
- g_free (key);
- pango_int_set_destroy (value);
-}
-
-static void
free_metrics_info (PangoXMetricsInfo *info)
{
pango_font_metrics_unref (info->metrics);
@@ -1367,7 +1236,7 @@ pango_x_font_finalize (GObject *object)
PangoXFont *xfont = (PangoXFont *)object;
PangoXFontCache *cache = pango_x_font_map_get_font_cache (xfont->fontmap);
- int i, j;
+ int i;
for (i=0; i<xfont->n_subfonts; i++)
{
@@ -1378,20 +1247,6 @@ pango_x_font_finalize (GObject *object)
if (info->font_struct)
pango_x_font_cache_unload (cache, info->font_struct);
- if (info->ligs)
- {
-
- for (j=0; j<info->n_ligs;j++)
- {
- g_free (info->ligs[j].source);
- }
-
- g_free (info->ligs);
-
- g_hash_table_foreach (info->ligature_sets, free_sets_foreach, NULL);
- g_hash_table_destroy (info->ligature_sets);
- }
-
g_free (info);
}
@@ -1759,243 +1614,17 @@ pango_x_get_item_properties (PangoItem *item,
}
}
-static void
-font_struct_get_ligatures (PangoFontMap *fontmap,
- Display *display,
- XFontStruct *fs,
- PangoXSubfontInfo *info)
-{
- int i;
-
- PangoXLigatureInfo *linfo = 0;
- int n_linfo = 0;
-
- GList *list = g_list_append (NULL, g_strdup ("PANGO_LIGATURE_HACK"));
- GList *list_start = list;
-
- info->ligature_sets = g_hash_table_new (g_str_hash, g_str_equal);
-
- while (list)
- {
- Atom this_atom = pango_x_fontmap_atom_from_name (fontmap, (char *)list->data);
- for (i = 0; i < fs->n_properties; i++)
- {
- if (fs->properties[i].name == this_atom)
- {
- char *val = g_strdup (pango_x_fontmap_name_from_atom (fontmap, fs->properties[i].card32));
- char *p;
- char *a = my_strtok_r (val, " ", &p);
- while (a)
- {
- char *r;
- char *m;
- char *q;
- PangoXLigatureSource *source = NULL;
- gunichar *dest = NULL;
- int n_source = 0;
- int n_dest = 0;
- PangoXLigatureInfo *xli;
-
- switch (*a)
- {
-
- case '$':
- /* class being defined */
- {
- char *name = a + 1;
- char *data = strchr (a, '=');
- PangoIntSet *set;
- if (!data)
- {
-#ifdef PANGO_LIGATURE_HACK_DEBUG
- g_warning ("Error parsing ligature info: Isolated $.\n");
-#endif
- break;
- }
-
- *data = 0;
- data++;
- set = parse_gintset_spec (data);
- if (!set)
- {
-#ifdef PANGO_LIGATURE_HACK_DEBUG
- g_warning ("Error parsing ligature info: Invalid glyphset.\n");
-#endif
- break;
- }
- g_hash_table_insert (info->ligature_sets,
- g_strdup (name), set);
- break;
- }
-
- case ':':
- /* a pointer */
- {
- char *lang = a+1;
- char *name = strchr (lang, ':');
- if (name)
- {
- name++;
- list = g_list_append (list, g_strdup (name));
- }
- else
- {
-#ifdef PANGO_LIGATURE_HACK_DEBUG
- g_warning ("Error parsing ligature info: Bad pointer.\n");
-#endif
- }
- break;
- }
-
- default:
- /* a literal */
- {
- n_linfo++;
- linfo = g_realloc (linfo, sizeof (PangoXLigatureInfo) *
- n_linfo);
- r = strchr (a, '=');
- if (!r)
- {
-#ifdef PANGO_LIGATURE_HACK_DEBUG
- g_warning ("Error parsing ligature info: No equals.\n");
-#endif
- n_linfo--;
- break;
- }
- *r = 0;
- r++;
- q = a;
- q = my_strtok_r (q, "+", &m);
- while (q)
- {
- n_source ++;
- source = g_realloc (source, n_source *
- sizeof (PangoXLigatureSource));
- if (q[0] == '%')
- {
- source[n_source-1].is_set = 1;
- source[n_source-1].data.set =
- g_hash_table_lookup (info->ligature_sets,
- q+1);
- if (!source[n_source-1].data.set)
- {
-#ifdef PANGO_LIGATURE_HACK_DEBUG
- g_warning ("Error parsing ligature info: Unable to locate glyphset : %s\n", q+1);
-#endif
- source [n_source-1].is_set = 0;
- source [n_source-1].data.glyph = 0;
- }
- }
- else
- {
- int i = hex_to_integer (q);
- if (i == -1)
- {
-#ifdef PANGO_LIGATURE_HACK_DEBUG
- g_warning ("Error parsing ligature info: Bad character value : %s. Assuming 0\n", q);
-#endif
- i = 0;
- }
- source [n_source-1].is_set = 0;
- source [n_source-1].data.glyph = i;
- }
- q = my_strtok_r (NULL, "+", &m);
- }
- q = r;
- q = my_strtok_r (q, "+", &m);
- while (q)
- {
- n_dest++;
- dest = g_realloc (dest, n_dest * sizeof (gunichar));
-
- if (q[0] == '%')
- {
- char *er;
- dest[n_dest-1] = -strtol (q+1, &er, 10);
- if (*er)
- {
-#ifdef PANGO_LIGATURE_HACK_DEBUG
- g_warning ("Error parsing ligature info: Bad %% reference. Assuming 1");
-#endif
- dest[n_dest-1] = -1;
- }
- }
- else
- {
- int i = hex_to_integer (q);
- if (i != -1)
- {
- dest[n_dest-1] = i;
- }
- else
- {
- dest[n_dest-1] = 0;
- }
- }
-
- q = my_strtok_r (NULL, "+", &m);
- }
-
- xli = linfo + n_linfo - 1;
-
- xli->source = source;
- xli->n_source = n_source;
- xli->dest = dest;
- xli->n_dest = n_dest;
-
- if (xli->n_dest > xli->n_source)
- {
- g_warning ("Error parsing ligature info: Warning : truncating substitute string.");
- xli->n_dest = n_source;
- }
- }
- }
-
- /* end switch */
- a = my_strtok_r (NULL, " ", &p);
- }
- g_free (val);
- }
- }
- list = g_list_next (list);
- }
-
- list = list_start;
-
- while (list)
- {
- g_free (list->data);
- list = g_list_next (list);
- }
-
- g_list_free (list_start);
-
- info->n_ligs = n_linfo;
- info->ligs = linfo;
-}
-
/**
* pango_x_apply_ligatures:
- * @font: a #PangoFont.
- * @subfont: a #PangoXSubFont.
- * @glyphs: a pointer to a pointer to an array of
- * glyph indices. This holds the input glyphs
- * on entry, and ligation will be performed
- * on this array in-place. If the number
- * of glyphs is increased, Pango will
- * call g_realloc() on @glyphs, so @chars
- * must be allocated with g_malloc().
- * @n_glyphs: a pointer to the number of glyphs
- * *@n_glyphs is the number of original glyphs
- * on entry and the number of resulting glyphs
- * upon return.
- * @clusters: a pointer to the cluster information.
+ * @font: unused
+ * @subfont: unused
+ * @glyphs: unused
+ * @n_glyphs: unused
+ * @clusters: unused
*
- * Does subfont-specific ligation. This involves replacing
- * groups of glyphs in @chars with alternate groups of glyphs
- * based on information provided in the X font.
+ * Previously did subfont-specific ligation. Now a no-op.
*
- * Return value: %TRUE if any ligations were performed.
+ * Return value: %FALSE, always.
*/
gboolean
pango_x_apply_ligatures (PangoFont *font,
@@ -2004,81 +1633,7 @@ pango_x_apply_ligatures (PangoFont *font,
int *n_glyphs,
int **clusters)
{
- int hits = 0;
- int i, j, k;
- PangoXSubfontInfo *subfont;
- PangoXLigatureInfo *linfo;
- int n_linfo = 0;
- XFontStruct *fs;
-
- g_return_val_if_fail (font != NULL, 0);
-
- subfont = pango_x_find_subfont (font, subfont_id);
- if (!subfont)
- return 0;
-
- fs = pango_x_get_font_struct (font, subfont);
- if (!fs)
- return 0;
-
- linfo = subfont->ligs;
- n_linfo = subfont->n_ligs;
-
- for (i = 0; i < *n_glyphs; i++)
- for (j= 0; j < n_linfo; j++)
- {
- PangoXLigatureInfo *li = &linfo[j];
- gunichar *temp;
-
- if (i + li->n_source > *n_glyphs)
- continue;
-
- for (k = 0; k < li->n_source; k++)
- {
- if ((li->source[k].is_set &&
- !pango_int_set_contains (li->source[k].data.set,
- (*glyphs)[i + k]))
- || (!li->source[k].is_set &&
- (*glyphs)[i + k] != li->source[k].data.glyph))
- goto next_pattern;
- }
-
-
- {
- gunichar buffer[16];
- if (li->n_source < G_N_ELEMENTS (buffer))
- {
- memcpy (buffer, &(*glyphs)[i], li->n_source * sizeof (gunichar));
- temp = buffer;
- }
- else
- {
- temp = g_memdup (&(*glyphs)[i], li->n_source * sizeof (gunichar));
- }
-
- for (k = 0; k < li->n_dest; k++)
- {
- int f = li->dest[k];
- if (f < 0)
- f = temp[i - (1+f)];
-
- (*glyphs) [i + k - (li->n_dest - li->n_source)] = f;
- }
-
- for (k = 0; k < li->n_source-li->n_dest; k++)
- (*glyphs) [i+k] = 0;
-
- hits++;
- i += li->n_source - 1;
-
- if (temp != buffer)
- g_free (temp);
- }
-
- next_pattern: ;
- }
-
- return hits >= 1;
+ return FALSE;
}
/**