268
315
unsigned int yoff = (y + 1) * dp->drv.p->font_height
269
316
- dp->drv.p->font_offset;
270
317
uint32_t *chars = dp->cv->chars + y * dp->cv->width;
318
uint32_t *attrs = dp->cv->attrs + y * dp->cv->width;
272
for(x = 0; x < dp->cv->width; x++, chars++)
320
for(x = 0; x < dp->cv->width; x++, chars++, attrs++)
274
uint32_t *attrs = dp->cv->attrs + x + y * dp->cv->width;
277
if(*attrs & CUCUL_UNDERLINE)
278
XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
280
x * dp->drv.p->font_width,
281
(y + 1) * dp->drv.p->font_height - 1,
282
dp->drv.p->font_width, 1);
285
if(*chars <= 0x00000020)
288
if(*chars == CUCUL_MAGIC_FULLWIDTH)
291
322
XSetForeground(dp->drv.p->dpy, dp->drv.p->gc,
292
323
dp->drv.p->colors[_cucul_attr_to_rgb12fg(*attrs)]);
294
/* Plain ASCII, no problem. */
295
if(*chars > 0x00000020 && *chars < 0x00000080)
297
char ch = (uint8_t)*chars;
298
XDrawString(dp->drv.p->dpy, dp->drv.p->pixmap, dp->drv.p->gc,
299
x * dp->drv.p->font_width, yoff, &ch, 1);
303
/* We want to be able to print a few special Unicode characters
304
* such as the CP437 gradients and half blocks. For unknown
305
* characters, just print '?'. */
308
case 0x000000b7: /* · */
309
XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
311
x * dp->drv.p->font_width
312
+ dp->drv.p->font_width / 2,
313
y * dp->drv.p->font_height
314
+ dp->drv.p->font_height / 2, 2, 2);
316
case 0x00002500: /* ─ */
317
XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
319
x * dp->drv.p->font_width,
320
y * dp->drv.p->font_height
321
+ dp->drv.p->font_height / 2 + 1,
322
dp->drv.p->font_width, 1);
324
case 0x00002580: /* ▀ */
325
XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
327
x * dp->drv.p->font_width,
328
y * dp->drv.p->font_height,
329
dp->drv.p->font_width,
330
dp->drv.p->font_height / 2);
332
case 0x00002584: /* ▄ */
333
XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
335
x * dp->drv.p->font_width,
336
(y + 1) * dp->drv.p->font_height
337
- dp->drv.p->font_height / 2,
338
dp->drv.p->font_width,
339
dp->drv.p->font_height / 2);
341
case 0x00002588: /* █ */
342
XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
344
x * dp->drv.p->font_width,
345
y * dp->drv.p->font_height,
346
dp->drv.p->font_width,
347
dp->drv.p->font_height);
349
case 0x0000258c: /* ▌ */
350
XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
352
x * dp->drv.p->font_width,
353
y * dp->drv.p->font_height,
354
dp->drv.p->font_width / 2,
355
dp->drv.p->font_height);
357
case 0x00002590: /* ▐ */
358
XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
360
(x + 1) * dp->drv.p->font_width
361
- dp->drv.p->font_width / 2,
362
y * dp->drv.p->font_height,
363
dp->drv.p->font_width / 2,
364
dp->drv.p->font_height);
366
case 0x000025a0: /* ■ */
367
XFillRectangle(dp->drv.p->dpy, dp->drv.p->pixmap,
369
x * dp->drv.p->font_width,
370
y * dp->drv.p->font_height
371
+ dp->drv.p->font_height / 4,
372
dp->drv.p->font_width,
373
dp->drv.p->font_height / 2);
375
case 0x00002593: /* ▓ */
376
case 0x00002592: /* ▒ */
377
case 0x00002591: /* ░ */
379
/* FIXME: this sucks utterly */
380
int i, j, k = *chars - 0x00002591;
381
for(j = dp->drv.p->font_height; j--; )
382
for(i = dp->drv.p->font_width; i--; )
384
if(((i + 2 * (j & 1)) & 3) > k)
387
XDrawPoint(dp->drv.p->dpy, dp->drv.p->pixmap,
389
x * dp->drv.p->font_width + i,
390
y * dp->drv.p->font_height + j);
398
XDrawString(dp->drv.p->dpy, dp->drv.p->pixmap,
400
x * dp->drv.p->font_width, yoff, &ch, 1);
325
x11_put_glyph(dp, x * dp->drv.p->font_width,
326
y * dp->drv.p->font_height, yoff,
327
dp->drv.p->font_width, dp->drv.p->font_height,
549
static void x11_put_glyph(caca_display_t *dp, int x, int y, int yoff,
550
int w, int h, uint32_t attr, uint32_t ch)
552
static uint8_t const udlr[] =
554
/* 0x2500 - 0x250f: ─ . │ . . . . . . . . . ┌ . . . */
555
0x05, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
556
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
557
/* 0x2510 - 0x251f: ┐ . . . └ . . . ┘ . . . ├ . . . */
558
0x14, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00,
559
0x44, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00,
560
/* 0x2520 - 0x252f: . . . . ┤ . . . . . . . ┬ . . . */
561
0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
562
0x00, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
563
/* 0x2530 - 0x253f: . . . . ┴ . . . . . . . ┼ . . . */
564
0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00,
565
0x00, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00,
566
/* 0x2540 - 0x254f: . . . . . . . . . . . . . . . . */
567
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
568
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
569
/* 0x2550 - 0x255f: ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ */
570
0x0a, 0xa0, 0x12, 0x21, 0x22, 0x18, 0x24, 0x28,
571
0x42, 0x81, 0x82, 0x48, 0x84, 0x88, 0x52, 0xa1,
572
/* 0x2560 - 0x256c: ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬ */
573
0xa2, 0x58, 0xa4, 0xa8, 0x1a, 0x25, 0x2a, 0x4a,
574
0x85, 0x8a, 0x5a, 0xa5, 0xaa,
577
Display *dpy = dp->drv.p->dpy;
578
Pixmap px = dp->drv.p->pixmap;
579
GC gc = dp->drv.p->gc;
584
if(attr & CUCUL_UNDERLINE)
585
XFillRectangle(dpy, px, gc, x, y + h - 1, w, 1);
587
/* Skip spaces and magic stuff */
591
if(ch == CUCUL_MAGIC_FULLWIDTH)
595
if(cucul_utf32_is_fullwidth(ch))
598
/* We want to be able to print a few special Unicode characters
599
* such as the CP437 gradients and half blocks. For unknown
600
* characters, print what cucul_utf32_to_ascii() returns. */
602
if(ch >= 0x2500 && ch <= 0x256c && udlr[ch - 0x2500])
604
uint16_t D = udlr[ch - 0x2500];
607
XFillRectangle(dpy, px, gc, x, y + h / 2, fw / 2 + 1, 1);
610
XFillRectangle(dpy, px, gc,
611
x + fw / 2, y + h / 2, (fw + 1) / 2, 1);
614
XFillRectangle(dpy, px, gc, x + fw / 2, y, 1, h / 2 + 1);
617
XFillRectangle(dpy, px, gc, x + fw / 2, y + h / 2, 1, (h + 1) / 2);
619
#define STEPIF(a,b) (D&(a)?-1:(D&(b))?1:0)
623
XFillRectangle(dpy, px, gc, x, y - 1 + h / 2,
624
fw / 2 + 1 + STEPIF(0xc0,0x20), 1);
625
XFillRectangle(dpy, px, gc, x, y + 1 + h / 2,
626
fw / 2 + 1 + STEPIF(0x30,0x80), 1);
631
XFillRectangle(dpy, px, gc, x - STEPIF(0xc0,0x20) + fw / 2,
632
y - 1 + h / 2, (fw + 1) / 2 + STEPIF(0xc0,0x20), 1);
633
XFillRectangle(dpy, px, gc, x - STEPIF(0x30,0x80) + fw / 2,
634
y + 1 + h / 2, (fw + 1) / 2 + STEPIF(0x30,0x80), 1);
639
XFillRectangle(dpy, px, gc, x - 1 + fw / 2, y,
640
1, h / 2 + 1 + STEPIF(0x0c,0x02));
641
XFillRectangle(dpy, px, gc, x + 1 + fw / 2, y,
642
1, h / 2 + 1 + STEPIF(0x03,0x08));
647
XFillRectangle(dpy, px, gc, x - 1 + fw / 2,
648
y - STEPIF(0x0c,0x02) + h / 2,
649
1, (h + 1) / 2 + STEPIF(0x0c,0x02));
650
XFillRectangle(dpy, px, gc, x + 1 + fw / 2,
651
y - STEPIF(0x03,0x08) + h / 2,
652
1, (h + 1) / 2 + STEPIF(0x03,0x08));
660
case 0x000000b7: /* · */
661
case 0x00002219: /* ∙ */
662
case 0x000030fb: /* ・ */
663
XFillRectangle(dpy, px, gc, x + fw / 2 - 1, y + h / 2 - 1, 2, 2);
666
case 0x00002261: /* ≡ */
667
XFillRectangle(dpy, px, gc, x + 1, y - 2 + h / 2, fw - 1, 1);
668
XFillRectangle(dpy, px, gc, x + 1, y + h / 2, fw - 1, 1);
669
XFillRectangle(dpy, px, gc, x + 1, y + 2 + h / 2, fw - 1, 1);
672
case 0x00002580: /* ▀ */
673
XFillRectangle(dpy, px, gc, x, y, fw, h / 2);
676
case 0x00002584: /* ▄ */
677
XFillRectangle(dpy, px, gc, x, y + h - h / 2, fw, h / 2);
680
case 0x00002588: /* █ */
681
case 0x000025ae: /* ▮ */
682
XFillRectangle(dpy, px, gc, x, y, fw, h);
685
case 0x0000258c: /* ▌ */
686
XFillRectangle(dpy, px, gc, x, y, fw / 2, h);
689
case 0x00002590: /* ▐ */
690
XFillRectangle(dpy, px, gc, x + fw - fw / 2, y, fw / 2, h);
693
case 0x000025a0: /* ■ */
694
case 0x000025ac: /* ▬ */
695
XFillRectangle(dpy, px, gc, x, y + h / 4, fw, h / 2);
698
case 0x00002593: /* ▓ */
699
case 0x00002592: /* ▒ */
700
case 0x00002591: /* ░ */
702
/* FIXME: this sucks utterly */
703
int i, j, k = ch - 0x00002591;
707
if(((i + 2 * (j & 1)) & 3) > k)
710
XDrawPoint(dpy, px, gc, x + i, y + j);
715
case 0x000025cb: /* ○ */
716
case 0x00002022: /* • */
717
case 0x000025cf: /* ● */
721
d = fw >> (~ch & 0x1); /* XXX: hack */
729
XDrawArc(dpy, px, gc, x + xo, y + yo, d, d, 0, 64 * 360);
731
XFillArc(dpy, px, gc, x + xo, y + yo, d, d, 0, 64 * 360);
736
if(ch >= 0x00000020 && ch <= dp->drv.p->max_char)
738
/* ascii, latin-1 or unicode font (might draw a blank square) */
739
ch16.byte1 = (ch) >> 8;
740
ch16.byte2 = (ch) & 0xff;
745
ch16.byte2 = cucul_utf32_to_ascii(ch);
748
XDrawString16(dpy, px, gc, x + (ch16.byte1 ? 0 : (fw - w) / 2), yoff, &ch16, 1);
625
752
* Driver initialisation