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.44 by pcg, Tue Mar 16 04:52:20 2004 UTC vs.
Revision 1.45 by pcg, Tue Mar 16 05:51:36 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
205#include "table/linedraw.h"
206
205struct rxvt_font_default : rxvt_font { 207struct rxvt_font_default : rxvt_font {
208
206 rxvt_fontprop properties () 209 rxvt_fontprop properties ()
207 { 210 {
208 rxvt_fontprop p; 211 rxvt_fontprop p;
209 212
210 p.width = p.height = 1; 213 p.width = p.height = 1;
217 bool load (const rxvt_fontprop &prop) 220 bool load (const rxvt_fontprop &prop)
218 { 221 {
219 width = 1; height = 1; 222 width = 1; height = 1;
220 ascent = 1; descent = 0; 223 ascent = 1; descent = 0;
221 224
222 set_name ("built-in pseudofont"); 225 set_name (strdup ("built-in pseudofont"));
223 226
224 return true; 227 return true;
225 } 228 }
226 229
227 bool has_codepoint (unicode_t unicode) 230 bool has_codepoint (unicode_t unicode)
230 return true; 233 return true;
231 234
232 if (unicode >= 0x0080 && unicode <= 0x009f) 235 if (unicode >= 0x0080 && unicode <= 0x009f)
233 return true; 236 return true;
234 237
235 if (unicode >= 0x2500 && unicode <= 0x259f) 238 if (unicode >= 0x2500 && unicode <= 0x259f
239 && linedraw_offs[unicode - 0x2500] & 15)
236 return true; 240 return true;
237 241
238 if (IS_COMPOSE (unicode)) 242 if (IS_COMPOSE (unicode))
239 return true; 243 return true;
240 244
250 void draw (rxvt_drawable &d, int x, int y, 254 void draw (rxvt_drawable &d, int x, int y,
251 const text_t *text, int len, 255 const text_t *text, int len,
252 int fg, int bg); 256 int fg, int bg);
253}; 257};
254 258
255static void rect_stipple (Display *display, Drawable d, GC gc, int s1, int s2, int x, int y, int w, int h)
256{
257 XGCValues gcv;
258 char bm[2] = { s1, s2 };
259
260 gcv.fill_style = FillStippled;
261 gcv.stipple = XCreateBitmapFromData (display, d, bm, 2, 2);
262 gcv.ts_x_origin = x;
263 gcv.ts_y_origin = y;
264
265 if (!gcv.stipple)
266 return;
267
268 XChangeGC (display, gc, GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
269 XFillRectangle (display, d, gc, x, y, w, h);
270
271 XFreePixmap (display, gcv.stipple);
272
273 gcv.fill_style = FillSolid;
274 XChangeGC (display, gc, GCFillStyle, &gcv);
275}
276
277#include "table/linedraw.h"
278
279void 259void
280rxvt_font_default::draw (rxvt_drawable &d, int x, int y, 260rxvt_font_default::draw (rxvt_drawable &d, int x, int y,
281 const text_t *text, int len, 261 const text_t *text, int len,
282 int fg, int bg) 262 int fg, int bg)
283{ 263{
264return;
284 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); 265 clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg);
285 266
286 XSetForeground (d.display->display, TGC, r->PixColors[fg]); 267 XSetForeground (d.display->display, TGC, r->PixColors[fg]);
287 268
288 while (len--) 269 while (len--)
289 { 270 {
290#if ENABLE_COMBINING 271#if ENABLE_COMBINING
291 compose_char *cc; 272 compose_char *cc;
292#endif 273#endif
293 text_t t = *text++; 274 text_t t = *text++;
294
295 int x_[16];
296 int y_[16];
297 275
298 int W = r->TermWin.fwidth , w = (W - 1) / 2; 276 int W = r->TermWin.fwidth , w = (W - 1) / 2;
299 int H = r->TermWin.fheight, h = (H - 1) / 2; 277 int H = r->TermWin.fheight, h = (H - 1) / 2;
300 int x0 = x, x1 = x + w, x2 = x + r->TermWin.fwidth ; 278 int x0 = x, x1 = x + w, x2 = x + r->TermWin.fwidth ;
301 int y0 = y, y1 = y + h, y2 = y + r->TermWin.fheight; 279 int y0 = y, y1 = y + h, y2 = y + r->TermWin.fheight;
302 280
281 if (0x2500 <= t && t <= 0x259f
282 && linedraw_offs[t - 0x2500] & 15)
283 {
284 uint16_t offs = linedraw_offs[t - 0x2500];
285 uint32_t *a = linedraw_command + (offs >> 4);
286 uint32_t *b = a + (offs & 15);
287
288 int x_[16];
289 int y_[16];
290
303 for (int i = 0; i <= 8; i++) 291 for (int i = 0; i <= 8; i++)
304 {
305 x_[i] = x + ((W-1) * i + (i*7/8)) / 8;
306 y_[i] = y + ((H-1) * i + (i*7/8)) / 8;
307 }
308
309 x_[10] = x + (W - 1) / 2; x_[9] = x_[10] - 1; x_[11] = x_[10] + 1;
310 y_[10] = y + (H - 1) / 2; y_[9] = y_[10] - 1; y_[11] = y_[10] + 1;
311
312 int i1 = linedraw_offs[t - 0x2500];
313 int i2 = linedraw_offs[t - 0x2500 + 1];
314
315 XGCValues gcv;
316
317 gcv.cap_style = CapButt;
318 gcv.line_width = 0;
319 XChangeGC (d.display->display, TGC, GCLineWidth | GCCapStyle, &gcv);
320
321 if (i1 != i2)
322 {
323 while (i1 < i2)
324 { 292 {
293 x_[i] = x + ((W-1) * i + (i*7/8)) / 8;
294 y_[i] = y + ((H-1) * i + (i*7/8)) / 8;
295 }
296
297 x_[10] = x + (W - 1) / 2; x_[9] = x_[10] - 1; x_[11] = x_[10] + 1;
298 y_[10] = y + (H - 1) / 2; y_[9] = y_[10] - 1; y_[11] = y_[10] + 1;
299
300 XGCValues gcv;
301
302 gcv.cap_style = CapButt;
303 gcv.line_width = 0;
304 XChangeGC (d.display->display, TGC, GCLineWidth | GCCapStyle, &gcv);
305
306 while (a < b)
307 {
325 uint32_t command = linedraw_command [i1++]; 308 uint32_t command = *a++;
326 309
327 int op = (command >> 24) & 255; 310 int op = (command >> 24) & 255;
328 int a = (command >> 20) & 15; 311 int a = (command >> 20) & 15;
329 int b = (command >> 16) & 15; 312 int b = (command >> 16) & 15;
330 int x1 = x_[(command >> 12) & 15]; 313 int x1 = x_[(command >> 12) & 15];
339 break; 322 break;
340 323
341 case 1: // rectangle, possibly stippled 324 case 1: // rectangle, possibly stippled
342 if (a) 325 if (a)
343 { 326 {
344 static char bm[] = { 0,0 , 1,3 , 2,1 , 0,1 }; 327 static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 };
345 328
346 gcv.fill_style = FillStippled; 329 gcv.fill_style = FillStippled;
347 gcv.stipple = XCreateBitmapFromData (d.display->display, d, bm + a * 2, 2, 2); 330 gcv.stipple = XCreateBitmapFromData (d.display->display, d, bm + a * 2, 2, 2);
348 gcv.ts_x_origin = x; 331 gcv.ts_x_origin = x;
349 gcv.ts_y_origin = y; 332 gcv.ts_y_origin = y;
357 XFillRectangle (d.display->display, d, TGC, x1, y1, x2 - x1 + 1, y2 - y1 + 1); 340 XFillRectangle (d.display->display, d, TGC, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
358 341
359 if (a) 342 if (a)
360 { 343 {
361 XFreePixmap (d.display->display, gcv.stipple); 344 XFreePixmap (d.display->display, gcv.stipple);
345 gcv.stipple = 0;
362 gcv.fill_style = FillSolid; 346 gcv.fill_style = FillSolid;
363 XChangeGC (d.display->display, TGC, GCFillStyle, &gcv); 347 XChangeGC (d.display->display, TGC, GCFillStyle, &gcv);
364 } 348 }
365 349
366 break; 350 break;
367 case 2: // arc 351 case 2: // arc
352 XDrawArc (d.display->display, d, TGC,
353 x1 - W/2, y1 - H/2, W-1, H-1,
354 (a - 1) * 90*64, (b - 1) * 90*64);
368 break; 355 break;
369 } 356 }
370 } 357 }
371
372#if 0
373 case 'A': XDrawArc (d.display->display, d, TGC, x1 , y1 , W-1, H-1, 90*64, 90*64); break;
374 case 'B': XDrawArc (d.display->display, d, TGC, x1-W+1, y1 , W-1, H-1, 0*64, 90*64); break;
375 case 'C': XDrawArc (d.display->display, d, TGC, x1-W+1, y1-H+1, W-1, H-1, 0*64, -90*64); break;
376 case 'D': XDrawArc (d.display->display, d, TGC, x1 , y1-H+1, W-1, H-1, -90*64, -90*64); break;
377
378 case 'i': XFillRectangle (d.display->display, d, TGC, x0, y0, x1 - x0 + 1, y1 - y0 + 1); break;
379 case 'j': XFillRectangle (d.display->display, d, TGC, x1, y0, x2 - x1, y1 - y0 + 1); break;
380 case 'k': XFillRectangle (d.display->display, d, TGC, x0, y1, x1 - x0 + 1, y2 - y1); break;
381 case 'l': XFillRectangle (d.display->display, d, TGC, x1, y1, x2 - x1, y2 - y1); break;
382 }
383 }
384#endif
385
386 } 358 }
387#if ENABLE_COMBINING 359#if ENABLE_COMBINING
388 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) 360 else if (IS_COMPOSE (t) && (cc = rxvt_composite[t]))
389 { 361 {
390 rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)]; 362 rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)];
403 else 375 else
404 switch (t) 376 switch (t)
405 { 377 {
406 case ZERO_WIDTH_CHAR: 378 case ZERO_WIDTH_CHAR:
407 break; 379 break;
408
409#if 0
410 case 0x2580: XFillRectangle (d.display->display, d, TGC, x0, y0, W, y1 - y0 + 1); break;
411 case 0x2581: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 7 - 1) / 8, W, H - (H * 7 - 1) / 8); break;
412 case 0x2582: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 6 - 2) / 8, W, H - (H * 6 - 2) / 8); break;
413 case 0x2583: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 5 - 3) / 8, W, H - (H * 5 - 3) / 8); break;
414 case 0x2584: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 4 - 4) / 8, W, H - (H * 4 - 4) / 8); break;
415 case 0x2585: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 3 - 5) / 8, W, H - (H * 3 - 5) / 8); break;
416 case 0x2586: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 2 - 6) / 8, W, H - (H * 2 - 6) / 8); break;
417 case 0x2587: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 1 - 7) / 8, W, H - (H * 1 - 7) / 8); break;
418 case 0x2588: XFillRectangle (d.display->display, d, TGC, x0, y0, W, H); break;
419 case 0x2589: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 7 - 1) / 8, H); break;
420 case 0x258a: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 6 - 2) / 8, H); break;
421 case 0x258b: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 5 - 3) / 8, H); break;
422 case 0x258c: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 4 - 4) / 8, H); break;
423 case 0x258d: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 3 - 5) / 8, H); break;
424 case 0x258e: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 2 - 6) / 8, H); break;
425 case 0x258f: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 1 - 7) / 8, H); break;
426 case 0x2590: XFillRectangle (d.display->display, d, TGC, x1, y0, x2 - x1, H); break;
427
428 case 0x2591: rect_stipple (d.display->display, d, TGC, 0x00, 0x01, x0, y0, W, H); break;
429 case 0x2592: rect_stipple (d.display->display, d, TGC, 0x02, 0x01, x0, y0, W, H); break;
430 case 0x2593: rect_stipple (d.display->display, d, TGC, 0x01, 0x03, x0, y0, W, H); break;
431
432 case 0x2594: XFillRectangle (d.display->display, d, TGC, x0, y0, W, (H * 1 - 7) / 8); break;
433 case 0x2595: XFillRectangle (d.display->display, d, TGC, x0 + (W * 7 - 1) / 8, y0, W - (W * 7 - 1) / 8, H); break;
434#endif
435 380
436 default: 381 default:
437 int w = 0; 382 int w = 0;
438 while (len > 0 && *text == NOCHAR) 383 while (len > 0 && *text == NOCHAR)
439 { 384 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines