ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/defaultfont.C
(Generate patch)

Comparing rxvt-unicode/src/defaultfont.C (file contents):
Revision 1.43 by pcg, Mon Mar 15 07:10:47 2004 UTC vs.
Revision 1.47 by pcg, Tue Mar 16 06:04:28 2004 UTC

200 XFillRectangle (d.display->display, d, TGC, x, y, w, h); 200 XFillRectangle (d.display->display, d, TGC, x, y, w, h);
201#endif 201#endif
202 } 202 }
203} 203}
204 204
205static const char *linedraw_cmds[128 + 32] = { 205#include "table/linedraw.h"
206 "1-", "2-", "1|", "2|",
207 0, 0, 0, 0,
208 0, 0, 0, 0,
209 "1HV", "2H1V", "1H2V", "2HV",
210
211 // 2510
212 "1hV", "2h1V", "1h2V", "2hV",
213 "1Hv", "2H1v", "1H2v", "2Hv",
214 "1hv", "2h1v", "1h2v", "2hv",
215 "1H|", "2H1|", "1HV2v", "1Hv2V",
216
217 // 2520
218 "1H2|", "2Hv1V", "2HV1v", "2H|",
219 "1h|", "2h1|", "1hV2v", "1hv2V",
220 "1h2|", "2hv1V", "1v2hV", "2h|",
221 "1-V", "2h1HV", "2H1hV", "2-1V",
222
223 // 2530
224 "1-2V", "2hV1H", "1h2HV", "2-V",
225 "1-v", "1vH2h", "1hv2H", "1v2-",
226 "1-2v", "1H2hv", "1h2Hv", "2-v",
227 "1-|", "1|H2h", "1h|2H", "1|2-",
228
229 // 2540
230 "1-V2v", "1-v2V", "1-2|", "1HV2hv",
231 "1hV2Hv", "1Hv2hV", "1hv2HV", "1V2-v",
232 "1v2-V", "1H2h|", "1h2H|", "2-|",
233 0, 0, 0, 0,
234
235 // 2550
236 0, 0, 0, 0,
237 0, 0, 0, 0,
238 0, 0, 0, 0,
239 0, 0, 0, 0,
240
241 // 2560
242 0, 0, 0, 0,
243 0, 0, 0, 0,
244 0, 0, 0, 0,
245 0, "A", "B", "C",
246
247 // 2570
248 "D", "1/", "1\\", "1/\\",
249 "1h", "1v", "1H", "1V",
250 "2h", "2v", "2H", "2V",
251 "1h2H", "1v2V", "1H2h", "1V2v",
252
253 // 2580
254 0, 0, 0, 0,
255 0, 0, 0, 0,
256 0, 0, 0, 0,
257 0, 0, 0, 0,
258
259 // 2590
260 0, 0, 0, 0,
261 0, 0, "k", "l",
262 "i", "ikl", "il", "ijk",
263 "ijl", "j", "jk", "jkl",
264
265 // to be done
266};
267 206
268struct rxvt_font_default : rxvt_font { 207struct rxvt_font_default : rxvt_font {
208
269 rxvt_fontprop properties () 209 rxvt_fontprop properties ()
270 { 210 {
271 rxvt_fontprop p; 211 rxvt_fontprop p;
272 212
273 p.width = p.height = 1; 213 p.width = p.height = 1;
280 bool load (const rxvt_fontprop &prop) 220 bool load (const rxvt_fontprop &prop)
281 { 221 {
282 width = 1; height = 1; 222 width = 1; height = 1;
283 ascent = 1; descent = 0; 223 ascent = 1; descent = 0;
284 224
285 set_name ("built-in pseudofont"); 225 set_name (strdup ("built-in pseudofont"));
286 226
287 return true; 227 return true;
288 } 228 }
289 229
290 bool has_codepoint (unicode_t unicode) 230 bool has_codepoint (unicode_t unicode)
293 return true; 233 return true;
294 234
295 if (unicode >= 0x0080 && unicode <= 0x009f) 235 if (unicode >= 0x0080 && unicode <= 0x009f)
296 return true; 236 return true;
297 237
298 if (unicode >= 0x2500 && unicode <= 0x257f
299 && linedraw_cmds[unicode - 0x2500])
300 return true;
301
302 if (unicode >= 0x2580 && unicode <= 0x259f) 238 if (unicode >= 0x2500 && unicode <= 0x259f)
303 return true; 239 return true;
304 240
305 if (IS_COMPOSE (unicode)) 241 if (IS_COMPOSE (unicode))
306 return true; 242 return true;
307 243
317 void draw (rxvt_drawable &d, int x, int y, 253 void draw (rxvt_drawable &d, int x, int y,
318 const text_t *text, int len, 254 const text_t *text, int len,
319 int fg, int bg); 255 int fg, int bg);
320}; 256};
321 257
322static void rect_stipple (Display *display, Drawable d, GC gc, int s1, int s2, int x, int y, int w, int h)
323{
324 XGCValues gcv;
325 char bm[2] = { s1, s2 };
326
327 gcv.fill_style = FillStippled;
328 gcv.stipple = XCreateBitmapFromData (display, d, bm, 2, 2);
329 gcv.ts_x_origin = x;
330 gcv.ts_y_origin = y;
331
332 if (!gcv.stipple)
333 return;
334
335 XChangeGC (display, gc, GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
336 XFillRectangle (display, d, gc, x, y, w, h);
337
338 XFreePixmap (display, gcv.stipple);
339
340 gcv.fill_style = FillSolid;
341 XChangeGC (display, gc, GCFillStyle, &gcv);
342}
343
344void 258void
345rxvt_font_default::draw (rxvt_drawable &d, int x, int y, 259rxvt_font_default::draw (rxvt_drawable &d, int x, int y,
346 const text_t *text, int len, 260 const text_t *text, int len,
347 int fg, int bg) 261 int fg, int bg)
348{ 262{
355#if ENABLE_COMBINING 269#if ENABLE_COMBINING
356 compose_char *cc; 270 compose_char *cc;
357#endif 271#endif
358 text_t t = *text++; 272 text_t t = *text++;
359 273
360 int W = r->TermWin.fwidth , w = (W - 1) / 2; 274 if (0x2500 <= t && t <= 0x259f)
275 {
276 uint16_t offs = linedraw_offs[t - 0x2500];
277 uint32_t *a = linedraw_command + (offs >> 4);
278 uint32_t *b = a + (offs & 15);
279
280 int W = r->TermWin.fwidth;
361 int H = r->TermWin.fheight, h = (H - 1) / 2; 281 int H = r->TermWin.fheight;
362 int x0 = x, x1 = x + w, x2 = x + r->TermWin.fwidth ;
363 int y0 = y, y1 = y + h, y2 = y + r->TermWin.fheight;
364 282
365 // is it in our linedrawing table? 283 int x_[16];
366 if (t >= 0x2500 & t <= 0x259f && linedraw_cmds[t - 0x2500]) 284 int y_[16];
285
286 for (int i = 0; i <= 8; i++)
367 { 287 {
368 const char *p = linedraw_cmds[t - 0x2500]; 288 x_[i] = x + ((W-1) * i + (i*7/8)) / 8;
289 y_[i] = y + ((H-1) * i + (i*7/8)) / 8;
290 }
291
292 x_[10] = x + (W - 1) / 2; x_[9] = x_[10] - 1; x_[11] = x_[10] + 1;
293 y_[10] = y + (H - 1) / 2; y_[9] = y_[10] - 1; y_[11] = y_[10] + 1;
369 294
370 XGCValues gcv; 295 XGCValues gcv;
371 296
372 gcv.cap_style = CapNotLast; 297 gcv.cap_style = CapButt;
298 gcv.line_width = 0;
373 XChangeGC (d.display->display, TGC, GCCapStyle, &gcv); 299 XChangeGC (d.display->display, TGC, GCLineWidth | GCCapStyle, &gcv);
374 300
375 while (*p) 301 while (a < b)
376 { 302 {
303 uint32_t command = *a++;
304
305 int op = (command >> 24) & 255;
306 int a = (command >> 20) & 15;
307 int b = (command >> 16) & 15;
308 int x1 = x_[(command >> 12) & 15];
309 int y1 = y_[(command >> 8) & 15];
310 int x2 = x_[(command >> 4) & 15];
311 int y2 = y_[(command >> 0) & 15];
312
377 switch (*p++) 313 switch (op)
378 { 314 {
379 case '1': 315 case 0: // line
380 gcv.line_width = 0; 316 XDrawLine (d.display->display, d, TGC, x1, y1, x2, y2);
381 XChangeGC (d.display->display, TGC, GCLineWidth, &gcv);
382 break; 317 break;
383 318
384 case '2': 319 case 1: // rectangle, possibly stippled
320 if (a)
321 {
322 static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 };
323
324 gcv.fill_style = FillStippled;
325 gcv.stipple = XCreateBitmapFromData (d.display->display, d, bm + a * 2, 2, 2);
326 gcv.ts_x_origin = x;
327 gcv.ts_y_origin = y;
328
329 XChangeGC (d.display->display, TGC,
330 GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin,
331 &gcv);
332 }
333
334 XFillRectangle (d.display->display, d, TGC, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
335
336 if (a)
337 {
338 XFreePixmap (d.display->display, gcv.stipple);
385 gcv.line_width = 3; 339 gcv.stipple = 0;
340 gcv.fill_style = FillSolid;
386 XChangeGC (d.display->display, TGC, GCLineWidth, &gcv); 341 XChangeGC (d.display->display, TGC, GCFillStyle, &gcv);
342 }
387 break; 343 break;
388 344 case 2: // arc
389 case 'h': XDrawLine (d.display->display, d, TGC, x0, y1, x1+1, y1 ); break; 345 XDrawArc (d.display->display, d, TGC,
390 case 'H': XDrawLine (d.display->display, d, TGC, x1, y1, x2 , y1 ); break; 346 x1 - W/2, y1 - H/2, W-1, H-1,
391 case '-': XDrawLine (d.display->display, d, TGC, x0, y1, x2 , y1 ); break; 347 (a - 1) * 90*64, (b - 1) * 90*64);
392 case 'v': XDrawLine (d.display->display, d, TGC, x1, y0, x1 , y1+1); break; 348 break;
393 case 'V': XDrawLine (d.display->display, d, TGC, x1, y1, x1 , y2 ); break;
394 case '|': XDrawLine (d.display->display, d, TGC, x1, y0, x1 , y2 ); break;
395
396 case '/' : XDrawLine (d.display->display, d, TGC, x0, y2, x2 , y0 ); break;
397 case '\\': XDrawLine (d.display->display, d, TGC, x0, y0, x2 , y2 ); break;
398
399 case 'A': XDrawArc (d.display->display, d, TGC, x1 , y1 , W-1, H-1, 90*64, 90*64); break;
400 case 'B': XDrawArc (d.display->display, d, TGC, x1-W+1, y1 , W-1, H-1, 0*64, 90*64); break;
401 case 'C': XDrawArc (d.display->display, d, TGC, x1-W+1, y1-H+1, W-1, H-1, 0*64, -90*64); break;
402 case 'D': XDrawArc (d.display->display, d, TGC, x1 , y1-H+1, W-1, H-1, -90*64, -90*64); break;
403
404 case 'i': XFillRectangle (d.display->display, d, TGC, x0, y0, x1 - x0 + 1, y1 - y0 + 1); break;
405 case 'j': XFillRectangle (d.display->display, d, TGC, x1, y0, x2 - x1, y1 - y0 + 1); break;
406 case 'k': XFillRectangle (d.display->display, d, TGC, x0, y1, x1 - x0 + 1, y2 - y1); break;
407 case 'l': XFillRectangle (d.display->display, d, TGC, x1, y1, x2 - x1, y2 - y1); break;
408 } 349 }
409 } 350 }
410
411 gcv.line_width = 0;
412 XChangeGC (d.display->display, TGC, GCLineWidth, &gcv);
413 } 351 }
414
415#if ENABLE_COMBINING 352#if ENABLE_COMBINING
416 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) 353 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t]))
417 { 354 {
418 rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)]; 355 rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)];
419 f1->draw (d, x, y, &(t = cc->c1), 1, fg, bg); 356 f1->draw (d, x, y, &(t = cc->c1), 1, fg, bg);
431 else 368 else
432 switch (t) 369 switch (t)
433 { 370 {
434 case ZERO_WIDTH_CHAR: 371 case ZERO_WIDTH_CHAR:
435 break; 372 break;
436
437 case 0x2580: XFillRectangle (d.display->display, d, TGC, x0, y0, W, y1 - y0 + 1); break;
438 case 0x2581: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 7 - 1) / 8, W, H - (H * 7 - 1) / 8); break;
439 case 0x2582: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 6 - 2) / 8, W, H - (H * 6 - 2) / 8); break;
440 case 0x2583: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 5 - 3) / 8, W, H - (H * 5 - 3) / 8); break;
441 case 0x2584: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 4 - 4) / 8, W, H - (H * 4 - 4) / 8); break;
442 case 0x2585: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 3 - 5) / 8, W, H - (H * 3 - 5) / 8); break;
443 case 0x2586: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 2 - 6) / 8, W, H - (H * 2 - 6) / 8); break;
444 case 0x2587: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 1 - 7) / 8, W, H - (H * 1 - 7) / 8); break;
445 case 0x2588: XFillRectangle (d.display->display, d, TGC, x0, y0, W, H); break;
446 case 0x2589: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 7 - 1) / 8, H); break;
447 case 0x258a: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 6 - 2) / 8, H); break;
448 case 0x258b: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 5 - 3) / 8, H); break;
449 case 0x258c: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 4 - 4) / 8, H); break;
450 case 0x258d: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 3 - 5) / 8, H); break;
451 case 0x258e: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 2 - 6) / 8, H); break;
452 case 0x258f: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 1 - 7) / 8, H); break;
453 case 0x2590: XFillRectangle (d.display->display, d, TGC, x1, y0, x2 - x1, H); break;
454
455 case 0x2591: rect_stipple (d.display->display, d, TGC, 0x00, 0x01, x0, y0, W, H); break;
456 case 0x2592: rect_stipple (d.display->display, d, TGC, 0x02, 0x01, x0, y0, W, H); break;
457 case 0x2593: rect_stipple (d.display->display, d, TGC, 0x01, 0x03, x0, y0, W, H); break;
458
459 case 0x2594: XFillRectangle (d.display->display, d, TGC, x0, y0, W, (H * 1 - 7) / 8); break;
460 case 0x2595: XFillRectangle (d.display->display, d, TGC, x0 + (W * 7 - 1) / 8, y0, W - (W * 7 - 1) / 8, H); break;
461 373
462 default: 374 default:
463 int w = 0; 375 int w = 0;
464 while (len > 0 && *text == NOCHAR) 376 while (len > 0 && *text == NOCHAR)
465 { 377 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines