Mercurial > emacs
annotate src/xftfont.c @ 105215:48313e2e9ae3
Comments.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 26 Sep 2009 20:02:42 +0000 |
parents | a7805f91abdd |
children | 68dd71358159 |
rev | line source |
---|---|
90400 | 1 /* xftfont.c -- XFT font driver. |
100951 | 2 Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
3 Copyright (C) 2006, 2007, 2008, 2009 | |
90400 | 4 National Institute of Advanced Industrial Science and Technology (AIST) |
5 Registration Number H13PRO009 | |
6 | |
7 This file is part of GNU Emacs. | |
8 | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94941
diff
changeset
|
9 GNU Emacs is free software: you can redistribute it and/or modify |
90400 | 10 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94941
diff
changeset
|
11 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94941
diff
changeset
|
12 (at your option) any later version. |
90400 | 13 |
14 GNU Emacs is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94941
diff
changeset
|
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
90400 | 21 |
22 #include <config.h> | |
23 #include <stdio.h> | |
24 #include <X11/Xlib.h> | |
25 #include <X11/Xft/Xft.h> | |
26 | |
27 #include "lisp.h" | |
28 #include "dispextern.h" | |
29 #include "xterm.h" | |
30 #include "frame.h" | |
31 #include "blockinput.h" | |
32 #include "character.h" | |
33 #include "charset.h" | |
34 #include "fontset.h" | |
35 #include "font.h" | |
91143 | 36 #include "ftfont.h" |
90400 | 37 |
38 /* Xft font driver. */ | |
39 | |
40 static Lisp_Object Qxft; | |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
41 static Lisp_Object QChinting , QCautohint, QChintstyle, QCrgba, QCembolden; |
90400 | 42 |
43 /* The actual structure for Xft font that can be casted to struct | |
44 font. */ | |
45 | |
46 struct xftfont_info | |
47 { | |
48 struct font font; | |
101555
a8e049b0d2c2
(struct xftfont_info): New member `index'.
Kenichi Handa <handa@m17n.org>
parents:
100951
diff
changeset
|
49 /* The following four members must be here in this order to be |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
50 compatible with struct ftfont_info (in ftfont.c). */ |
91143 | 51 #ifdef HAVE_LIBOTF |
52 int maybe_otf; /* Flag to tell if this may be OTF or not. */ | |
53 OTF *otf; | |
91163 | 54 #endif /* HAVE_LIBOTF */ |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
55 FT_Size ft_size; |
101555
a8e049b0d2c2
(struct xftfont_info): New member `index'.
Kenichi Handa <handa@m17n.org>
parents:
100951
diff
changeset
|
56 int index; |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
57 Display *display; |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
58 int screen; |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
59 XftFont *xftfont; |
90400 | 60 }; |
61 | |
62 /* Structure pointed by (struct face *)->extra */ | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
63 |
90400 | 64 struct xftface_info |
65 { | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
66 XftColor xft_fg; /* color for face->foreground */ |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
67 XftColor xft_bg; /* color for face->background */ |
90400 | 68 }; |
69 | |
70 static void xftfont_get_colors P_ ((FRAME_PTR, struct face *, GC gc, | |
71 struct xftface_info *, | |
72 XftColor *fg, XftColor *bg)); | |
73 | |
74 | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
75 /* Setup foreground and background colors of GC into FG and BG. If |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
76 XFTFACE_INFO is not NULL, reuse the colors in it if possible. BG |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
77 may be NULL. */ |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
78 |
90400 | 79 static void |
80 xftfont_get_colors (f, face, gc, xftface_info, fg, bg) | |
81 FRAME_PTR f; | |
82 struct face *face; | |
83 GC gc; | |
84 struct xftface_info *xftface_info; | |
85 XftColor *fg, *bg; | |
86 { | |
87 if (xftface_info && face->gc == gc) | |
88 { | |
89 *fg = xftface_info->xft_fg; | |
90 if (bg) | |
91 *bg = xftface_info->xft_bg; | |
92 } | |
93 else | |
94 { | |
95 XGCValues xgcv; | |
96 int fg_done = 0, bg_done = 0; | |
97 | |
98 BLOCK_INPUT; | |
99 XGetGCValues (FRAME_X_DISPLAY (f), gc, | |
100 GCForeground | GCBackground, &xgcv); | |
101 if (xftface_info) | |
102 { | |
103 if (xgcv.foreground == face->foreground) | |
104 *fg = xftface_info->xft_fg, fg_done = 1; | |
105 else if (xgcv.foreground == face->background) | |
106 *fg = xftface_info->xft_bg, fg_done = 1; | |
107 if (! bg) | |
108 bg_done = 1; | |
109 else if (xgcv.background == face->background) | |
110 *bg = xftface_info->xft_bg, bg_done = 1; | |
111 else if (xgcv.background == face->foreground) | |
112 *bg = xftface_info->xft_fg, bg_done = 1; | |
113 } | |
114 | |
115 if (fg_done + bg_done < 2) | |
116 { | |
117 XColor colors[2]; | |
118 | |
119 colors[0].pixel = fg->pixel = xgcv.foreground; | |
120 if (bg) | |
121 colors[1].pixel = bg->pixel = xgcv.background; | |
122 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors, | |
123 bg ? 2 : 1); | |
124 fg->color.alpha = 0xFFFF; | |
125 fg->color.red = colors[0].red; | |
126 fg->color.green = colors[0].green; | |
127 fg->color.blue = colors[0].blue; | |
128 if (bg) | |
129 { | |
130 bg->color.alpha = 0xFFFF; | |
131 bg->color.red = colors[1].red; | |
132 bg->color.green = colors[1].green; | |
133 bg->color.blue = colors[1].blue; | |
134 } | |
135 } | |
136 UNBLOCK_INPUT; | |
137 } | |
138 } | |
139 | |
140 | |
141 static Lisp_Object xftfont_list P_ ((Lisp_Object, Lisp_Object)); | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
142 static Lisp_Object xftfont_match P_ ((Lisp_Object, Lisp_Object)); |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
143 static Lisp_Object xftfont_open P_ ((FRAME_PTR, Lisp_Object, int)); |
90400 | 144 static void xftfont_close P_ ((FRAME_PTR, struct font *)); |
145 static int xftfont_prepare_face P_ ((FRAME_PTR, struct face *)); | |
146 static void xftfont_done_face P_ ((FRAME_PTR, struct face *)); | |
101640
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
147 static int xftfont_has_char P_ ((Lisp_Object, int)); |
90400 | 148 static unsigned xftfont_encode_char P_ ((struct font *, int)); |
149 static int xftfont_text_extents P_ ((struct font *, unsigned *, int, | |
150 struct font_metrics *)); | |
151 static int xftfont_draw P_ ((struct glyph_string *, int, int, int, int, int)); | |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
152 static int xftfont_end_for_frame P_ ((FRAME_PTR f)); |
90400 | 153 |
154 struct font_driver xftfont_driver; | |
155 | |
156 static Lisp_Object | |
157 xftfont_list (frame, spec) | |
158 Lisp_Object frame; | |
159 Lisp_Object spec; | |
160 { | |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
161 Lisp_Object list = ftfont_driver.list (frame, spec), tail; |
101943
97c9e9322753
Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents:
101640
diff
changeset
|
162 |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
163 for (tail = list; CONSP (tail); tail = XCDR (tail)) |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
164 ASET (XCAR (tail), FONT_TYPE_INDEX, Qxft); |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
165 return list; |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
166 } |
90400 | 167 |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
168 static Lisp_Object |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
169 xftfont_match (frame, spec) |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
170 Lisp_Object frame; |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
171 Lisp_Object spec; |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
172 { |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
173 Lisp_Object entity = ftfont_driver.match (frame, spec); |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
174 |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
175 if (! NILP (entity)) |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
176 ASET (entity, FONT_TYPE_INDEX, Qxft); |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
177 return entity; |
90400 | 178 } |
179 | |
96431
abddf0a4cec0
(xftfont_open): Don't call FcConfigSubstitute and
Kenichi Handa <handa@m17n.org>
parents:
96146
diff
changeset
|
180 extern Lisp_Object ftfont_font_format P_ ((FcPattern *, Lisp_Object)); |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
181 extern FcCharSet *ftfont_get_fc_charset P_ ((Lisp_Object)); |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
182 extern Lisp_Object QCantialias; |
90700
b165eceb829f
(ftfont_font_format): Extern declaration.
Kenichi Handa <handa@m17n.org>
parents:
90675
diff
changeset
|
183 |
90400 | 184 static FcChar8 ascii_printable[95]; |
185 | |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
186 static Lisp_Object |
90400 | 187 xftfont_open (f, entity, pixel_size) |
188 FRAME_PTR f; | |
189 Lisp_Object entity; | |
190 int pixel_size; | |
191 { | |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
192 FcResult result; |
90400 | 193 Display *display = FRAME_X_DISPLAY (f); |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
194 Lisp_Object val, filename, index, tail, font_object; |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
195 FcPattern *pat = NULL, *match; |
90460
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
196 struct xftfont_info *xftfont_info = NULL; |
90400 | 197 struct font *font; |
198 double size = 0; | |
90460
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
199 XftFont *xftfont = NULL; |
90400 | 200 int spacing; |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
201 char name[256]; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
202 int len, i; |
90959
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
203 XGlyphInfo extents; |
91226
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
204 FT_Face ft_face; |
90400 | 205 |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
206 val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX)); |
95102
a3868b9c34f4
(xftfont_open): Ajusted for the change of extra info
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
207 if (! CONSP (val)) |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
208 return Qnil; |
95102
a3868b9c34f4
(xftfont_open): Ajusted for the change of extra info
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
209 val = XCDR (val); |
a3868b9c34f4
(xftfont_open): Ajusted for the change of extra info
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
210 filename = XCAR (val); |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
211 index = XCDR (val); |
90400 | 212 size = XINT (AREF (entity, FONT_SIZE_INDEX)); |
213 if (size == 0) | |
214 size = pixel_size; | |
215 pat = FcPatternCreate (); | |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
216 FcPatternAddInteger (pat, FC_WEIGHT, FONT_WEIGHT_NUMERIC (entity)); |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
217 i = FONT_SLANT_NUMERIC (entity) - 100; |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
218 if (i < 0) i = 0; |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
219 FcPatternAddInteger (pat, FC_SLANT, i); |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
220 FcPatternAddInteger (pat, FC_WIDTH, FONT_WIDTH_NUMERIC (entity)); |
90400 | 221 FcPatternAddDouble (pat, FC_PIXEL_SIZE, pixel_size); |
90714
698001835583
(xftfont_open): Call FcConfigSubstitute.
Kenichi Handa <handa@m17n.org>
parents:
90712
diff
changeset
|
222 val = AREF (entity, FONT_FAMILY_INDEX); |
698001835583
(xftfont_open): Call FcConfigSubstitute.
Kenichi Handa <handa@m17n.org>
parents:
90712
diff
changeset
|
223 if (! NILP (val)) |
698001835583
(xftfont_open): Call FcConfigSubstitute.
Kenichi Handa <handa@m17n.org>
parents:
90712
diff
changeset
|
224 FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) SDATA (SYMBOL_NAME (val))); |
96094
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
225 val = AREF (entity, FONT_FOUNDRY_INDEX); |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
226 if (! NILP (val)) |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
227 FcPatternAddString (pat, FC_FOUNDRY, (FcChar8 *) SDATA (SYMBOL_NAME (val))); |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
228 val = AREF (entity, FONT_SPACING_INDEX); |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
229 if (! NILP (val)) |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
230 FcPatternAddInteger (pat, FC_SPACING, XINT (val)); |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
231 val = AREF (entity, FONT_DPI_INDEX); |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
232 if (! NILP (val)) |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
233 { |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
234 double dbl = XINT (val); |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
235 |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
236 FcPatternAddDouble (pat, FC_DPI, dbl); |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
237 } |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
238 val = AREF (entity, FONT_AVGWIDTH_INDEX); |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
239 if (INTEGERP (val) && XINT (val) == 0) |
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
240 FcPatternAddBool (pat, FC_SCALABLE, FcTrue); |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
241 /* This is necessary to identify the exact font (e.g. 10x20.pcf.gz |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
242 over 10x20-ISO8859-1.pcf.gz). */ |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
243 FcPatternAddCharSet (pat, FC_CHARSET, ftfont_get_fc_charset (entity)); |
96094
0304b3142c84
(xftfont_open): Add FOUNDRY, SPACING, DPI, SCALABLE to the pattern.
Kenichi Handa <handa@m17n.org>
parents:
96075
diff
changeset
|
244 |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
245 for (tail = AREF (entity, FONT_EXTRA_INDEX); CONSP (tail); tail = XCDR (tail)) |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
246 { |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
247 Lisp_Object key, val; |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
248 |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
249 key = XCAR (XCAR (tail)), val = XCDR (XCAR (tail)); |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
250 if (EQ (key, QCantialias)) |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
251 FcPatternAddBool (pat, FC_ANTIALIAS, NILP (val) ? FcFalse : FcTrue); |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
252 else if (EQ (key, QChinting)) |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
253 FcPatternAddBool (pat, FC_HINTING, NILP (val) ? FcFalse : FcTrue); |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
254 else if (EQ (key, QCautohint)) |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
255 FcPatternAddBool (pat, FC_AUTOHINT, NILP (val) ? FcFalse : FcTrue); |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
256 else if (EQ (key, QChintstyle)) |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
257 { |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
258 if (INTEGERP (val)) |
103838
a7805f91abdd
(xftfont_open): Fix typo: FC_RGBA->FC_HINT_STYLE.
Kenichi Handa <handa@m17n.org>
parents:
103650
diff
changeset
|
259 FcPatternAddInteger (pat, FC_HINT_STYLE, XINT (val)); |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
260 } |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
261 else if (EQ (key, QCrgba)) |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
262 { |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
263 if (INTEGERP (val)) |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
264 FcPatternAddInteger (pat, FC_RGBA, XINT (val)); |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
265 } |
96146
e26d249d40df
(xftfont_open): Handle QCembolden only when FC_EMBOLDEN is defined.
Kenichi Handa <handa@m17n.org>
parents:
96094
diff
changeset
|
266 #ifdef FC_EMBOLDEN |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
267 else if (EQ (key, QCembolden)) |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
268 FcPatternAddBool (pat, FC_EMBOLDEN, NILP (val) ? FcFalse : FcTrue); |
96146
e26d249d40df
(xftfont_open): Handle QCembolden only when FC_EMBOLDEN is defined.
Kenichi Handa <handa@m17n.org>
parents:
96094
diff
changeset
|
269 #endif |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
270 } |
90442
d6abf2344438
(xftfont_open): Make the font name fontconfig's
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
271 |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
272 FcPatternAddString (pat, FC_FILE, (FcChar8 *) SDATA (filename)); |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
273 FcPatternAddInteger (pat, FC_INDEX, XINT (index)); |
101943
97c9e9322753
Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents:
101640
diff
changeset
|
274 |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
275 |
90442
d6abf2344438
(xftfont_open): Make the font name fontconfig's
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
276 BLOCK_INPUT; |
103199
3b14cedd241f
(xftfont_open): Make sure that Xrender extension is added
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
102992
diff
changeset
|
277 /* Make sure that the Xrender extension is added before the Xft one. |
3b14cedd241f
(xftfont_open): Make sure that Xrender extension is added
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
102992
diff
changeset
|
278 Otherwise, the close-display hook set by Xft is called after the |
3b14cedd241f
(xftfont_open): Make sure that Xrender extension is added
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
102992
diff
changeset
|
279 one for Xrender, and the former tries to re-add the latter. This |
3b14cedd241f
(xftfont_open): Make sure that Xrender extension is added
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
102992
diff
changeset
|
280 results in inconsistency of internal states and leads to X |
3b14cedd241f
(xftfont_open): Make sure that Xrender extension is added
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
102992
diff
changeset
|
281 protocol error when one reconnects to the same X server. |
3b14cedd241f
(xftfont_open): Make sure that Xrender extension is added
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
102992
diff
changeset
|
282 (Bug#1696) */ |
3b14cedd241f
(xftfont_open): Make sure that Xrender extension is added
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
102992
diff
changeset
|
283 { |
3b14cedd241f
(xftfont_open): Make sure that Xrender extension is added
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
102992
diff
changeset
|
284 int event_base, error_base; |
3b14cedd241f
(xftfont_open): Make sure that Xrender extension is added
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
102992
diff
changeset
|
285 XRenderQueryExtension (display, &event_base, &error_base); |
3b14cedd241f
(xftfont_open): Make sure that Xrender extension is added
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
102992
diff
changeset
|
286 } |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
287 match = XftFontMatch (display, FRAME_X_SCREEN_NUMBER (f), pat, &result); |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
288 FcPatternDestroy (pat); |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
289 xftfont = XftFontOpenPattern (display, match); |
103650
e561e9f73ad4
* xftfont.c (xftfont_open): Avoid passing NULL argument to
Chong Yidong <cyd@stupidchicken.com>
parents:
103199
diff
changeset
|
290 if (!xftfont) |
e561e9f73ad4
* xftfont.c (xftfont_open): Avoid passing NULL argument to
Chong Yidong <cyd@stupidchicken.com>
parents:
103199
diff
changeset
|
291 { |
e561e9f73ad4
* xftfont.c (xftfont_open): Avoid passing NULL argument to
Chong Yidong <cyd@stupidchicken.com>
parents:
103199
diff
changeset
|
292 UNBLOCK_INPUT; |
e561e9f73ad4
* xftfont.c (xftfont_open): Avoid passing NULL argument to
Chong Yidong <cyd@stupidchicken.com>
parents:
103199
diff
changeset
|
293 XftPatternDestroy (match); |
e561e9f73ad4
* xftfont.c (xftfont_open): Avoid passing NULL argument to
Chong Yidong <cyd@stupidchicken.com>
parents:
103199
diff
changeset
|
294 return Qnil; |
e561e9f73ad4
* xftfont.c (xftfont_open): Avoid passing NULL argument to
Chong Yidong <cyd@stupidchicken.com>
parents:
103199
diff
changeset
|
295 } |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
296 ft_face = XftLockFace (xftfont); |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
297 UNBLOCK_INPUT; |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
298 |
90400 | 299 /* We should not destroy PAT here because it is kept in XFTFONT and |
300 destroyed automatically when XFTFONT is closed. */ | |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
301 font_object = font_make_object (VECSIZE (struct xftfont_info), entity, size); |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
302 ASET (font_object, FONT_TYPE_INDEX, Qxft); |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
303 len = font_unparse_xlfd (entity, size, name, 256); |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
304 if (len > 0) |
100551
42e9e426d886
(xftfont_open): Genarate a multibyte string if give names are utf-8.
Kenichi Handa <handa@m17n.org>
parents:
100427
diff
changeset
|
305 ASET (font_object, FONT_NAME_INDEX, make_string (name, len)); |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
306 len = font_unparse_fcname (entity, size, name, 256); |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
307 if (len > 0) |
100551
42e9e426d886
(xftfont_open): Genarate a multibyte string if give names are utf-8.
Kenichi Handa <handa@m17n.org>
parents:
100427
diff
changeset
|
308 ASET (font_object, FONT_FULLNAME_INDEX, make_string (name, len)); |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
309 else |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
310 ASET (font_object, FONT_FULLNAME_INDEX, |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
311 AREF (font_object, FONT_NAME_INDEX)); |
95102
a3868b9c34f4
(xftfont_open): Ajusted for the change of extra info
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
312 ASET (font_object, FONT_FILE_INDEX, filename); |
a3868b9c34f4
(xftfont_open): Ajusted for the change of extra info
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
313 ASET (font_object, FONT_FORMAT_INDEX, |
96431
abddf0a4cec0
(xftfont_open): Don't call FcConfigSubstitute and
Kenichi Handa <handa@m17n.org>
parents:
96146
diff
changeset
|
314 ftfont_font_format (xftfont->pattern, filename)); |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
315 font = XFONT_OBJECT (font_object); |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
316 font->pixel_size = pixel_size; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
317 font->driver = &xftfont_driver; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
318 font->encoding_charset = font->repertory_charset = -1; |
90400 | 319 |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
320 xftfont_info = (struct xftfont_info *) font; |
90400 | 321 xftfont_info->display = display; |
322 xftfont_info->screen = FRAME_X_SCREEN_NUMBER (f); | |
323 xftfont_info->xftfont = xftfont; | |
324 font->pixel_size = size; | |
325 font->driver = &xftfont_driver; | |
95102
a3868b9c34f4
(xftfont_open): Ajusted for the change of extra info
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
326 if (INTEGERP (AREF (entity, FONT_SPACING_INDEX))) |
a3868b9c34f4
(xftfont_open): Ajusted for the change of extra info
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
327 spacing = XINT (AREF (entity, FONT_SPACING_INDEX)); |
a3868b9c34f4
(xftfont_open): Ajusted for the change of extra info
Kenichi Handa <handa@m17n.org>
parents:
94963
diff
changeset
|
328 else |
90400 | 329 spacing = FC_PROPORTIONAL; |
90959
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
330 if (! ascii_printable[0]) |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
331 { |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
332 int i; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
333 for (i = 0; i < 95; i++) |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
334 ascii_printable[i] = ' ' + i; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
335 } |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
336 BLOCK_INPUT; |
90400 | 337 if (spacing != FC_PROPORTIONAL) |
90959
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
338 { |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
339 font->min_width = font->average_width = font->space_width |
90959
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
340 = xftfont->max_advance_width; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
341 XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents); |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
342 } |
90400 | 343 else |
344 { | |
345 XftTextExtents8 (display, xftfont, ascii_printable, 1, &extents); | |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
346 font->space_width = extents.xOff; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
347 if (font->space_width <= 0) |
90400 | 348 /* dirty workaround */ |
101943
97c9e9322753
Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents:
101640
diff
changeset
|
349 font->space_width = pixel_size; |
90400 | 350 XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents); |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
351 font->average_width = (font->space_width + extents.xOff) / 95; |
90400 | 352 } |
90442
d6abf2344438
(xftfont_open): Make the font name fontconfig's
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
353 UNBLOCK_INPUT; |
90400 | 354 |
90959
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
355 font->ascent = xftfont->ascent; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
356 font->descent = xftfont->descent; |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
357 if (pixel_size >= 5) |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
358 { |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
359 /* The above condition is a dirty workaround because |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
360 XftTextExtents8 behaves strangely for some fonts |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
361 (e.g. "Dejavu Sans Mono") when pixel_size is less than 5. */ |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
362 if (font->ascent < extents.y) |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
363 font->ascent = extents.y; |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
364 if (font->descent < extents.height - extents.y) |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
365 font->descent = extents.height - extents.y; |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
366 } |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
367 font->height = font->ascent + font->descent; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
368 |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
369 if (XINT (AREF (entity, FONT_SIZE_INDEX)) == 0) |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
370 { |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
371 int upEM = ft_face->units_per_EM; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
372 |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
373 font->underline_position = -ft_face->underline_position * size / upEM; |
102861
0ea82e792866
(xftfont_open): Fix setting font->underline_thickness.
Kenichi Handa <handa@m17n.org>
parents:
101943
diff
changeset
|
374 font->underline_thickness = ft_face->underline_thickness * size / upEM; |
95293
089ad7a58f94
(xftfont_open): Delete unused variable. If
Kenichi Handa <handa@m17n.org>
parents:
95102
diff
changeset
|
375 if (font->underline_thickness > 2) |
089ad7a58f94
(xftfont_open): Delete unused variable. If
Kenichi Handa <handa@m17n.org>
parents:
95102
diff
changeset
|
376 font->underline_position -= font->underline_thickness / 2; |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
377 } |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
378 else |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
379 { |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
380 font->underline_position = -1; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
381 font->underline_thickness = 0; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
382 } |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
383 #ifdef HAVE_LIBOTF |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
384 xftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
385 xftfont_info->otf = NULL; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
386 #endif /* HAVE_LIBOTF */ |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
387 xftfont_info->ft_size = ft_face->size; |
90959
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
388 |
90400 | 389 /* Unfortunately Xft doesn't provide a way to get minimum char |
390 width. So, we use space_width instead. */ | |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
391 font->min_width = font->space_width; |
90400 | 392 |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
393 font->baseline_offset = 0; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
394 font->relative_compose = 0; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
395 font->default_ascent = 0; |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
396 font->vertical_centering = 0; |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
397 #ifdef FT_BDF_H |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
398 if (! (ft_face->face_flags & FT_FACE_FLAG_SFNT)) |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
399 { |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
400 BDF_PropertyRec rec; |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
401 |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
402 if (FT_Get_BDF_Property (ft_face, "_MULE_BASELINE_OFFSET", &rec) == 0 |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
403 && rec.type == BDF_PROPERTY_TYPE_INTEGER) |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
404 font->baseline_offset = rec.u.integer; |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
405 if (FT_Get_BDF_Property (ft_face, "_MULE_RELATIVE_COMPOSE", &rec) == 0 |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
406 && rec.type == BDF_PROPERTY_TYPE_INTEGER) |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
407 font->relative_compose = rec.u.integer; |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
408 if (FT_Get_BDF_Property (ft_face, "_MULE_DEFAULT_ASCENT", &rec) == 0 |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
409 && rec.type == BDF_PROPERTY_TYPE_INTEGER) |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
410 font->default_ascent = rec.u.integer; |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
411 } |
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
412 #endif |
90400 | 413 |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
414 return font_object; |
90400 | 415 } |
416 | |
417 static void | |
418 xftfont_close (f, font) | |
419 FRAME_PTR f; | |
420 struct font *font; | |
421 { | |
422 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; | |
423 | |
91143 | 424 #ifdef HAVE_LIBOTF |
425 if (xftfont_info->otf) | |
426 OTF_close (xftfont_info->otf); | |
427 #endif | |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
428 BLOCK_INPUT; |
96562
ea11c7e02573
(struct xftfont_info): New member ft_size. Make the
Kenichi Handa <handa@m17n.org>
parents:
96431
diff
changeset
|
429 XftUnlockFace (xftfont_info->xftfont); |
90400 | 430 XftFontClose (xftfont_info->display, xftfont_info->xftfont); |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
431 UNBLOCK_INPUT; |
90400 | 432 } |
433 | |
434 static int | |
435 xftfont_prepare_face (f, face) | |
436 FRAME_PTR f; | |
437 struct face *face; | |
438 { | |
90489
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
439 struct xftface_info *xftface_info; |
90400 | 440 |
90499
32b8f672da38
(xftfont_prepare_face): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
90489
diff
changeset
|
441 #if 0 |
32b8f672da38
(xftfont_prepare_face): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
90489
diff
changeset
|
442 /* This doesn't work if face->ascii_face doesn't use an Xft font. */ |
90489
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
443 if (face != face->ascii_face) |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
444 { |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
445 face->extra = face->ascii_face->extra; |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
446 return 0; |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
447 } |
90499
32b8f672da38
(xftfont_prepare_face): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
90489
diff
changeset
|
448 #endif |
90489
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
449 |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
450 xftface_info = malloc (sizeof (struct xftface_info)); |
90400 | 451 if (! xftface_info) |
452 return -1; | |
453 xftfont_get_colors (f, face, face->gc, NULL, | |
454 &xftface_info->xft_fg, &xftface_info->xft_bg); | |
455 face->extra = xftface_info; | |
456 return 0; | |
457 } | |
458 | |
459 static void | |
460 xftfont_done_face (f, face) | |
461 FRAME_PTR f; | |
462 struct face *face; | |
463 { | |
90489
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
464 struct xftface_info *xftface_info; |
101943
97c9e9322753
Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents:
101640
diff
changeset
|
465 |
90499
32b8f672da38
(xftfont_prepare_face): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
90489
diff
changeset
|
466 #if 0 |
32b8f672da38
(xftfont_prepare_face): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
90489
diff
changeset
|
467 /* This doesn't work if face->ascii_face doesn't use an Xft font. */ |
90489
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
468 if (face != face->ascii_face |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
469 || ! face->extra) |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
470 return; |
90499
32b8f672da38
(xftfont_prepare_face): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
90489
diff
changeset
|
471 #endif |
90400 | 472 |
90489
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
473 xftface_info = (struct xftface_info *) face->extra; |
90527
63b888896eba
* xftfont.c (xftfont_done_face): Call XftDrawDestroy only if xftface_info
Jan Djärv <jan.h.d@swipnet.se>
parents:
90511
diff
changeset
|
474 if (xftface_info) |
63b888896eba
* xftfont.c (xftfont_done_face): Call XftDrawDestroy only if xftface_info
Jan Djärv <jan.h.d@swipnet.se>
parents:
90511
diff
changeset
|
475 { |
63b888896eba
* xftfont.c (xftfont_done_face): Call XftDrawDestroy only if xftface_info
Jan Djärv <jan.h.d@swipnet.se>
parents:
90511
diff
changeset
|
476 free (xftface_info); |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
477 face->extra = NULL; |
90527
63b888896eba
* xftfont.c (xftfont_done_face): Call XftDrawDestroy only if xftface_info
Jan Djärv <jan.h.d@swipnet.se>
parents:
90511
diff
changeset
|
478 } |
90400 | 479 } |
480 | |
102992
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
481 extern Lisp_Object Qja, Qko; |
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
482 |
101640
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
483 static int |
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
484 xftfont_has_char (font, c) |
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
485 Lisp_Object font; |
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
486 int c; |
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
487 { |
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
488 struct xftfont_info *xftfont_info; |
102992
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
489 struct charset *cs = NULL; |
101640
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
490 |
102992
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
491 if (EQ (AREF (font, FONT_ADSTYLE_INDEX), Qja) |
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
492 && charset_jisx0208 >= 0) |
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
493 cs = CHARSET_FROM_ID (charset_jisx0208); |
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
494 else if (EQ (AREF (font, FONT_ADSTYLE_INDEX), Qko) |
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
495 && charset_ksc5601 >= 0) |
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
496 cs = CHARSET_FROM_ID (charset_ksc5601); |
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
497 if (cs) |
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
498 return (ENCODE_CHAR (cs, c) != CHARSET_INVALID_CODE (cs)); |
64cdf8a83bdd
(xftfont_has_char): Special handling of `ja' and `ko' adstyle.
Kenichi Handa <handa@m17n.org>
parents:
102861
diff
changeset
|
499 |
103838
a7805f91abdd
(xftfont_open): Fix typo: FC_RGBA->FC_HINT_STYLE.
Kenichi Handa <handa@m17n.org>
parents:
103650
diff
changeset
|
500 if (FONT_ENTITY_P (font)) |
a7805f91abdd
(xftfont_open): Fix typo: FC_RGBA->FC_HINT_STYLE.
Kenichi Handa <handa@m17n.org>
parents:
103650
diff
changeset
|
501 return ftfont_driver.has_char (font, c); |
101640
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
502 xftfont_info = (struct xftfont_info *) XFONT_OBJECT (font); |
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
503 return (XftCharExists (xftfont_info->display, xftfont_info->xftfont, |
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
504 (FcChar32) c) == FcTrue); |
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
505 } |
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
506 |
90400 | 507 static unsigned |
508 xftfont_encode_char (font, c) | |
509 struct font *font; | |
510 int c; | |
511 { | |
512 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; | |
513 unsigned code = XftCharIndex (xftfont_info->display, xftfont_info->xftfont, | |
514 (FcChar32) c); | |
101943
97c9e9322753
Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents:
101640
diff
changeset
|
515 |
91269
421d7c7d296a
(xftfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91243
diff
changeset
|
516 return (code ? code : FONT_INVALID_CODE); |
90400 | 517 } |
518 | |
519 static int | |
520 xftfont_text_extents (font, code, nglyphs, metrics) | |
521 struct font *font; | |
522 unsigned *code; | |
523 int nglyphs; | |
524 struct font_metrics *metrics; | |
525 { | |
526 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; | |
527 XGlyphInfo extents; | |
528 | |
529 BLOCK_INPUT; | |
530 XftGlyphExtents (xftfont_info->display, xftfont_info->xftfont, code, nglyphs, | |
531 &extents); | |
532 UNBLOCK_INPUT; | |
533 if (metrics) | |
534 { | |
535 metrics->lbearing = - extents.x; | |
536 metrics->rbearing = - extents.x + extents.width; | |
537 metrics->width = extents.xOff; | |
538 metrics->ascent = extents.y; | |
90616
68d59ef20174
(xftfont_text_extents): Fix calculation of descent
Kenichi Handa <handa@m17n.org>
parents:
90589
diff
changeset
|
539 metrics->descent = extents.height - extents.y; |
90400 | 540 } |
541 return extents.xOff; | |
542 } | |
543 | |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
544 static XftDraw * |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
545 xftfont_get_xft_draw (f) |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
546 FRAME_PTR f; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
547 { |
101943
97c9e9322753
Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents:
101640
diff
changeset
|
548 XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver); |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
549 |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
550 if (! xft_draw) |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
551 { |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
552 BLOCK_INPUT; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
553 xft_draw= XftDrawCreate (FRAME_X_DISPLAY (f), |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
554 FRAME_X_WINDOW (f), |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
555 FRAME_X_VISUAL (f), |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
556 FRAME_X_COLORMAP (f)); |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
557 UNBLOCK_INPUT; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
558 if (! xft_draw) |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
559 abort (); |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
560 font_put_frame_data (f, &xftfont_driver, xft_draw); |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
561 } |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
562 return xft_draw; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
563 } |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
564 |
90400 | 565 static int |
566 xftfont_draw (s, from, to, x, y, with_background) | |
567 struct glyph_string *s; | |
568 int from, to, x, y, with_background; | |
569 { | |
570 FRAME_PTR f = s->f; | |
571 struct face *face = s->face; | |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
572 struct xftfont_info *xftfont_info = (struct xftfont_info *) s->font; |
91011
7239c19e55e9
(xftfont_draw): If s->font_info != s->face->font_info,
Kenichi Handa <handa@m17n.org>
parents:
90959
diff
changeset
|
573 struct xftface_info *xftface_info = NULL; |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
574 XftDraw *xft_draw = xftfont_get_xft_draw (f); |
90400 | 575 FT_UInt *code; |
576 XftColor fg, bg; | |
577 int len = to - from; | |
578 int i; | |
579 | |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
580 if (s->font == face->font) |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
581 xftface_info = (struct xftface_info *) face->extra; |
90400 | 582 xftfont_get_colors (f, face, s->gc, xftface_info, |
90426
e9ed7d437c21
(xftfont_default_fid): Set fid_known to 1.
Kenichi Handa <handa@m17n.org>
parents:
90400
diff
changeset
|
583 &fg, with_background ? &bg : NULL); |
90400 | 584 BLOCK_INPUT; |
91027
04b81a720da9
(xftfont_draw): Adjusted for the change of struct
Kenichi Handa <handa@m17n.org>
parents:
91011
diff
changeset
|
585 if (s->num_clips > 0) |
04b81a720da9
(xftfont_draw): Adjusted for the change of struct
Kenichi Handa <handa@m17n.org>
parents:
91011
diff
changeset
|
586 XftDrawSetClipRectangles (xft_draw, 0, 0, s->clip, s->num_clips); |
04b81a720da9
(xftfont_draw): Adjusted for the change of struct
Kenichi Handa <handa@m17n.org>
parents:
91011
diff
changeset
|
587 else |
04b81a720da9
(xftfont_draw): Adjusted for the change of struct
Kenichi Handa <handa@m17n.org>
parents:
91011
diff
changeset
|
588 XftDrawSetClip (xft_draw, NULL); |
04b81a720da9
(xftfont_draw): Adjusted for the change of struct
Kenichi Handa <handa@m17n.org>
parents:
91011
diff
changeset
|
589 |
90400 | 590 if (with_background) |
94941
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
591 XftDrawRect (xft_draw, &bg, |
8cbdb26068b4
(xftfont_list): Adjusted for the change of `list'
Kenichi Handa <handa@m17n.org>
parents:
92184
diff
changeset
|
592 x, y - face->font->ascent, s->width, face->font->height); |
90400 | 593 code = alloca (sizeof (FT_UInt) * len); |
594 for (i = 0; i < len; i++) | |
595 code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8) | |
596 | XCHAR2B_BYTE2 (s->char2b + from + i)); | |
597 | |
92184
6218afb021ac
(xftfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91907
diff
changeset
|
598 if (s->padding_p) |
6218afb021ac
(xftfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91907
diff
changeset
|
599 for (i = 0; i < len; i++) |
6218afb021ac
(xftfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91907
diff
changeset
|
600 XftDrawGlyphs (xft_draw, &fg, xftfont_info->xftfont, |
6218afb021ac
(xftfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91907
diff
changeset
|
601 x + i, y, code + i, 1); |
6218afb021ac
(xftfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91907
diff
changeset
|
602 else |
6218afb021ac
(xftfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91907
diff
changeset
|
603 XftDrawGlyphs (xft_draw, &fg, xftfont_info->xftfont, |
6218afb021ac
(xftfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents:
91907
diff
changeset
|
604 x, y, code, len); |
90400 | 605 UNBLOCK_INPUT; |
606 | |
607 return len; | |
608 } | |
609 | |
610 static int | |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
611 xftfont_end_for_frame (f) |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
612 FRAME_PTR f; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
613 { |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
614 XftDraw *xft_draw = font_get_frame_data (f, &xftfont_driver); |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
615 |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
616 if (xft_draw) |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
617 { |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
618 BLOCK_INPUT; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
619 XftDrawDestroy (xft_draw); |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
620 UNBLOCK_INPUT; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
621 font_put_frame_data (f, &xftfont_driver, NULL); |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
622 } |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
623 return 0; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
624 } |
90400 | 625 |
626 void | |
627 syms_of_xftfont () | |
628 { | |
629 DEFSYM (Qxft, "xft"); | |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
630 DEFSYM (QChinting, ":hinting"); |
100301
5c8b389c391a
(syms_of_xftfont): Fix typo.
Chong Yidong <cyd@stupidchicken.com>
parents:
96562
diff
changeset
|
631 DEFSYM (QCautohint, ":autohint"); |
96075
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
632 DEFSYM (QChintstyle, ":hintstyle"); |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
633 DEFSYM (QCrgba, ":rgba"); |
3376493a3ad4
(QChinting , QCautohint, QChintstyle, QCrgba)
Kenichi Handa <handa@m17n.org>
parents:
95293
diff
changeset
|
634 DEFSYM (QCembolden, ":embolden"); |
90400 | 635 |
636 xftfont_driver = ftfont_driver; | |
637 xftfont_driver.type = Qxft; | |
638 xftfont_driver.get_cache = xfont_driver.get_cache; | |
639 xftfont_driver.list = xftfont_list; | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
640 xftfont_driver.match = xftfont_match; |
90400 | 641 xftfont_driver.open = xftfont_open; |
642 xftfont_driver.close = xftfont_close; | |
643 xftfont_driver.prepare_face = xftfont_prepare_face; | |
644 xftfont_driver.done_face = xftfont_done_face; | |
101640
6a674ba1901f
(xftfont_has_char): New function.
Kenichi Handa <handa@m17n.org>
parents:
101555
diff
changeset
|
645 xftfont_driver.has_char = xftfont_has_char; |
90400 | 646 xftfont_driver.encode_char = xftfont_encode_char; |
647 xftfont_driver.text_extents = xftfont_text_extents; | |
648 xftfont_driver.draw = xftfont_draw; | |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
649 xftfont_driver.end_for_frame = xftfont_end_for_frame; |
90400 | 650 |
651 register_font_driver (&xftfont_driver, NULL); | |
652 } | |
90427 | 653 |
654 /* arch-tag: 64ec61bf-7c8e-4fe6-b953-c6a85d5e1605 | |
655 (do not change this comment) */ |