Mercurial > emacs
annotate src/xftfont.c @ 91239:2fcaae6177a5
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-300
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 16 Dec 2007 05:08:49 +0000 |
parents | 040f2e332dc3 |
children | 9477734eac90 |
rev | line source |
---|---|
90400 | 1 /* xftfont.c -- XFT font driver. |
2 Copyright (C) 2006 Free Software Foundation, Inc. | |
91143 | 3 Copyright (C) 2006, 2007 |
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 | |
9 GNU Emacs is free software; you can redistribute it and/or modify | |
10 it under the terms of the GNU General Public License as published by | |
11 the Free Software Foundation; either version 2, or (at your option) | |
12 any later version. | |
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 | |
20 along with GNU Emacs; see the file COPYING. If not, write to | |
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
22 Boston, MA 02110-1301, USA. */ | |
23 | |
24 #include <config.h> | |
25 #include <stdio.h> | |
26 #include <X11/Xlib.h> | |
27 #include <X11/Xft/Xft.h> | |
28 | |
29 #include "lisp.h" | |
30 #include "dispextern.h" | |
31 #include "xterm.h" | |
32 #include "frame.h" | |
33 #include "blockinput.h" | |
34 #include "character.h" | |
35 #include "charset.h" | |
36 #include "fontset.h" | |
37 #include "font.h" | |
91143 | 38 #include "ftfont.h" |
90400 | 39 |
40 /* Xft font driver. */ | |
41 | |
42 static Lisp_Object Qxft; | |
43 | |
44 /* The actual structure for Xft font that can be casted to struct | |
45 font. */ | |
46 | |
47 struct xftfont_info | |
48 { | |
49 struct font font; | |
50 Display *display; | |
51 int screen; | |
52 XftFont *xftfont; | |
91143 | 53 #ifdef HAVE_LIBOTF |
54 int maybe_otf; /* Flag to tell if this may be OTF or not. */ | |
55 OTF *otf; | |
91163 | 56 #endif /* HAVE_LIBOTF */ |
90400 | 57 }; |
58 | |
59 /* Structure pointed by (struct face *)->extra */ | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
60 |
90400 | 61 struct xftface_info |
62 { | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
63 XftColor xft_fg; /* color for face->foreground */ |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
64 XftColor xft_bg; /* color for face->background */ |
90400 | 65 }; |
66 | |
67 static void xftfont_get_colors P_ ((FRAME_PTR, struct face *, GC gc, | |
68 struct xftface_info *, | |
69 XftColor *fg, XftColor *bg)); | |
70 static Font xftfont_default_fid P_ ((FRAME_PTR)); | |
71 | |
72 | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
73 /* 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
|
74 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
|
75 may be NULL. */ |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
76 |
90400 | 77 static void |
78 xftfont_get_colors (f, face, gc, xftface_info, fg, bg) | |
79 FRAME_PTR f; | |
80 struct face *face; | |
81 GC gc; | |
82 struct xftface_info *xftface_info; | |
83 XftColor *fg, *bg; | |
84 { | |
85 if (xftface_info && face->gc == gc) | |
86 { | |
87 *fg = xftface_info->xft_fg; | |
88 if (bg) | |
89 *bg = xftface_info->xft_bg; | |
90 } | |
91 else | |
92 { | |
93 XGCValues xgcv; | |
94 int fg_done = 0, bg_done = 0; | |
95 | |
96 BLOCK_INPUT; | |
97 XGetGCValues (FRAME_X_DISPLAY (f), gc, | |
98 GCForeground | GCBackground, &xgcv); | |
99 if (xftface_info) | |
100 { | |
101 if (xgcv.foreground == face->foreground) | |
102 *fg = xftface_info->xft_fg, fg_done = 1; | |
103 else if (xgcv.foreground == face->background) | |
104 *fg = xftface_info->xft_bg, fg_done = 1; | |
105 if (! bg) | |
106 bg_done = 1; | |
107 else if (xgcv.background == face->background) | |
108 *bg = xftface_info->xft_bg, bg_done = 1; | |
109 else if (xgcv.background == face->foreground) | |
110 *bg = xftface_info->xft_fg, bg_done = 1; | |
111 } | |
112 | |
113 if (fg_done + bg_done < 2) | |
114 { | |
115 XColor colors[2]; | |
116 | |
117 colors[0].pixel = fg->pixel = xgcv.foreground; | |
118 if (bg) | |
119 colors[1].pixel = bg->pixel = xgcv.background; | |
120 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors, | |
121 bg ? 2 : 1); | |
122 fg->color.alpha = 0xFFFF; | |
123 fg->color.red = colors[0].red; | |
124 fg->color.green = colors[0].green; | |
125 fg->color.blue = colors[0].blue; | |
126 if (bg) | |
127 { | |
128 bg->color.alpha = 0xFFFF; | |
129 bg->color.red = colors[1].red; | |
130 bg->color.green = colors[1].green; | |
131 bg->color.blue = colors[1].blue; | |
132 } | |
133 } | |
134 UNBLOCK_INPUT; | |
135 } | |
136 } | |
137 | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
138 /* Return the default Font ID on frame F. The Returned Font ID is |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
139 stored in the GC of the frame F, but the font is never used. So, |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
140 any ID is ok as long as it is valid. */ |
90400 | 141 |
142 static Font | |
143 xftfont_default_fid (f) | |
144 FRAME_PTR f; | |
145 { | |
146 static int fid_known; | |
147 static Font fid; | |
148 | |
149 if (! fid_known) | |
150 { | |
151 fid = XLoadFont (FRAME_X_DISPLAY (f), "fixed"); | |
152 if (! fid) | |
153 { | |
154 fid = XLoadFont (FRAME_X_DISPLAY (f), "*"); | |
155 if (! fid) | |
156 abort (); | |
157 } | |
90426
e9ed7d437c21
(xftfont_default_fid): Set fid_known to 1.
Kenichi Handa <handa@m17n.org>
parents:
90400
diff
changeset
|
158 fid_known = 1; |
90400 | 159 } |
160 return fid; | |
161 } | |
162 | |
163 | |
164 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
|
165 static Lisp_Object xftfont_match P_ ((Lisp_Object, Lisp_Object)); |
90400 | 166 static struct font *xftfont_open P_ ((FRAME_PTR, Lisp_Object, int)); |
167 static void xftfont_close P_ ((FRAME_PTR, struct font *)); | |
168 static int xftfont_prepare_face P_ ((FRAME_PTR, struct face *)); | |
169 static void xftfont_done_face P_ ((FRAME_PTR, struct face *)); | |
170 static unsigned xftfont_encode_char P_ ((struct font *, int)); | |
171 static int xftfont_text_extents P_ ((struct font *, unsigned *, int, | |
172 struct font_metrics *)); | |
173 static int xftfont_draw P_ ((struct glyph_string *, int, int, int, int, int)); | |
174 | |
175 static int xftfont_anchor_point P_ ((struct font *, unsigned, int, | |
176 int *, int *)); | |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
177 static int xftfont_start_for_frame P_ ((FRAME_PTR f)); |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
178 static int xftfont_end_for_frame P_ ((FRAME_PTR f)); |
90400 | 179 |
180 struct font_driver xftfont_driver; | |
181 | |
182 static Lisp_Object | |
183 xftfont_list (frame, spec) | |
184 Lisp_Object frame; | |
185 Lisp_Object spec; | |
186 { | |
187 Lisp_Object val = ftfont_driver.list (frame, spec); | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
188 int i; |
90400 | 189 |
190 if (! NILP (val)) | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
191 for (i = 0; i < ASIZE (val); i++) |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
192 ASET (AREF (val, i), FONT_TYPE_INDEX, Qxft); |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
193 return val; |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
194 } |
90400 | 195 |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
196 static Lisp_Object |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
197 xftfont_match (frame, spec) |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
198 Lisp_Object frame; |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
199 Lisp_Object spec; |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
200 { |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
201 Lisp_Object entity = ftfont_driver.match (frame, spec); |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
202 |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
203 if (VECTORP (entity)) |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
204 ASET (entity, FONT_TYPE_INDEX, Qxft); |
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
205 return entity; |
90400 | 206 } |
207 | |
90700
b165eceb829f
(ftfont_font_format): Extern declaration.
Kenichi Handa <handa@m17n.org>
parents:
90675
diff
changeset
|
208 extern Lisp_Object ftfont_font_format P_ ((FcPattern *)); |
b165eceb829f
(ftfont_font_format): Extern declaration.
Kenichi Handa <handa@m17n.org>
parents:
90675
diff
changeset
|
209 |
90400 | 210 static FcChar8 ascii_printable[95]; |
211 | |
212 static struct font * | |
213 xftfont_open (f, entity, pixel_size) | |
214 FRAME_PTR f; | |
215 Lisp_Object entity; | |
216 int pixel_size; | |
217 { | |
218 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | |
219 Display *display = FRAME_X_DISPLAY (f); | |
220 Lisp_Object val; | |
90460
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
221 FcPattern *pattern, *pat = NULL; |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
222 FcChar8 *file; |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
223 struct xftfont_info *xftfont_info = NULL; |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
224 XFontStruct *xfont = NULL; |
90400 | 225 struct font *font; |
226 double size = 0; | |
90460
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
227 XftFont *xftfont = NULL; |
90400 | 228 int spacing; |
90460
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
229 char *name; |
90442
d6abf2344438
(xftfont_open): Make the font name fontconfig's
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
230 int len; |
90959
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
231 XGlyphInfo extents; |
91226
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
232 FT_Face ft_face; |
90400 | 233 |
234 val = AREF (entity, FONT_EXTRA_INDEX); | |
235 if (XTYPE (val) != Lisp_Misc | |
236 || XMISCTYPE (val) != Lisp_Misc_Save_Value) | |
237 return NULL; | |
238 pattern = XSAVE_VALUE (val)->pointer; | |
239 if (FcPatternGetString (pattern, FC_FILE, 0, &file) != FcResultMatch) | |
240 return NULL; | |
241 | |
242 size = XINT (AREF (entity, FONT_SIZE_INDEX)); | |
243 if (size == 0) | |
244 size = pixel_size; | |
90442
d6abf2344438
(xftfont_open): Make the font name fontconfig's
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
245 |
90400 | 246 pat = FcPatternCreate (); |
247 FcPatternAddString (pat, FC_FILE, file); | |
248 FcPatternAddDouble (pat, FC_PIXEL_SIZE, pixel_size); | |
90712
8594053c8fec
(xftfont_open): Don't enable antialias explicitly.
Kenichi Handa <handa@m17n.org>
parents:
90700
diff
changeset
|
249 /*FcPatternAddBool (pat, FC_ANTIALIAS, FcTrue);*/ |
90714
698001835583
(xftfont_open): Call FcConfigSubstitute.
Kenichi Handa <handa@m17n.org>
parents:
90712
diff
changeset
|
250 val = AREF (entity, FONT_FAMILY_INDEX); |
698001835583
(xftfont_open): Call FcConfigSubstitute.
Kenichi Handa <handa@m17n.org>
parents:
90712
diff
changeset
|
251 if (! NILP (val)) |
698001835583
(xftfont_open): Call FcConfigSubstitute.
Kenichi Handa <handa@m17n.org>
parents:
90712
diff
changeset
|
252 FcPatternAddString (pat, FC_FAMILY, (FcChar8 *) SDATA (SYMBOL_NAME (val))); |
698001835583
(xftfont_open): Call FcConfigSubstitute.
Kenichi Handa <handa@m17n.org>
parents:
90712
diff
changeset
|
253 FcConfigSubstitute (NULL, pat, FcMatchPattern); |
90442
d6abf2344438
(xftfont_open): Make the font name fontconfig's
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
254 |
d6abf2344438
(xftfont_open): Make the font name fontconfig's
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
255 BLOCK_INPUT; |
90589
697dcc1df88d
(xftfont_open): Call XftDefaultSubstitute before
Kenichi Handa <handa@m17n.org>
parents:
90559
diff
changeset
|
256 XftDefaultSubstitute (display, FRAME_X_SCREEN_NUMBER (f), pat); |
90400 | 257 xftfont = XftFontOpenPattern (display, pat); |
258 /* We should not destroy PAT here because it is kept in XFTFONT and | |
259 destroyed automatically when XFTFONT is closed. */ | |
260 if (! xftfont) | |
90460
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
261 goto err; |
90400 | 262 |
263 xftfont_info = malloc (sizeof (struct xftfont_info)); | |
264 if (! xftfont_info) | |
90460
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
265 goto err; |
90400 | 266 xfont = malloc (sizeof (XFontStruct)); |
90460
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
267 if (! xfont) |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
268 goto err; |
90400 | 269 xftfont_info->display = display; |
270 xftfont_info->screen = FRAME_X_SCREEN_NUMBER (f); | |
271 xftfont_info->xftfont = xftfont; | |
91143 | 272 #ifdef HAVE_LIBOTF |
91226
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
273 ft_face = XftLockFace (xftfont); |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
274 xftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
275 XftUnlockFace (xftfont); |
91143 | 276 xftfont_info->otf = NULL; |
91163 | 277 #endif /* HAVE_LIBOTF */ |
90400 | 278 |
279 font = (struct font *) xftfont_info; | |
90675
dfe6bfcd570f
(xftfont_open): Set font->format.
Kenichi Handa <handa@m17n.org>
parents:
90616
diff
changeset
|
280 font->format = ftfont_font_format (xftfont->pattern); |
90400 | 281 font->entity = entity; |
282 font->pixel_size = size; | |
283 font->driver = &xftfont_driver; | |
90473
9c75458ea910
(xftfont_open): For generating a name, start from
Kenichi Handa <handa@m17n.org>
parents:
90460
diff
changeset
|
284 len = 96; |
90460
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
285 name = malloc (len); |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
286 while (name && font_unparse_fcname (entity, pixel_size, name, len) < 0) |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
287 { |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
288 char *new = realloc (name, len += 32); |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
289 |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
290 if (! new) |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
291 free (name); |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
292 name = new; |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
293 } |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
294 if (! name) |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
295 goto err; |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
296 font->font.full_name = font->font.name = name; |
90400 | 297 font->file_name = (char *) file; |
298 font->font.size = xftfont->max_advance_width; | |
90511
2cd8e24f656a
(xftfont_open): Set charset related members to -1.
Kenichi Handa <handa@m17n.org>
parents:
90499
diff
changeset
|
299 font->font.charset = font->encoding_charset = font->repertory_charset = -1; |
90400 | 300 |
301 if (FcPatternGetInteger (xftfont->pattern, FC_SPACING, 0, &spacing) | |
302 != FcResultMatch) | |
303 spacing = FC_PROPORTIONAL; | |
90959
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
304 if (! ascii_printable[0]) |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
305 { |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
306 int i; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
307 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
|
308 ascii_printable[i] = ' ' + i; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
309 } |
90400 | 310 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
|
311 { |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
312 font->font.average_width = font->font.space_width |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
313 = xftfont->max_advance_width; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
314 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
|
315 } |
90400 | 316 else |
317 { | |
318 XftTextExtents8 (display, xftfont, ascii_printable, 1, &extents); | |
319 font->font.space_width = extents.xOff; | |
320 if (font->font.space_width <= 0) | |
321 /* dirty workaround */ | |
322 font->font.space_width = pixel_size; | |
323 XftTextExtents8 (display, xftfont, ascii_printable + 1, 94, &extents); | |
324 font->font.average_width = (font->font.space_width + extents.xOff) / 95; | |
325 } | |
90442
d6abf2344438
(xftfont_open): Make the font name fontconfig's
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
326 UNBLOCK_INPUT; |
90400 | 327 |
90959
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
328 font->ascent = xftfont->ascent; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
329 if (font->ascent < extents.y) |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
330 font->ascent = extents.y; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
331 font->descent = xftfont->descent; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
332 if (font->descent < extents.height - extents.y) |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
333 font->descent = extents.height - extents.y; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
334 font->font.height = font->ascent + font->descent; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
335 |
90400 | 336 /* Unfortunately Xft doesn't provide a way to get minimum char |
337 width. So, we use space_width instead. */ | |
338 font->min_width = font->font.space_width; | |
339 | |
340 font->font.baseline_offset = 0; | |
341 font->font.relative_compose = 0; | |
342 font->font.default_ascent = 0; | |
343 font->font.vertical_centering = 0; | |
344 | |
345 /* Setup pseudo XFontStruct */ | |
346 xfont->fid = xftfont_default_fid (f); | |
90959
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
347 xfont->ascent = font->ascent; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
348 xfont->descent = font->descent; |
3f83c9d3f96c
(xftfont_open): If one of font's ASCII glyph has
Kenichi Handa <handa@m17n.org>
parents:
90714
diff
changeset
|
349 xfont->max_bounds.descent = font->descent; |
90400 | 350 xfont->max_bounds.width = xftfont->max_advance_width; |
351 xfont->min_bounds.width = font->font.space_width; | |
352 font->font.font = xfont; | |
353 | |
354 dpyinfo->n_fonts++; | |
355 | |
356 /* Set global flag fonts_changed_p to non-zero if the font loaded | |
357 has a character with a smaller width than any other character | |
358 before, or if the font loaded has a smaller height than any other | |
359 font loaded before. If this happens, it will make a glyph matrix | |
360 reallocation necessary. */ | |
361 if (dpyinfo->n_fonts == 1) | |
362 { | |
363 dpyinfo->smallest_font_height = font->font.height; | |
364 dpyinfo->smallest_char_width = font->min_width; | |
365 fonts_changed_p = 1; | |
366 } | |
367 else | |
368 { | |
369 if (dpyinfo->smallest_font_height > font->font.height) | |
370 dpyinfo->smallest_font_height = font->font.height, | |
371 fonts_changed_p |= 1; | |
372 if (dpyinfo->smallest_char_width > font->min_width) | |
373 dpyinfo->smallest_char_width = font->min_width, | |
374 fonts_changed_p |= 1; | |
375 } | |
376 | |
377 return font; | |
90460
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
378 |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
379 err: |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
380 if (xftfont) XftFontClose (display, xftfont); |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
381 UNBLOCK_INPUT; |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
382 if (xftfont_info) free (xftfont_info); |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
383 if (xfont) free (xfont); |
86449661f321
(xftfont_open): Change coding style of error
Kenichi Handa <handa@m17n.org>
parents:
90442
diff
changeset
|
384 return NULL; |
90400 | 385 } |
386 | |
387 static void | |
388 xftfont_close (f, font) | |
389 FRAME_PTR f; | |
390 struct font *font; | |
391 { | |
392 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; | |
393 | |
91143 | 394 #ifdef HAVE_LIBOTF |
395 if (xftfont_info->otf) | |
396 OTF_close (xftfont_info->otf); | |
397 #endif | |
90400 | 398 XftFontClose (xftfont_info->display, xftfont_info->xftfont); |
90442
d6abf2344438
(xftfont_open): Make the font name fontconfig's
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
399 if (font->font.name) |
d6abf2344438
(xftfont_open): Make the font name fontconfig's
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
400 free (font->font.name); |
90400 | 401 free (font); |
402 FRAME_X_DISPLAY_INFO (f)->n_fonts--; | |
403 } | |
404 | |
405 static int | |
406 xftfont_prepare_face (f, face) | |
407 FRAME_PTR f; | |
408 struct face *face; | |
409 { | |
90489
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
410 struct xftface_info *xftface_info; |
90400 | 411 |
90499
32b8f672da38
(xftfont_prepare_face): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
90489
diff
changeset
|
412 #if 0 |
32b8f672da38
(xftfont_prepare_face): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
90489
diff
changeset
|
413 /* 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
|
414 if (face != face->ascii_face) |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
415 { |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
416 face->extra = face->ascii_face->extra; |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
417 return 0; |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
418 } |
90499
32b8f672da38
(xftfont_prepare_face): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
90489
diff
changeset
|
419 #endif |
90489
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
420 |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
421 xftface_info = malloc (sizeof (struct xftface_info)); |
90400 | 422 if (! xftface_info) |
423 return -1; | |
424 | |
425 BLOCK_INPUT; | |
426 xftfont_get_colors (f, face, face->gc, NULL, | |
427 &xftface_info->xft_fg, &xftface_info->xft_bg); | |
428 UNBLOCK_INPUT; | |
429 | |
430 face->extra = xftface_info; | |
431 return 0; | |
432 } | |
433 | |
434 static void | |
435 xftfont_done_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; |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
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 || ! face->extra) |
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
445 return; |
90499
32b8f672da38
(xftfont_prepare_face): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
90489
diff
changeset
|
446 #endif |
90400 | 447 |
90489
78a820ef12db
(xftfont_prepare_face): Make non-ascii face share
Kenichi Handa <handa@m17n.org>
parents:
90473
diff
changeset
|
448 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
|
449 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
|
450 { |
63b888896eba
* xftfont.c (xftfont_done_face): Call XftDrawDestroy only if xftface_info
Jan Djärv <jan.h.d@swipnet.se>
parents:
90511
diff
changeset
|
451 free (xftface_info); |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
452 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
|
453 } |
90400 | 454 } |
455 | |
456 static unsigned | |
457 xftfont_encode_char (font, c) | |
458 struct font *font; | |
459 int c; | |
460 { | |
461 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; | |
462 unsigned code = XftCharIndex (xftfont_info->display, xftfont_info->xftfont, | |
463 (FcChar32) c); | |
464 | |
465 return (code ? code : 0xFFFFFFFF); | |
466 } | |
467 | |
468 static int | |
469 xftfont_text_extents (font, code, nglyphs, metrics) | |
470 struct font *font; | |
471 unsigned *code; | |
472 int nglyphs; | |
473 struct font_metrics *metrics; | |
474 { | |
475 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; | |
476 XGlyphInfo extents; | |
477 | |
478 BLOCK_INPUT; | |
479 XftGlyphExtents (xftfont_info->display, xftfont_info->xftfont, code, nglyphs, | |
480 &extents); | |
481 UNBLOCK_INPUT; | |
482 if (metrics) | |
483 { | |
484 metrics->lbearing = - extents.x; | |
485 metrics->rbearing = - extents.x + extents.width; | |
486 metrics->width = extents.xOff; | |
487 metrics->ascent = extents.y; | |
90616
68d59ef20174
(xftfont_text_extents): Fix calculation of descent
Kenichi Handa <handa@m17n.org>
parents:
90589
diff
changeset
|
488 metrics->descent = extents.height - extents.y; |
90400 | 489 } |
490 return extents.xOff; | |
491 } | |
492 | |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
493 static XftDraw * |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
494 xftfont_get_xft_draw (f) |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
495 FRAME_PTR f; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
496 { |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
497 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
|
498 |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
499 if (! xft_draw) |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
500 { |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
501 BLOCK_INPUT; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
502 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
|
503 FRAME_X_WINDOW (f), |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
504 FRAME_X_VISUAL (f), |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
505 FRAME_X_COLORMAP (f)); |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
506 UNBLOCK_INPUT; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
507 if (! xft_draw) |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
508 abort (); |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
509 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
|
510 } |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
511 return xft_draw; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
512 } |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
513 |
90400 | 514 static int |
515 xftfont_draw (s, from, to, x, y, with_background) | |
516 struct glyph_string *s; | |
517 int from, to, x, y, with_background; | |
518 { | |
519 FRAME_PTR f = s->f; | |
520 struct face *face = s->face; | |
91011
7239c19e55e9
(xftfont_draw): If s->font_info != s->face->font_info,
Kenichi Handa <handa@m17n.org>
parents:
90959
diff
changeset
|
521 struct xftfont_info *xftfont_info = (struct xftfont_info *) s->font_info; |
7239c19e55e9
(xftfont_draw): If s->font_info != s->face->font_info,
Kenichi Handa <handa@m17n.org>
parents:
90959
diff
changeset
|
522 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
|
523 XftDraw *xft_draw = xftfont_get_xft_draw (f); |
90400 | 524 FT_UInt *code; |
525 XftColor fg, bg; | |
526 XRectangle r; | |
527 int len = to - from; | |
528 int i; | |
529 | |
91011
7239c19e55e9
(xftfont_draw): If s->font_info != s->face->font_info,
Kenichi Handa <handa@m17n.org>
parents:
90959
diff
changeset
|
530 if (s->font_info == face->font_info) |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
531 xftface_info = (struct xftface_info *) face->extra; |
90400 | 532 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
|
533 &fg, with_background ? &bg : NULL); |
90400 | 534 BLOCK_INPUT; |
91027
04b81a720da9
(xftfont_draw): Adjusted for the change of struct
Kenichi Handa <handa@m17n.org>
parents:
91011
diff
changeset
|
535 if (s->num_clips > 0) |
04b81a720da9
(xftfont_draw): Adjusted for the change of struct
Kenichi Handa <handa@m17n.org>
parents:
91011
diff
changeset
|
536 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
|
537 else |
04b81a720da9
(xftfont_draw): Adjusted for the change of struct
Kenichi Handa <handa@m17n.org>
parents:
91011
diff
changeset
|
538 XftDrawSetClip (xft_draw, NULL); |
04b81a720da9
(xftfont_draw): Adjusted for the change of struct
Kenichi Handa <handa@m17n.org>
parents:
91011
diff
changeset
|
539 |
90400 | 540 if (with_background) |
541 { | |
542 struct font *font = (struct font *) face->font_info; | |
543 | |
91011
7239c19e55e9
(xftfont_draw): If s->font_info != s->face->font_info,
Kenichi Handa <handa@m17n.org>
parents:
90959
diff
changeset
|
544 XftDrawRect (xft_draw, &bg, |
90400 | 545 x, y - face->font->ascent, s->width, font->font.height); |
546 } | |
547 code = alloca (sizeof (FT_UInt) * len); | |
548 for (i = 0; i < len; i++) | |
549 code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8) | |
550 | XCHAR2B_BYTE2 (s->char2b + from + i)); | |
551 | |
91011
7239c19e55e9
(xftfont_draw): If s->font_info != s->face->font_info,
Kenichi Handa <handa@m17n.org>
parents:
90959
diff
changeset
|
552 XftDrawGlyphs (xft_draw, &fg, xftfont_info->xftfont, |
90400 | 553 x, y, code, len); |
554 UNBLOCK_INPUT; | |
555 | |
556 return len; | |
557 } | |
558 | |
559 static int | |
560 xftfont_anchor_point (font, code, index, x, y) | |
561 struct font *font; | |
562 unsigned code; | |
563 int index; | |
564 int *x, *y; | |
565 { | |
566 struct xftfont_info *xftfont_info = (struct xftfont_info *) font; | |
91226
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
567 FT_Face ft_face = XftLockFace (xftfont_info->xftfont); |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
568 int result; |
90400 | 569 |
570 if (FT_Load_Glyph (ft_face, code, FT_LOAD_DEFAULT) != 0) | |
91226
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
571 result = -1; |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
572 else if (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE) |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
573 result = -1; |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
574 else if (index >= ft_face->glyph->outline.n_points) |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
575 result = -1; |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
576 else |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
577 { |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
578 *x = ft_face->glyph->outline.points[index].x; |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
579 *y = ft_face->glyph->outline.points[index].y; |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
580 } |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
581 XftUnlockFace (xftfont_info->xftfont); |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
582 return result; |
90400 | 583 } |
584 | |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
585 static int |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
586 xftfont_end_for_frame (f) |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
587 FRAME_PTR f; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
588 { |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
589 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
|
590 |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
591 if (xft_draw) |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
592 { |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
593 BLOCK_INPUT; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
594 XftDrawDestroy (xft_draw); |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
595 UNBLOCK_INPUT; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
596 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
|
597 } |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
598 return 0; |
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
599 } |
90400 | 600 |
91143 | 601 #ifdef HAVE_LIBOTF |
602 #ifdef HAVE_M17N_FLT | |
603 static Lisp_Object | |
604 xftfont_shape (lgstring) | |
605 Lisp_Object lgstring; | |
606 { | |
607 struct font *font; | |
608 struct xftfont_info *xftfont_info; | |
91226
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
609 int result; |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
610 FT_Face ft_face; |
91143 | 611 |
612 CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font); | |
613 xftfont_info = (struct xftfont_info *) font; | |
614 if (! xftfont_info->maybe_otf) | |
615 return Qnil; | |
91226
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
616 ft_face = XftLockFace (xftfont_info->xftfont); |
91143 | 617 if (! xftfont_info->otf) |
618 { | |
91226
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
619 OTF *otf = OTF_open_ft_face (ft_face); |
91143 | 620 |
621 if (! otf || OTF_get_table (otf, "head") < 0) | |
622 { | |
623 if (otf) | |
624 OTF_close (otf); | |
625 xftfont_info->maybe_otf = 0; | |
91226
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
626 XftUnlockFace (xftfont_info->xftfont); |
91143 | 627 return 0; |
628 } | |
629 xftfont_info->otf = otf; | |
630 } | |
631 | |
91226
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
632 result = ftfont_shape_by_flt (lgstring, font, ft_face, xftfont_info->otf); |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
633 XftUnlockFace (xftfont_info->xftfont); |
040f2e332dc3
(struct xftfont_info): Delete the member ft_face.
Kenichi Handa <handa@m17n.org>
parents:
91163
diff
changeset
|
634 return result; |
91143 | 635 } |
636 #endif /* HAVE_M17N_FLT */ | |
637 #endif /* HAVE_LIBOTF */ | |
638 | |
90400 | 639 void |
640 syms_of_xftfont () | |
641 { | |
642 DEFSYM (Qxft, "xft"); | |
643 | |
644 xftfont_driver = ftfont_driver; | |
645 xftfont_driver.type = Qxft; | |
646 xftfont_driver.get_cache = xfont_driver.get_cache; | |
647 xftfont_driver.list = xftfont_list; | |
90559
fb5d3ac2d786
(xftfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents:
90527
diff
changeset
|
648 xftfont_driver.match = xftfont_match; |
90400 | 649 xftfont_driver.open = xftfont_open; |
650 xftfont_driver.close = xftfont_close; | |
651 xftfont_driver.prepare_face = xftfont_prepare_face; | |
652 xftfont_driver.done_face = xftfont_done_face; | |
653 xftfont_driver.encode_char = xftfont_encode_char; | |
654 xftfont_driver.text_extents = xftfont_text_extents; | |
655 xftfont_driver.draw = xftfont_draw; | |
656 xftfont_driver.anchor_point = xftfont_anchor_point; | |
91110
82a42637237c
(struct xftface_info): Delete the member xft_draw.
Kenichi Handa <handa@m17n.org>
parents:
91027
diff
changeset
|
657 xftfont_driver.end_for_frame = xftfont_end_for_frame; |
91143 | 658 #ifdef HAVE_LIBOTF |
659 #ifdef HAVE_M17N_FLT | |
660 xftfont_driver.shape = xftfont_shape; | |
661 #endif /* HAVE_M17N_FLT */ | |
662 #endif /* HAVE_LIBOTF */ | |
90400 | 663 |
664 register_font_driver (&xftfont_driver, NULL); | |
665 } | |
90427 | 666 |
667 /* arch-tag: 64ec61bf-7c8e-4fe6-b953-c6a85d5e1605 | |
668 (do not change this comment) */ |