24141
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
1 /* Implementation of BDF font handling on the Microsoft W32 API.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
2 Copyright (C) 1999 Free Software Foundation, Inc.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
3
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
4 This file is part of GNU Emacs.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
5
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
7 it under the terms of the GNU General Public License as published by
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
9 any later version.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
10
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
14 GNU General Public License for more details.
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
15
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
16 You should have received a copy of the GNU General Public License
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
19 Boston, MA 02111-1307, USA. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
20
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
21 /* Based heavily on code by H. Miyashita for Meadow (a descendant of
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
22 MULE for W32). */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
23
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
24 #include <windows.h>
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
25 #include "config.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
26 #include "lisp.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
27 #include "charset.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
28 #include "fontset.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
29 #include "blockinput.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
30 #include "w32gui.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
31 #include "w32term.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
32 #include "w32bdf.h"
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
33
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
34 #define min(a, b) ((a) < (b) ? (a) : (b))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
35 #define max(a, b) ((a) > (b) ? (a) : (b))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
36
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
37 void w32_free_bdf_font(bdffont *fontp);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
38 bdffont *w32_init_bdf_font(char *filename);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
39
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
40 static int
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
41 search_file_line(char *key, char *start, int len, char **val, char **next)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
42 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
43 int linelen;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
44 unsigned char *p, *q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
45
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
46 p = memchr(start, '\n', len);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
47 if (!p) return -1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
48 for (;start < p;start++)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
49 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
50 if ((*start != ' ') || (*start != '\t')) break;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
51 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
52 linelen = p - start + 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
53 *next = p + 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
54 if (strncmp(start, key, min(strlen(key), linelen)) == 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
55 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
56 *val = start + strlen(key);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
57 return 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
58 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
59
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
60 return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
61 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
62
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
63 static int
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
64 proceed_file_line(char *key, char *start, int *len, char **val, char **next)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
65 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
66 int flag = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
67
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
68 do {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
69 flag = search_file_line(key, start, *len, val, next);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
70 *len -= (int)(*next - start);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
71 start = *next;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
72 }while(flag == 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
73
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
74 if (flag == -1) return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
75 return 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
76 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
77
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
78 static int
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
79 set_bdf_font_info(bdffont *fontp)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
80 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
81 unsigned char *start, *p, *q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
82 int len, flag;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
83 int bbw, bbh, bbx, bby;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
84 int val1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
85
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
86 len = fontp->size;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
87 start = fontp->font;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
88
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
89 fontp->yoffset = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
90 fontp->relative_compose = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
91 fontp->default_ascent = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
92
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
93 flag = proceed_file_line("FONTBOUNDINGBOX", start, &len, &p, &q);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
94 if (!flag) return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
95 bbw = strtol(p, &start, 10);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
96 p = start;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
97 bbh = strtol(p, &start, 10);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
98 p = start;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
99 bbx = strtol(p, &start, 10);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
100 p = start;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
101 bby = strtol(p, &start, 10);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
102
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
103 fontp->llx = bbx;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
104 fontp->lly = bby;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
105 fontp->urx = bbw + bbx;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
106 fontp->ury = bbh + bby;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
107 fontp->width = bbw;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
108 fontp->height = bbh;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
109 start = q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
110 flag = proceed_file_line("STARTPROPERTIES", start, &len, &p, &q);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
111 if (!flag) return 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
112
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
113 do {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
114 start = q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
115 if (search_file_line("PIXEL_SIZE", start, len, &p, &q) == 1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
116 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
117 val1 = atoi(p);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
118 fontp->pixsz = val1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
119 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
120 else if (search_file_line("FONT_ASCENT", start, len, &p, &q) == 1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
121 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
122 val1 = atoi(p);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
123 fontp->ury = val1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
124 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
125 else if (search_file_line("FONT_DESCENT", start, len, &p, &q) == 1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
126 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
127 val1 = atoi(p);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
128 fontp->lly = -val1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
129 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
130 else if (search_file_line("_MULE_BASELINE_OFFSET", start, len, &p, &q) == 1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
131 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
132 val1 = atoi(p);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
133 fontp->yoffset = val1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
134 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
135 else if (search_file_line("_MULE_RELATIVE_COMPOSE", start, len, &p, &q) == 1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
136 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
137 val1 = atoi(p);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
138 fontp->relative_compose = val1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
139 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
140 else if (search_file_line("_MULE_DEFAULT_ASCENT", start, len, &p, &q) == 1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
141 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
142 val1 = atoi(p);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
143 fontp->default_ascent = val1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
144 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
145 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
146 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
147 flag = search_file_line("ENDPROPERTIES", start, len, &p, &q);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
148 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
149 if (flag == -1) return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
150 len -= (q - start);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
151 }while(flag == 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
152 start = q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
153 flag = proceed_file_line("CHARS", start, &len, &p, &q);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
154 if (!flag) return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
155 fontp->seeked = q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
156
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
157 return 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
158 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
159
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
160 bdffont*
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
161 w32_init_bdf_font(char *filename)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
162 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
163 HANDLE hfile, hfilemap;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
164 bdffont *bdffontp;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
165 unsigned char *font;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
166 BY_HANDLE_FILE_INFORMATION fileinfo;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
167 int i;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
168
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
169 hfile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
170 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
171 if (hfile == INVALID_HANDLE_VALUE) return NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
172 if (!GetFileInformationByHandle(hfile, &fileinfo) ||
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
173 (fileinfo.nFileSizeHigh != 0) ||
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
174 (fileinfo.nFileSizeLow > BDF_FILE_SIZE_MAX))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
175 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
176 CloseHandle(hfile);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
177 error("Fail to open BDF file.");
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
178 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
179 hfilemap = CreateFileMapping(hfile, NULL, PAGE_READONLY, 0, 0, NULL);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
180 if (hfilemap == INVALID_HANDLE_VALUE)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
181 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
182 CloseHandle(hfile);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
183 error("Can't map font.");
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
184 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
185
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
186 font = MapViewOfFile(hfilemap, FILE_MAP_READ, 0, 0, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
187
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
188 if (!font)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
189 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
190 CloseHandle(hfile);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
191 CloseHandle(hfilemap);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
192 error("Can't view font.");
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
193 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
194
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
195 bdffontp = (bdffont *) xmalloc(sizeof(bdffont));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
196
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
197 for(i = 0;i < BDF_FIRST_OFFSET_TABLE;i++)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
198 bdffontp->offset[i] = NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
199 bdffontp->size = fileinfo.nFileSizeLow;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
200 bdffontp->font = font;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
201 bdffontp->hfile = hfile;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
202 bdffontp->hfilemap = hfilemap;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
203 bdffontp->filename = (char*) xmalloc(strlen(filename) + 1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
204 strcpy(bdffontp->filename, filename);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
205
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
206 if (!set_bdf_font_info(bdffontp))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
207 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
208 w32_free_bdf_font(bdffontp);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
209 error("Invalid BDF font!");
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
210 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
211 return bdffontp;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
212 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
213
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
214 void
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
215 w32_free_bdf_font(bdffont *fontp)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
216 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
217 int i;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
218
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
219 UnmapViewOfFile(fontp->hfilemap);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
220 CloseHandle(fontp->hfilemap);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
221 CloseHandle(fontp->hfile);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
222 xfree(fontp->filename);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
223 for(i = 0;i < BDF_FIRST_OFFSET_TABLE;i++)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
224 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
225 if (fontp->offset[i]) xfree(fontp->offset[i]);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
226 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
227 xfree(fontp);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
228 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
229
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
230 static unsigned char*
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
231 get_cached_char_offset(bdffont *fontp, int index)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
232 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
233 unsigned char **offset1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
234 unsigned char *offset2;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
235 int i;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
236
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
237 if (index > 0xffff)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
238 return NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
239
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
240 offset1 = fontp->offset[BDF_FIRST_OFFSET(index)];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
241 if (!offset1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
242 return NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
243 offset2 = offset1[BDF_SECOND_OFFSET(index)];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
244
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
245 if (offset2) return offset2;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
246
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
247 return NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
248 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
249
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
250 static void
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
251 cache_char_offset(bdffont *fontp, int index, unsigned char *offset)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
252 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
253 unsigned char **offset1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
254 int i;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
255
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
256 if (index > 0xffff)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
257 return;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
258
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
259 offset1 = fontp->offset[BDF_FIRST_OFFSET(index)];
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
260 if (!offset1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
261 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
262 offset1 = fontp->offset[BDF_FIRST_OFFSET(index)] =
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
263 (unsigned char **) xmalloc(sizeof(unsigned char*) *
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
264 BDF_SECOND_OFFSET_TABLE);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
265 memset(offset1, 0, sizeof(unsigned char*) * BDF_SECOND_OFFSET_TABLE);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
266 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
267 offset1[BDF_SECOND_OFFSET(index)] = offset;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
268
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
269 return;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
270 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
271
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
272 static unsigned char*
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
273 seek_char_offset(bdffont *fontp, int index)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
274 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
275 int len, flag, font_index;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
276 unsigned char *start, *p, *q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
277
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
278 if (!fontp->seeked) return NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
279
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
280 start = fontp->seeked;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
281 len = fontp->size - (start - fontp->font);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
282
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
283 do {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
284 flag = proceed_file_line("ENCODING", start, &len, &p, &q);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
285 if (!flag)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
286 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
287 fontp->seeked = NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
288 return NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
289 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
290 font_index = atoi(p);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
291 cache_char_offset(fontp, font_index, q);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
292 start = q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
293 } while (font_index != index);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
294 fontp->seeked = q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
295
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
296 return q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
297 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
298
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
299 #define GET_HEX_VAL(x) ((isdigit(x)) ? ((x) - '0') : \
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
300 (((x) >= 'A') && ((x) <= 'Z')) ? ((x) - 'A' + 10) : \
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
301 (((x) >= 'a') && ((x) <= 'z')) ? ((x) - 'a' + 10) : \
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
302 (-1))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
303
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
304 int
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
305 w32_get_bdf_glyph(bdffont *fontp, int index, int size, glyph_struct *glyph)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
306 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
307 unsigned char *start, *p, *q, *bitmapp;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
308 unsigned char val1, val2;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
309 int i, j, len, flag;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
310
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
311 start = get_cached_char_offset(fontp, index);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
312 if (!start)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
313 start = seek_char_offset(fontp, index);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
314 if (!start)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
315 return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
316
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
317 len = fontp->size - (start - fontp->font);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
318
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
319 flag = proceed_file_line("DWIDTH", start, &len, &p, &q);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
320 if (!flag)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
321 return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
322 glyph->dwidth = atoi(p);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
323
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
324 start = q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
325 flag = proceed_file_line("BBX", start, &len, &p, &q);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
326 if (!flag)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
327 return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
328 glyph->bbw = strtol(p, &start, 10);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
329 p = start;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
330 glyph->bbh = strtol(p, &start, 10);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
331 p = start;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
332 glyph->bbox = strtol(p, &start, 10);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
333 p = start;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
334 glyph->bboy = strtol(p, &start, 10);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
335
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
336 if (size == 0) return 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
337
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
338 start = q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
339 flag = proceed_file_line("BITMAP", start, &len, &p, &q);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
340 if (!flag)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
341 return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
342
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
343 p = q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
344 bitmapp = glyph->bitmap;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
345 for(i = 0;i < glyph->bbh;i++)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
346 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
347 q = memchr(p, '\n', len);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
348 if (!q) return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
349 for(j = 0;((q > p) && (j < ((glyph->bbw + 7) / 8 )));j++)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
350 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
351 val1 = GET_HEX_VAL(*p);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
352 if (val1 == -1) return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
353 p++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
354 val2 = GET_HEX_VAL(*p);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
355 if (val2 == -1) return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
356 p++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
357 size--;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
358 if (size <= 0) return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
359 /* NAND Operation. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
360 *bitmapp++ = (unsigned char)~((val1 << 4) | val2);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
361 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
362 /* CreateBitmap requires WORD alignment. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
363 if (j % 2)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
364 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
365 *bitmapp++ = 0xff;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
366 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
367 p = q + 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
368 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
369
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
370 return 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
371 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
372
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
373 int
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
374 w32_BDF_TextOut(bdffont *fontp, HDC hdc, int left,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
375 int top, unsigned char *text, int dim, int bytelen,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
376 int fixed_pitch_size)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
377 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
378 int bitmap_size, index, btop;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
379 unsigned char *textp;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
380 glyph_struct glyph;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
381 HDC hCompatDC = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
382 HBITMAP hBMP;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
383 HBRUSH hFgBrush, hOrgBrush;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
384 HANDLE holdobj, horgobj = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
385 UINT textalign;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
386 int flag = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
387
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
388 bitmap_size = ((fontp->urx - fontp->llx) / 8 + 2) * (fontp->ury - fontp->lly)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
389 + 256;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
390
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
391 glyph.bitmap = (unsigned char*) alloca(sizeof(unsigned char) * bitmap_size);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
392
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
393 hCompatDC = CreateCompatibleDC(hdc);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
394
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
395 textalign = GetTextAlign(hdc);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
396
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
397 SaveDC(hdc);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
398
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
399 hFgBrush = CreateSolidBrush(GetTextColor(hdc));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
400 hOrgBrush = SelectObject(hdc, hFgBrush);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
401 SetTextColor(hdc, RGB(0, 0, 0));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
402 SetBkColor(hdc, RGB(0xff, 0xff, 0xff));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
403
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
404 textp = text;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
405 while(bytelen > 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
406 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
407 if (dim == 1)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
408 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
409 index = *textp++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
410 bytelen--;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
411 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
412 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
413 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
414 bytelen -= 2;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
415 if (bytelen < 0) break;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
416 index = MAKELENDSHORT(textp[1], textp[0]);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
417 textp += 2;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
418 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
419 if (!w32_get_bdf_glyph(fontp, index, bitmap_size, &glyph))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
420 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
421 if (horgobj)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
422 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
423 SelectObject(hCompatDC, horgobj);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
424 DeleteObject(hBMP);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
425 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
426 DeleteDC(hCompatDC);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
427 return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
428 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
429 hBMP = CreateBitmap(glyph.bbw, glyph.bbh, 1, 1, glyph.bitmap);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
430 if (textalign & TA_BASELINE)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
431 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
432 btop = top - (glyph.bbh + glyph.bboy);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
433 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
434 else if (textalign & TA_BOTTOM)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
435 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
436 btop = top - glyph.bbh;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
437 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
438 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
439 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
440 btop = top;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
441 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
442
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
443 if (horgobj)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
444 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
445 SelectObject(hCompatDC, hBMP);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
446 DeleteObject(holdobj);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
447 holdobj = hBMP;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
448 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
449 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
450 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
451 horgobj = SelectObject(hCompatDC, hBMP);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
452 holdobj = hBMP;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
453 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
454 #if 0
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
455 BitBlt(hdc, left, btop, glyph.bbw, glyph.bbh, hCompatDC, 0, 0, SRCCOPY);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
456 #else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
457 BitBlt(hdc, left, btop, glyph.bbw, glyph.bbh, hCompatDC, 0, 0, 0xB8074A);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
458 #endif
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
459 if (fixed_pitch_size)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
460 left += fixed_pitch_size;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
461 else
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
462 left += glyph.dwidth;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
463 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
464 SelectObject(hCompatDC, horgobj);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
465 SelectObject(hdc, hOrgBrush);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
466 DeleteObject(hFgBrush);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
467 DeleteObject(hBMP);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
468 DeleteDC(hCompatDC);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
469 RestoreDC(hdc, -1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
470
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
471 return 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
472 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
473
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
474 struct font_info *w32_load_bdf_font (struct frame *f, char *fontname,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
475 int size, char* filename)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
476 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
477 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
478 struct font_info *fontp;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
479 XFontStruct *font;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
480 bdffont* bdf_font;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
481
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
482 bdf_font = w32_init_bdf_font (filename);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
483
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
484 if (!bdf_font) return NULL;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
485
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
486 font = (XFontStruct *) xmalloc (sizeof (XFontStruct));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
487
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
488 font->bdf = bdf_font;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
489 font->hfont = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
490
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
491 /* Do we need to create the table? */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
492 if (dpyinfo->font_table_size == 0)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
493 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
494 dpyinfo->font_table_size = 16;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
495 dpyinfo->font_table
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
496 = (struct font_info *) xmalloc (dpyinfo->font_table_size
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
497 * sizeof (struct font_info));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
498 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
499 /* Do we need to grow the table? */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
500 else if (dpyinfo->n_fonts
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
501 >= dpyinfo->font_table_size)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
502 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
503 dpyinfo->font_table_size *= 2;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
504 dpyinfo->font_table
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
505 = (struct font_info *) xrealloc (dpyinfo->font_table,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
506 (dpyinfo->font_table_size
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
507 * sizeof (struct font_info)));
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
508 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
509
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
510 fontp = dpyinfo->font_table + dpyinfo->n_fonts;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
511
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
512 /* Now fill in the slots of *FONTP. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
513 BLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
514 fontp->font = font;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
515 fontp->font_idx = dpyinfo->n_fonts;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
516 fontp->name = (char *) xmalloc (strlen (fontname) + 1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
517 bcopy (fontname, fontp->name, strlen (fontname) + 1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
518 fontp->full_name = fontp->name;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
519 fontp->size = FONT_WIDTH (font);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
520 fontp->height = FONT_HEIGHT (font);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
521
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
522 /* The slot `encoding' specifies how to map a character
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
523 code-points (0x20..0x7F or 0x2020..0x7F7F) of each charset to
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
524 the font code-points (0:0x20..0x7F, 1:0xA0..0xFF, 0:0x2020..0x7F7F,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
525 the font code-points (0:0x20..0x7F, 1:0xA0..0xFF,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
526 0:0x2020..0x7F7F, 1:0xA0A0..0xFFFF, 3:0x20A0..0x7FFF, or
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
527 2:0xA020..0xFF7F). For the moment, we don't know which charset
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
528 uses this font. So, we set informatoin in fontp->encoding[1]
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
529 which is never used by any charset. If mapping can't be
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
530 decided, set FONT_ENCODING_NOT_DECIDED. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
531 fontp->encoding[1] = FONT_ENCODING_NOT_DECIDED;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
532 fontp->baseline_offset = bdf_font->yoffset;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
533 fontp->relative_compose = bdf_font->relative_compose;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
534 fontp->default_ascent = bdf_font->default_ascent;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
535
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
536 UNBLOCK_INPUT;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
537 dpyinfo->n_fonts++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
538 return fontp;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
539 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
540
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
541 /* Check a file for an XFLD string describing it. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
542 int w32_BDF_to_x_font (char *file, char* xstr, int len)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
543 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
544 HANDLE hfile, hfilemap;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
545 BY_HANDLE_FILE_INFORMATION fileinfo;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
546 unsigned char *font, *start, *p, *q;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
547 int flag, size, retval = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
548
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
549 hfile = CreateFile (file, GENERIC_READ, FILE_SHARE_READ, NULL,
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
550 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
551 if (hfile == INVALID_HANDLE_VALUE) return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
552 if (!GetFileInformationByHandle(hfile, &fileinfo) ||
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
553 (fileinfo.nFileSizeHigh != 0) ||
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
554 (fileinfo.nFileSizeLow > BDF_FILE_SIZE_MAX))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
555 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
556 CloseHandle (hfile);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
557 return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
558 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
559 size = fileinfo.nFileSizeLow;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
560
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
561 hfilemap = CreateFileMapping (hfile, NULL, PAGE_READONLY, 0, 0, NULL);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
562 if (hfilemap == INVALID_HANDLE_VALUE)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
563 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
564 CloseHandle (hfile);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
565 return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
566 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
567
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
568 font = MapViewOfFile (hfilemap, FILE_MAP_READ, 0, 0, 0);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
569 if (!font)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
570 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
571 CloseHandle (hfile);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
572 CloseHandle (hfilemap);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
573 return 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
574 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
575 start = font;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
576
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
577 flag = proceed_file_line ("FONT ", start, &size, &p, &q);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
578 if (flag)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
579 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
580 /* If font provides a description of itself, check it is a
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
581 full XLFD before accepting it. */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
582 int count = 0;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
583 char *s;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
584
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
585 for (s = p; s < q; s++)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
586 if (*s == '\n')
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
587 break;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
588 else if (*s == '-')
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
589 count++;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
590 if (count == 14 && q - p - 1 <= len)
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
591 {
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
592 strncpy (xstr, p, q-p-1);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
593 xstr[q-p-1] = '\0';
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
594 /* Files may have DOS line ends (ie still ^M on end). */
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
595 if (iscntrl(xstr[q-p-2]))
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
596 xstr[q-p-2] = '\0';
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
597
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
598 retval = 1;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
599 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
600 }
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
601 CloseHandle (hfile);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
602 CloseHandle (hfilemap);
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
603 return retval;
|
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff
changeset
|
604 }
|