Commit 4493df72 authored by Nalin Dahyabhai's avatar Nalin Dahyabhai

Add (#134429). take a VteTerminalAntiAlias argument. take a

* src/vte.h, src/vte.c (vte_terminal_set_font_full): Add (#134429).
* src/vteglyph.c(_vte_glyph_cache_set_font_description): take a
	VteTerminalAntiAlias argument.
* src/vteft2.c, src/vtegl.c, src/pango.c, src/pango.x, src/vtexft.c
	(*_set_text_font): take a VteTerminalAntiAlias argument.
parent d3f6530c
2004-04-19 nalin
* src/vte.h, src/vte.c (vte_terminal_set_font_full): Add (#134429).
* src/vteglyph.c(_vte_glyph_cache_set_font_description): take a
VteTerminalAntiAlias argument.
* src/vteft2.c, src/vtegl.c, src/pango.c, src/pango.x, src/vtexft.c
(*_set_text_font): take a VteTerminalAntiAlias argument.
2004-04-19 Victor Zverovich <vitaut@users.sourceforge.net>
* src/vte.h src/vte.c: Added default signal handlers to
VteTerminalClass (#137961). [NOTE: ABI change.]
......
......@@ -322,6 +322,7 @@ struct _VteTerminalPrivate {
/* Data used when rendering the text which does not require server
* resources and which can be kept after unrealizing. */
PangoFontDescription *fontdesc;
VteTerminalAntiAlias fontantialias;
GtkSettings *connected_settings;
/* Data used when rendering the text which reflects server resources
......@@ -8156,7 +8157,8 @@ vte_terminal_style_changed(GtkWidget *widget, GtkStyle *style, gpointer data)
if (pango_font_description_equal(style->font_desc,
widget->style->font_desc) ||
(terminal->pvt->fontdesc == NULL)) {
vte_terminal_set_font(terminal, terminal->pvt->fontdesc);
vte_terminal_set_font_full(terminal, terminal->pvt->fontdesc,
terminal->pvt->fontantialias);
}
}
......@@ -10420,9 +10422,10 @@ vte_terminal_apply_metrics(VteTerminal *terminal,
}
/**
* vte_terminal_set_font:
* vte_terminal_set_font_full:
* @terminal: a #VteTerminal
* @font_desc: The #PangoFontDescription of the desired font.
* @anti_alias: Specify if anti aliasing of the fonts is to be used or not.
*
* Sets the font used for rendering all text displayed by the terminal,
* overriding any fonts set using gtk_widget_modify_font(). The terminal
......@@ -10430,10 +10433,12 @@ vte_terminal_apply_metrics(VteTerminal *terminal,
* metrics, and attempt to resize itself to keep the same number of rows
* and columns.
*
* Since: 0.11.11
*/
void
vte_terminal_set_font(VteTerminal *terminal,
const PangoFontDescription *font_desc)
vte_terminal_set_font_full(VteTerminal *terminal,
const PangoFontDescription *font_desc,
VteTerminalAntiAlias anti_alias)
{
GtkWidget *widget;
PangoFontDescription *desc;
......@@ -10464,15 +10469,19 @@ vte_terminal_set_font(VteTerminal *terminal,
}
#endif
}
terminal->pvt->fontantialias = anti_alias;
/* Free the old font description and save the new one. */
if (terminal->pvt->fontdesc != NULL) {
pango_font_description_free(terminal->pvt->fontdesc);
}
terminal->pvt->fontdesc = desc;
terminal->pvt->fontantialias = anti_alias;
/* Set the drawing font. */
_vte_draw_set_text_font(terminal->pvt->draw, terminal->pvt->fontdesc);
_vte_draw_set_text_font(terminal->pvt->draw,
terminal->pvt->fontdesc,
anti_alias);
vte_terminal_apply_metrics(terminal,
_vte_draw_get_text_width(terminal->pvt->draw),
_vte_draw_get_text_height(terminal->pvt->draw),
......@@ -10484,16 +10493,39 @@ vte_terminal_set_font(VteTerminal *terminal,
}
/**
* vte_terminal_set_font_from_string:
* vte_terminal_set_font:
* @terminal: a #VteTerminal
* @font_desc: The #PangoFontDescription of the desired font.
*
* Sets the font used for rendering all text displayed by the terminal,
* overriding any fonts set using gtk_widget_modify_font(). The terminal
* will immediately attempt to load the desired font, retrieve its
* metrics, and attempt to resize itself to keep the same number of rows
* and columns.
*
*/
void
vte_terminal_set_font(VteTerminal *terminal,
const PangoFontDescription *font_desc)
{
vte_terminal_set_font_full(terminal, font_desc,
VTE_ANTI_ALIAS_USE_DEFAULT);
}
/**
* vte_terminal_set_font_from_string_full:
* @terminal: a #VteTerminal
* @name: A string describing the font.
* @antialias: Whether or not to antialias the font (if possible).
*
* A convenience function which converts @name into a #PangoFontDescription and
* passes it to vte_terminal_set_font().
* passes it to vte_terminal_set_font_full().
*
* Since: 0.11.11
*/
void
vte_terminal_set_font_from_string(VteTerminal *terminal, const char *name)
vte_terminal_set_font_from_string_full(VteTerminal *terminal, const char *name,
VteTerminalAntiAlias antialias)
{
PangoFontDescription *font_desc;
g_return_if_fail(VTE_IS_TERMINAL(terminal));
......@@ -10501,10 +10533,26 @@ vte_terminal_set_font_from_string(VteTerminal *terminal, const char *name)
g_return_if_fail(strlen(name) > 0);
font_desc = pango_font_description_from_string(name);
vte_terminal_set_font(terminal, font_desc);
vte_terminal_set_font_full(terminal, font_desc, antialias);
pango_font_description_free(font_desc);
}
/**
* vte_terminal_set_font_from_string:
* @terminal: a #VteTerminal
* @name: A string describing the font.
*
* A convenience function which converts @name into a #PangoFontDescription and
* passes it to vte_terminal_set_font().
*
*/
void
vte_terminal_set_font_from_string(VteTerminal *terminal, const char *name)
{
vte_terminal_set_font_from_string_full(terminal, name,
VTE_ANTI_ALIAS_USE_DEFAULT);
}
/**
* vte_terminal_get_font:
* @terminal: a #VteTerminal
......@@ -10892,7 +10940,8 @@ vte_terminal_fc_settings_changed(GtkSettings *settings, GParamSpec *spec,
spec->name);
}
#endif
vte_terminal_set_font(terminal, terminal->pvt->fontdesc);
vte_terminal_set_font_full(terminal, terminal->pvt->fontdesc,
terminal->pvt->fontantialias);
}
/* Connect to notifications from our settings object that font hints have
......@@ -11197,10 +11246,11 @@ vte_terminal_init(VteTerminal *terminal, gpointer *klass)
/* The font description. */
pvt->fontdesc = NULL;
pvt->fontantialias = VTE_ANTI_ALIAS_USE_DEFAULT;
pvt->connected_settings = NULL;
gtk_widget_ensure_style(widget);
vte_terminal_connect_xft_settings(terminal);
vte_terminal_set_font(terminal, NULL);
vte_terminal_set_font_full(terminal, NULL, VTE_ANTI_ALIAS_USE_DEFAULT);
/* Input method support. */
pvt->im_context = NULL;
......@@ -11555,6 +11605,7 @@ vte_terminal_finalize(GObject *object)
pango_font_description_free(terminal->pvt->fontdesc);
terminal->pvt->fontdesc = NULL;
}
terminal->pvt->fontantialias = VTE_ANTI_ALIAS_USE_DEFAULT;
vte_terminal_disconnect_xft_settings(terminal);
/* Free matching data. */
......@@ -11839,7 +11890,8 @@ vte_terminal_realize(GtkWidget *widget)
GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
/* Actually load the font. */
vte_terminal_set_font(terminal, terminal->pvt->fontdesc);
vte_terminal_set_font_full(terminal, terminal->pvt->fontdesc,
terminal->pvt->fontantialias);
/* Allocate colors. */
for (i = 0; i < G_N_ELEMENTS(terminal->pvt->palette); i++) {
......
......@@ -154,6 +154,13 @@ typedef enum {
VTE_ERASE_DELETE_SEQUENCE
} VteTerminalEraseBinding;
/* Values for the anti alias setting */
typedef enum {
VTE_ANTI_ALIAS_USE_DEFAULT,
VTE_ANTI_ALIAS_FORCE_ENABLE,
VTE_ANTI_ALIAS_FORCE_DISABLE,
} VteTerminalAntiAlias;
/* The structure we return as the supplemental attributes for strings. */
struct _VteCharAttributes {
long row, column;
......@@ -277,7 +284,13 @@ void vte_terminal_im_append_menuitems(VteTerminal *terminal,
/* Set or retrieve the current font. */
void vte_terminal_set_font(VteTerminal *terminal,
const PangoFontDescription *font_desc);
void vte_terminal_set_font_full(VteTerminal *terminal,
const PangoFontDescription *font_desc,
VteTerminalAntiAlias anti_alias);
void vte_terminal_set_font_from_string(VteTerminal *terminal, const char *name);
void vte_terminal_set_font_from_string_full(VteTerminal *terminal,
const char *name,
VteTerminalAntiAlias anti_alias);
const PangoFontDescription *vte_terminal_get_font(VteTerminal *terminal);
gboolean vte_terminal_get_using_xft(VteTerminal *terminal);
void vte_terminal_set_allow_bold(VteTerminal *terminal, gboolean allow_bold);
......
......@@ -399,6 +399,7 @@ main(int argc, char **argv)
console = FALSE, scroll = FALSE, keep = FALSE,
icon_title = FALSE, shell = TRUE, highlight_set = FALSE,
cursor_set = FALSE;
VteTerminalAntiAlias antialias = VTE_ANTI_ALIAS_USE_DEFAULT;
long lines = 100;
const char *message = "Launching interactive shell...\r\n";
const char *font = NULL;
......@@ -463,9 +464,21 @@ main(int argc, char **argv)
g_assert(i < (g_list_length(args) + 2));
/* Parse some command-line options. */
while ((opt = getopt(argc, argv, "B:CDST2abc:df:ghkn:rst:w:-")) != -1) {
while ((opt = getopt(argc, argv,
"AB:CDST2abc:df:ghkn:rst:w:-")) != -1) {
gboolean bail = FALSE;
switch (opt) {
case 'A':
switch (antialias) {
case VTE_ANTI_ALIAS_FORCE_DISABLE:
antialias = VTE_ANTI_ALIAS_FORCE_ENABLE;
break;
case VTE_ANTI_ALIAS_USE_DEFAULT:
case VTE_ANTI_ALIAS_FORCE_ENABLE:
antialias = VTE_ANTI_ALIAS_FORCE_DISABLE;
break;
}
break;
case 'B':
background = optarg;
break;
......@@ -656,9 +669,11 @@ main(int argc, char **argv)
}
/* Set the default font. */
if (font != NULL) {
vte_terminal_set_font_from_string(VTE_TERMINAL(widget), font);
if (font == NULL) {
font = "Sans 12";
}
vte_terminal_set_font_from_string_full(VTE_TERMINAL(widget),
font, antialias);
/* Match "abcdefg". */
vte_terminal_match_add(VTE_TERMINAL(widget), "abcdefg");
......
......@@ -215,11 +215,12 @@ _vte_draw_clear(struct _vte_draw *draw, gint x, gint y, gint width, gint height)
void
_vte_draw_set_text_font(struct _vte_draw *draw,
const PangoFontDescription *fontdesc)
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias anti_alias)
{
g_return_if_fail(draw->impl != NULL);
g_return_if_fail(draw->impl->set_text_font != NULL);
draw->impl->set_text_font(draw, fontdesc);
draw->impl->set_text_font(draw, fontdesc, anti_alias);
}
int
......
......@@ -26,6 +26,7 @@
#include <glib.h>
#include <gtk/gtk.h>
#include "vtebg.h"
#include "vte.h"
G_BEGIN_DECLS
......@@ -66,7 +67,9 @@ struct _vte_draw_impl {
double saturation);
gboolean requires_repaint;
void (*clear)(struct _vte_draw *, gint, gint, gint, gint);
void (*set_text_font)(struct _vte_draw *, const PangoFontDescription *);
void (*set_text_font)(struct _vte_draw *,
const PangoFontDescription *,
VteTerminalAntiAlias);
int (*get_text_width)(struct _vte_draw *);
int (*get_text_height)(struct _vte_draw *);
int (*get_text_ascent)(struct _vte_draw *);
......@@ -126,7 +129,8 @@ void _vte_draw_clear(struct _vte_draw *draw,
/* Set the font which will be used to draw text. */
void _vte_draw_set_text_font(struct _vte_draw *draw,
const PangoFontDescription *fontdesc);
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias anti_alias);
/* Read font metrics. */
int _vte_draw_get_text_width(struct _vte_draw *draw);
int _vte_draw_get_text_height(struct _vte_draw *draw);
......
......@@ -174,7 +174,23 @@ _vte_fc_transcribe_from_pango_font_description(GtkWidget *widget,
}
static void
_vte_fc_defaults_from_gtk(GtkWidget *widget, FcPattern *pattern)
_vte_fc_set_antialias(FcPattern *pattern, VteTerminalAntiAlias antialias)
{
FcBool aa;
if (antialias != VTE_ANTI_ALIAS_USE_DEFAULT) {
if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0,
&aa) != FcResultNoMatch) {
FcPatternDel(pattern, FC_ANTIALIAS);
}
aa = (antialias == VTE_ANTI_ALIAS_FORCE_ENABLE) ?
FcTrue : FcFalse;
FcPatternAddBool(pattern, FC_ANTIALIAS, aa);
}
}
static void
_vte_fc_defaults_from_gtk(GtkWidget *widget, FcPattern *pattern,
VteTerminalAntiAlias explicit_antialias)
{
GtkSettings *settings;
#if GTK_CHECK_VERSION(2,2,0)
......@@ -219,6 +235,7 @@ _vte_fc_defaults_from_gtk(GtkWidget *widget, FcPattern *pattern)
FcPatternDel(pattern, FC_ANTIALIAS);
FcPatternAddBool(pattern, FC_ANTIALIAS, antialias > 0);
}
_vte_fc_set_antialias(pattern, explicit_antialias);
/* Pick up the configured DPI setting. */
if (dpi >= 0) {
......@@ -302,7 +319,8 @@ _vte_fc_defaults_from_gtk(GtkWidget *widget, FcPattern *pattern)
}
static void
_vte_fc_defaults_from_rdb(GtkWidget *widget, FcPattern *pattern)
_vte_fc_defaults_from_rdb(GtkWidget *widget, FcPattern *pattern,
VteTerminalAntiAlias explicit_antialias)
{
FcBool fcb;
double fcd;
......@@ -320,6 +338,16 @@ _vte_fc_defaults_from_rdb(GtkWidget *widget, FcPattern *pattern)
antialias = _vte_rdb_get_antialias(widget);
FcPatternAddBool(pattern, FC_ANTIALIAS, antialias);
}
if (explicit_antialias != VTE_ANTI_ALIAS_USE_DEFAULT) {
FcBool aa;
if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0,
&aa) != FcResultNoMatch) {
FcPatternDel(pattern, FC_ANTIALIAS);
}
aa = (explicit_antialias == VTE_ANTI_ALIAS_FORCE_ENABLE) ?
FcTrue : FcFalse;
FcPatternAddBool(pattern, FC_ANTIALIAS, aa);
}
/* Pick up the hinting setting. */
if (FcPatternGetBool(pattern, FC_HINTING, 0,
......@@ -388,6 +416,7 @@ _vte_fc_defaults_from_rdb(GtkWidget *widget, FcPattern *pattern)
gboolean
_vte_fc_patterns_from_pango_font_desc(GtkWidget *widget,
const PangoFontDescription *font_desc,
VteTerminalAntiAlias antialias,
GArray *pattern_array,
_vte_fc_defaults_cb defaults_cb,
gpointer defaults_data)
......@@ -412,10 +441,13 @@ _vte_fc_patterns_from_pango_font_desc(GtkWidget *widget,
FcConfigSubstitute(NULL, pattern, FcMatchPattern);
/* Add any defaults configured for GTK+. */
_vte_fc_defaults_from_gtk(widget, pattern);
_vte_fc_defaults_from_gtk(widget, pattern, antialias);
/* Add defaults configured via the resource database. */
_vte_fc_defaults_from_rdb(widget, pattern);
_vte_fc_defaults_from_rdb(widget, pattern, antialias);
/* Add any hard-coded default for antialiasing. */
_vte_fc_set_antialias(pattern, antialias);
/* Add any defaults which are hard-coded in fontconfig. */
FcDefaultSubstitute(pattern);
......@@ -433,7 +465,8 @@ _vte_fc_patterns_from_pango_font_desc(GtkWidget *widget,
tmp = FcFontRenderPrepare(NULL,
pattern,
fontset->fonts[i]);
_vte_fc_defaults_from_gtk(widget, tmp);
_vte_fc_defaults_from_gtk(widget, tmp, antialias);
_vte_fc_set_antialias(tmp, antialias);
save = FcPatternDuplicate(tmp);
FcPatternDestroy(tmp);
g_array_append_val(pattern_array, save);
......@@ -447,7 +480,8 @@ _vte_fc_patterns_from_pango_font_desc(GtkWidget *widget,
match = FcFontMatch(NULL, pattern, &result);
if (result == FcResultMatch) {
tmp = FcPatternDuplicate(match);
_vte_fc_defaults_from_gtk(widget, tmp);
_vte_fc_defaults_from_gtk(widget, tmp, antialias);
_vte_fc_set_antialias(tmp, antialias);
save = FcPatternDuplicate(tmp);
FcPatternDestroy(tmp);
g_array_append_val(pattern_array, save);
......
......@@ -26,6 +26,7 @@
#include <fontconfig/fontconfig.h>
#include <pango/pango.h>
#include <glib.h>
#include "vte.h"
G_BEGIN_DECLS
......@@ -34,6 +35,7 @@ typedef void (*_vte_fc_defaults_cb)(FcPattern *pattern, gpointer data);
gboolean
_vte_fc_patterns_from_pango_font_desc(GtkWidget *widget,
const PangoFontDescription *font_desc,
VteTerminalAntiAlias antialias,
GArray *pattern_array,
_vte_fc_defaults_cb defaults_cb,
gpointer defaults_data);
......
......@@ -212,7 +212,8 @@ _vte_ft2_clear(struct _vte_draw *draw,
static void
_vte_ft2_set_text_font(struct _vte_draw *draw,
const PangoFontDescription *fontdesc)
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias anti_alias)
{
struct _vte_ft2_data *data;
......@@ -224,7 +225,7 @@ _vte_ft2_set_text_font(struct _vte_draw *draw,
}
data->cache = _vte_glyph_cache_new();
_vte_glyph_cache_set_font_description(draw->widget, NULL,
data->cache, fontdesc,
data->cache, fontdesc, anti_alias,
NULL, NULL);
}
......
......@@ -384,7 +384,8 @@ _vte_gl_fcpattern_disable_rgba(FcPattern *pattern, gpointer data)
static void
_vte_gl_set_text_font(struct _vte_draw *draw,
const PangoFontDescription *fontdesc)
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias antialias)
{
struct _vte_gl_data *data;
......@@ -397,6 +398,7 @@ _vte_gl_set_text_font(struct _vte_draw *draw,
_vte_glyph_cache_set_font_description(draw->widget,
NULL, data->cache, fontdesc,
antialias,
_vte_gl_fcpattern_disable_rgba,
NULL);
}
......
......@@ -138,6 +138,7 @@ _vte_glyph_cache_set_font_description(GtkWidget *widget,
FcConfig *config,
struct _vte_glyph_cache *cache,
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias antialias,
_vte_fc_defaults_cb defaults_cb,
gpointer defaults_data)
{
......@@ -155,7 +156,9 @@ _vte_glyph_cache_set_font_description(GtkWidget *widget,
/* 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(widget, fontdesc, patterns,
if (!_vte_fc_patterns_from_pango_font_desc(widget, fontdesc,
antialias,
patterns,
defaults_cb,
defaults_data)) {
g_array_free(patterns, TRUE);
......
......@@ -70,6 +70,7 @@ const FcPattern *_vte_glyph_cache_get_pattern(struct _vte_glyph_cache *cache);
void _vte_glyph_cache_set_font_description(GtkWidget *widget, FcConfig *config,
struct _vte_glyph_cache *cache,
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias anti_alias,
_vte_fc_defaults_cb defaults_cb,
gpointer defaults_data);
gboolean _vte_glyph_cache_has_char(struct _vte_glyph_cache *cache, gunichar c);
......
......@@ -258,7 +258,8 @@ _vte_pango_clear(struct _vte_draw *draw,
static void
_vte_pango_set_text_font(struct _vte_draw *draw,
const PangoFontDescription *fontdesc)
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias antialias)
{
#if GTK_CHECK_VERSION(2,2,0)
GdkScreen *screen;
......
......@@ -271,7 +271,8 @@ _vte_pango_x_clear(struct _vte_draw *draw,
static void
_vte_pango_x_set_text_font(struct _vte_draw *draw,
const PangoFontDescription *fontdesc)
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias antialias)
{
PangoContext *ctx;
Display *display;
......
......@@ -158,6 +158,7 @@ _vte_rdb_double(GtkWidget *widget, const char *setting, double default_value)
return dbl;
}
#if 0
static int
_vte_rdb_integer(GtkWidget *widget, const char *setting, int default_value)
{
......@@ -174,6 +175,7 @@ _vte_rdb_integer(GtkWidget *widget, const char *setting, int default_value)
g_free(start);
return n;
}
#endif
static gboolean
_vte_rdb_boolean(GtkWidget *widget, const char *setting, gboolean default_value)
......
......@@ -137,7 +137,8 @@ _vte_skel_clear(struct _vte_draw *draw,
static void
_vte_skel_set_text_font(struct _vte_draw *draw,
const PangoFontDescription *fontdesc)
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias antialias)
{
struct _vte_skel_data *data;
data = (struct _vte_skel_data*) draw->impl_data;
......
......@@ -105,14 +105,15 @@ _vte_xft_text_extents(struct _vte_xft_font *font, XftFont *ftfont, FcChar32 c,
}
static struct _vte_xft_font *
_vte_xft_font_open(GtkWidget *widget, const PangoFontDescription *fontdesc)
_vte_xft_font_open(GtkWidget *widget, const PangoFontDescription *fontdesc,
VteTerminalAntiAlias antialias)
{
struct _vte_xft_font *font;
GArray *patterns;
patterns = g_array_new(TRUE, TRUE, sizeof(FcPattern*));
if (!_vte_fc_patterns_from_pango_font_desc(widget, fontdesc, patterns,
NULL, NULL)) {
if (!_vte_fc_patterns_from_pango_font_desc(widget, fontdesc, antialias,
patterns, NULL, NULL)) {
g_array_free(patterns, TRUE);
return NULL;
}
......@@ -530,7 +531,8 @@ _vte_xft_clear(struct _vte_draw *draw,
static void
_vte_xft_set_text_font(struct _vte_draw *draw,
const PangoFontDescription *fontdesc)
const PangoFontDescription *fontdesc,
VteTerminalAntiAlias antialias)
{
GString *string;
XftFont *font;
......@@ -546,7 +548,7 @@ _vte_xft_set_text_font(struct _vte_draw *draw,
_vte_xft_font_close(data->font);
data->font = NULL;
}
data->font = _vte_xft_font_open(draw->widget, fontdesc);
data->font = _vte_xft_font_open(draw->widget, fontdesc, antialias);
draw->width = 1;
draw->height = 1;
......
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