1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
--- gtk+-2.2.1/gdk/x11/gdkevents-x11.c.xftprefs Thu Jan 23 16:57:04 2003
+++ gtk+-2.2.1/gdk/x11/gdkevents-x11.c Sun Feb 2 22:29:22 2003
@@ -2497,7 +2497,12 @@
{ "Gtk/IMStatusStyle", "gtk-im-status-style" },
{ "Net/CursorBlink", "gtk-cursor-blink" },
{ "Net/CursorBlinkTime", "gtk-cursor-blink-time" },
- { "Net/ThemeName", "gtk-theme-name" }
+ { "Net/ThemeName", "gtk-theme-name" },
+ { "Xft/Antialias", "gtk-xft-antialias" },
+ { "Xft/Hinting", "gtk-xft-hinting" },
+ { "Xft/HintStyle", "gtk-xft-hintstyle" },
+ { "Xft/RGBA", "gtk-xft-rgba" },
+ { "Xft/DPI", "gtk-xft-dpi" },
};
static void
--- gtk+-2.2.1/gtk/gtksettings.c.xftprefs Sun Feb 2 22:29:22 2003
+++ gtk+-2.2.1/gtk/gtksettings.c Sun Feb 2 22:31:55 2003
@@ -42,6 +42,12 @@
GtkSettingsSource source;
};
+#ifdef GDK_WINDOWING_X11
+#include <X11/Xft/Xft.h>
+#include <pango/pangoxft.h>
+#include <gdk/x11/gdkx.h>
+#endif
+
enum {
PROP_0,
PROP_DOUBLE_CLICK_TIME,
@@ -53,7 +59,12 @@
PROP_MENU_BAR_ACCEL,
PROP_DND_DRAG_THRESHOLD,
PROP_FONT_NAME,
- PROP_ICON_SIZES
+ PROP_ICON_SIZES,
+ PROP_XFT_ANTIALIAS,
+ PROP_XFT_HINTING,
+ PROP_XFT_HINTSTYLE,
+ PROP_XFT_RGBA,
+ PROP_XFT_DPI
};
@@ -112,6 +123,85 @@
return settings_type;
}
+#ifdef GDK_WINDOWING_X11
+static void
+gtk_default_substitute (FcPattern *pattern,
+ gpointer data)
+{
+ GtkSettings *settings = data;
+ gint antialias;
+ gint hinting;
+ char *rgba;
+ char *hintstyle;
+ gint dpi;
+ FcValue v;
+
+ g_object_get (G_OBJECT (settings),
+ "gtk-xft-antialias", &antialias,
+ "gtk-xft-hinting", &hinting,
+ "gtk-xft-hintstyle", &hintstyle,
+ "gtk-xft-rgba", &rgba,
+ "gtk-xft-dpi", &dpi,
+ NULL);
+
+ if (antialias >= 0 &&
+ FcPatternGet (pattern, FC_ANTIALIAS, 0, &v) == FcResultNoMatch)
+ FcPatternAddBool (pattern, FC_ANTIALIAS, antialias != 0);
+
+ if (hinting >= 0 &&
+ FcPatternGet (pattern, FC_HINTING, 0, &v) == FcResultNoMatch)
+ FcPatternAddBool (pattern, FC_HINTING, hinting != 0);
+
+ if (hintstyle && FcPatternGet (pattern, FC_HINT_STYLE, 0, &v) == FcResultNoMatch)
+ {
+ int val = FC_HINT_FULL; /* Quiet GCC */
+ gboolean found = TRUE;
+
+ if (strcmp (hintstyle, "hintnone") == 0)
+ val = FC_HINT_NONE;
+ else if (strcmp (hintstyle, "hintslight") == 0)
+ val = FC_HINT_SLIGHT;
+ else if (strcmp (hintstyle, "hintmedium") == 0)
+ val = FC_HINT_MEDIUM;
+ else if (strcmp (hintstyle, "hintfull") == 0)
+ val = FC_HINT_FULL;
+ else
+ found = FALSE;
+
+ if (found)
+ FcPatternAddInteger (pattern, FC_HINT_STYLE, val);
+ }
+
+ if (rgba && FcPatternGet (pattern, FC_RGBA, 0, &v) == FcResultNoMatch)
+ {
+ int val = FC_RGBA_NONE; /* Quiet GCC */
+ gboolean found = TRUE;
+
+ if (strcmp (rgba, "none") == 0)
+ val = FC_RGBA_NONE;
+ else if (strcmp (rgba, "rgb") == 0)
+ val = FC_RGBA_RGB;
+ else if (strcmp (rgba, "bgr") == 0)
+ val = FC_RGBA_BGR;
+ else if (strcmp (rgba, "vrgb") == 0)
+ val = FC_RGBA_VRGB;
+ else if (strcmp (rgba, "vbgr") == 0)
+ val = FC_RGBA_VBGR;
+ else
+ found = FALSE;
+
+ if (found)
+ FcPatternAddInteger (pattern, FC_RGBA, val);
+ }
+
+ if (dpi >= 0 && FcPatternGet (pattern, FC_DPI, 0, &v) == FcResultNoMatch)
+ FcPatternAddDouble (pattern, FC_DPI, dpi / 1024.);
+
+ g_free (hintstyle);
+ g_free (rgba);
+}
+#endif /* GDK_WINDOWING_X11 */
+
static void
gtk_settings_init (GtkSettings *settings)
{
@@ -247,6 +337,58 @@
G_PARAM_READWRITE),
NULL);
g_assert (result == PROP_ICON_SIZES);
+
+#ifdef GDK_WINDOWING_X11
+ result = settings_install_property_parser (class,
+ g_param_spec_int ("gtk-xft-antialias",
+ _("Xft Antialias"),
+ _("Whether to antialias Xft fonts; 0=no, 1=yes, -1=default"),
+ -1, 1, -1,
+ G_PARAM_READWRITE),
+ NULL);
+
+ g_assert (result == PROP_XFT_ANTIALIAS);
+
+ result = settings_install_property_parser (class,
+ g_param_spec_int ("gtk-xft-hinting",
+ _("Xft Hinting"),
+ _("Whether to hint Xft fonts; 0=no, 1=yes, -1=default"),
+ -1, 1, -1,
+ G_PARAM_READWRITE),
+ NULL);
+
+ g_assert (result == PROP_XFT_HINTING);
+
+ result = settings_install_property_parser (class,
+ g_param_spec_string ("gtk-xft-hintstyle",
+ _("Xft Hint Style"),
+ _("What degree of hinting to use; none, slight, medium, or full"),
+ NULL,
+ G_PARAM_READWRITE),
+ NULL);
+
+ g_assert (result == PROP_XFT_HINTSTYLE);
+
+ result = settings_install_property_parser (class,
+ g_param_spec_string ("gtk-xft-rgba",
+ _("Xft RGBA"),
+ _("Type of subpixel antialiasing; none, rgb, bgr, vrgb, vbgr"),
+ NULL,
+ G_PARAM_READWRITE),
+ NULL);
+
+ g_assert (result == PROP_XFT_RGBA);
+
+ result = settings_install_property_parser (class,
+ g_param_spec_int ("gtk-xft-dpi",
+ _("Xft DPI"),
+ _("Resolution for Xft, in 1024 * dots/inch. -1 to use default value"),
+ -1, 1024*1024, -1,
+ G_PARAM_READWRITE),
+ NULL);
+
+ g_assert (result == PROP_XFT_DPI);
+#endif /* GDK_WINDOWING_X11 */
}
static void
@@ -288,7 +430,17 @@
{
settings = g_object_new (GTK_TYPE_SETTINGS, NULL);
settings->screen = screen;
- g_object_set_data (G_OBJECT (screen), "gtk-settings", settings);
+ g_object_set_data (G_OBJECT (screen), "gtk-settings", settings);
+
+#ifdef GDK_WINDOWING_X11
+ /* Set the default substitution function for the Pango fontmap.
+ */
+ pango_xft_set_default_substitute (GDK_SCREEN_XDISPLAY (screen),
+ GDK_SCREEN_XNUMBER (screen),
+ gtk_default_substitute,
+ settings, NULL);
+#endif /* GDK_WINDOWING_X11 */
+
gtk_rc_reparse_all_for_settings (settings, TRUE);
settings_update_double_click_time (settings);
}
@@ -413,6 +565,19 @@
case PROP_DOUBLE_CLICK_TIME:
settings_update_double_click_time (settings);
break;
+#ifdef GDK_WINDOWING_X11
+ case PROP_XFT_ANTIALIAS:
+ case PROP_XFT_HINTING:
+ case PROP_XFT_HINTSTYLE:
+ case PROP_XFT_RGBA:
+ case PROP_XFT_DPI:
+ pango_xft_substitute_changed (GDK_SCREEN_XDISPLAY (settings->screen),
+ GDK_SCREEN_XNUMBER (settings->screen));
+ /* See comments with _gtk_rc_reset_styles for why this is a hack
+ */
+ _gtk_rc_reset_styles (GTK_SETTINGS (object));
+ break;
+#endif /* GDK_WINDOWING_X11 */
}
}
|