… | |
… | |
59 | |
59 | |
60 | // japanese |
60 | // japanese |
61 | #if ENCODING_JP || ENCODING_JP_EXT |
61 | #if ENCODING_JP || ENCODING_JP_EXT |
62 | # if XFT |
62 | # if XFT |
63 | // prefer xft for complex scripts |
63 | // prefer xft for complex scripts |
64 | { CS_UNICODE, "xft:Kochi Gothic:antialias=false" }, |
64 | { CS_UNICODE, "xft:Kochi Gothic:antialias=false" }, |
65 | # endif |
65 | # endif |
66 | { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
66 | { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
67 | { CS_JIS0208_1983_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
67 | { CS_JIS0208_1983_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
68 | { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, |
68 | { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, |
69 | #endif |
69 | #endif |
70 | |
70 | |
71 | #if ENCODING_CN || ENCODING_CN_EXT |
71 | #if ENCODING_CN || ENCODING_CN_EXT |
72 | # if XFT |
72 | # if XFT |
73 | { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" }, |
73 | { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" }, |
74 | { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" }, |
74 | { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" }, |
75 | { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" }, |
75 | { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" }, |
76 | { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" }, |
76 | { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" }, |
77 | # endif |
77 | # endif |
78 | { CS_CNS11643_1992_1, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-1" }, |
78 | { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-1" }, |
79 | { CS_CNS11643_1992_2, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-2" }, |
79 | { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-2" }, |
80 | { CS_CNS11643_1992_3, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-3" }, |
80 | { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-3" }, |
81 | { CS_CNS11643_1992_4, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-4" }, |
81 | { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-4" }, |
82 | { CS_CNS11643_1992_5, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-5" }, |
82 | { CS_CNS11643_1992_5, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-5" }, |
83 | { CS_CNS11643_1992_6, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-6" }, |
83 | { CS_CNS11643_1992_6, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-6" }, |
84 | { CS_CNS11643_1992_7, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-7" }, |
84 | { CS_CNS11643_1992_7, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-7" }, |
85 | { CS_CNS11643_1992_F, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-f" }, |
85 | { CS_CNS11643_1992_F, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-f" }, |
86 | #endif |
86 | #endif |
87 | |
87 | |
88 | #if XFT |
88 | #if XFT |
89 | { CS_UNICODE, "xft:Andale Mono" }, |
89 | { CS_UNICODE, "xft:Andale Mono" }, |
90 | { CS_UNICODE, "xft:Arial Unicode MS" }, |
90 | { CS_UNICODE, "xft:Arial Unicode MS" }, |
91 | #endif |
91 | #endif |
92 | { CS_UNICODE, "-*-lucidatypewriter-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, |
92 | { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" }, |
|
|
93 | { CS_UNICODE, "xft:FreeMono" }, |
|
|
94 | { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, |
|
|
95 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, |
93 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, |
96 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, |
94 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, |
|
|
95 | { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, |
|
|
96 | |
97 | |
97 | { CS_UNKNOWN, 0 } |
98 | { CS_UNKNOWN, 0 } |
98 | }; |
99 | }; |
99 | |
100 | |
100 | ///////////////////////////////////////////////////////////////////////////// |
101 | ///////////////////////////////////////////////////////////////////////////// |
… | |
… | |
226 | struct rxvt_font_default : rxvt_font { |
227 | struct rxvt_font_default : rxvt_font { |
227 | rxvt_fontprop properties () |
228 | rxvt_fontprop properties () |
228 | { |
229 | { |
229 | rxvt_fontprop p; |
230 | rxvt_fontprop p; |
230 | |
231 | |
231 | p.height = 1; |
232 | p.width = p.height = 1; |
232 | p.weight = rxvt_fontprop::medium; |
233 | p.weight = rxvt_fontprop::medium; |
233 | p.slant = rxvt_fontprop::roman; |
234 | p.slant = rxvt_fontprop::roman; |
234 | |
235 | |
235 | return p; |
236 | return p; |
236 | } |
237 | } |
… | |
… | |
336 | rxvt_font_x11 () { f = 0; } |
337 | rxvt_font_x11 () { f = 0; } |
337 | |
338 | |
338 | void clear (); |
339 | void clear (); |
339 | |
340 | |
340 | rxvt_fontprop properties (); |
341 | rxvt_fontprop properties (); |
341 | rxvt_fontprop properties (XFontStruct *f); |
|
|
342 | |
342 | |
343 | bool load (const rxvt_fontprop &prop); |
343 | bool load (const rxvt_fontprop &prop); |
344 | |
344 | |
345 | bool has_codepoint (uint32_t unicode); |
345 | bool has_codepoint (uint32_t unicode); |
346 | |
346 | |
… | |
… | |
351 | XFontStruct *f; |
351 | XFontStruct *f; |
352 | codeset cs; |
352 | codeset cs; |
353 | bool enc2b, encm; |
353 | bool enc2b, encm; |
354 | |
354 | |
355 | const char *get_property (XFontStruct *f, const char *property, const char *repl) const; |
355 | const char *get_property (XFontStruct *f, const char *property, const char *repl) const; |
|
|
356 | bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); |
|
|
357 | bool set_properties (rxvt_fontprop &p, XFontStruct *f); |
|
|
358 | bool set_properties (rxvt_fontprop &p, const char *name); |
356 | }; |
359 | }; |
357 | |
360 | |
358 | const char * |
361 | const char * |
359 | rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const |
362 | rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const |
360 | { |
363 | { |
… | |
… | |
367 | } |
370 | } |
368 | |
371 | |
369 | rxvt_fontprop |
372 | rxvt_fontprop |
370 | rxvt_font_x11::properties () |
373 | rxvt_font_x11::properties () |
371 | { |
374 | { |
372 | return properties (f); |
|
|
373 | } |
|
|
374 | |
|
|
375 | rxvt_fontprop |
|
|
376 | rxvt_font_x11::properties (XFontStruct *f) |
|
|
377 | { |
|
|
378 | rxvt_fontprop p; |
375 | rxvt_fontprop p; |
|
|
376 | set_properties (p, f); |
|
|
377 | return p; |
|
|
378 | } |
379 | |
379 | |
|
|
380 | bool |
|
|
381 | rxvt_font_x11::set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth) |
|
|
382 | { |
|
|
383 | p.width = avgwidth ? (avgwidth + 1) / 10 : (height + 1) / 2; |
|
|
384 | p.height = height; |
|
|
385 | p.weight = *weight == 'B' || *weight == 'b' ? rxvt_fontprop::bold : rxvt_fontprop::medium; |
|
|
386 | p.slant = *slant == 'r' || *slant == 'R' ? rxvt_fontprop::roman : rxvt_fontprop::italic; |
|
|
387 | |
|
|
388 | return true; |
|
|
389 | } |
|
|
390 | |
|
|
391 | bool |
|
|
392 | rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) |
|
|
393 | { |
380 | const char *weight = get_property (f, "WEIGHT_NAME", "medium"); |
394 | const char *weight = get_property (f, "WEIGHT_NAME", "medium"); |
381 | const char *slant = get_property (f, "SLANT", "r"); |
395 | const char *slant = get_property (f, "SLANT", "r"); |
382 | |
396 | |
383 | p.height = height; |
397 | unsigned long height; |
384 | p.weight = *weight == 'B' || *weight == 'b' ? rxvt_fontprop::bold : rxvt_fontprop::medium; |
398 | if (!XGetFontProperty (f, XInternAtom (DISPLAY, "PIXEL_SIZE", 0), &height)) |
385 | p.slant = *slant == 'r' || *slant == 'R' ? rxvt_fontprop::roman : rxvt_fontprop::italic; |
399 | return false; |
386 | |
400 | |
387 | return p; |
401 | unsigned long avgwidth; |
|
|
402 | if (!XGetFontProperty (f, XInternAtom (DISPLAY, "AVERAGE_WIDTH", 0), &avgwidth)) |
|
|
403 | avgwidth = 0; |
|
|
404 | |
|
|
405 | return set_properties (p, height, weight, slant, avgwidth); |
|
|
406 | } |
|
|
407 | |
|
|
408 | bool |
|
|
409 | rxvt_font_x11::set_properties (rxvt_fontprop &p, const char *name) |
|
|
410 | { |
|
|
411 | int slashes = 0; |
|
|
412 | const char *comp[12]; |
|
|
413 | |
|
|
414 | for (const char *c = name; *c; c++) |
|
|
415 | if (*c == '-') |
|
|
416 | { |
|
|
417 | comp[slashes++] = c + 1; |
|
|
418 | if (slashes >= 13) |
|
|
419 | break; |
|
|
420 | } |
|
|
421 | |
|
|
422 | /* can we short-circuit the costly XLoadQueryFont? */ |
|
|
423 | if (slashes >= 13 |
|
|
424 | && (*comp[ 6] >= '1' && *comp[ 6] <= '9') |
|
|
425 | && (*comp[11] >= '0' && *comp[11] <= '9')) |
|
|
426 | return set_properties (p, atoi (comp[6]), comp[2], comp[3], atoi (comp[11])); |
|
|
427 | |
|
|
428 | XFontStruct *f = XLoadQueryFont (DISPLAY, name); |
|
|
429 | |
|
|
430 | if (f) |
|
|
431 | { |
|
|
432 | // the font should really exists now. if not, we have a problem |
|
|
433 | // (e.g. if the user did xset fp rehash just when we were searching fonts). |
|
|
434 | // in that case, just return garbage. |
|
|
435 | bool ret = set_properties (p, f); |
|
|
436 | XFreeFont (DISPLAY, f); |
|
|
437 | return ret; |
|
|
438 | } |
|
|
439 | else |
|
|
440 | return false; |
|
|
441 | } |
|
|
442 | |
|
|
443 | // fix the size of scalable fonts |
|
|
444 | static void |
|
|
445 | fix_scalable (char *buf, const char *name, const rxvt_fontprop &prop) |
|
|
446 | { |
|
|
447 | int slashes = 0; |
|
|
448 | const char *size; |
|
|
449 | |
|
|
450 | for (const char *c = name; *c; c++) |
|
|
451 | if (*c == '-') |
|
|
452 | { |
|
|
453 | if (slashes == 6) |
|
|
454 | size = c + 1; |
|
|
455 | |
|
|
456 | if (++slashes >= 13) |
|
|
457 | break; |
|
|
458 | } |
|
|
459 | |
|
|
460 | if (slashes >= 13 && size[0] == '0') |
|
|
461 | { |
|
|
462 | strncpy (buf, name, size - name); |
|
|
463 | buf += size - name; |
|
|
464 | buf += sprintf (buf, "%d", prop.height); |
|
|
465 | strcpy (buf, size + 1); |
|
|
466 | } |
|
|
467 | else |
|
|
468 | strcpy (buf, name); |
388 | } |
469 | } |
389 | |
470 | |
390 | bool |
471 | bool |
391 | rxvt_font_x11::load (const rxvt_fontprop &prop) |
472 | rxvt_font_x11::load (const rxvt_fontprop &prop) |
392 | { |
473 | { |
393 | clear (); |
474 | clear (); |
394 | |
475 | |
395 | char **list; |
476 | char **list; |
396 | int count; |
477 | int count; |
397 | XFontStruct *info; |
|
|
398 | list = XListFontsWithInfo (DISPLAY, name, 128, &count, &info); |
478 | list = XListFonts (DISPLAY, name, 512, &count); |
|
|
479 | set_name (0); |
399 | |
480 | |
400 | if (!list) |
481 | if (!list) |
401 | return false; |
482 | return false; |
402 | |
483 | |
403 | int bestdiff = 0x7fffffff; |
484 | int bestdiff = 0x7fffffff; |
404 | XFontStruct *best = 0; |
|
|
405 | for (int i = 0; i < count; i++) |
485 | for (int i = 0; i < count; i++) |
406 | { |
486 | { |
407 | XFontStruct *f = info + i; |
487 | rxvt_fontprop p; |
|
|
488 | char fname[1024]; |
|
|
489 | fix_scalable (fname, list[i], prop); |
408 | |
490 | |
|
|
491 | if (!set_properties (p, fname)) |
|
|
492 | continue; |
|
|
493 | |
409 | if (f->ascent + f->descent <= prop.height) // weed out too large fonts |
494 | if (p.height > prop.height) // weed out too large fonts |
410 | { |
495 | continue; |
411 | rxvt_fontprop p = properties (f); |
496 | |
412 | int diff = (prop.height - f->ascent + f->descent) * 32 |
497 | int diff = (prop.height - p.height) * 32 |
413 | + abs (prop.weight - p.weight) |
498 | + abs (prop.weight - p.weight) |
414 | + abs (prop.slant - p.slant ); |
499 | + abs (prop.slant - p.slant ); |
415 | |
500 | |
416 | if (!best // compare against best found so far |
501 | if (!name // compare against best found so far |
417 | || diff < bestdiff) |
502 | || diff < bestdiff) |
418 | { |
503 | { |
419 | best = f; |
504 | set_name (strdup (fname)); |
420 | bestdiff = diff; |
505 | bestdiff = diff; |
421 | } |
506 | } |
422 | } |
|
|
423 | } |
507 | } |
424 | |
508 | |
425 | set_name (strdup (list[best - info])); |
509 | XFreeFontNames (list); |
426 | |
510 | |
427 | XFreeFontInfo (list, info, count); |
511 | if (!name) |
|
|
512 | return false; |
428 | |
513 | |
429 | f = XLoadQueryFont (DISPLAY, name); |
514 | f = XLoadQueryFont (DISPLAY, name); |
430 | |
515 | |
431 | if (!f) |
516 | if (!f) |
432 | return false; |
517 | return false; |
… | |
… | |
654 | //#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables |
739 | //#define SWATHBITS (UNIBITS / 2 + 3) // minimum size for "full" tables |
655 | #define SWATHBITS 8 |
740 | #define SWATHBITS 8 |
656 | #endif |
741 | #endif |
657 | |
742 | |
658 | struct rxvt_font_xft : rxvt_font { |
743 | struct rxvt_font_xft : rxvt_font { |
659 | #if 0 |
|
|
660 | enum { |
|
|
661 | SWATHCOUNT = 1 << (21 - UNIBITS), |
|
|
662 | SWATHSIZE = 1 << (SWATHBITS - 5) |
|
|
663 | }; |
|
|
664 | typedef uint32_t swath[SWATHSIZE]; |
|
|
665 | |
|
|
666 | swath *cvr[SWATHCOUNT]; |
|
|
667 | #endif |
|
|
668 | |
|
|
669 | #if 0 |
|
|
670 | void gen_coverage_swath (unsigned int page); |
|
|
671 | |
|
|
672 | bool has_char (uint32_t ch) |
|
|
673 | { |
|
|
674 | unsigned int page = ch >> SWATHBITS; |
|
|
675 | unsigned int idx = ch & ((1 << SWATHBITS) - 1); |
|
|
676 | |
|
|
677 | if (page >= SWATHCOUNT) |
|
|
678 | return false; |
|
|
679 | |
|
|
680 | if (!cvr[page]) gen_coverage_swath (page); |
|
|
681 | |
|
|
682 | return cvr[page][idx >> 5] & (1 << (idx & 31)); |
|
|
683 | } |
|
|
684 | #endif |
|
|
685 | rxvt_font_xft () { f = 0; d = 0; } |
744 | rxvt_font_xft () { f = 0; d = 0; } |
686 | |
745 | |
687 | void clear (); |
746 | void clear (); |
688 | |
747 | |
689 | rxvt_fontprop properties (); |
748 | rxvt_fontprop properties (); |
… | |
… | |
697 | bool has_codepoint (uint32_t unicode); |
756 | bool has_codepoint (uint32_t unicode); |
698 | |
757 | |
699 | protected: |
758 | protected: |
700 | XftFont *f; |
759 | XftFont *f; |
701 | XftDraw *d; |
760 | XftDraw *d; |
702 | |
|
|
703 | #if 0 |
|
|
704 | virtual void populate_coverage_swath (uint32_t lo, uint32_t hi) = 0; |
|
|
705 | void set_swath (uint32_t ch) |
|
|
706 | { |
|
|
707 | cvr[ch >> SWATHBITS] |= 1 << (ch & ((1 << SWATHBITS) - 1)); |
|
|
708 | } |
|
|
709 | #endif |
|
|
710 | }; |
761 | }; |
711 | |
762 | |
712 | void |
763 | void |
713 | rxvt_font_xft::clear () |
764 | rxvt_font_xft::clear () |
714 | { |
765 | { |
… | |
… | |
721 | if (d) |
772 | if (d) |
722 | { |
773 | { |
723 | XftDrawDestroy (d); |
774 | XftDrawDestroy (d); |
724 | d = 0; |
775 | d = 0; |
725 | } |
776 | } |
726 | |
|
|
727 | #if 0 |
|
|
728 | for (int i = 0; i < SWATHCOUNT; i++) |
|
|
729 | delete cvr[i]; |
|
|
730 | #endif |
|
|
731 | } |
777 | } |
732 | |
778 | |
733 | rxvt_fontprop |
779 | rxvt_fontprop |
734 | rxvt_font_xft::properties () |
780 | rxvt_font_xft::properties () |
735 | { |
781 | { |
736 | rxvt_fontprop p; |
782 | rxvt_fontprop p; |
737 | |
783 | |
738 | FT_Face face = XftLockFace (f); |
784 | FT_Face face = XftLockFace (f); |
739 | |
785 | |
740 | p.height = height; |
786 | p.width = width; p.height = height; |
741 | p.weight = face->style_flags & FT_STYLE_FLAG_BOLD ? rxvt_fontprop::bold : rxvt_fontprop::medium; |
787 | p.weight = face->style_flags & FT_STYLE_FLAG_BOLD ? rxvt_fontprop::bold : rxvt_fontprop::medium; |
742 | p.slant = face->style_flags & FT_STYLE_FLAG_ITALIC ? rxvt_fontprop::italic : rxvt_fontprop::roman; |
788 | p.slant = face->style_flags & FT_STYLE_FLAG_ITALIC ? rxvt_fontprop::italic : rxvt_fontprop::roman; |
743 | |
789 | |
744 | XftUnlockFace (f); |
790 | XftUnlockFace (f); |
745 | |
791 | |
… | |
… | |
767 | FcPatternAddInteger (p, FC_WEIGHT, prop.weight); |
813 | FcPatternAddInteger (p, FC_WEIGHT, prop.weight); |
768 | |
814 | |
769 | if (FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) |
815 | if (FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) |
770 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
816 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
771 | |
817 | |
|
|
818 | #if 0 // clipping unfortunately destroys our precious double-width-characters |
|
|
819 | // clip width, we can't do better, or can we? |
|
|
820 | if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) |
|
|
821 | FcPatternAddInteger (p, FC_CHAR_WIDTH, prop.width); |
|
|
822 | #endif |
|
|
823 | |
772 | //FcPatternAddBool (p, FC_MINSPACE, 1); |
824 | //FcPatternAddBool (p, FC_MINSPACE, 1); |
773 | |
825 | |
774 | XftResult result; |
826 | XftResult result; |
775 | FcPattern *match = XftFontMatch (DISPLAY, DefaultScreen (DISPLAY), p, &result); |
827 | FcPattern *match = XftFontMatch (DISPLAY, DefaultScreen (DISPLAY), p, &result); |
776 | |
828 | |
… | |
… | |
828 | XftUnlockFace (f); |
880 | XftUnlockFace (f); |
829 | |
881 | |
830 | return true; |
882 | return true; |
831 | } |
883 | } |
832 | |
884 | |
833 | #if 0 |
|
|
834 | void rxvt_font::gen_coverage_swath (unsigned int page) |
|
|
835 | { |
|
|
836 | cvr[page] = new swath; |
|
|
837 | |
|
|
838 | for (int i = 0; i < SWATHSIZE; i++) |
|
|
839 | cvr[page][i] = 0; |
|
|
840 | |
|
|
841 | populate_coverage_swath (cvr[page], page << SWATHBITS, ((page + 1) << SWATHBITS) - 1); |
|
|
842 | } |
|
|
843 | #endif |
|
|
844 | |
|
|
845 | bool |
885 | bool |
846 | rxvt_font_xft::has_codepoint (uint32_t unicode) |
886 | rxvt_font_xft::has_codepoint (uint32_t unicode) |
847 | { |
887 | { |
848 | return XftCharExists (DISPLAY, f, unicode); |
888 | return XftCharExists (DISPLAY, f, unicode); |
849 | } |
889 | } |
… | |
… | |
862 | if (bg >= 0 && bg != Color_bg) |
902 | if (bg >= 0 && bg != Color_bg) |
863 | XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); |
903 | XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); |
864 | else |
904 | else |
865 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
905 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
866 | |
906 | |
867 | if (!slow && width == r->TermWin.fwidth) |
907 | if (!slow && width == r->TermWin.fwidth && 0) |
868 | { |
908 | { |
869 | if (sizeof (text_t) == sizeof (FcChar16)) |
909 | if (sizeof (text_t) == sizeof (FcChar16)) |
870 | XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, len); |
910 | XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, len); |
871 | else |
911 | else |
872 | XftDrawString32 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar32 *)text, len); |
912 | XftDrawString32 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar32 *)text, len); |
… | |
… | |
875 | { |
915 | { |
876 | while (len) |
916 | while (len) |
877 | { |
917 | { |
878 | if (*text != NOCHAR && *text != ' ') |
918 | if (*text != NOCHAR && *text != ' ') |
879 | { |
919 | { |
|
|
920 | XGlyphInfo extents; |
880 | if (sizeof (text_t) == sizeof (FcChar16)) |
921 | if (sizeof (text_t) == sizeof (FcChar16)) |
881 | XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, 1); |
922 | { |
|
|
923 | XftTextExtents16 (DISPLAY, f, (const FcChar16 *)text, 1, &extents); |
|
|
924 | XftDrawString16 (d, &r->PixColors[fg].c, f, x + extents.x + (r->TermWin.fwidth - extents.width) / 2, |
|
|
925 | y + r->TermWin.fbase, (const FcChar16 *)text, 1); |
|
|
926 | } |
882 | else |
927 | else |
883 | XftDrawString32 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar32 *)text, 1); |
928 | { |
|
|
929 | XGlyphInfo extents; |
|
|
930 | XftTextExtents32 (DISPLAY, f, (const FcChar32 *)text, 1, &extents); |
|
|
931 | XftDrawString32 (d, &r->PixColors[fg].c, f, x + extents.x + (r->TermWin.fwidth - extents.width) / 2, |
|
|
932 | y + r->TermWin.fbase, (const FcChar32 *)text, 1); |
|
|
933 | } |
884 | } |
934 | } |
885 | |
935 | |
886 | x += r->TermWin.fwidth; |
936 | x += r->TermWin.fwidth; |
887 | text++; |
937 | text++; |
888 | len--; |
938 | len--; |