2004-05-10 Joe Marcus Clarke * src/gnome-terminal.glade2: add an option menu for controlling the font smoothing behavior in the terminal. * src/gnome-terminal.schemas.in: add a key for font smoothing behavior. * src/profile-editor.c(font_smoothing_changed, profile_editor_update_font_smoothing): new functions for controlling font smoothing behavior. * src/terminal-profile.c(terminal_profile_get_font_smoothing, terminal_profile_set_font_smoothing, set_font_smoothing): new functions for controlling font smoothing behavior. * src/terminal-profile.h: add function prototypes for controlling font smoothing behavior. * src/terminal-screen.c(terminal_screen_update_on_realize): * src/terminal-widget-zvt.c(terminal_widget_set_pango_font): * src/terminal-widget-vte.c(terminal_widget_set_pango_font): add support for setting font smoothing behavior in terminal widgets. * src/terminal-widget.h(terminal_widget_set_pango_font): modify prototype to support a font smoothing argument. --- src/gnome-terminal.glade2.orig Mon Mar 1 20:06:53 2004 +++ src/gnome-terminal.glade2 Mon May 10 14:38:56 2004 @@ -1784,7 +1784,7 @@ 12 True - 6 + 7 1 False 12 @@ -1859,129 +1859,6 @@ - - True - 0 - 0.1 - 0.95 - 0 - 0 - 0 - 0 - 0 - - - - True - False - 0 - - - - True - _Shade transparent or image background: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - darken-background-scale - - - 1 - False - False - - - - - - True - False - 0 - - - - True - <small><i>None</i></small> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 6 - 0 - - - 0 - False - False - - - - - - True - True - False - GTK_POS_BOTTOM - 2 - GTK_UPDATE_DELAYED - False - 0.1 0 1 0.01 0.1 0 - - - 0 - True - True - - - - - - True - <small><i>Maximum</i></small> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 6 - 0 - - - 0 - False - False - - - - - 1 - True - True - - - - - - - 0 - 1 - 5 - 6 - - - - True False @@ -2154,6 +2031,218 @@ 2 3 fill + + + + + + True + 0 + 0.1 + 0.95 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 0 + + + + True + _Shade transparent or image background: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + darken-background-scale + + + 1 + False + False + + + + + + True + False + 0 + + + + True + <small><i>None</i></small> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 6 + 0 + + + 0 + False + False + + + + + + True + True + False + GTK_POS_BOTTOM + 2 + GTK_UPDATE_DELAYED + False + 0.1 0 1 0.01 0.1 0 + + + 0 + True + True + + + + + + True + <small><i>Maximum</i></small> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 6 + 0 + + + 0 + False + False + + + + + 1 + True + True + + + + + + + 0 + 1 + 5 + 6 + fill + + + + + + True + 1 + 2 + False + 12 + 12 + + + + True + _Font smoothing: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + font-smoothing-optionmenu + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + True + 0 + + + + + + + True + Default + True + + + + + + True + Enabled + True + + + + + + True + Disabled + True + + + + + + + 1 + 2 + 0 + 1 + fill + + + + + + 0 + 1 + 6 + 7 + fill --- src/gnome-terminal.schemas.in.orig Mon May 10 14:39:24 2004 +++ src/gnome-terminal.schemas Mon May 10 14:42:43 2004 @@ -458,6 +458,21 @@ + /schemas/apps/gnome-terminal/profiles/Default/font_smoothing + /apps/gnome-terminal/profiles/Default/font_smoothing + gnome-terminal + string + default + + Font smoothing behavior + + Controls the font smoothing behavior for this profile. Possibilities + are "default", "enabled", and "disabled". + + + + + /schemas/apps/gnome-terminal/profiles/Default/background_type /apps/gnome-terminal/profiles/Default/background_type gnome-terminal --- src/profile-editor.c.orig Sat Feb 14 02:22:21 2004 +++ src/profile-editor.c Mon May 10 14:39:01 2004 @@ -135,6 +135,8 @@ TerminalProfile *profile); static void profile_editor_update_use_system_font (GtkWidget *widget, TerminalProfile *profile); +static void profile_editor_update_font_smoothing (GtkWidget *widget, + TerminalProfile *profile); static void profile_editor_update_font (GtkWidget *widget, TerminalProfile *profile); @@ -336,6 +338,9 @@ if (mask->use_system_font) profile_editor_update_use_system_font (editor, profile); + if (mask->font_smoothing) + profile_editor_update_font_smoothing (editor, profile); + if (mask->font) profile_editor_update_font (editor, profile); @@ -737,6 +742,17 @@ } static void +font_smoothing_changed (GtkWidget *option_menu, + TerminalProfile *profile) +{ + int i; + + i = gtk_option_menu_get_history (GTK_OPTION_MENU (option_menu)); + + terminal_profile_set_font_smoothing (profile, i); +} + +static void font_set (GtkWidget *fontpicker, TerminalProfile *profile) { @@ -1172,6 +1188,7 @@ if (terminal_widget_supports_pango_fonts ()) { GtkWidget *font_label; + GtkWidget *font_smoothing_optionmenu; fontsel = gtk_font_button_new (); g_object_set_data (G_OBJECT (editor), "font-selector", fontsel); @@ -1206,6 +1223,13 @@ glade_xml_get_widget (xml, "profile-icon-label")); g_object_unref (G_OBJECT (size_group)); + + font_smoothing_optionmenu = + glade_xml_get_widget (xml, "font-smoothing-optionmenu"); + profile_editor_update_font_smoothing (editor, profile); + g_signal_connect (G_OBJECT (font_smoothing_optionmenu), "changed", + G_CALLBACK (font_smoothing_changed), + profile); } else { @@ -1439,6 +1463,9 @@ set_insensitive (editor, "system-font-checkbutton", mask->use_system_font); + set_insensitive (editor, "font-smoothing-optionmenu", + mask->font_smoothing); + { int i; @@ -1976,6 +2003,19 @@ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), terminal_profile_get_use_system_font (profile)); +} + +static void +profile_editor_update_font_smoothing (GtkWidget *editor, + TerminalProfile *profile) +{ + GtkWidget *w; + + w = profile_editor_get_widget (editor, "font-smoothing-optionmenu"); + + gtk_option_menu_set_history (GTK_OPTION_MENU (w), + terminal_profile_get_font_smoothing (profile)); + } static void --- src/terminal-profile.c.orig Tue Sep 30 20:06:17 2003 +++ src/terminal-profile.c Mon May 10 14:39:01 2004 @@ -68,6 +68,7 @@ #define KEY_DELETE_BINDING "delete_binding" #define KEY_USE_THEME_COLORS "use_theme_colors" #define KEY_USE_SYSTEM_FONT "use_system_font" +#define KEY_FONT_SMOOTHING "font_smoothing" #define KEY_USE_SKEY "use_skey" #define KEY_FONT "font" @@ -93,6 +94,7 @@ TerminalTitleMode title_mode; char *word_chars; TerminalScrollbarPosition scrollbar_position; + TerminalFontSmoothing font_smoothing; int scrollback_lines; TerminalExitAction exit_action; char *custom_command; @@ -167,6 +169,13 @@ { -1, NULL } }; +static const GConfEnumStringPair font_smoothing_behaviors[] = { + { TERMINAL_FONT_SMOOTHING_DEFAULT, "default" }, + { TERMINAL_FONT_SMOOTHING_ENABLED, "enabled" }, + { TERMINAL_FONT_SMOOTHING_DISABLED, "disabled" }, + { -1, NULL } +}; + static const GConfEnumStringPair exit_actions[] = { { TERMINAL_EXIT_CLOSE, "close" }, { TERMINAL_EXIT_RESTART, "restart" }, @@ -290,6 +299,7 @@ profile->priv->delete_binding = TERMINAL_ERASE_ESCAPE_SEQUENCE; profile->priv->use_theme_colors = TRUE; profile->priv->use_system_font = TRUE; + profile->priv->font_smoothing = TERMINAL_FONT_SMOOTHING_DEFAULT; profile->priv->use_skey = TRUE; profile->priv->font = pango_font_description_new (); pango_font_description_set_family (profile->priv->font, @@ -1438,6 +1448,36 @@ g_free (key); } +TerminalFontSmoothing +terminal_profile_get_font_smoothing (TerminalProfile *profile) +{ + g_return_val_if_fail (TERMINAL_IS_PROFILE (profile), 0); + + return profile->priv->font_smoothing; +} + +void +terminal_profile_set_font_smoothing (TerminalProfile *profile, + TerminalFontSmoothing setting) +{ + char *key; + const char *smoothing_behavior; + + RETURN_IF_NOTIFYING (profile); + + key = gconf_concat_dir_and_key (profile->priv->profile_dir, + KEY_FONT_SMOOTHING); + + smoothing_behavior = gconf_enum_to_string (font_smoothing_behaviors, setting); + + gconf_client_set_string (profile->priv->conf, + key, + smoothing_behavior, + NULL); + + g_free (key); +} + gboolean terminal_profile_get_use_skey (TerminalProfile *profile) { @@ -1648,6 +1688,25 @@ } static gboolean +set_font_smoothing (TerminalProfile *profile, + const char *str_val) +{ + int behavior; /* TerminalFontSmoothing */ + + if (str_val && + gconf_string_to_enum (font_smoothing_behaviors, str_val, &behavior) && + behavior != profile->priv->font_smoothing) + { + profile->priv->font_smoothing = behavior; + return TRUE; + } + else + { + return FALSE; + } +} + +static gboolean set_exit_action (TerminalProfile *profile, const char *str_val) { @@ -1981,6 +2040,7 @@ UPDATE_STRING (KEY_DELETE_BINDING, delete_binding); UPDATE_BOOLEAN (KEY_USE_THEME_COLORS, use_theme_colors); UPDATE_BOOLEAN (KEY_USE_SYSTEM_FONT, use_system_font); + UPDATE_STRING (KEY_FONT_SMOOTHING, font_smoothing); UPDATE_STRING (KEY_FONT, font); #undef UPDATE_BOOLEAN @@ -2127,6 +2187,7 @@ UPDATE_STRING (KEY_DELETE_BINDING, delete_binding, NULL); UPDATE_BOOLEAN (KEY_USE_THEME_COLORS, use_theme_colors, TRUE); UPDATE_BOOLEAN (KEY_USE_SYSTEM_FONT, use_system_font, TRUE); + UPDATE_STRING (KEY_FONT_SMOOTHING, font_smoothing, NULL); UPDATE_STRING (KEY_FONT, font, NULL); } @@ -2858,6 +2919,16 @@ gconf_client_set_bool (base_profile->priv->conf, key, base_profile->priv->use_system_font, &err); + BAIL_OUT_CHECK (); + + g_free (key); + key = gconf_concat_dir_and_key (profile_dir, + KEY_FONT_SMOOTHING); + cs = gconf_enum_to_string (font_smoothing_behaviors, + base_profile->priv->font_smoothing); + gconf_client_set_string (base_profile->priv->conf, + key, cs, + &err); BAIL_OUT_CHECK (); g_free (key); --- src/terminal-profile.h.orig Sun Dec 8 00:00:25 2002 +++ src/terminal-profile.h Mon May 10 14:39:01 2004 @@ -65,6 +65,7 @@ unsigned int delete_binding : 1; unsigned int use_theme_colors : 1; unsigned int use_system_font : 1; + unsigned int font_smoothing : 1; unsigned int font : 1; } TerminalSettingMask; @@ -95,6 +96,13 @@ TERMINAL_SCROLLBAR_HIDDEN } TerminalScrollbarPosition; +typedef enum +{ + TERMINAL_FONT_SMOOTHING_DEFAULT, + TERMINAL_FONT_SMOOTHING_ENABLED, + TERMINAL_FONT_SMOOTHING_DISABLED +} TerminalFontSmoothing; + typedef enum { TERMINAL_EXIT_CLOSE, @@ -183,6 +191,7 @@ gboolean terminal_profile_get_use_theme_colors (TerminalProfile *profile); gboolean terminal_profile_get_use_system_font (TerminalProfile *profile); +TerminalFontSmoothing terminal_profile_get_font_smoothing (TerminalProfile *profile); gboolean terminal_profile_get_use_skey (TerminalProfile *profile); const PangoFontDescription* terminal_profile_get_font (TerminalProfile *profile); @@ -256,6 +265,9 @@ void terminal_profile_set_use_system_font (TerminalProfile *profile, gboolean setting); + +void terminal_profile_set_font_smoothing (TerminalProfile *profile, + TerminalFontSmoothing setting); void terminal_profile_set_use_skey (TerminalProfile *profile, gboolean setting); --- src/terminal-screen.c.orig Fri Feb 20 18:14:09 2004 +++ src/terminal-screen.c Mon May 10 14:39:01 2004 @@ -727,17 +727,20 @@ if (terminal_widget_supports_pango_fonts ()) { PangoFontDescription *desc; + TerminalFontSmoothing font_smoothing; if (terminal_profile_get_use_system_font (profile)) desc = get_system_monospace_font (); else desc = pango_font_description_copy (terminal_profile_get_font (profile)); + font_smoothing = terminal_profile_get_font_smoothing (profile); + pango_font_description_set_size (desc, screen->priv->font_scale * pango_font_description_get_size (desc)); - terminal_widget_set_pango_font (term, desc); + terminal_widget_set_pango_font (term, desc, font_smoothing); pango_font_description_free (desc); } --- src/terminal-widget-vte.c.orig Tue Sep 30 20:06:17 2003 +++ src/terminal-widget-vte.c Mon May 10 14:39:01 2004 @@ -565,10 +565,26 @@ void terminal_widget_set_pango_font (GtkWidget *widget, - const PangoFontDescription *font_desc) + const PangoFontDescription *font_desc, + TerminalFontSmoothing font_smoothing) { + VteTerminalAntiAlias vte_antialias; + g_return_if_fail (font_desc != NULL); - vte_terminal_set_font (VTE_TERMINAL (widget), font_desc); + + switch (font_smoothing) { + case TERMINAL_FONT_SMOOTHING_ENABLED: + vte_antialias = VTE_ANTI_ALIAS_FORCE_ENABLE; + break; + case TERMINAL_FONT_SMOOTHING_DISABLED: + vte_antialias = VTE_ANTI_ALIAS_FORCE_DISABLE; + break; + default: + vte_antialias = VTE_ANTI_ALIAS_USE_DEFAULT; + break; + } + + vte_terminal_set_font_full (VTE_TERMINAL (widget), font_desc, vte_antialias); } gboolean --- src/terminal-widget.h.orig Mon Dec 2 23:07:17 2002 +++ src/terminal-widget.h Mon May 10 14:39:01 2004 @@ -156,7 +156,8 @@ int len); void terminal_widget_set_pango_font (GtkWidget *widget, - const PangoFontDescription *font_desc); + const PangoFontDescription *font_desc, + TerminalFontSmoothing font_smoothing); gboolean terminal_widget_supports_pango_fonts (void);