File: xterm-146-dw-patch

package info (click to toggle)
qemacs 0.3.1-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,040 kB
  • ctags: 3,226
  • sloc: ansic: 29,371; sh: 353; makefile: 338
file content (79 lines) | stat: -rw-r--r-- 2,345 bytes parent folder | download | duplicates (3)
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
--- xterm-146/fontutils.c	Mon Sep 11 11:35:21 2000
+++ xterm-146-w/fontutils.c	Tue Oct 24 01:07:37 2000
@@ -469,8 +469,17 @@
 static int
 is_fixed_font(XFontStruct *fs)
 {
-	return (fs->min_bounds.width == fs->max_bounds.width
-	   &&   fs->min_bounds.width == fs->min_bounds.width);
+	return (fs->min_bounds.width == fs->max_bounds.width);
+}
+
+/*
+ * Check if the font looks like a double width font (i.e. contains
+ * characters of width X and 2X
+ */
+static int
+is_double_width_font(XFontStruct *fs)
+{
+	return (2 * fs->min_bounds.width == fs->max_bounds.width);
 }
 
 #define EmptyFont(fs) ((fs)->ascent + (fs)->descent == 0 \
@@ -518,7 +527,7 @@
 	if (!(nfs = XLoadQueryFont (screen->display, nfontname))) goto bad;
 	if (EmptyFont(nfs))
 		goto bad;		/* can't use a 0-sized font */
-
+        
 
 	strcpy(normal, nfontname);
 	if (bfontname == 0) {
@@ -550,7 +559,7 @@
 	 * fonts for 9x18 and 6x13.
 	 */
 	if_OPT_WIDE_CHARS(screen, {
-		if (wfontname == 0) {
+		if (wfontname == 0 && !is_double_width_font(nfs)) {
 			fp = get_font_name_props(screen->display, nfs, normal);
 			if (fp != 0) {
 				wfontname = wide_font_name(fp);
@@ -593,13 +602,20 @@
 		}
 	}
 
+
+        /*
+         * We accept that the normal font is a double width font (such
+         * as the GNU unifont, so that we do not need to use the -fw
+         * option 
+         */
+        if (is_double_width_font(nfs)) {
+            wfs = nfs;
+        } else if (!is_fixed_font(nfs)
+                   || !is_fixed_font(bfs)
+                   || nfs->max_bounds.width != bfs->max_bounds.width) {
 	/*
 	 * Normal/bold fonts should be the same width.  Also, the min/max
-	 * values should be the same.
-	 */
-	if (!is_fixed_font(nfs)
-	 || !is_fixed_font(bfs)
-	 || nfs->max_bounds.width != bfs->max_bounds.width) {
+	 * values should be the same.  */
 		TRACE(("Proportional font! normal %d/%d, bold %d/%d\n",
 			nfs->min_bounds.width,
 			nfs->max_bounds.width,
@@ -770,7 +786,11 @@
 {
 	int i, j, width, height;
 
-	win->f_width  = (font->max_bounds.width);
+        if (is_double_width_font(font)) {
+            win->f_width  = (font->min_bounds.width);
+        } else {
+            win->f_width  = (font->max_bounds.width);
+        }
 	win->f_height = (font->ascent + font->descent);
 	i = 2 * screen->border + sbwidth;
 	j = 2 * screen->border;