… | |
… | |
79 | |
79 | |
80 | // japanese |
80 | // japanese |
81 | #if ENCODING_JP || ENCODING_JP_EXT |
81 | #if ENCODING_JP || ENCODING_JP_EXT |
82 | # if XFT |
82 | # if XFT |
83 | // prefer xft for complex scripts |
83 | // prefer xft for complex scripts |
|
|
84 | { CS_JIS0208_1990_0, "xft:Sazanami Mincho:antialias=false" }, |
84 | { CS_JIS0208_1990_0, "xft:Kochi Gothic:antialias=false" }, |
85 | { CS_JIS0208_1990_0, "xft:Kochi Gothic:antialias=false" }, |
85 | { CS_JIS0208_1990_0, "xft:Sazanami Mincho:antialias=false" }, |
|
|
86 | { CS_JIS0208_1990_0, "xft:Mincho:antialias=false" }, |
86 | { CS_JIS0208_1990_0, "xft:Mincho:antialias=false" }, |
87 | { CS_JIS0208_1990_0, "xft::lang=ja:antialias=false" }, |
87 | { CS_JIS0208_1990_0, "xft::lang=ja:antialias=false" }, |
88 | # endif |
88 | # endif |
89 | { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
89 | { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, |
90 | { CS_JIS0208_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
90 | { CS_JIS0208_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, |
… | |
… | |
216 | : name(0), width(rxvt_fontprop::unset), height(rxvt_fontprop::unset) |
216 | : name(0), width(rxvt_fontprop::unset), height(rxvt_fontprop::unset) |
217 | { |
217 | { |
218 | } |
218 | } |
219 | |
219 | |
220 | void |
220 | void |
221 | rxvt_font::set_name (char *name) |
221 | rxvt_font::set_name (char *name_) |
222 | { |
222 | { |
223 | if (this->name == name) |
223 | if (name == name_) |
224 | return; |
224 | return; |
225 | |
225 | |
226 | if (this->name) free (this->name); // let the compiler optimize |
226 | if (name) free (name); // let the compiler optimize |
227 | this->name = name; |
227 | name = name_; |
228 | } |
228 | } |
229 | |
229 | |
230 | void |
230 | void |
231 | rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const |
231 | rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color) const |
232 | { |
232 | { |
… | |
… | |
792 | return false; |
792 | return false; |
793 | |
793 | |
794 | char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0); |
794 | char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0); |
795 | char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0); |
795 | char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0); |
796 | |
796 | |
|
|
797 | cs = CS_UNKNOWN; |
|
|
798 | |
797 | if (registry && encoding) |
799 | if (registry && encoding) |
798 | { |
800 | { |
799 | char charset[64]; |
801 | char charset[64]; |
800 | snprintf (charset, 64, "%s-%s", registry, encoding); |
802 | snprintf (charset, 64, "%s-%s", registry, encoding); |
801 | |
803 | |
802 | cs = codeset_from_name (charset); |
804 | cs = codeset_from_name (charset); |
|
|
805 | |
|
|
806 | if (cs == CS_UNKNOWN) |
|
|
807 | rxvt_warn ("%s: cannot deduce encoding from registry/encoding properties \"%s\", ignoring font.\n", name, charset); |
803 | } |
808 | } |
804 | else |
809 | |
|
|
810 | free (registry); |
|
|
811 | free (encoding); |
|
|
812 | |
|
|
813 | if (cs == CS_UNKNOWN) |
805 | { |
814 | { |
806 | const char *charset = get_property (f, XA_FONT, 0); |
815 | const char *charset = get_property (f, XA_FONT, 0); |
807 | |
816 | |
808 | if (!charset) |
817 | if (!charset) |
809 | charset = name; |
818 | charset = name; |
… | |
… | |
812 | while (*charset) |
821 | while (*charset) |
813 | if (*charset++ == '-' && !--count) |
822 | if (*charset++ == '-' && !--count) |
814 | break; |
823 | break; |
815 | |
824 | |
816 | cs = codeset_from_name (charset); |
825 | cs = codeset_from_name (charset); |
|
|
826 | if (cs == CS_UNKNOWN) |
|
|
827 | rxvt_warn ("%s: cannot deduce encoding from font name property \"%s\", ignoring font.\n", name, charset); |
|
|
828 | } |
|
|
829 | |
|
|
830 | if (cs == CS_UNKNOWN) |
817 | } |
831 | { |
818 | |
832 | clear (); |
819 | free (registry); |
833 | return false; |
820 | free (encoding); |
834 | } |
821 | |
835 | |
822 | if (cs == CS_UNICODE) |
836 | if (cs == CS_UNICODE) |
823 | cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font |
837 | cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font |
824 | |
838 | |
825 | encm = f->min_byte1 != 0 || f->max_byte1 != 0; |
839 | encm = f->min_byte1 != 0 || f->max_byte1 != 0; |
… | |
… | |
870 | |
884 | |
871 | int wcw = WCWIDTH (*t); |
885 | int wcw = WCWIDTH (*t); |
872 | if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
886 | if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; |
873 | |
887 | |
874 | if (width < g.width) width = g.width; |
888 | if (width < g.width) width = g.width; |
875 | } |
|
|
876 | |
|
|
877 | if (cs == CS_UNKNOWN) |
|
|
878 | { |
|
|
879 | fprintf (stderr, "unable to deduce codeset, ignoring font '%s'\n", name); |
|
|
880 | |
|
|
881 | clear (); |
|
|
882 | return false; |
|
|
883 | } |
889 | } |
884 | |
890 | |
885 | #if 0 // do it per-character |
891 | #if 0 // do it per-character |
886 | if (prop && width > prop->width) |
892 | if (prop && width > prop->width) |
887 | { |
893 | { |
… | |
… | |
1133 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1139 | FcPatternAddInteger (p, FC_SLANT, prop.slant); |
1134 | |
1140 | |
1135 | #if 0 // clipping unfortunately destroys our precious double-width-characters |
1141 | #if 0 // clipping unfortunately destroys our precious double-width-characters |
1136 | // clip width, we can't do better, or can we? |
1142 | // clip width, we can't do better, or can we? |
1137 | if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) |
1143 | if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) |
1138 | FcPatternAddInteger (p, FC_CHAR_WIDTH, prop->width); |
1144 | FcPatternAddInteger (p, FC_CHAR_WIDTH, prop.width); |
1139 | #endif |
1145 | #endif |
1140 | |
1146 | |
1141 | if (FcPatternGet (p, FC_MINSPACE, 0, &v) != FcResultMatch) |
1147 | if (FcPatternGet (p, FC_MINSPACE, 0, &v) != FcResultMatch) |
1142 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1148 | FcPatternAddBool (p, FC_MINSPACE, 1); |
1143 | |
1149 | |
… | |
… | |
1287 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1293 | rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, |
1288 | const text_t *text, int len, |
1294 | const text_t *text, int len, |
1289 | int fg, int bg) |
1295 | int fg, int bg) |
1290 | { |
1296 | { |
1291 | XGlyphInfo extents; |
1297 | XGlyphInfo extents; |
1292 | XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); |
1298 | XftGlyphSpec *enc = rxvt_temp_buf<XftGlyphSpec> (len); |
1293 | XftGlyphSpec *ep = enc; |
1299 | XftGlyphSpec *ep = enc; |
1294 | |
1300 | |
1295 | dTermDisplay; |
1301 | dTermDisplay; |
1296 | dTermGC; |
1302 | dTermGC; |
1297 | |
1303 | |
1298 | int w = term->fwidth * len; |
1304 | int w = term->fwidth * len; |
1299 | int h = term->fheight; |
1305 | int h = term->fheight; |
1300 | |
1306 | |
1301 | /* |
|
|
1302 | * Maybe make buffering into a resource flag? Compile time option doesn't seems like a |
|
|
1303 | * good idea from the perspective of packaging for wide variety of user configs. |
|
|
1304 | */ |
|
|
1305 | bool buffered = bg >= Color_transparent |
1307 | bool buffered = bg >= Color_transparent |
1306 | && term->option (Opt_buffered); |
1308 | && term->option (Opt_buffered); |
1307 | |
1309 | |
1308 | // cut trailing spaces |
1310 | // cut trailing spaces |
1309 | while (len && text [len - 1] == ' ') |
1311 | while (len && text [len - 1] == ' ') |
1310 | len--; |
1312 | len--; |
1311 | |
1313 | |
… | |
… | |
1673 | FcPatternDestroy (match); |
1675 | FcPatternDestroy (match); |
1674 | |
1676 | |
1675 | if (find_font (font) < 0) |
1677 | if (find_font (font) < 0) |
1676 | { |
1678 | { |
1677 | char fontname[4096]; |
1679 | char fontname[4096]; |
1678 | sprintf (fontname, "xft:%-.4090s", font); |
1680 | snprintf (fontname, sizeof (fontname), "xft:%s", font); |
1679 | |
1681 | |
1680 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1682 | fonts.push_back (new_font (fontname, CS_UNICODE)); |
1681 | } |
1683 | } |
1682 | |
1684 | |
1683 | free (font); |
1685 | free (font); |
… | |
… | |
1707 | } |
1709 | } |
1708 | |
1710 | |
1709 | return i; |
1711 | return i; |
1710 | } |
1712 | } |
1711 | |
1713 | |
1712 | |
|
|
1713 | |
|
|