Commit 0e259e34 authored by Nalin Dahyabhai's avatar Nalin Dahyabhai

disable pangox, xft, glx drawing if run invoked with the --without-x flag.

* configure.in: disable pangox, xft, glx drawing if run invoked with the
	--without-x flag.
* vte.pc.in: include CFLAGS found by AC_PATH_XTRA when built with X.
* src/iso2022.c(_vte_iso2022_substitute_single): clean up and ensure that
	ambiguous widths are respected.
* src/iso2022.c, src/iso2022.h: add _vte_iso2022_unichar_width().
* src/vte.c: remove old xft2/xft1/pango/pangox/core drawing code, making draw
	the only supported method.  Remove most dependencies on gdkx and Xlib,
	except for root pixmap ID watching.
* src/vtedraw.c: only use pangox, xft if X_DISPLAY_MISSING is not defined.
* src/vtedraw.c, src/vtedraw.h: add get_using_fontconfig() method.
* src/vte.c(vte_terminal_get_using_xft): use _vte_draw_get_using_fontconfig(),
	which is what apps really want to know when they call this function.
* src/vtegl.c: wrap in #ifndef X_DISPLAY_MISSING.
* src/vtepangox.c: wrap in #ifndef X_DISPLAY_MISSING.
* src/vtexft.c: wrap in #ifndef X_DISPLAY_MISSING.
* src/vteglyph.c(_vte_glyph_cache_set_description): use horizontal advance
	instead of bitmap width when calculating display widths.
	Rename to _vte_glyph_cache_set_font_description.
