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