aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in6
-rw-r--r--src/deps.mk3
-rw-r--r--src/font.c1
-rw-r--r--src/font.h6
-rw-r--r--src/ftxfont.c371
-rw-r--r--src/xfns.c4
6 files changed, 5 insertions, 386 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
index ab63b926272..552dd2e50ae 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -295,8 +295,8 @@ EMACSRES = @EMACSRES@
295W32_RES_LINK=@W32_RES_LINK@ 295W32_RES_LINK=@W32_RES_LINK@
296 296
297## Empty if !HAVE_X_WINDOWS 297## Empty if !HAVE_X_WINDOWS
298## xfont.o ftfont.o xftfont.o ftxfont.o if HAVE_XFT 298## xfont.o ftfont.o xftfont.o if HAVE_XFT
299## xfont.o ftfont.o ftxfont.o if HAVE_FREETYPE 299## xfont.o ftfont.o if HAVE_FREETYPE
300## xfont.o ftfont.o ftcrfont.o if USE_CAIRO 300## xfont.o ftfont.o ftcrfont.o if USE_CAIRO
301## else xfont.o 301## else xfont.o
302## if HAVE_HARFBUZZ, hbfont.o is added regardless of the rest 302## if HAVE_HARFBUZZ, hbfont.o is added regardless of the rest
@@ -436,7 +436,7 @@ SOME_MACHINE_OBJECTS = dosfns.o msdos.o \
436 nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macfont.o \ 436 nsterm.o nsfns.o nsmenu.o nsselect.o nsimage.o nsfont.o macfont.o \
437 w32.o w32console.o w32cygwinx.o w32fns.o w32heap.o w32inevt.o w32notify.o \ 437 w32.o w32console.o w32cygwinx.o w32fns.o w32heap.o w32inevt.o w32notify.o \
438 w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \ 438 w32menu.o w32proc.o w32reg.o w32select.o w32term.o w32xfns.o \
439 w16select.o widget.o xfont.o ftfont.o xftfont.o ftxfont.o gtkutil.o \ 439 w16select.o widget.o xfont.o ftfont.o xftfont.o gtkutil.o \
440 xsettings.o xgselect.o termcap.o hbfont.o 440 xsettings.o xgselect.o termcap.o hbfont.o
441 441
442## gmalloc.o if !SYSTEM_MALLOC && !DOUG_LEA_MALLOC, else empty. 442## gmalloc.o if !SYSTEM_MALLOC && !DOUG_LEA_MALLOC, else empty.
diff --git a/src/deps.mk b/src/deps.mk
index a7e1b559173..4d162eeb0f2 100644
--- a/src/deps.mk
+++ b/src/deps.mk
@@ -239,9 +239,6 @@ xfont.o: dispextern.h xterm.h frame.h blockinput.h character.h charset.h \
239xftfont.o: xftfont.c dispextern.h xterm.h frame.h blockinput.h character.h \ 239xftfont.o: xftfont.c dispextern.h xterm.h frame.h blockinput.h character.h \
240 charset.h font.h lisp.h globals.h $(config_h) atimer.h systime.h \ 240 charset.h font.h lisp.h globals.h $(config_h) atimer.h systime.h \
241 fontset.h ccl.h ftfont.h composite.h 241 fontset.h ccl.h ftfont.h composite.h
242ftxfont.o: ftxfont.c dispextern.h xterm.h frame.h blockinput.h character.h \
243 charset.h font.h lisp.h globals.h $(config_h) atimer.h systime.h \
244 fontset.h ccl.h
245menu.o: menu.c lisp.h keyboard.h keymap.h frame.h termhooks.h blockinput.h \ 242menu.o: menu.c lisp.h keyboard.h keymap.h frame.h termhooks.h blockinput.h \
246 dispextern.h $(srcdir)/../lwlib/lwlib.h xterm.h gtkutil.h menu.h \ 243 dispextern.h $(srcdir)/../lwlib/lwlib.h xterm.h gtkutil.h menu.h \
247 lisp.h globals.h $(config_h) systime.h coding.h composite.h window.h \ 244 lisp.h globals.h $(config_h) systime.h coding.h composite.h window.h \
diff --git a/src/font.c b/src/font.c
index 2b90903c909..bb39aef92d5 100644
--- a/src/font.c
+++ b/src/font.c
@@ -5545,7 +5545,6 @@ cause Xft crashes. Only has an effect in Xft builds. */);
5545#ifdef USE_CAIRO 5545#ifdef USE_CAIRO
5546 syms_of_ftcrfont (); 5546 syms_of_ftcrfont ();
5547#else 5547#else
5548 syms_of_ftxfont ();
5549#ifdef HAVE_XFT 5548#ifdef HAVE_XFT
5550 syms_of_xftfont (); 5549 syms_of_xftfont ();
5551#endif /* HAVE_XFT */ 5550#endif /* HAVE_XFT */
diff --git a/src/font.h b/src/font.h
index 633d92709c5..0561e3c83f5 100644
--- a/src/font.h
+++ b/src/font.h
@@ -69,8 +69,8 @@ INLINE_HEADER_BEGIN
69 69
70enum font_property_index 70enum font_property_index
71 { 71 {
72 /* FONT-TYPE is a symbol indicating a font backend; currently `x', 72 /* FONT-TYPE is a symbol indicating a font backend; currently `x'
73 `xft', and `ftx' are available on X, `uniscribe' and `gdi' on 73 and `xft' are available on X, `uniscribe' and `gdi' on
74 Windows, and `ns' under Cocoa / GNUstep. */ 74 Windows, and `ns' under Cocoa / GNUstep. */
75 FONT_TYPE_INDEX, 75 FONT_TYPE_INDEX,
76 76
@@ -938,7 +938,6 @@ extern void syms_of_ftfont (void);
938extern struct font_driver const xfont_driver; 938extern struct font_driver const xfont_driver;
939extern Lisp_Object xfont_get_cache (struct frame *); 939extern Lisp_Object xfont_get_cache (struct frame *);
940extern void syms_of_xfont (void); 940extern void syms_of_xfont (void);
941extern void syms_of_ftxfont (void);
942#ifdef HAVE_XFT 941#ifdef HAVE_XFT
943extern struct font_driver const xftfont_driver; 942extern struct font_driver const xftfont_driver;
944#ifdef HAVE_HARFBUZZ 943#ifdef HAVE_HARFBUZZ
@@ -946,7 +945,6 @@ extern struct font_driver xfthbfont_driver;
946#endif /* HAVE_HARFBUZZ */ 945#endif /* HAVE_HARFBUZZ */
947#endif 946#endif
948#if defined HAVE_FREETYPE || defined HAVE_XFT 947#if defined HAVE_FREETYPE || defined HAVE_XFT
949extern struct font_driver const ftxfont_driver;
950extern void syms_of_xftfont (void); 948extern void syms_of_xftfont (void);
951#endif 949#endif
952#ifdef HAVE_BDFFONT 950#ifdef HAVE_BDFFONT
diff --git a/src/ftxfont.c b/src/ftxfont.c
deleted file mode 100644
index 9bbb2c064c2..00000000000
--- a/src/ftxfont.c
+++ /dev/null
@@ -1,371 +0,0 @@
1/* ftxfont.c -- FreeType font driver on X (without using XFT).
2 Copyright (C) 2006-2020 Free Software Foundation, Inc.
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
4 National Institute of Advanced Industrial Science and Technology (AIST)
5 Registration Number H13PRO009
6
7This file is part of GNU Emacs.
8
9GNU Emacs is free software: you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation, either version 3 of the License, or (at
12your option) any later version.
13
14GNU Emacs is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
21
22#include <config.h>
23#include <X11/Xlib.h>
24
25#include "lisp.h"
26#include "xterm.h"
27#include "frame.h"
28#include "blockinput.h"
29#include "font.h"
30#include "pdumper.h"
31
32/* FTX font driver. */
33
34struct ftxfont_frame_data
35{
36 /* Background and foreground colors. */
37 XColor colors[2];
38 /* GCs interpolating the above colors. gcs[0] is for a color
39 closest to BACKGROUND, and gcs[5] is for a color closest to
40 FOREGROUND. */
41 GC gcs[6];
42 struct ftxfont_frame_data *next;
43};
44
45
46/* Return an array of 6 GCs for antialiasing. */
47
48static GC *
49ftxfont_get_gcs (struct frame *f, unsigned long foreground, unsigned long background)
50{
51 XColor color;
52 XGCValues xgcv;
53 int i;
54 struct ftxfont_frame_data *data = font_get_frame_data (f, Qftx);
55 struct ftxfont_frame_data *prev = NULL, *this = NULL, *new;
56
57 if (data)
58 {
59 for (this = data; this; prev = this, this = this->next)
60 {
61 if (this->colors[0].pixel < background)
62 continue;
63 if (this->colors[0].pixel > background)
64 break;
65 if (this->colors[1].pixel < foreground)
66 continue;
67 if (this->colors[1].pixel > foreground)
68 break;
69 return this->gcs;
70 }
71 }
72
73 new = xmalloc (sizeof *new);
74 new->next = this;
75 if (prev)
76 prev->next = new;
77 font_put_frame_data (f, Qftx, new);
78
79 new->colors[0].pixel = background;
80 new->colors[1].pixel = foreground;
81
82 block_input ();
83 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), new->colors, 2);
84 for (i = 1; i < 7; i++)
85 {
86 /* Interpolate colors linearly. Any better algorithm? */
87 color.red
88 = (new->colors[1].red * i + new->colors[0].red * (8 - i)) / 8;
89 color.green
90 = (new->colors[1].green * i + new->colors[0].green * (8 - i)) / 8;
91 color.blue
92 = (new->colors[1].blue * i + new->colors[0].blue * (8 - i)) / 8;
93 if (! x_alloc_nearest_color (f, FRAME_X_COLORMAP (f), &color))
94 break;
95 xgcv.foreground = color.pixel;
96 new->gcs[i - 1] = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f),
97 GCForeground, &xgcv);
98 }
99 unblock_input ();
100
101 if (i < 7)
102 {
103 block_input ();
104 for (i--; i >= 0; i--)
105 XFreeGC (FRAME_X_DISPLAY (f), new->gcs[i]);
106 unblock_input ();
107 if (prev)
108 prev->next = new->next;
109 else if (data)
110 font_put_frame_data (f, Qftx, new->next);
111 xfree (new);
112 return NULL;
113 }
114 return new->gcs;
115}
116
117static int
118ftxfont_draw_bitmap (struct frame *f, GC gc_fore, GC *gcs, struct font *font,
119 unsigned int code, int x, int y, XPoint *p, int size,
120 int *n, bool flush)
121{
122 struct font_bitmap bitmap;
123 unsigned char *b;
124 int i, j;
125
126 if (ftfont_get_bitmap (font, code, &bitmap, size > 0x100 ? 1 : 8) < 0)
127 return 0;
128 if (size > 0x100)
129 {
130 for (i = 0, b = bitmap.buffer; i < bitmap.rows;
131 i++, b += bitmap.pitch)
132 {
133 for (j = 0; j < bitmap.width; j++)
134 if (b[j / 8] & (1 << (7 - (j % 8))))
135 {
136 p[n[0]].x = x + bitmap.left + j;
137 p[n[0]].y = y - bitmap.top + i;
138 if (++n[0] == size)
139 {
140 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f),
141 gc_fore, p, size, CoordModeOrigin);
142 n[0] = 0;
143 }
144 }
145 }
146 if (flush && n[0] > 0)
147 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f),
148 gc_fore, p, n[0], CoordModeOrigin);
149 }
150 else
151 {
152 for (i = 0, b = bitmap.buffer; i < bitmap.rows;
153 i++, b += bitmap.pitch)
154 {
155 for (j = 0; j < bitmap.width; j++)
156 {
157 int idx = (bitmap.bits_per_pixel == 1
158 ? ((b[j / 8] & (1 << (7 - (j % 8)))) ? 6 : -1)
159 : (b[j] >> 5) - 1);
160
161 if (idx >= 0)
162 {
163 XPoint *pp = p + size * idx;
164
165 pp[n[idx]].x = x + bitmap.left + j;
166 pp[n[idx]].y = y - bitmap.top + i;
167 if (++(n[idx]) == size)
168 {
169 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f),
170 idx == 6 ? gc_fore : gcs[idx], pp, size,
171 CoordModeOrigin);
172 n[idx] = 0;
173 }
174 }
175 }
176 }
177 if (flush)
178 {
179 for (i = 0; i < 6; i++)
180 if (n[i] > 0)
181 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f),
182 gcs[i], p + 0x100 * i, n[i], CoordModeOrigin);
183 if (n[6] > 0)
184 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f),
185 gc_fore, p + 0x600, n[6], CoordModeOrigin);
186 }
187 }
188
189 /* There is no ftfont_free_bitmap, so do not try to free BITMAP. */
190
191 return bitmap.advance;
192}
193
194static void
195ftxfont_draw_background (struct frame *f, struct font *font, GC gc, int x, int y,
196 int width)
197{
198 XGCValues xgcv;
199
200 XGetGCValues (FRAME_X_DISPLAY (f), gc,
201 GCForeground | GCBackground, &xgcv);
202 XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.background);
203 XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_DRAWABLE (f), gc,
204 x, y - FONT_BASE (font), width, FONT_HEIGHT (font));
205 XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.foreground);
206}
207
208static Lisp_Object
209ftxfont_list (struct frame *f, Lisp_Object spec)
210{
211 return ftfont_list2 (f, spec, Qftx);
212}
213
214static Lisp_Object
215ftxfont_match (struct frame *f, Lisp_Object spec)
216{
217 return ftfont_match2 (f, spec, Qftx);
218}
219
220static Lisp_Object
221ftxfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
222{
223 Lisp_Object font_object = ftfont_open (f, entity, pixel_size);
224 if (NILP (font_object))
225 return Qnil;
226 struct font *font = XFONT_OBJECT (font_object);
227 font->driver = &ftxfont_driver;
228 return font_object;
229}
230
231static void
232ftxfont_close (struct font *font)
233{
234 ftfont_close (font);
235}
236
237static int
238ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y,
239 bool with_background)
240{
241 struct frame *f = s->f;
242 struct face *face = s->face;
243 struct font *font = s->font;
244 XPoint p[0x700];
245 int n[7];
246 unsigned *code = s->char2b + from;
247 int len = to - from;
248 int i;
249 GC *gcs;
250 int xadvance;
251
252 n[0] = n[1] = n[2] = n[3] = n[4] = n[5] = n[6] = 0;
253
254 block_input ();
255 if (with_background)
256 ftxfont_draw_background (f, font, s->gc, x, y, s->width);
257
258 if (face->gc == s->gc)
259 {
260 gcs = ftxfont_get_gcs (f, face->foreground, face->background);
261 }
262 else
263 {
264 XGCValues xgcv;
265 unsigned long mask = GCForeground | GCBackground;
266
267 XGetGCValues (FRAME_X_DISPLAY (f), s->gc, mask, &xgcv);
268 gcs = ftxfont_get_gcs (f, xgcv.foreground, xgcv.background);
269 }
270
271 if (gcs)
272 {
273 if (s->num_clips)
274 for (i = 0; i < 6; i++)
275 XSetClipRectangles (FRAME_X_DISPLAY (f), gcs[i], 0, 0,
276 s->clip, s->num_clips, Unsorted);
277
278 for (i = 0; i < len; i++)
279 {
280 xadvance = ftxfont_draw_bitmap (f, s->gc, gcs, font, code[i], x, y,
281 p, 0x100, n, i + 1 == len);
282 x += (s->padding_p ? 1 : xadvance);
283 }
284 if (s->num_clips)
285 for (i = 0; i < 6; i++)
286 XSetClipMask (FRAME_X_DISPLAY (f), gcs[i], None);
287 }
288 else
289 {
290 /* We can't draw with antialiasing.
291 s->gc should already have a proper clipping setting. */
292 for (i = 0; i < len; i++)
293 {
294 xadvance = ftxfont_draw_bitmap (f, s->gc, NULL, font, code[i], x, y,
295 p, 0x700, n, i + 1 == len);
296 x += (s->padding_p ? 1 : xadvance);
297 }
298 }
299
300 unblock_input ();
301
302 return len;
303}
304
305static int
306ftxfont_end_for_frame (struct frame *f)
307{
308 struct ftxfont_frame_data *data = font_get_frame_data (f, Qftx);
309
310 block_input ();
311 while (data)
312 {
313 struct ftxfont_frame_data *next = data->next;
314 int i;
315
316 for (i = 0; i < 6; i++)
317 XFreeGC (FRAME_X_DISPLAY (f), data->gcs[i]);
318 xfree (data);
319 data = next;
320 }
321 unblock_input ();
322 font_put_frame_data (f, Qftx, NULL);
323 return 0;
324}
325
326
327
328static void syms_of_ftxfont_for_pdumper (void);
329
330struct font_driver const ftxfont_driver =
331 {
332 /* We can't draw a text without device dependent functions. */
333 .type = LISPSYM_INITIALLY (Qftx),
334 .get_cache = ftfont_get_cache,
335 .list = ftxfont_list,
336 .match = ftxfont_match,
337 .list_family = ftfont_list_family,
338 .open_font = ftxfont_open,
339 .close_font = ftxfont_close,
340 .has_char = ftfont_has_char,
341 .encode_char = ftfont_encode_char,
342 .text_extents = ftfont_text_extents,
343 .draw = ftxfont_draw,
344 .get_bitmap = ftfont_get_bitmap,
345 .anchor_point = ftfont_anchor_point,
346#ifdef HAVE_LIBOTF
347 .otf_capability = ftfont_otf_capability,
348#endif
349 .end_for_frame = ftxfont_end_for_frame,
350#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF
351 .shape = ftfont_shape,
352#endif
353#if defined HAVE_OTF_GET_VARIATION_GLYPHS || defined HAVE_FT_FACE_GETCHARVARIANTINDEX
354 .get_variation_glyphs = ftfont_variation_glyphs,
355#endif
356 .filter_properties = ftfont_filter_properties,
357 .combining_capability = ftfont_combining_capability,
358 };
359
360void
361syms_of_ftxfont (void)
362{
363 DEFSYM (Qftx, "ftx");
364 pdumper_do_now_and_after_load (syms_of_ftxfont_for_pdumper);
365}
366
367static void
368syms_of_ftxfont_for_pdumper (void)
369{
370 register_font_driver (&ftxfont_driver, NULL);
371}
diff --git a/src/xfns.c b/src/xfns.c
index 276ea1c3935..5758bb7a18c 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -3878,8 +3878,6 @@ This function is an internal primitive--use `make-frame' instead. */)
3878#ifdef HAVE_HARFBUZZ 3878#ifdef HAVE_HARFBUZZ
3879 register_font_driver (&xfthbfont_driver, f); 3879 register_font_driver (&xfthbfont_driver, f);
3880#endif 3880#endif
3881#else /* not HAVE_XFT */
3882 register_font_driver (&ftxfont_driver, f);
3883#endif /* not HAVE_XFT */ 3881#endif /* not HAVE_XFT */
3884#endif /* HAVE_FREETYPE */ 3882#endif /* HAVE_FREETYPE */
3885#endif /* not USE_CAIRO */ 3883#endif /* not USE_CAIRO */
@@ -6364,8 +6362,6 @@ x_create_tip_frame (struct x_display_info *dpyinfo, Lisp_Object parms)
6364#ifdef HAVE_HARFBUZZ 6362#ifdef HAVE_HARFBUZZ
6365 register_font_driver (&xfthbfont_driver, f); 6363 register_font_driver (&xfthbfont_driver, f);
6366#endif 6364#endif
6367#else /* not HAVE_XFT */
6368 register_font_driver (&ftxfont_driver, f);
6369#endif /* not HAVE_XFT */ 6365#endif /* not HAVE_XFT */
6370#endif /* HAVE_FREETYPE */ 6366#endif /* HAVE_FREETYPE */
6371#endif /* not USE_CAIRO */ 6367#endif /* not USE_CAIRO */