parent dca7f0cd
2003-04-14 nalin
* configure.in: disable pangox, xft, glx drawing if run invoked with
the --without-x flag.
* vte.pc.in: include CFLAGS found by AC_PATH_XTRA when built with X.
* src/iso2022.c(_vte_iso2022_substitute_single): clean up and ensure
that ambiguous widths are respected.
* src/iso2022.c, src/iso2022.h: add _vte_iso2022_unichar_width().
* src/vte.c: remove old xft2/xft1/pango/pangox/core drawing code,
making draw the only supported method. Remove most dependencies on
gdkx and Xlib, except for root pixmap ID watching.
* src/vtedraw.c: only use pangox, xft if X_DISPLAY_MISSING is not
defined.
* src/vtedraw.c, src/vtedraw.h: add get_using_fontconfig() method.
* src/vte.c(vte_terminal_get_using_xft): use
_vte_draw_get_using_fontconfig(), which is what apps really want to
know when they call this function.
* src/vtegl.c: wrap in #ifndef X_DISPLAY_MISSING.
* src/vtepangox.c: wrap in #ifndef X_DISPLAY_MISSING.
* src/vtexft.c: wrap in #ifndef X_DISPLAY_MISSING.
* src/vteglyph.c(_vte_glyph_cache_set_description): use horizontal
advance instead of bitmap width when calculating display widths.
Rename to _vte_glyph_cache_set_font_description.
2003-04-09 nalin
* src/vte.c: add back some variables which are used after all.
......
......@@ -17,57 +17,70 @@ AM_GLIB_GNU_GETTEXT
# X_PRE_LIBS and X_EXTRA_LIBS to add even more libraries, and add -lX11 to
# the list of libraries for grins.
AC_PATH_XTRA
X_CFLAGS=
X_LIBS=
if test $with_x = yes ; then
if test "$have_x" = yes ; then
if test -d "$ac_x_includes" ; then
X_CFLAGS="-I$ac_x_includes $X_CFLAGS"
fi
X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
if test -d "$ac_x_libraries" ; then
X_LIBS="-L$ac_x_libraries $X_LIBS"
fi
fi
savelibs="$LIBS"
CFLAGS="$X_CFLAGS $CFLAGS"
LIBS="$X_LIBS $LIBS"
PKG_CHECK_MODULES(GLIB,glib-2.0)
PKG_CHECK_MODULES(GOBJECT,[glib-2.0 gobject-2.0])
PKG_CHECK_MODULES(GTK,[glib-2.0 gobject-2.0 gtk+-2.0])
# Require GTK+ 2.0 and fontconfig.
wantedmodules="glib-2.0 gobject-2.0 gtk+-2.0 fontconfig"
# Require GTK+ 2.2 (we use some of the GdkScreen APIs) and fontconfig.
wantedmodules="glib-2.0 gobject-2.0 gtk+-2.0 >= 2.2.0 fontconfig"
# Use Xft2 if Pango has Xft2 support and it isn't disabled.
AC_ARG_WITH(xft2,[ --with-xft2 enable drawing using Xft2],with_xft2=$withval,with_xft2=yes)
if test $with_xft2 = yes ; then
if pkg-config --exists pangoxft '>=' 1.1.0 ; then
AC_DEFINE(HAVE_XFT2,1,[Whether we have Xft2])
wantedmodules="$wantedmodules pangoxft >= 1.1.0 xft >= 2.0"
else
AC_MSG_WARN([Xft2 not detected])
if test "$have_x" = yes ; then
AC_ARG_WITH(xft2,[ --with-xft2 enable drawing using Xft2],with_xft2=$withval,with_xft2=yes)
if test $with_xft2 = yes ; then
if pkg-config --exists pangoxft '>=' 1.1.0 ; then
AC_DEFINE(HAVE_XFT2,1,[Whether we have Xft2])
wantedmodules="$wantedmodules pangoxft >= 1.1.0"
wantedmodules="$wantedmodules xft >= 2.0"
else
AC_MSG_WARN([Xft2 not detected])
fi
fi
fi
# Use PangoX if we have it and it isn't disabled.
AC_ARG_WITH(pangox,[ --with-pangox enable drawing using PangoX],with_pangox=$withval,with_pangox=yes)
if test $with_pangox = yes ; then
if pkg-config --exists pangox ; then
AC_DEFINE(HAVE_PANGOX,1,[Whether we have PangoX])
wantedmodules="$wantedmodules pangox"
else
AC_MSG_WARN([PangoX not detected])
if test "$have_x" = yes ; then
AC_ARG_WITH(pangox,[ --with-pangox enable drawing using PangoX],with_pangox=$withval,with_pangox=yes)
if test $with_pangox = yes ; then
if pkg-config --exists pangox ; then
AC_DEFINE(HAVE_PANGOX,1,[Whether we have PangoX])
wantedmodules="$wantedmodules pangox"
else
AC_MSG_WARN([PangoX not detected])
fi
fi
fi
# Use glX if we have it and it isn't disabled.
AC_ARG_WITH(glX,[ --with-glX enable drawing using glX],with_glx=$withval,with_glx=yes)
if test $with_glx = yes ; then
have_gl=0
have_libgl=0
AC_CHECK_HEADERS(GL/glx.h)
if test $ac_cv_header_GL_glx_h = yes ; then
AC_CHECK_FUNC(glXQueryExtension,[have_gl=1],AC_CHECK_LIB(GL,glXQueryExtension,[have_gl=1;have_libgl=1]))
fi
if test $have_gl = 1 ; then
AC_DEFINE(HAVE_GL,1,[Whether we have GL and glX.])
fi
if test $have_libgl = 1 ; then
LIBS="-lGLU -lGL $LIBS"
if test "$have_x" = yes ; then
AC_ARG_WITH(glX,[ --with-glX enable drawing using glX],with_glx=$withval,with_glx=yes)
if test $with_glx = yes ; then
have_gl=0
have_libgl=0
AC_CHECK_HEADERS(GL/glx.h)
if test $ac_cv_header_GL_glx_h = yes ; then
AC_CHECK_FUNC(glXQueryExtension,[have_gl=1],AC_CHECK_LIB(GL,glXQueryExtension,[have_gl=1;have_libgl=1]))
fi
if test $have_gl = 1 ; then
AC_DEFINE(HAVE_GL,1,[Whether we have GL and glX.])
fi
if test $have_libgl = 1 ; then
LIBS="-lGLU -lGL $LIBS"
fi
fi
fi
......@@ -86,8 +99,19 @@ savecflags="$CFLAGS"
CFLAGS="$CFLAGS $FT2_CFLAGS"
savecppflags="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $FT2_CFLAGS"
if test -d "$ac_x_includes" ; then
CFLAGS="$CFLAGS -I$ac_x_includes"
CPPFLAGS="$CPPFLAGS -I$ac_x_includes"
fi
AC_CHECK_HEADERS(ft2build.h)
AC_CHECK_DECLS(ft_render_mode_mono,,,[
#ifdef HAVE_FT2BUILD_H
#include <ft2build.h>
#include FT_FREETYPE_H
#endif
])
AC_CHECK_DECLS(FT_RENDER_MODE_MONO,,,[
#ifdef HAVE_FT2BUILD_H
#include <ft2build.h>
......@@ -168,6 +192,8 @@ if test x$ac_cv_lib_ncurses_tgetent != xyes ; then
fi
# Save the names of these other libraries.
OTHERCFLAGS="$X_CFLAGS"
AC_SUBST(OTHERCFLAGS)
OTHERLIBS="$LIBS"
AC_SUBST(OTHERLIBS)
......
......@@ -279,7 +279,7 @@ _vte_iso2022_is_ambiguous(gunichar c)
}
}
p = GINT_TO_POINTER(c);
return g_tree_lookup(ambiguous, p) != NULL;
return g_tree_lookup(ambiguous, p) == p;
}
struct _vte_iso2022 *
......@@ -551,11 +551,12 @@ _vte_iso2022_substitute_single(gunichar mapname, gunichar c)
(long) c);
}
#endif
} else
if (g_unichar_iswide(result)) {
width = 2;
} else {
width = 1;
if (g_unichar_iswide(result)) {
width = 2;
} else {
width = 1;
}
}
/* Encode the width. */
result = _vte_iso2022_set_encoded_width(result, width);
......@@ -996,6 +997,19 @@ _vte_iso2022_substitute(struct _vte_iso2022 *outside_state,
return j;
}
gssize
_vte_iso2022_unichar_width(gunichar c)
{
c = c & ~(VTE_ISO2022_ENCODED_WIDTH_MASK); /* just in case */
if (_vte_iso2022_is_ambiguous(c)) {
return _vte_iso2022_ambiguous_width();
}
if (g_unichar_iswide(c)) {
return 2;
}
return 1;
}
#ifdef ISO2022_MAIN
static void
debug_print(FILE *fp, const char *string)
......
......@@ -43,6 +43,7 @@ gssize _vte_iso2022_substitute(struct _vte_iso2022 *state,
#define VTE_ISO2022_HAS_ENCODED_WIDTH(__c) (((__c) & VTE_ISO2022_ENCODED_WIDTH_MASK) != 0)
gssize _vte_iso2022_get_encoded_width(gunichar c);
gboolean _vte_iso2022_is_ambiguous(gunichar c);
gssize _vte_iso2022_unichar_width(gunichar c);
G_END_DECLS
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -37,17 +37,23 @@
struct _vte_draw_impl
*_vte_draw_impls[] = {
&_vte_draw_skel,
#ifndef X_DISPLAY_MISSING
#ifdef HAVE_GL
/* &_vte_draw_gl, */
#endif
#endif
#ifndef X_DISPLAY_MISSING
#ifdef HAVE_XFT2
&_vte_draw_xft,
#endif
#endif
&_vte_draw_ft2,
&_vte_draw_pango,
#ifndef X_DISPLAY_MISSING
#ifdef HAVE_PANGOX
&_vte_draw_pango_x,
#endif
#endif
};
struct _vte_draw *
......@@ -202,6 +208,14 @@ _vte_draw_get_text_ascent(struct _vte_draw *draw)
return draw->impl->get_text_ascent(draw);
}
gboolean
_vte_draw_get_using_fontconfig(struct _vte_draw *draw)
{
g_return_val_if_fail(draw->impl != NULL, 1);
g_return_val_if_fail(draw->impl->get_using_fontconfig != NULL, FALSE);
return draw->impl->get_using_fontconfig(draw);
}
void
_vte_draw_text(struct _vte_draw *draw,
struct _vte_draw_text_request *requests, gsize n_requests,
......
......@@ -35,8 +35,13 @@ G_BEGIN_DECLS
#define VTE_DRAW_OPAQUE 0xff
#define VTE_DRAW_MAX_LENGTH 88
/* The _vte_draw structure. */
struct _vte_draw;
/* A request to draw a particular character spanning a given number of columns
at the given location. Unlike most APIs, (x,y) specifies the top-left
corner of the cell into which the character will be drawn instead of the
left end of the baseline. */
struct _vte_draw_text_request {
gunichar c;
gint x, y, columns;
......@@ -58,6 +63,7 @@ struct _vte_draw_impl {
int (*get_text_width)(struct _vte_draw *);
int (*get_text_height)(struct _vte_draw *);
int (*get_text_ascent)(struct _vte_draw *);
gboolean (*get_using_fontconfig)(struct _vte_draw *);
void (*draw_text)(struct _vte_draw *,
struct _vte_draw_text_request *, gsize,
GdkColor *, guchar);
......@@ -78,33 +84,49 @@ struct _vte_draw {
gpointer impl_data;
};
/* Create and destroy a draw structure. */
struct _vte_draw *_vte_draw_new(GtkWidget *widget);
void _vte_draw_free(struct _vte_draw *draw);
/* Get the visual and colormap the draw structure desires. Certain draw
implementations may require that this visual/colormap pair be used when
creating a window, and may fail otherwise. */
GdkVisual *_vte_draw_get_visual(struct _vte_draw *draw);
GdkColormap *_vte_draw_get_colormap(struct _vte_draw *draw);
/* Begin and end a drawing operation. If anything is buffered locally, it is
flushed to the window system when _end() is called. */
void _vte_draw_start(struct _vte_draw *draw);
void _vte_draw_end(struct _vte_draw *draw);
/* Set the background color, a background pixbuf (if you want transparency,
you'll have to do that yourself), and clear an area to the default. */
void _vte_draw_set_background_color(struct _vte_draw *draw, GdkColor *color);
void _vte_draw_set_background_pixbuf(struct _vte_draw *draw, GdkPixbuf *pixbuf);
void _vte_draw_clear(struct _vte_draw *draw,
gint x, gint y, gint width, gint height);
/* Set the font which will be used to draw text. */
void _vte_draw_set_text_font(struct _vte_draw *draw,
const PangoFontDescription *fontdesc);
/* Read font metrics. */
int _vte_draw_get_text_width(struct _vte_draw *draw);
int _vte_draw_get_text_height(struct _vte_draw *draw);
int _vte_draw_get_text_ascent(struct _vte_draw *draw);
gboolean _vte_draw_get_using_fontconfig(struct _vte_draw *draw);
/* Draw text or rectangles. */
void _vte_draw_text(struct _vte_draw *draw,
struct _vte_draw_text_request *requests, gsize n_requests,
GdkColor *color, guchar alpha);
void _vte_draw_fill_rectangle(struct _vte_draw *draw,
gint x, gint y, gint width, gint height,
GdkColor *color, guchar alpha);
void _vte_draw_draw_rectangle(struct _vte_draw *draw,
gint x, gint y, gint width, gint height,
GdkColor *color, guchar alpha);
/* Set the scrolling offset for painting in a pixbuf background. */
void _vte_draw_set_scroll(struct _vte_draw *draw, gint x, gint y);
G_END_DECLS
......
......@@ -146,87 +146,84 @@ _vte_fc_defaults_from_gtk(FcPattern *pattern)
/* Pick up the antialiasing setting. */
if (antialias >= 0) {
result = FcPatternGetBool(pattern, FC_ANTIALIAS, 0, &i);
if (result == FcResultNoMatch) {
FcPatternAddBool(pattern, FC_ANTIALIAS, antialias > 0);
}
FcPatternDel(pattern, FC_ANTIALIAS);
FcPatternAddBool(pattern, FC_ANTIALIAS, antialias > 0);
}
/* Pick up the configured DPI setting. */
if (dpi >= 0) {
result = FcPatternGetDouble(pattern, FC_DPI, 0, &d);
if (result == FcResultNoMatch) {
FcPatternAddDouble(pattern, FC_DPI, dpi / 1024.0);
}
FcPatternDel(pattern, FC_DPI);
FcPatternAddDouble(pattern, FC_DPI, dpi / 1024.0);
}
/* Pick up the configured subpixel rendering setting. */
if (rgba != NULL) {
result = FcPatternGetInteger(pattern, FC_RGBA, 0, &i);
if (result == FcResultNoMatch) {
gboolean found;
gboolean found;
i = FC_RGBA_NONE;
if (strcmp(rgba, "none") == 0) {
i = FC_RGBA_NONE;
found = TRUE;
if (strcmp(rgba, "none") == 0) {
i = FC_RGBA_NONE;
} else
if (strcmp(rgba, "rgb") == 0) {
i = FC_RGBA_RGB;
} else
if (strcmp(rgba, "bgr") == 0) {
i = FC_RGBA_BGR;
} else
if (strcmp(rgba, "vrgb") == 0) {
i = FC_RGBA_VRGB;
} else
if (strcmp(rgba, "vbgr") == 0) {
i = FC_RGBA_VBGR;
} else {
found = FALSE;
}
if (found) {
FcPatternAddInteger(pattern, FC_RGBA, i);
}
} else
if (strcmp(rgba, "rgb") == 0) {
i = FC_RGBA_RGB;
found = TRUE;
} else
if (strcmp(rgba, "bgr") == 0) {
i = FC_RGBA_BGR;
found = TRUE;
} else
if (strcmp(rgba, "vrgb") == 0) {
i = FC_RGBA_VRGB;
found = TRUE;
} else
if (strcmp(rgba, "vbgr") == 0) {
i = FC_RGBA_VBGR;
found = TRUE;
} else {
found = FALSE;
}
if (found) {
FcPatternDel(pattern, FC_RGBA);
FcPatternAddInteger(pattern, FC_RGBA, i);
}
}
/* Pick up the configured hinting setting. */
if (hinting >= 0) {
result = FcPatternGetBool(pattern, FC_HINTING, 0, &i);
if (result == FcResultNoMatch) {
FcPatternAddBool(pattern, FC_HINTING, hinting > 0);
}
FcPatternDel(pattern, FC_HINTING);
FcPatternAddBool(pattern, FC_HINTING, hinting > 0);
}
#ifdef FC_HINT_STYLE
/* Pick up the default hinting style. */
if (hintstyle != NULL) {
result = FcPatternGetInteger(pattern, FC_HINT_STYLE, 0, &i);
if (result == FcResultNoMatch) {
gboolean found;
gboolean found;
i = FC_HINT_NONE;
if (strcmp(hintstyle, "hintnone") == 0) {
i = FC_HINT_NONE;
found = TRUE;
if (strcmp(hintstyle, "hintnone") == 0) {
i = FC_HINT_NONE;
} else
if (strcmp(hintstyle, "hintslight") == 0) {
i = FC_HINT_SLIGHT;
} else
if (strcmp(hintstyle, "hintmedium") == 0) {
i = FC_HINT_MEDIUM;
} else
if (strcmp(hintstyle, "hintfull") == 0) {
i = FC_HINT_FULL;
} else {
found = FALSE;
}
if (found) {
FcPatternAddInteger(pattern, FC_HINT_STYLE, i);
}
} else
if (strcmp(hintstyle, "hintslight") == 0) {
i = FC_HINT_SLIGHT;
found = TRUE;
} else
if (strcmp(hintstyle, "hintmedium") == 0) {
i = FC_HINT_MEDIUM;
found = TRUE;
} else
if (strcmp(hintstyle, "hintfull") == 0) {
i = FC_HINT_FULL;
found = TRUE;
} else {
found = FALSE;
}
if (found) {
FcPatternDel(pattern, FC_HINT_STYLE);
FcPatternAddInteger(pattern, FC_HINT_STYLE, i);
}
}
#endif
......@@ -269,6 +266,7 @@ _vte_fc_patterns_from_pango_font_desc(const PangoFontDescription *font_desc,
tmp = FcFontRenderPrepare(NULL,
pattern,
fontset->fonts[i]);
_vte_fc_defaults_from_gtk(tmp);
g_array_append_val(pattern_array, tmp);
}
FcFontSetDestroy(fontset);
......@@ -280,6 +278,7 @@ _vte_fc_patterns_from_pango_font_desc(const PangoFontDescription *font_desc,
match = FcFontMatch(NULL, pattern, &result);
if (result == FcResultMatch) {
tmp = FcPatternDuplicate(match);
_vte_fc_defaults_from_gtk(tmp);
g_array_append_val(pattern_array, tmp);
ret = TRUE;
} else {
......
......@@ -215,7 +215,7 @@ _vte_ft2_set_text_font(struct _vte_draw *draw,
data->cache = NULL;
}
data->cache = _vte_glyph_cache_new();
_vte_glyph_cache_set_description(NULL, data->cache, fontdesc);
_vte_glyph_cache_set_font_description(NULL, data->cache, fontdesc);
}
static int
......@@ -242,17 +242,21 @@ _vte_ft2_get_text_ascent(struct _vte_draw *draw)
return data->cache->ascent;
}
static gboolean
_vte_ft2_get_using_fontconfig(struct _vte_draw *draw)
{
return TRUE;
}
static void
_vte_ft2_draw_text(struct _vte_draw *draw,
struct _vte_draw_text_request *requests, gsize n_requests,
GdkColor *color, guchar alpha)
{
struct _vte_ft2_data *data;
struct _vte_glyph_cache *cache;
int i;
data = (struct _vte_ft2_data*) draw->impl_data;
cache = data->cache;
for (i = 0; i < n_requests; i++) {
_vte_glyph_draw(data->cache, requests[i].c, color,
......@@ -261,7 +265,8 @@ _vte_ft2_draw_text(struct _vte_draw *draw,
0,
data->rgb);
update_bbox(data, requests[i].x, requests[i].y,
cache->width * requests[i].columns, cache->height);
data->cache->width * requests[i].columns,
data->cache->height);
}
}
......@@ -331,6 +336,7 @@ struct _vte_draw_impl _vte_draw_ft2 = {
_vte_ft2_get_text_width,
_vte_ft2_get_text_height,
_vte_ft2_get_text_ascent,
_vte_ft2_get_using_fontconfig,
_vte_ft2_draw_text,
_vte_ft2_draw_rectangle,
_vte_ft2_fill_rectangle,
......
......@@ -18,6 +18,7 @@
#include "../config.h"
#ifndef X_DISPLAY_MISSING
#ifdef HAVE_GL
#include <sys/param.h>
......@@ -337,6 +338,12 @@ _vte_gl_get_text_ascent(struct _vte_draw *draw)
return 8;
}
static gboolean
_vte_gl_get_using_fontconfig(struct _vte_draw *draw)
{
return TRUE;
}
static void
_vte_gl_draw_text(struct _vte_draw *draw,
struct _vte_draw_text_request *requests, gsize n_requests,
......@@ -405,6 +412,7 @@ struct _vte_draw_impl _vte_draw_gl = {
_vte_gl_get_text_width,
_vte_gl_get_text_height,
_vte_gl_get_text_ascent,
_vte_gl_get_using_fontconfig,
_vte_gl_draw_text,
_vte_gl_draw_rectangle,
_vte_gl_fill_rectangle,
......@@ -412,3 +420,4 @@ struct _vte_draw_impl _vte_draw_gl = {
};
#endif
#endif
......@@ -23,6 +23,7 @@
#include <math.h>
#include <gdk/gdk.h>
#include <glib.h>
#include "iso2022.h"
#include "vtedraw.h"
#include "vtefc.h"
#include "vteglyph.h"
......@@ -118,9 +119,9 @@ _vte_glyph_cache_free(struct _vte_glyph_cache *cache)
}
void
_vte_glyph_cache_set_description(FcConfig *config,
struct _vte_glyph_cache *cache,
const PangoFontDescription *fontdesc)
_vte_glyph_cache_set_font_description(FcConfig *config,
struct _vte_glyph_cache *cache,
const PangoFontDescription *fontdesc)
{
FcChar8 *facefile;
int i, j, error, count, width, faceindex;
......@@ -208,23 +209,32 @@ _vte_glyph_cache_set_description(FcConfig *config,
cache->ft_render_flags = 0;
i = 0;
pattern = g_array_index(cache->patterns, FcPattern*, 0);
/* Read and set the "use the autohinter", er, hint. */
#if defined(FC_AUTOHINT) && defined(FT_LOAD_FORCE_AUTOHINT)
if (FcPatternGetBool(pattern, FC_AUTOHINT, 0, &i) == FcResultMatch) {
if (i != 0) {
cache->ft_load_flags |= FT_LOAD_FORCE_AUTOHINT;
}
}
#endif
/* Read and set the "use antialiasing" hint. */
if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0, &i) == FcResultMatch) {
if (i == 0) {
cache->ft_load_flags |= FT_LOAD_MONOCHROME;
#if HAVE_DECL_FT_RENDER_MODE_MONO
cache->ft_render_flags = FT_RENDER_MODE_MONO;
#endif
#if HAVE_DECL_ft_render_mode_mono
cache->ft_render_flags = ft_render_mode_mono;
#endif
}
}
/* Read and set the "hinting" hint. */
if (FcPatternGetBool(pattern, FC_HINTING, 0, &i) == FcResultMatch) {
if (i == 0) {
cache->ft_load_flags |= FT_LOAD_NO_HINTING;
} else {
#if defined(FC_AUTOHINT) && defined(FT_LOAD_FORCE_AUTOHINT)
if (FcPatternGetBool(pattern, FC_AUTOHINT, 0,
&i) == FcResultMatch) {
if (i != 0) {
......@@ -232,6 +242,8 @@ _vte_glyph_cache_set_description(FcConfig *config,
FT_LOAD_FORCE_AUTOHINT;
}
}
#endif
#ifdef FC_HINT_STYLE
if (FcPatternGetInteger(pattern, FC_HINT_STYLE, 0,
&i) == FcResultMatch) {
switch (i) {
......@@ -241,18 +253,21 @@ _vte_glyph_cache_set_description(FcConfig *config,
FT_LOAD_NO_HINTING;
break;
#endif
#if 0
/* FT_RENDER_MODE_LIGHT doesn't appear to work reliably enough. */
#if HAVE_DECL_FT_RENDER_MODE_LIGHT
case FC_HINT_SLIGHT:
cache->ft_render_flags |=
FT_RENDER_MODE_LIGHT;
break;
#endif
#if HAVE_DECL_FT_RENDER_MODE_NORMAL
#if HAVE_DECL_FT_RENDER_MODE_LIGHT
case FC_HINT_MEDIUM:
cache->ft_render_flags |=
FT_RENDER_MODE_NORMAL;
FT_RENDER_MODE_LIGHT;
break;
#endif
#endif
#if HAVE_DECL_FT_RENDER_MODE_NORMAL
case FC_HINT_FULL:
cache->ft_render_flags |=
......@@ -263,6 +278,7 @@ _vte_glyph_cache_set_description(FcConfig *config,
break;
}
}
#endif
}
}
......@@ -279,9 +295,13 @@ _vte_glyph_cache_set_description(FcConfig *config,
}
error = FT_Load_Char((FT_Face) face,
VTE_DRAW_SINGLE_WIDE_CHARACTERS[i],
FT_LOAD_RENDER | cache->ft_load_flags);
cache->ft_load_flags);
if (error == 0) {
error = FT_Render_Glyph(face->glyph,
cache->ft_render_flags);
}
if (error == 0) {
cache->width += face->glyph->bitmap.width;
cache->width += face->glyph->metrics.horiAdvance;
if (face->size->metrics.ascender != 0) {
cache->height += face->size->metrics.ascender -
face->size->metrics.descender;
......@@ -298,7 +318,7 @@ _vte_glyph_cache_set_description(FcConfig *config,
}
}
if (count > 0) {
cache->width = howmany(cache->width, count);
cache->width = howmany(cache->width / 64, count);
cache->height = howmany((cache->height / 64), count);
cache->ascent = howmany((cache->ascent / 64), count);
} else {
......@@ -315,14 +335,18 @@ _vte_glyph_cache_set_description(FcConfig *config,
}
error = FT_Load_Char((FT_Face) face,
double_wide_characters[i],
FT_LOAD_RENDER | cache->ft_load_flags);
cache->ft_load_flags);
if (error == 0) {
error = FT_Render_Glyph(face->glyph,
cache->ft_render_flags);
}
if (error == 0) {
width += face->glyph->bitmap.width;
width += face->glyph->metrics.horiAdvance;
count++;
}
}
if (count > 0) {
if (cache->width == width / count) {
if (cache->width == width / 64 / count) {
cache->width /= 2;
}
}
......@@ -717,7 +741,8 @@ _vte_glyph_draw_string(struct _vte_glyph_cache *cache,
while (*s != '\0') {
c = g_utf8_get_char(s);
width = 1; /* FIXME */
width = _vte_iso2022_unichar_width(c);
g_assert(width >= 0);
if (x + width * cache->width > buffer->width) {
break;
}
......
......@@ -66,9 +66,9 @@ struct _vte_glyph_cache {
struct _vte_glyph_cache *_vte_glyph_cache_new(void);
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_description(FcConfig *config,
struct _vte_glyph_cache *cache,
const PangoFontDescription *fontdesc);
void _vte_glyph_cache_set_font_description(FcConfig *config,
struct _vte_glyph_cache *cache,
const PangoFontDescription *fontdesc);
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);
......
......@@ -19,6 +19,7 @@
#include "../config.h"
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <pango/pango.h>
......@@ -251,6 +252,7 @@ _vte_pango_set_text_font(struct _vte_draw *draw,
GdkScreen *screen;
PangoContext *ctx;
PangoLayout *layout;
PangoLayoutIter *iter;
PangoRectangle ink, logical;
gunichar full_codepoints[] = {VTE_DRAW_DOUBLE_WIDE_CHARACTERS};
GString *full_string;
......@@ -277,6 +279,10 @@ _vte_pango_set_text_font(struct _vte_draw *draw,
draw->width = logical.width;
draw->width = howmany(draw->width,
strlen(VTE_DRAW_SINGLE_WIDE_CHARACTERS));
iter = pango_layout_get_iter(layout);
draw->height = PANGO_PIXELS(logical.height);
draw->ascent = PANGO_PIXELS(pango_layout_iter_get_baseline(iter));
pango_layout_iter_free(iter);
/* Estimate for CJK characters. */