comparison src/xftfont.c @ 109126:aec1143e8d85

Convert (most) functions in src to standard C. * src/alloc.c: Convert function definitions to standard C. * src/atimer.c: * src/bidi.c: * src/bytecode.c: * src/callint.c: * src/callproc.c: * src/casefiddle.c: * src/casetab.c: * src/category.c: * src/ccl.c: * src/character.c: * src/charset.c: * src/chartab.c: * src/cmds.c: * src/coding.c: * src/composite.c: * src/data.c: * src/dbusbind.c: * src/dired.c: * src/dispnew.c: * src/doc.c: * src/doprnt.c: * src/ecrt0.c: * src/editfns.c: * src/fileio.c: * src/filelock.c: * src/filemode.c: * src/fns.c: * src/font.c: * src/fontset.c: * src/frame.c: * src/fringe.c: * src/ftfont.c: * src/ftxfont.c: * src/gtkutil.c: * src/indent.c: * src/insdel.c: * src/intervals.c: * src/keymap.c: * src/lread.c: * src/macros.c: * src/marker.c: * src/md5.c: * src/menu.c: * src/minibuf.c: * src/prefix-args.c: * src/print.c: * src/ralloc.c: * src/regex.c: * src/region-cache.c: * src/scroll.c: * src/search.c: * src/sound.c: * src/strftime.c: * src/syntax.c: * src/sysdep.c: * src/termcap.c: * src/terminal.c: * src/terminfo.c: * src/textprop.c: * src/tparam.c: * src/undo.c: * src/unexelf.c: * src/window.c: * src/xfaces.c: * src/xfns.c: * src/xfont.c: * src/xftfont.c: * src/xgselect.c: * src/xmenu.c: * src/xrdb.c: * src/xselect.c: * src/xsettings.c: * src/xsmfns.c: * src/xterm.c: Likewise.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 04 Jul 2010 00:50:25 -0700
parents 2bc9a0c04c87
children c4c8e4a16194
comparison
equal deleted inserted replaced
109125:12b02558bf51 109126:aec1143e8d85
78 /* Setup foreground and background colors of GC into FG and BG. If 78 /* Setup foreground and background colors of GC into FG and BG. If
79 XFTFACE_INFO is not NULL, reuse the colors in it if possible. BG 79 XFTFACE_INFO is not NULL, reuse the colors in it if possible. BG
80 may be NULL. */ 80 may be NULL. */
81 81
82 static void 82 static void
83 xftfont_get_colors (f, face, gc, xftface_info, fg, bg) 83 xftfont_get_colors (FRAME_PTR f, struct face *face, GC gc, struct xftface_info *xftface_info, XftColor *fg, XftColor *bg)
84 FRAME_PTR f;
85 struct face *face;
86 GC gc;
87 struct xftface_info *xftface_info;
88 XftColor *fg, *bg;
89 { 84 {
90 if (xftface_info && face->gc == gc) 85 if (xftface_info && face->gc == gc)
91 { 86 {
92 *fg = xftface_info->xft_fg; 87 *fg = xftface_info->xft_fg;
93 if (bg) 88 if (bg)
155 static int xftfont_end_for_frame (FRAME_PTR f); 150 static int xftfont_end_for_frame (FRAME_PTR f);
156 151
157 struct font_driver xftfont_driver; 152 struct font_driver xftfont_driver;
158 153
159 static Lisp_Object 154 static Lisp_Object
160 xftfont_list (frame, spec) 155 xftfont_list (Lisp_Object frame, Lisp_Object spec)
161 Lisp_Object frame;
162 Lisp_Object spec;
163 { 156 {
164 Lisp_Object list = ftfont_driver.list (frame, spec), tail; 157 Lisp_Object list = ftfont_driver.list (frame, spec), tail;
165 158
166 for (tail = list; CONSP (tail); tail = XCDR (tail)) 159 for (tail = list; CONSP (tail); tail = XCDR (tail))
167 ASET (XCAR (tail), FONT_TYPE_INDEX, Qxft); 160 ASET (XCAR (tail), FONT_TYPE_INDEX, Qxft);
168 return list; 161 return list;
169 } 162 }
170 163
171 static Lisp_Object 164 static Lisp_Object
172 xftfont_match (frame, spec) 165 xftfont_match (Lisp_Object frame, Lisp_Object spec)
173 Lisp_Object frame;
174 Lisp_Object spec;
175 { 166 {
176 Lisp_Object entity = ftfont_driver.match (frame, spec); 167 Lisp_Object entity = ftfont_driver.match (frame, spec);
177 168
178 if (! NILP (entity)) 169 if (! NILP (entity))
179 ASET (entity, FONT_TYPE_INDEX, Qxft); 170 ASET (entity, FONT_TYPE_INDEX, Qxft);
185 extern Lisp_Object QCantialias; 176 extern Lisp_Object QCantialias;
186 177
187 static FcChar8 ascii_printable[95]; 178 static FcChar8 ascii_printable[95];
188 179
189 static void 180 static void
190 xftfont_fix_match (pat, match) 181 xftfont_fix_match (FcPattern *pat, FcPattern *match)
191 FcPattern *pat, *match;
192 { 182 {
193 /* These values are not used for matching (except antialias), but for 183 /* These values are not used for matching (except antialias), but for
194 rendering, so make sure they are carried over to the match. 184 rendering, so make sure they are carried over to the match.
195 We also put antialias here because most fonts are antialiased, so 185 We also put antialias here because most fonts are antialiased, so
196 the match will have antialias true. */ 186 the match will have antialias true. */
236 FcPatternAddDouble (match, FC_DPI, dpi); 226 FcPatternAddDouble (match, FC_DPI, dpi);
237 } 227 }
238 } 228 }
239 229
240 static void 230 static void
241 xftfont_add_rendering_parameters (pat, entity) 231 xftfont_add_rendering_parameters (FcPattern *pat, Lisp_Object entity)
242 FcPattern *pat;
243 Lisp_Object entity;
244 { 232 {
245 Lisp_Object tail; 233 Lisp_Object tail;
246 int ival; 234 int ival;
247 235
248 for (tail = AREF (entity, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail)) 236 for (tail = AREF (entity, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail))
286 #endif 274 #endif
287 } 275 }
288 } 276 }
289 277
290 static Lisp_Object 278 static Lisp_Object
291 xftfont_open (f, entity, pixel_size) 279 xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
292 FRAME_PTR f;
293 Lisp_Object entity;
294 int pixel_size;
295 { 280 {
296 FcResult result; 281 FcResult result;
297 Display *display = FRAME_X_DISPLAY (f); 282 Display *display = FRAME_X_DISPLAY (f);
298 Lisp_Object val, filename, index, font_object; 283 Lisp_Object val, filename, index, font_object;
299 FcPattern *pat = NULL, *match; 284 FcPattern *pat = NULL, *match;
508 493
509 return font_object; 494 return font_object;
510 } 495 }
511 496
512 static void 497 static void
513 xftfont_close (f, font) 498 xftfont_close (FRAME_PTR f, struct font *font)
514 FRAME_PTR f;
515 struct font *font;
516 { 499 {
517 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; 500 struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
518 501
519 #ifdef HAVE_LIBOTF 502 #ifdef HAVE_LIBOTF
520 if (xftfont_info->otf) 503 if (xftfont_info->otf)
525 XftFontClose (xftfont_info->display, xftfont_info->xftfont); 508 XftFontClose (xftfont_info->display, xftfont_info->xftfont);
526 UNBLOCK_INPUT; 509 UNBLOCK_INPUT;
527 } 510 }
528 511
529 static int 512 static int
530 xftfont_prepare_face (f, face) 513 xftfont_prepare_face (FRAME_PTR f, struct face *face)
531 FRAME_PTR f;
532 struct face *face;
533 { 514 {
534 struct xftface_info *xftface_info; 515 struct xftface_info *xftface_info;
535 516
536 #if 0 517 #if 0
537 /* This doesn't work if face->ascii_face doesn't use an Xft font. */ 518 /* This doesn't work if face->ascii_face doesn't use an Xft font. */
550 face->extra = xftface_info; 531 face->extra = xftface_info;
551 return 0; 532 return 0;
552 } 533 }
553 534
554 static void 535 static void
555 xftfont_done_face (f, face) 536 xftfont_done_face (FRAME_PTR f, struct face *face)
556 FRAME_PTR f;
557 struct face *face;
558 { 537 {
559 struct xftface_info *xftface_info; 538 struct xftface_info *xftface_info;
560 539
561 #if 0 540 #if 0
562 /* This doesn't work if face->ascii_face doesn't use an Xft font. */ 541 /* This doesn't work if face->ascii_face doesn't use an Xft font. */
574 } 553 }
575 554
576 extern Lisp_Object Qja, Qko; 555 extern Lisp_Object Qja, Qko;
577 556
578 static int 557 static int
579 xftfont_has_char (font, c) 558 xftfont_has_char (Lisp_Object font, int c)
580 Lisp_Object font;
581 int c;
582 { 559 {
583 struct xftfont_info *xftfont_info; 560 struct xftfont_info *xftfont_info;
584 struct charset *cs = NULL; 561 struct charset *cs = NULL;
585 562
586 if (EQ (AREF (font, FONT_ADSTYLE_INDEX), Qja) 563 if (EQ (AREF (font, FONT_ADSTYLE_INDEX), Qja)
598 return (XftCharExists (xftfont_info->display, xftfont_info->xftfont, 575 return (XftCharExists (xftfont_info->display, xftfont_info->xftfont,
599 (FcChar32) c) == FcTrue); 576 (FcChar32) c) == FcTrue);
600 } 577 }
601 578
602 static unsigned 579 static unsigned
603 xftfont_encode_char (font, c) 580 xftfont_encode_char (struct font *font, int c)
604 struct font *font;
605 int c;
606 { 581 {
607 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; 582 struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
608 unsigned code = XftCharIndex (xftfont_info->display, xftfont_info->xftfont, 583 unsigned code = XftCharIndex (xftfont_info->display, xftfont_info->xftfont,
609 (FcChar32) c); 584 (FcChar32) c);
610 585
611 return (code ? code : FONT_INVALID_CODE); 586 return (code ? code : FONT_INVALID_CODE);
612 } 587 }
613 588
614 static int 589 static int
615 xftfont_text_extents (font, code, nglyphs, metrics) 590 xftfont_text_extents (struct font *font, unsigned int *code, int nglyphs, struct font_metrics *metrics)
616 struct font *font;
617 unsigned *code;
618 int nglyphs;
619 struct font_metrics *metrics;
620 { 591 {
621 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; 592 struct xftfont_info *xftfont_info = (struct xftfont_info *) font;
622 XGlyphInfo extents; 593 XGlyphInfo extents;
623 594
624 BLOCK_INPUT; 595 BLOCK_INPUT;
635 } 606 }
636 return extents.xOff; 607 return extents.xOff;
637 } 608 }
638 609
639 static XftDraw * 610 static XftDraw *
640 xftfont_get_xft_draw (f) 611 xftfont_get_xft_draw (FRAME_PTR f)
641 FRAME_PTR f;
642 { 612 {
643 XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver); 613 XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver);
644 614
645 if (! xft_draw) 615 if (! xft_draw)
646 { 616 {
656 } 626 }
657 return xft_draw; 627 return xft_draw;
658 } 628 }
659 629
660 static int 630 static int
661 xftfont_draw (s, from, to, x, y, with_background) 631 xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background)
662 struct glyph_string *s;
663 int from, to, x, y, with_background;
664 { 632 {
665 FRAME_PTR f = s->f; 633 FRAME_PTR f = s->f;
666 struct face *face = s->face; 634 struct face *face = s->face;
667 struct xftfont_info *xftfont_info = (struct xftfont_info *) s->font; 635 struct xftfont_info *xftfont_info = (struct xftfont_info *) s->font;
668 struct xftface_info *xftface_info = NULL; 636 struct xftface_info *xftface_info = NULL;
701 669
702 return len; 670 return len;
703 } 671 }
704 672
705 static int 673 static int
706 xftfont_end_for_frame (f) 674 xftfont_end_for_frame (FRAME_PTR f)
707 FRAME_PTR f;
708 { 675 {
709 XftDraw *xft_draw; 676 XftDraw *xft_draw;
710 677
711 /* Don't do anything if display is dead */ 678 /* Don't do anything if display is dead */
712 if (FRAME_X_DISPLAY (f) == NULL) return 0; 679 if (FRAME_X_DISPLAY (f) == NULL) return 0;
722 } 689 }
723 return 0; 690 return 0;
724 } 691 }
725 692
726 static int 693 static int
727 xftfont_cached_font_ok (f, font_object, entity) 694 xftfont_cached_font_ok (struct frame *f, Lisp_Object font_object, Lisp_Object entity)
728 struct frame *f;
729 Lisp_Object font_object;
730 Lisp_Object entity;
731
732 { 695 {
733 struct xftfont_info *info = (struct xftfont_info *) XFONT_OBJECT (font_object); 696 struct xftfont_info *info = (struct xftfont_info *) XFONT_OBJECT (font_object);
734 FcPattern *oldpat = info->xftfont->pattern; 697 FcPattern *oldpat = info->xftfont->pattern;
735 Display *display = FRAME_X_DISPLAY (f); 698 Display *display = FRAME_X_DISPLAY (f);
736 FcPattern *pat = FcPatternCreate (); 699 FcPattern *pat = FcPatternCreate ();
769 FcPatternDestroy (pat); 732 FcPatternDestroy (pat);
770 return ok; 733 return ok;
771 } 734 }
772 735
773 void 736 void
774 syms_of_xftfont () 737 syms_of_xftfont (void)
775 { 738 {
776 DEFSYM (Qxft, "xft"); 739 DEFSYM (Qxft, "xft");
777 DEFSYM (QChinting, ":hinting"); 740 DEFSYM (QChinting, ":hinting");
778 DEFSYM (QCautohint, ":autohint"); 741 DEFSYM (QCautohint, ":autohint");
779 DEFSYM (QChintstyle, ":hintstyle"); 742 DEFSYM (QChintstyle, ":hintstyle");