Commit 29a746c9 authored by Nalin Dahyabhai's avatar Nalin Dahyabhai

include <glib.h> for gboolean type definition. include "config.h" and

* src/debug.h: include <glib.h> for gboolean type definition.
* src/matcher.c: include "config.h" and "debug.h".
* src/matcher.h: use G_BEGIN_DECLS/G_END_DECLS
* src/table.h: use G_BEGIN_DECLS/G_END_DECLS
* src/termcap.h: include <glib.h>, again for gboolean.
* src/vtebg.h,src/vterdb.h,src/vtergb.h: adjust macro used to prevent multiple
	inclusions to match the rest of the tree.
* src/vtefc.c(_vte_fc_patterns_from_pango_font_desc): provide a callback which
	can be used to override all defaults.
* src/vtegl.h,src/vtexft.h: don't include "config.h"
* src/vteglyph.c, src/vteglyph.h: add _vte_glyph_get_uncached().
parent 6186156a
2003-05-05 nalin
* src/debug.h: include <glib.h> for gboolean type definition.
* src/matcher.c: include "config.h" and "debug.h".
* src/matcher.h: use G_BEGIN_DECLS/G_END_DECLS
* src/table.h: use G_BEGIN_DECLS/G_END_DECLS
* src/termcap.h: include <glib.h>, again for gboolean.
* src/vtebg.h,src/vterdb.h,src/vtergb.h: adjust macro used to prevent
multiple inclusions to match the rest of the tree.
* src/vtefc.c(_vte_fc_patterns_from_pango_font_desc): provide a callback
which can be used to override all defaults.
* src/vtegl.h,src/vtexft.h: don't include "config.h"
* src/vteglyph.c, src/vteglyph.h: add _vte_glyph_get_uncached().
2003-05-04 nalin
* gnome-pty-helper/gnome-login-support.c(n_read,n_write): if ERESTART
is defined, treat it like EINTR and EAGAIN.
......
......@@ -23,6 +23,8 @@
#ident "$Id$"
#include <glib.h>
G_BEGIN_DECLS
typedef enum {
......
......@@ -18,10 +18,12 @@
#ident "$Id$"
#include "../config.h"
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <glib-object.h>
#include "debug.h"
#include "matcher.h"
#include "table.h"
#include "trie.h"
......
......@@ -25,6 +25,8 @@
#include <glib-object.h>
G_BEGIN_DECLS
struct _vte_matcher;
/* Create an initial matcher. */
......@@ -50,4 +52,6 @@ void _vte_matcher_print(struct _vte_matcher *matcher);
/* A gunichar-compatible giconv target, if one can be found. */
const char *_vte_matcher_wide_encoding(void);
G_END_DECLS
#endif
......@@ -25,6 +25,8 @@
#include <glib-object.h>
G_BEGIN_DECLS
struct _vte_table;
/* Create an empty, one-level table. */
......@@ -46,4 +48,6 @@ const char *_vte_table_match(struct _vte_table *table,
/* Dump out the contents of a tree. */
void _vte_table_print(struct _vte_table *table);
G_END_DECLS
#endif
......@@ -23,6 +23,8 @@
#ident "$Id$"
#include <glib.h>
G_BEGIN_DECLS
struct _vte_termcap;
......
......@@ -18,8 +18,8 @@
#ident "$Id$"
#ifndef vte_bg_included
#define vte_bg_included
#ifndef vte_vtebg_included
#define vte_vtebg_included
#include <gtk/gtk.h>
......
......@@ -325,7 +325,10 @@ _vte_fc_defaults_from_rdb(FcPattern *pattern)
* and append them to the array. */
gboolean
_vte_fc_patterns_from_pango_font_desc(const PangoFontDescription *font_desc,
GArray *pattern_array)
GArray *pattern_array,
_vte_fc_defaults_cb defaults_cb,
gpointer defaults_data)
{
FcPattern *pattern, *match, *tmp;
FcFontSet *fontset;
......@@ -353,6 +356,11 @@ _vte_fc_patterns_from_pango_font_desc(const PangoFontDescription *font_desc,
/* Add any defaults which are hard-coded in fontconfig. */
FcDefaultSubstitute(pattern);
/* Add any defaults via a callback. */
if (defaults_cb != NULL) {
defaults_cb(pattern, defaults_data);
}
/* Get a sorted list of patterns, duplicate them, and append them
* to the passed-in array. */
fontset = FcFontSort(NULL, pattern, FcTrue, NULL, &result);
......
......@@ -29,9 +29,13 @@
G_BEGIN_DECLS
typedef void (*_vte_fc_defaults_cb)(FcPattern *pattern, gpointer data);
gboolean
_vte_fc_patterns_from_pango_font_desc(const PangoFontDescription *font_desc,
GArray *pattern_array);
GArray *pattern_array,
_vte_fc_defaults_cb defaults_cb,
gpointer defaults_data);
void _vte_fc_connect_settings_changes(GtkWidget *widget, GCallback *changed_cb);
void _vte_fc_disconnect_settings_changes(GtkWidget *widget,
......
......@@ -23,7 +23,6 @@
#ident "$Id$"
#include "../config.h"
#include "vtedraw.h"
G_BEGIN_DECLS
......
......@@ -73,11 +73,17 @@ _vte_glyph_cache_new(void)
return ret;
}
void
_vte_glyph_free(struct _vte_glyph *glyph)
{
g_free(glyph);
}
static gboolean
free_tree_value(gpointer key, gpointer value, gpointer data)
{
if (GPOINTER_TO_INT(value) != INVALID_GLYPH) {
g_free(value);
_vte_glyph_free(value);
}
return FALSE;
}
......@@ -130,7 +136,9 @@ _vte_glyph_cache_free(struct _vte_glyph_cache *cache)
void
_vte_glyph_cache_set_font_description(FcConfig *config,
struct _vte_glyph_cache *cache,
const PangoFontDescription *fontdesc)
const PangoFontDescription *fontdesc,
_vte_fc_defaults_cb defaults_cb,
gpointer defaults_data)
{
FcChar8 *facefile;
int i, j, error, count, width, faceindex;
......@@ -146,7 +154,9 @@ _vte_glyph_cache_set_font_description(FcConfig *config,
/* Convert the font description to a sorted set of patterns. */
patterns = g_array_new(TRUE, TRUE, sizeof(FcPattern*));
if (!_vte_fc_patterns_from_pango_font_desc(fontdesc, patterns)) {
if (!_vte_fc_patterns_from_pango_font_desc(fontdesc, patterns,
defaults_cb,
defaults_data)) {
g_array_free(patterns, TRUE);
g_assert_not_reached();
}
......@@ -428,28 +438,20 @@ _vte_glyph_remap_char(struct _vte_glyph_cache *cache, gunichar origc)
}
}
const struct _vte_glyph *
_vte_glyph_get(struct _vte_glyph_cache *cache, gunichar c)
#define DEFAULT_BYTES_PER_PIXEL 3
struct _vte_glyph *
_vte_glyph_get_uncached(struct _vte_glyph_cache *cache, gunichar c)
{
int error = 0;
GList *iter;
struct _vte_glyph *glyph = NULL;
FT_Face face;
gpointer p;
gint x, y, ooffset, ioffset;
guchar r, g, b, t;
g_return_val_if_fail(cache != NULL, NULL);
/* See if we already have a glyph for this character. */
if ((p = g_tree_lookup(cache->cache, GINT_TO_POINTER(c))) != NULL) {
if (GPOINTER_TO_INT(p) == INVALID_GLYPH) {
return NULL;
} else {
return p;
}
}
/* Search through all of the faces to find one which contains a glyph
* for this character. */
iter = cache->faces;
......@@ -500,19 +502,19 @@ _vte_glyph_get(struct _vte_glyph_cache *cache, gunichar c)
glyph = g_malloc0(sizeof(struct _vte_glyph) +
face->glyph->bitmap.width *
face->glyph->bitmap.rows *
4);
DEFAULT_BYTES_PER_PIXEL);
glyph->width = face->glyph->bitmap.width;
glyph->height = face->glyph->bitmap.rows;
glyph->skip = MAX((face->size->metrics.ascender >> 6) -
face->glyph->bitmap_top, 0);
glyph->bytes_per_pixel = 4;
glyph->bytes_per_pixel = DEFAULT_BYTES_PER_PIXEL;
memset(glyph->bytes, 0,
glyph->width * glyph->height * glyph->bytes_per_pixel);
glyph->width * glyph->height * DEFAULT_BYTES_PER_PIXEL);
for (y = 0; y < face->glyph->bitmap.rows; y++)
for (x = 0; x < face->glyph->bitmap.width; x++) {
ooffset = (y * glyph->width + x) * 4;
ooffset = (y * glyph->width + x) * DEFAULT_BYTES_PER_PIXEL;
if (face->glyph->bitmap.pitch > 0) {
ioffset = y;
ioffset *= face->glyph->bitmap.pitch;
......@@ -584,7 +586,40 @@ _vte_glyph_get(struct _vte_glyph_cache *cache, gunichar c)
glyph->bytes[ooffset + 0] = r;
glyph->bytes[ooffset + 1] = g;
glyph->bytes[ooffset + 2] = b;
glyph->bytes[ooffset + 3] = 0xff;
#if DEFAULT_BYTES_PER_PIXEL > 3
memset(glyph->bytes[ooffset + 3], 0xff,
DEFAULT_BYTES_PER_PIXEL - 3);
#endif
}
return glyph;
}
const struct _vte_glyph *
_vte_glyph_get(struct _vte_glyph_cache *cache, gunichar c)
{
struct _vte_glyph *glyph = NULL;
gpointer p;
g_return_val_if_fail(cache != NULL, NULL);
/* See if we already have a glyph for this character. */
if ((p = g_tree_lookup(cache->cache, GINT_TO_POINTER(c))) != NULL) {
if (GPOINTER_TO_INT(p) == INVALID_GLYPH) {
return NULL;
} else {
return p;
}
}
/* Generate the glyph. */
glyph = _vte_glyph_get_uncached(cache, c);
/* Bail if we weren't able to load the glyph. */
if (glyph == NULL) {
g_tree_insert(cache->cache, GINT_TO_POINTER(c),
GINT_TO_POINTER(INVALID_GLYPH));
return NULL;
}
/* Cache it. */
......@@ -658,7 +693,7 @@ _vte_glyph_draw_loop:
ar = glyph->bytes[ioffset + 0];
ag = glyph->bytes[ioffset + 1];
ab = glyph->bytes[ioffset + 2];
ioffset += glyph->bytes_per_pixel;
ioffset += DEFAULT_BYTES_PER_PIXEL;
if (flags & vte_glyph_dim) {
ar = ar >> 1;
......
......@@ -22,6 +22,7 @@
#ident "$Id$"
#include <glib.h>
#include "vtefc.h"
#include "vtergb.h"
#include <fontconfig/fontconfig.h>
......@@ -68,10 +69,15 @@ void _vte_glyph_cache_free(struct _vte_glyph_cache *cache);
const FcPattern *_vte_glyph_cache_get_pattern(struct _vte_glyph_cache *cache);
void _vte_glyph_cache_set_font_description(FcConfig *config,
struct _vte_glyph_cache *cache,
const PangoFontDescription *fontdesc);
const PangoFontDescription *fontdesc,
_vte_fc_defaults_cb defaults_cb,
gpointer defaults_data);
gboolean _vte_glyph_cache_has_char(struct _vte_glyph_cache *cache, gunichar c);
const struct _vte_glyph *_vte_glyph_get(struct _vte_glyph_cache *cache,
gunichar c);
struct _vte_glyph *_vte_glyph_get_uncached(struct _vte_glyph_cache *cache,
gunichar c);
void _vte_glyph_free(struct _vte_glyph *glyph);
void _vte_glyph_draw(struct _vte_glyph_cache *cache,
gunichar c, GdkColor *color,
gint x, gint y, gint columns,
......
......@@ -18,8 +18,8 @@
#ident "$Id$"
#ifndef vte_rdb_h_included
#define vte_rdb_h_included
#ifndef vte_rdbh_included
#define vte_rdbh_included
#include <glib.h>
......
......@@ -16,8 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef vte_vte_rgb_h_included
#define vte_vte_rgb_h_included
#ifndef vte_vte_rgbh_included
#define vte_vte_rgbh_included
#ident "$Id$"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment