ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtfont.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtfont.C (file contents):
Revision 1.86 by root, Wed Jan 25 13:24:45 2006 UTC vs.
Revision 1.90 by root, Mon Jan 30 02:21:20 2006 UTC

157 0x304c, 0x672c, // が本 157 0x304c, 0x672c, // が本
158}; 158};
159 159
160#define NUM_EXTENT_TEST_CHARS (sizeof (extent_test_chars) / sizeof (extent_test_chars[0])) 160#define NUM_EXTENT_TEST_CHARS (sizeof (extent_test_chars) / sizeof (extent_test_chars[0]))
161 161
162#define dTermDisplay Display *disp = term->display->display 162#define dTermDisplay Display *disp = term->xdisp
163#define dTermGC GC gc = term->gc 163#define dTermGC GC gc = term->gc
164 164
165///////////////////////////////////////////////////////////////////////////// 165/////////////////////////////////////////////////////////////////////////////
166 166
167#if XFT 167#if XFT
172} 172}
173 173
174rxvt_drawable::operator XftDraw *() 174rxvt_drawable::operator XftDraw *()
175{ 175{
176 if (!xftdrawable) 176 if (!xftdrawable)
177 xftdrawable = XftDrawCreate (display->display, drawable, display->visual, display->cmap); 177 xftdrawable = XftDrawCreate (screen->xdisp, drawable, screen->visual, screen->cmap);
178 178
179 return xftdrawable; 179 return xftdrawable;
180} 180}
181#endif 181#endif
182 182
245{ 245{
246 dTermDisplay; 246 dTermDisplay;
247 dTermGC; 247 dTermGC;
248 248
249 if (color == Color_bg) 249 if (color == Color_bg)
250 XClearArea (disp, d, x, y, w, h, FALSE); 250 XClearArea (disp, d, x, y, w, h, false);
251 else if (color >= 0) 251 else if (color >= 0)
252 { 252 {
253#if XFT 253#if XFT
254 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h); 254 XftDrawRect (d, &term->pix_colors[color].c, x, y, w, h);
255#else 255#else
493 bool slow; // wether this is a proportional font or has other funny characteristics 493 bool slow; // wether this is a proportional font or has other funny characteristics
494 XFontStruct *f; 494 XFontStruct *f;
495 codeset cs; 495 codeset cs;
496 bool enc2b, encm; 496 bool enc2b, encm;
497 497
498 char *get_property (XFontStruct *f, const char *property, const char *repl) const; 498 char *get_property (XFontStruct *f, Atom property, const char *repl) const;
499 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); 499 bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth);
500 bool set_properties (rxvt_fontprop &p, XFontStruct *f); 500 bool set_properties (rxvt_fontprop &p, XFontStruct *f);
501 bool set_properties (rxvt_fontprop &p, const char *name); 501 bool set_properties (rxvt_fontprop &p, const char *name);
502}; 502};
503 503
504char * 504char *
505rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const 505rxvt_font_x11::get_property (XFontStruct *f, Atom property, const char *repl) const
506{ 506{
507 unsigned long value; 507 unsigned long value;
508 508
509 if (XGetFontProperty (f, XInternAtom (term->display->display, property, 0), &value)) 509 if (XGetFontProperty (f, property, &value))
510 return XGetAtomName (term->display->display, value); 510 return XGetAtomName (term->xdisp, value);
511 else 511 else
512 return rxvt_strdup (repl); 512 return rxvt_strdup (repl);
513} 513}
514 514
515rxvt_fontprop 515rxvt_fontprop
536rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) 536rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f)
537{ 537{
538 unsigned long height; 538 unsigned long height;
539 539
540#if 0 540#if 0
541 if (!XGetFontProperty (f, XInternAtom (term->display->display, "PIXEL_SIZE", 0), &height)) 541 if (!XGetFontProperty (f, XInternAtom (term->xdisp, "PIXEL_SIZE", 0), &height))
542 return false; 542 return false;
543#else 543#else
544 height = f->ascent + f->descent; 544 height = f->ascent + f->descent;
545#endif 545#endif
546 546
547 unsigned long avgwidth; 547 unsigned long avgwidth;
548 if (!XGetFontProperty (f, XInternAtom (term->display->display, "AVERAGE_WIDTH", 0), &avgwidth)) 548 if (!XGetFontProperty (f, term->xa [XA_AVERAGE_WIDTH], &avgwidth))
549 avgwidth = 0; 549 avgwidth = 0;
550 550
551 char *weight = get_property (f, "WEIGHT_NAME", "medium"); 551 char *weight = get_property (f, term->xa [XA_WEIGHT_NAME], "medium");
552 char *slant = get_property (f, "SLANT", "r"); 552 char *slant = get_property (f, term->xa [XA_SLANT], "r");
553 553
554 set_properties (p, height, weight, slant, avgwidth); 554 set_properties (p, height, weight, slant, avgwidth);
555 555
556 free (weight); 556 free (weight);
557 free (slant); 557 free (slant);
655 f = XLoadQueryFont (disp, name); 655 f = XLoadQueryFont (disp, name);
656 656
657 if (!f) 657 if (!f)
658 return false; 658 return false;
659 659
660 char *new_name = get_property (f, "FONT", name); 660 char *new_name = get_property (f, XA_FONT, name);
661 661
662 if (new_name) 662 if (new_name)
663 set_name (new_name); 663 set_name (new_name);
664 else 664 else
665 rxvt_warn ("font '%s' has no FONT property, continuing without.", name); 665 rxvt_warn ("font '%s' has no FONT property, continuing without.", name);
774 delete [] fonts; 774 delete [] fonts;
775 775
776 if (!f) 776 if (!f)
777 return false; 777 return false;
778 778
779 char *registry = get_property (f, "CHARSET_REGISTRY", 0); 779 char *registry = get_property (f, term->xa [XA_CHARSET_REGISTRY], 0);
780 char *encoding = get_property (f, "CHARSET_ENCODING", 0); 780 char *encoding = get_property (f, term->xa [XA_CHARSET_ENCODING], 0);
781 781
782 if (registry && encoding) 782 if (registry && encoding)
783 { 783 {
784 char charset[64]; 784 char charset[64];
785 snprintf (charset, 64, "%s-%s", registry, encoding); 785 snprintf (charset, 64, "%s-%s", registry, encoding);
786 786
787 cs = codeset_from_name (charset); 787 cs = codeset_from_name (charset);
788 } 788 }
789 else 789 else
790 { 790 {
791 const char *charset = get_property (f, "FONT", 0); 791 const char *charset = get_property (f, XA_FONT, 0);
792 792
793 if (!charset) 793 if (!charset)
794 charset = name; 794 charset = name;
795 795
796 int count = 13; 796 int count = 13;
884void 884void
885rxvt_font_x11::clear () 885rxvt_font_x11::clear ()
886{ 886{
887 if (f) 887 if (f)
888 { 888 {
889 XFreeFont (term->display->display, f); 889 XFreeFont (term->xdisp, f);
890 f = 0; 890 f = 0;
891 } 891 }
892} 892}
893 893
894bool 894bool
1066void 1066void
1067rxvt_font_xft::clear () 1067rxvt_font_xft::clear ()
1068{ 1068{
1069 if (f) 1069 if (f)
1070 { 1070 {
1071 XftFontClose (term->display->display, f); 1071 XftFontClose (term->xdisp, f);
1072 f = 0; 1072 f = 0;
1073 } 1073 }
1074} 1074}
1075 1075
1076rxvt_fontprop 1076rxvt_fontprop
1243bool 1243bool
1244rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const 1244rxvt_font_xft::has_char (unicode_t unicode, const rxvt_fontprop *prop, bool &careful) const
1245{ 1245{
1246 careful = false; 1246 careful = false;
1247 1247
1248 if (!XftCharExists (term->display->display, f, unicode)) 1248 if (!XftCharExists (term->xdisp, f, unicode))
1249 return false; 1249 return false;
1250 1250
1251 if (!prop || prop->width == rxvt_fontprop::unset) 1251 if (!prop || prop->width == rxvt_fontprop::unset)
1252 return true; 1252 return true;
1253 1253
1254 // check character against base font bounding box 1254 // check character against base font bounding box
1255 FcChar32 ch = unicode; 1255 FcChar32 ch = unicode;
1256 XGlyphInfo g; 1256 XGlyphInfo g;
1257 XftTextExtents32 (term->display->display, f, &ch, 1, &g); 1257 XftTextExtents32 (term->xdisp, f, &ch, 1, &g);
1258 1258
1259 int w = g.width - g.x; 1259 int w = g.width - g.x;
1260 int wcw = WCWIDTH (unicode); 1260 int wcw = WCWIDTH (unicode);
1261 if (wcw > 0) w = (w + wcw - 1) / wcw; 1261 if (wcw > 0) w = (w + wcw - 1) / wcw;
1262 1262
1560 FcPatternAddInteger (p, FC_SLANT, prop.slant); 1560 FcPatternAddInteger (p, FC_SLANT, prop.slant);
1561 FcPatternAddBool (p, FC_MINSPACE, 1); 1561 FcPatternAddBool (p, FC_MINSPACE, 1);
1562 //FcPatternAddBool (p, FC_ANTIALIAS, 1); 1562 //FcPatternAddBool (p, FC_ANTIALIAS, 1);
1563 1563
1564 XftResult result; 1564 XftResult result;
1565 FcPattern *match = XftFontMatch (term->display->display, term->display->screen, p, &result); 1565 FcPattern *match = XftFontMatch (term->xdisp, term->display->screen, p, &result);
1566 1566
1567 FcPatternDestroy (p); 1567 FcPatternDestroy (p);
1568 1568
1569 if (match) 1569 if (match)
1570 { 1570 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines