… | |
… | |
21 | |
21 | |
22 | #include "../config.h" |
22 | #include "../config.h" |
23 | #include "rxvt.h" |
23 | #include "rxvt.h" |
24 | #include "defaultfont.h" |
24 | #include "defaultfont.h" |
25 | |
25 | |
|
|
26 | #include <cstdlib> |
|
|
27 | |
26 | #define DISPLAY r->Xdisplay |
28 | #define DISPLAY r->Xdisplay |
27 | #define DRAWABLE r->TermWin.vt |
29 | #define DRAWABLE r->TermWin.vt |
28 | #define GC r->TermWin.gc |
30 | #define GC r->TermWin.gc |
29 | |
31 | |
30 | const struct rxvt_fallback_font { |
32 | const struct rxvt_fallback_font { |
… | |
… | |
57 | |
59 | |
58 | // japanese |
60 | // japanese |
59 | #if ENCODING_JP || ENCODING_JP_EXT |
61 | #if ENCODING_JP || ENCODING_JP_EXT |
60 | # if XFT |
62 | # if XFT |
61 | // prefer xft for complex scripts |
63 | // prefer xft for complex scripts |
62 | { CS_UNICODE, "xft:Kochi Gothic" }, |
64 | { CS_UNICODE, "xft:Kochi Gothic:antialias=false" }, |
63 | # endif |
65 | # endif |
64 | { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
66 | { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
65 | { CS_JIS0208_1983_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
67 | { CS_JIS0208_1983_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
66 | { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, |
68 | { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, |
67 | #endif |
69 | #endif |
… | |
… | |
220 | |
222 | |
221 | // to be done |
223 | // to be done |
222 | }; |
224 | }; |
223 | |
225 | |
224 | struct rxvt_font_default : rxvt_font { |
226 | struct rxvt_font_default : rxvt_font { |
225 | bool load (int maxheight) |
227 | rxvt_fontprop properties () |
|
|
228 | { |
|
|
229 | rxvt_fontprop p; |
|
|
230 | |
|
|
231 | p.height = 1; |
|
|
232 | p.weight = rxvt_fontprop::medium; |
|
|
233 | p.slant = rxvt_fontprop::roman; |
|
|
234 | |
|
|
235 | return p; |
|
|
236 | } |
|
|
237 | |
|
|
238 | bool load (const rxvt_fontprop &prop) |
226 | { |
239 | { |
227 | width = 1; height = 1; |
240 | width = 1; height = 1; |
228 | ascent = 1; descent = 0; |
241 | ascent = 1; descent = 0; |
229 | |
242 | |
230 | return true; |
243 | return true; |
… | |
… | |
270 | |
283 | |
271 | if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) |
284 | if (t >= 0x2500 & t <= 0x2580 && linedraw_cmds[t - 0x2500]) |
272 | { |
285 | { |
273 | const char *p = linedraw_cmds[t - 0x2500]; |
286 | const char *p = linedraw_cmds[t - 0x2500]; |
274 | |
287 | |
275 | int x0 = x, x1 = x + (r->TermWin.fwidth - 1) / 2, x2 = x + r->TermWin.fwidth - 1; |
288 | int x0 = x, x1 = x + r->TermWin.fwidth / 2, x2 = x + r->TermWin.fwidth ; |
276 | int y0 = y, y1 = y + (r->TermWin.fheight - 1) / 2, y2 = y + r->TermWin.fheight - 1; |
289 | int y0 = y, y1 = y + r->TermWin.fheight / 2, y2 = y + r->TermWin.fheight; |
277 | |
290 | |
278 | XGCValues gcv; |
291 | XGCValues gcv; |
279 | |
|
|
280 | gcv.cap_style = CapButt; |
|
|
281 | XChangeGC (DISPLAY, GC, GCCapStyle, &gcv); |
|
|
282 | |
292 | |
283 | while (*p) |
293 | while (*p) |
284 | { |
294 | { |
285 | switch (*p++) |
295 | switch (*p++) |
286 | { |
296 | { |
… | |
… | |
325 | struct rxvt_font_x11 : rxvt_font { |
335 | struct rxvt_font_x11 : rxvt_font { |
326 | rxvt_font_x11 () { f = 0; } |
336 | rxvt_font_x11 () { f = 0; } |
327 | |
337 | |
328 | void clear (); |
338 | void clear (); |
329 | |
339 | |
330 | bool load (int maxheight); |
340 | rxvt_fontprop properties (); |
|
|
341 | rxvt_fontprop properties (XFontStruct *f); |
|
|
342 | |
|
|
343 | bool load (const rxvt_fontprop &prop); |
331 | |
344 | |
332 | bool has_codepoint (uint32_t unicode); |
345 | bool has_codepoint (uint32_t unicode); |
333 | |
346 | |
334 | void draw (int x, int y, |
347 | void draw (int x, int y, |
335 | const text_t *text, int len, |
348 | const text_t *text, int len, |
… | |
… | |
337 | |
350 | |
338 | XFontStruct *f; |
351 | XFontStruct *f; |
339 | codeset cs; |
352 | codeset cs; |
340 | bool enc2b, encm; |
353 | bool enc2b, encm; |
341 | |
354 | |
342 | const char *get_property (const char *property, const char *repl) const; |
355 | const char *get_property (XFontStruct *f, const char *property, const char *repl) const; |
343 | }; |
356 | }; |
344 | |
357 | |
345 | const char * |
358 | const char * |
346 | rxvt_font_x11::get_property (const char *property, const char *repl) const |
359 | rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const |
347 | { |
360 | { |
348 | unsigned long value; |
361 | unsigned long value; |
349 | |
362 | |
350 | if (XGetFontProperty (f, XInternAtom (DISPLAY, property, 0), &value)) |
363 | if (XGetFontProperty (f, XInternAtom (DISPLAY, property, 0), &value)) |
351 | return XGetAtomName (DISPLAY, value); |
364 | return XGetAtomName (DISPLAY, value); |
352 | else |
365 | else |
353 | return repl; |
366 | return repl; |
354 | } |
367 | } |
355 | |
368 | |
|
|
369 | rxvt_fontprop |
|
|
370 | rxvt_font_x11::properties () |
|
|
371 | { |
|
|
372 | return properties (f); |
|
|
373 | } |
|
|
374 | |
|
|
375 | rxvt_fontprop |
|
|
376 | rxvt_font_x11::properties (XFontStruct *f) |
|
|
377 | { |
|
|
378 | rxvt_fontprop p; |
|
|
379 | |
|
|
380 | const char *weight = get_property (f, "WEIGHT_NAME", "medium"); |
|
|
381 | const char *slant = get_property (f, "SLANT", "r"); |
|
|
382 | |
|
|
383 | p.height = height; |
|
|
384 | p.weight = *weight == 'B' || *weight == 'b' ? rxvt_fontprop::bold : rxvt_fontprop::medium; |
|
|
385 | p.slant = *slant == 'r' || *slant == 'R' ? rxvt_fontprop::roman : rxvt_fontprop::italic; |
|
|
386 | |
|
|
387 | return p; |
|
|
388 | } |
|
|
389 | |
356 | bool |
390 | bool |
357 | rxvt_font_x11::load (int maxheight) |
391 | rxvt_font_x11::load (const rxvt_fontprop &prop) |
358 | { |
392 | { |
359 | clear (); |
393 | clear (); |
|
|
394 | |
|
|
395 | char **list; |
|
|
396 | int count; |
|
|
397 | XFontStruct *info; |
|
|
398 | list = XListFontsWithInfo (DISPLAY, name, 128, &count, &info); |
|
|
399 | |
|
|
400 | if (!list) |
|
|
401 | return false; |
|
|
402 | |
|
|
403 | int bestdiff = 0x7fffffff; |
|
|
404 | XFontStruct *best = 0; |
|
|
405 | for (int i = 0; i < count; i++) |
|
|
406 | { |
|
|
407 | XFontStruct *f = info + i; |
|
|
408 | |
|
|
409 | if (f->ascent + f->descent <= prop.height) // weed out too large fonts |
|
|
410 | { |
|
|
411 | rxvt_fontprop p = properties (f); |
|
|
412 | int diff = (prop.height - f->ascent + f->descent) * 32 |
|
|
413 | + abs (prop.weight - p.weight) |
|
|
414 | + abs (prop.slant - p.slant ); |
|
|
415 | |
|
|
416 | if (!best // compare against best found so far |
|
|
417 | || diff < bestdiff) |
|
|
418 | { |
|
|
419 | best = f; |
|
|
420 | bestdiff = diff; |
|
|
421 | } |
|
|
422 | } |
|
|
423 | } |
|
|
424 | |
|
|
425 | set_name (strdup (list[best - info])); |
|
|
426 | |
|
|
427 | XFreeFontInfo (list, info, count); |
360 | |
428 | |
361 | f = XLoadQueryFont (DISPLAY, name); |
429 | f = XLoadQueryFont (DISPLAY, name); |
362 | |
430 | |
363 | if (!f) |
431 | if (!f) |
364 | return false; |
432 | return false; |
365 | |
433 | |
366 | unsigned long value; |
434 | unsigned long value; |
367 | |
435 | |
368 | const char *registry = get_property ("CHARSET_REGISTRY", 0); |
436 | const char *registry = get_property (f, "CHARSET_REGISTRY", 0); |
369 | const char *encoding = get_property ("CHARSET_ENCODING", 0); |
437 | const char *encoding = get_property (f, "CHARSET_ENCODING", 0); |
370 | |
438 | |
371 | if (registry && encoding) |
439 | if (registry && encoding) |
372 | { |
440 | { |
373 | char charset[64]; |
441 | char charset[64]; |
374 | snprintf (charset, 64, "%s-%s", registry, encoding); |
442 | snprintf (charset, 64, "%s-%s", registry, encoding); |
375 | |
443 | |
376 | cs = codeset_from_name (charset); |
444 | cs = codeset_from_name (charset); |
377 | } |
445 | } |
378 | else |
446 | else |
379 | { |
447 | { |
380 | const char *charset = get_property ("FONT", 0); |
448 | const char *charset = get_property (f, "FONT", 0); |
381 | |
449 | |
382 | if (!charset) |
450 | if (!charset) |
383 | charset = name; |
451 | charset = name; |
384 | |
452 | |
385 | int count = 13; |
453 | int count = 13; |
… | |
… | |
398 | |
466 | |
399 | ascent = f->ascent; |
467 | ascent = f->ascent; |
400 | descent = f->descent; |
468 | descent = f->descent; |
401 | height = ascent + descent; |
469 | height = ascent + descent; |
402 | |
470 | |
403 | prop = false; |
471 | slow = false; |
404 | |
472 | |
405 | if (f->min_bounds.width == f->max_bounds.width) |
473 | if (f->min_bounds.width == f->max_bounds.width) |
406 | width = f->min_bounds.width; |
474 | width = f->min_bounds.width; |
407 | else if (f->per_char == NULL) |
475 | else if (f->per_char == NULL) |
408 | width = f->max_bounds.width; |
476 | width = f->max_bounds.width; |
409 | else |
477 | else |
410 | { |
478 | { |
411 | prop = true; |
479 | slow = true; |
412 | |
480 | |
413 | int N = f->max_char_or_byte2 - f->min_char_or_byte2; |
481 | int N = f->max_char_or_byte2 - f->min_char_or_byte2; |
414 | |
482 | |
415 | if (encm) |
483 | if (encm) |
416 | N += (f->max_byte1 - f->min_byte1) |
484 | N += (f->max_byte1 - f->min_byte1) |
… | |
… | |
501 | // this looks like a mess /. |
569 | // this looks like a mess /. |
502 | // and it is a mess /. |
570 | // and it is a mess /. |
503 | // yet we are trying to be perfect /. |
571 | // yet we are trying to be perfect /. |
504 | // but the result still isn't perfect /. |
572 | // but the result still isn't perfect /. |
505 | |
573 | |
506 | bool slow = prop |
574 | bool slow = this->slow |
507 | || width != r->TermWin.fwidth |
575 | || width != r->TermWin.fwidth |
508 | || height != r->TermWin.fheight; |
576 | || height != r->TermWin.fheight; |
509 | |
577 | |
510 | int base = r->TermWin.fbase; |
578 | int base = r->TermWin.fbase; |
511 | |
579 | |
… | |
… | |
616 | #endif |
684 | #endif |
617 | rxvt_font_xft () { f = 0; d = 0; } |
685 | rxvt_font_xft () { f = 0; d = 0; } |
618 | |
686 | |
619 | void clear (); |
687 | void clear (); |
620 | |
688 | |
621 | bool load (int maxheight); |
689 | rxvt_fontprop properties (); |
|
|
690 | |
|
|
691 | bool load (const rxvt_fontprop &prop); |
622 | |
692 | |
623 | void draw (int x, int y, |
693 | void draw (int x, int y, |
624 | const text_t *text, int len, |
694 | const text_t *text, int len, |
625 | int fg, int bg); |
695 | int fg, int bg); |
626 | |
696 | |
… | |
… | |
658 | for (int i = 0; i < SWATHCOUNT; i++) |
728 | for (int i = 0; i < SWATHCOUNT; i++) |
659 | delete cvr[i]; |
729 | delete cvr[i]; |
660 | #endif |
730 | #endif |
661 | } |
731 | } |
662 | |
732 | |
|
|
733 | rxvt_fontprop |
|
|
734 | rxvt_font_xft::properties () |
|
|
735 | { |
|
|
736 | rxvt_fontprop p; |
|
|
737 | |
|
|
738 | FT_Face face = XftLockFace (f); |
|
|
739 | |
|
|
740 | p.height = height; |
|
|
741 | 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; |
|
|
743 | |
|
|
744 | XftUnlockFace (f); |
|
|
745 | |
|
|
746 | return p; |
|
|
747 | } |
|
|
748 | |
663 | bool |
749 | bool |
664 | rxvt_font_xft::load (int maxheight) |
750 | rxvt_font_xft::load (const rxvt_fontprop &prop) |
665 | { |
751 | { |
666 | #if 0 |
752 | #if 0 |
667 | for (int i = 0; i < SWATHCOUNT; i++) |
753 | for (int i = 0; i < SWATHCOUNT; i++) |
668 | cvr[i] = 0; |
754 | cvr[i] = 0; |
669 | #endif |
755 | #endif |
670 | |
756 | |
671 | clear (); |
757 | clear (); |
672 | |
758 | |
673 | f = XftFontOpenName (DISPLAY, DefaultScreen (DISPLAY), name); |
759 | FcPattern *p = FcNameParse ((FcChar8 *) name); |
|
|
760 | |
|
|
761 | if (!p) |
|
|
762 | return false; |
|
|
763 | |
|
|
764 | FcValue v; |
|
|
765 | |
|
|
766 | if (FcPatternGet (p, FC_WEIGHT, 0, &v) != FcResultMatch) |
|
|
767 | FcPatternAddInteger (p, FC_WEIGHT, prop.weight); |
|
|
768 | |
|
|
769 | if (FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) |
|
|
770 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
|
|
771 | |
|
|
772 | //FcPatternAddBool (p, FC_MINSPACE, 1); |
|
|
773 | |
|
|
774 | XftResult result; |
|
|
775 | FcPattern *match = XftFontMatch (DISPLAY, DefaultScreen (DISPLAY), p, &result); |
|
|
776 | |
|
|
777 | FcPatternDestroy (p); |
|
|
778 | |
|
|
779 | if (!match) |
|
|
780 | return false; |
|
|
781 | |
|
|
782 | f = XftFontOpenPattern (DISPLAY, match); |
674 | |
783 | |
675 | if (!f) |
784 | if (!f) |
|
|
785 | { |
|
|
786 | FcPatternDestroy (match); |
676 | return false; |
787 | return false; |
|
|
788 | } |
677 | |
789 | |
678 | FT_Face face = XftLockFace (f); |
790 | FT_Face face = XftLockFace (f); |
679 | |
791 | |
680 | prop = !FT_IS_FIXED_WIDTH (face); |
792 | slow = !FT_IS_FIXED_WIDTH (face); |
681 | |
793 | |
682 | int ftheight = 0; |
794 | int ftheight = 0; |
683 | |
795 | |
684 | for (;;) |
796 | for (;;) |
685 | { |
797 | { |
… | |
… | |
687 | FcChar8 c; |
799 | FcChar8 c; |
688 | |
800 | |
689 | c = 'i'; XftTextExtents8 (DISPLAY, f, &c, 1, &g1); |
801 | c = 'i'; XftTextExtents8 (DISPLAY, f, &c, 1, &g1); |
690 | c = 'W'; XftTextExtents8 (DISPLAY, f, &c, 1, &g2); |
802 | c = 'W'; XftTextExtents8 (DISPLAY, f, &c, 1, &g2); |
691 | |
803 | |
692 | prop = prop || g1.xOff != g2.xOff; // don't simply trust the font |
804 | if (g1.xOff != g2.xOff) // don't simply trust the font |
|
|
805 | slow = true; |
693 | |
806 | |
694 | width = g2.xOff; |
807 | width = g2.xOff; |
695 | ascent = (face->size->metrics.ascender + 63) >> 6; |
808 | ascent = (face->size->metrics.ascender + 63) >> 6; |
696 | descent = (-face->size->metrics.descender + 63) >> 6; |
809 | descent = (-face->size->metrics.descender + 63) >> 6; |
697 | height = ascent + descent; |
810 | height = ascent + descent; |
698 | |
811 | |
699 | if (height <= maxheight || !maxheight) |
812 | if (height <= prop.height || !prop.height) |
700 | break; |
813 | break; |
701 | |
814 | |
702 | if (ftheight) |
815 | if (ftheight) |
703 | { |
816 | { |
704 | // take smaller steps near the end |
817 | // take smaller steps near the end |
705 | if (height > maxheight + 1) ftheight++; |
818 | if (height > prop.height + 1) ftheight++; |
706 | if (height > maxheight + 2) ftheight++; |
819 | if (height > prop.height + 2) ftheight++; |
707 | if (height > maxheight + 3) ftheight++; |
820 | if (height > prop.height + 3) ftheight++; |
708 | |
821 | |
709 | FT_Set_Pixel_Sizes (face, 0, ftheight -= height - maxheight); |
822 | FT_Set_Pixel_Sizes (face, 0, ftheight -= height - prop.height); |
710 | } |
823 | } |
711 | else |
824 | else |
712 | FT_Set_Pixel_Sizes (face, 0, ftheight = maxheight); |
825 | FT_Set_Pixel_Sizes (face, 0, ftheight = prop.height); |
713 | } |
826 | } |
714 | |
827 | |
715 | XftUnlockFace (f); |
828 | XftUnlockFace (f); |
716 | |
829 | |
717 | return true; |
830 | return true; |
… | |
… | |
749 | if (bg >= 0 && bg != Color_bg) |
862 | if (bg >= 0 && bg != Color_bg) |
750 | XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); |
863 | XftDrawRect (d, &r->PixColors[bg].c, x, y, r->TermWin.fwidth * len, r->TermWin.fheight); |
751 | else |
864 | else |
752 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
865 | clear_rect (x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg); |
753 | |
866 | |
754 | if (!prop && width == r->TermWin.fwidth) |
867 | if (!slow && width == r->TermWin.fwidth) |
755 | { |
868 | { |
756 | if (sizeof (text_t) == sizeof (FcChar16)) |
869 | if (sizeof (text_t) == sizeof (FcChar16)) |
757 | XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, len); |
870 | XftDrawString16 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar16 *)text, len); |
758 | else |
871 | else |
759 | XftDrawString32 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar32 *)text, len); |
872 | XftDrawString32 (d, &r->PixColors[fg].c, f, x, y + r->TermWin.fbase, (const FcChar32 *)text, len); |
… | |
… | |
799 | for (rxvt_font **i = fonts.begin (); i != fonts.end(); i++) |
912 | for (rxvt_font **i = fonts.begin (); i != fonts.end(); i++) |
800 | FONT_UNREF (*i); |
913 | FONT_UNREF (*i); |
801 | |
914 | |
802 | fonts.clear (); |
915 | fonts.clear (); |
803 | base_id = 0; |
916 | base_id = 0; |
804 | height = 0x7fffffff; |
917 | base_prop.height = 0x7fffffff; |
|
|
918 | base_prop.weight = rxvt_fontprop::medium; |
|
|
919 | base_prop.slant = rxvt_fontprop::roman; |
805 | |
920 | |
806 | fallback = fallback_fonts; |
921 | fallback = fallback_fonts; |
807 | } |
922 | } |
808 | |
923 | |
809 | rxvt_font * |
924 | rxvt_font * |
… | |
… | |
894 | rxvt_fontset::realize_font (int i) |
1009 | rxvt_fontset::realize_font (int i) |
895 | { |
1010 | { |
896 | if (fonts[i]->loaded) |
1011 | if (fonts[i]->loaded) |
897 | return true; |
1012 | return true; |
898 | |
1013 | |
899 | if (fonts[i]->load (height)) |
|
|
900 | return fonts[i]->loaded = true; |
1014 | fonts[i]->loaded = true; |
901 | |
1015 | |
902 | delete fonts[i]; |
1016 | if (!fonts[i]->load (base_prop)) |
903 | fonts.erase (fonts.begin () + i); |
1017 | { |
904 | |
1018 | fonts[i]->cs = CS_UNKNOWN; |
905 | return false; |
1019 | return false; |
|
|
1020 | } |
|
|
1021 | |
|
|
1022 | return true; |
906 | } |
1023 | } |
907 | |
1024 | |
908 | void |
1025 | void |
909 | rxvt_fontset::populate (const char *desc) |
1026 | rxvt_fontset::populate (const char *desc) |
910 | { |
1027 | { |
… | |
… | |
917 | |
1034 | |
918 | if (!base_id) |
1035 | if (!base_id) |
919 | base_id = 1; |
1036 | base_id = 1; |
920 | |
1037 | |
921 | // we currently need a base-font, no matter what |
1038 | // we currently need a base-font, no matter what |
922 | if (fonts.size () <= base_id) |
1039 | if (fonts.size () <= base_id || !realize_font (base_id)) |
923 | { |
1040 | { |
924 | add_fonts ("fixed"); |
1041 | add_fonts ("fixed"); |
925 | base_id = 1; |
1042 | base_id = fonts.size () - 1; |
926 | } |
1043 | } |
927 | |
1044 | |
928 | if (fonts.size () <= base_id || !realize_font (base_id)) |
1045 | if (fonts.size () <= base_id || !realize_font (base_id)) |
929 | { |
1046 | { |
930 | fprintf (stderr, "unable to load a base font, please provide one using -fn fontname\n"); |
1047 | fprintf (stderr, "unable to load a base font, please provide one using -fn fontname\n"); |
931 | exit (1); |
1048 | exit (1); |
932 | } |
1049 | } |
933 | |
1050 | |
934 | height = fonts[base_id]->height; |
1051 | base_prop = fonts[base_id]->properties (); |
935 | |
|
|
936 | /*add_fonts ("-efont-fixed-medium-r-normal-*-14-*-*-*-*-*-iso10646-1,"*/ |
|
|
937 | } |
1052 | } |
938 | |
1053 | |
939 | int |
1054 | int |
940 | rxvt_fontset::find_font (uint32_t unicode) |
1055 | rxvt_fontset::find_font (uint32_t unicode) |
941 | { |
1056 | { |
… | |
… | |
947 | { |
1062 | { |
948 | if (FROM_UNICODE (f->cs, unicode) == NOCHAR) |
1063 | if (FROM_UNICODE (f->cs, unicode) == NOCHAR) |
949 | goto next_font; |
1064 | goto next_font; |
950 | |
1065 | |
951 | if (!realize_font (i)) |
1066 | if (!realize_font (i)) |
952 | { |
|
|
953 | --i; |
|
|
954 | goto next_font; |
1067 | goto next_font; |
955 | } |
1068 | } |
956 | |
1069 | |
957 | //printf ("added font %s for %04lx\n", f->name, unicode); |
|
|
958 | } |
|
|
959 | |
|
|
960 | if (f->has_codepoint (unicode)) |
1070 | if (f->cs != CS_UNKNOWN && f->has_codepoint (unicode)) |
961 | return i; |
1071 | return i; |
962 | |
1072 | |
963 | next_font: |
1073 | next_font: |
964 | if (i == fonts.size () - 1 && fallback->name) |
1074 | if (i == fonts.size () - 1 && fallback->name) |
965 | { |
1075 | { |
966 | fonts.push_back (new_font (fallback->name, fallback->cs)); |
1076 | fonts.push_back (new_font (fallback->name, fallback->cs)); |
967 | fallback++; |
1077 | fallback++; |
|
|
1078 | i = 0; |
968 | } |
1079 | } |
969 | } |
1080 | } |
970 | |
1081 | |
971 | return 0; /* we must return SOME font */ |
1082 | return 0; /* we must return SOME font */ |
972 | } |
1083 | } |