annotate src/ftxfont.c @ 107845:688679bd79f5

Try to detect file modification within the same second. * buffer.h (struct buffer): New field modtime_size. * buffer.c (reset_buffer): Initialize it. * fileio.c (Finsert_file_contents, Fwrite_region): Set it. (Fverify_visited_file_modtime): Check it. (Fclear_visited_file_modtime, Fset_visited_file_modtime): Clear it. (Fset_visited_file_modtime): Set (or clear) it.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 12 Apr 2010 21:47:40 -0400
parents 1d1d5d9bd884
children 2bc9a0c04c87 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1 /* ftxfont.c -- FreeType font driver on X (without using XFT).
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105669
diff changeset
2 Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105669
diff changeset
3 Copyright (C) 2006, 2007, 2008, 2009, 2010
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
4 National Institute of Advanced Industrial Science and Technology (AIST)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
5 Registration Number H13PRO009
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
6
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7 This file is part of GNU Emacs.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
8
94963
8971ddf55736 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94932
diff changeset
9 GNU Emacs is free software: you can redistribute it and/or modify
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
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: 94932
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: 94932
diff changeset
12 (at your option) any later version.
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
13
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
14 GNU Emacs is distributed in the hope that it will be useful,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 GNU General Public License for more details.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
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: 94932
diff changeset
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 #include <config.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23 #include <stdio.h>
105669
68dd71358159 * alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 102862
diff changeset
24 #include <setjmp.h>
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25 #include <X11/Xlib.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27 #include "lisp.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28 #include "dispextern.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 #include "xterm.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 #include "frame.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 #include "blockinput.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 #include "character.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 #include "charset.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 #include "fontset.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 #include "font.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 /* FTX font driver. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 static Lisp_Object Qftx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 /* Prototypes for helper function. */
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
42 static GC *ftxfont_get_gcs P_ ((FRAME_PTR, unsigned long, unsigned long));
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
43 static int ftxfont_draw_bitmap P_ ((FRAME_PTR, GC, GC *, struct font *,
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
44 unsigned, int, int, XPoint *, int, int *,
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
45 int));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46 static void ftxfont_draw_backgrond P_ ((FRAME_PTR, struct font *, GC,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47 int, int, int));
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
48
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
49 struct ftxfont_frame_data
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
50 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
51 /* Background and foreground colors. */
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
52 XColor colors[2];
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
53 /* GCs interporationg the above colors. gcs[0] is for a color
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
54 closest to BACKGROUND, and gcs[5] is for a color closest to
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
55 FOREGROUND. */
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
56 GC gcs[6];
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
57 struct ftxfont_frame_data *next;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
58 };
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
59
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
60
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
61 /* Return an array of 6 GCs for antialiasing. */
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
62
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
63 static GC *
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
64 ftxfont_get_gcs (f, foreground, background)
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
65 FRAME_PTR f;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
66 unsigned long foreground, background;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
67 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
68 XColor color;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
69 XGCValues xgcv;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
70 int i;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
71 struct ftxfont_frame_data *data = font_get_frame_data (f, &ftxfont_driver);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
72 struct ftxfont_frame_data *prev = NULL, *this = NULL, *new;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
73
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
74 if (data)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
75 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
76 for (this = data; this; prev = this, this = this->next)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
77 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
78 if (this->colors[0].pixel < background)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
79 continue;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
80 if (this->colors[0].pixel > background)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
81 break;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
82 if (this->colors[1].pixel < foreground)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
83 continue;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
84 if (this->colors[1].pixel > foreground)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
85 break;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
86 return this->gcs;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
87 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
88 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
89
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
90 new = malloc (sizeof (struct ftxfont_frame_data));
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
91 if (! new)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
92 return NULL;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
93 new->next = this;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
94 if (prev)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
95 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
96 prev->next = new;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
97 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
98 else if (font_put_frame_data (f, &ftxfont_driver, new) < 0)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
99 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
100 free (new);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
101 return NULL;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
102 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
103
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
104 new->colors[0].pixel = background;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
105 new->colors[1].pixel = foreground;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
106
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
107 BLOCK_INPUT;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
108 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), new->colors, 2);
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
109 for (i = 1; i < 7; i++)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
110 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
111 /* Interpolate colors linearly. Any better algorithm? */
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
112 color.red
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
113 = (new->colors[1].red * i + new->colors[0].red * (8 - i)) / 8;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
114 color.green
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
115 = (new->colors[1].green * i + new->colors[0].green * (8 - i)) / 8;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
116 color.blue
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
117 = (new->colors[1].blue * i + new->colors[0].blue * (8 - i)) / 8;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
118 if (! x_alloc_nearest_color (f, FRAME_X_COLORMAP (f), &color))
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
119 break;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
120 xgcv.foreground = color.pixel;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
121 new->gcs[i - 1] = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
122 GCForeground, &xgcv);
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
123 }
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
124 UNBLOCK_INPUT;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
125
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
126 if (i < 7)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
127 {
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
128 BLOCK_INPUT;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
129 for (i--; i >= 0; i--)
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
130 XFreeGC (FRAME_X_DISPLAY (f), new->gcs[i]);
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
131 UNBLOCK_INPUT;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
132 if (prev)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
133 prev->next = new->next;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
134 else if (data)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
135 font_put_frame_data (f, &ftxfont_driver, new->next);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
136 free (new);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
137 return NULL;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
138 }
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
139 return new->gcs;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
140 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
141
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
142 static int
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
143 ftxfont_draw_bitmap (f, gc_fore, gcs, font, code, x, y, p, size, n, flush)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
144 FRAME_PTR f;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
145 GC gc_fore, *gcs;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
146 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
147 unsigned code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
148 int x, y;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
149 XPoint *p;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
150 int size, *n;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
151 int flush;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
152 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
153 struct font_bitmap bitmap;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
154 unsigned char *b;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
155 int i, j;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
156
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
157 if (ftfont_driver.get_bitmap (font, code, &bitmap, size > 0x100 ? 1 : 8) < 0)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
158 return 0;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
159 if (size > 0x100)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
160 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
161 for (i = 0, b = bitmap.buffer; i < bitmap.rows;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
162 i++, b += bitmap.pitch)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
163 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
164 for (j = 0; j < bitmap.width; j++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
165 if (b[j / 8] & (1 << (7 - (j % 8))))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
166 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
167 p[n[0]].x = x + bitmap.left + j;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
168 p[n[0]].y = y - bitmap.top + i;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
169 if (++n[0] == size)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
170 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
171 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
172 gc_fore, p, size, CoordModeOrigin);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
173 n[0] = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
174 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
175 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
176 }
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
177 if (flush && n[0] > 0)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
178 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
179 gc_fore, p, n[0], CoordModeOrigin);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
180 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
181 else
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
182 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
183 for (i = 0, b = bitmap.buffer; i < bitmap.rows;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
184 i++, b += bitmap.pitch)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
185 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
186 for (j = 0; j < bitmap.width; j++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
187 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
188 int idx = (bitmap.bits_per_pixel == 1
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
189 ? ((b[j / 8] & (1 << (7 - (j % 8)))) ? 6 : -1)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
190 : (b[j] >> 5) - 1);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
191
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
192 if (idx >= 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
193 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
194 XPoint *pp = p + size * idx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
195
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
196 pp[n[idx]].x = x + bitmap.left + j;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
197 pp[n[idx]].y = y - bitmap.top + i;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
198 if (++(n[idx]) == size)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
199 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
200 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
201 idx == 6 ? gc_fore : gcs[idx], pp, size,
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
202 CoordModeOrigin);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
203 n[idx] = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
204 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
205 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
206 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
207 }
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
208 if (flush)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
209 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
210 for (i = 0; i < 6; i++)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
211 if (n[i] > 0)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
212 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
213 gcs[i], p + 0x100 * i, n[i], CoordModeOrigin);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
214 if (n[6] > 0)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
215 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
216 gc_fore, p + 0x600, n[6], CoordModeOrigin);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
217 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
218 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
219
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
220 if (ftfont_driver.free_bitmap)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
221 ftfont_driver.free_bitmap (font, &bitmap);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
222
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
223 return bitmap.advance;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
224 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
225
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
226 static void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
227 ftxfont_draw_backgrond (f, font, gc, x, y, width)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
228 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
229 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
230 GC gc;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
231 int x, y, width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
232 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
233 XGCValues xgcv;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
234
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
235 XGetGCValues (FRAME_X_DISPLAY (f), gc,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
236 GCForeground | GCBackground, &xgcv);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
237 XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.background);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
238 XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
102862
edcf6efdc10a (ftxfont_draw_backgrond): Fix args to XFillRectangle.
Kenichi Handa <handa@m17n.org>
parents: 100951
diff changeset
239 x, y - FONT_BASE (font), width, FONT_HEIGHT (font));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
240 XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.foreground);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
241 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
242
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
243 /* Prototypes for font-driver methods. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
244 static Lisp_Object ftxfont_list P_ ((Lisp_Object, Lisp_Object));
90560
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
245 static Lisp_Object ftxfont_match P_ ((Lisp_Object, Lisp_Object));
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
246 static Lisp_Object ftxfont_open P_ ((FRAME_PTR, Lisp_Object, int));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
247 static void ftxfont_close P_ ((FRAME_PTR, struct font *));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
248 static int ftxfont_draw P_ ((struct glyph_string *, int, int, int, int, int));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
249
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
250 struct font_driver ftxfont_driver;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
251
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
252 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
253 ftxfont_list (frame, spec)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
254 Lisp_Object frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
255 Lisp_Object spec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
256 {
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
257 Lisp_Object list = ftfont_driver.list (frame, spec), tail;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
258
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
259 for (tail = list; CONSP (tail); tail = XCDR (tail))
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
260 ASET (XCAR (tail), FONT_TYPE_INDEX, Qftx);
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
261 return list;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
262 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
263
90560
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
264 static Lisp_Object
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
265 ftxfont_match (frame, spec)
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
266 Lisp_Object frame;
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
267 Lisp_Object spec;
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
268 {
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
269 Lisp_Object entity = ftfont_driver.match (frame, spec);
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
270
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
271 if (VECTORP (entity))
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
272 ASET (entity, FONT_TYPE_INDEX, Qftx);
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
273 return entity;
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
274 }
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
275
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
276 static Lisp_Object
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
277 ftxfont_open (f, entity, pixel_size)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
278 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
279 Lisp_Object entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
280 int pixel_size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
281 {
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
282 Lisp_Object font_object;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
283 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
284
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
285 font_object = ftfont_driver.open (f, entity, pixel_size);
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
286 if (NILP (font_object))
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
287 return Qnil;
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
288 font = XFONT_OBJECT (font_object);
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
289 font->driver = &ftxfont_driver;
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
290 return font_object;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
291 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
292
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
293 static void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
294 ftxfont_close (f, font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
295 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
296 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
297 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
298 ftfont_driver.close (f, font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
299 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
300
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
301 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
302 ftxfont_draw (s, from, to, x, y, with_background)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
303 struct glyph_string *s;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
304 int from, to, x, y, with_background;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
305 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
306 FRAME_PTR f = s->f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
307 struct face *face = s->face;
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
308 struct font *font = s->font;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
309 XPoint p[0x700];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
310 int n[7];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
311 unsigned *code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
312 int len = to - from;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
313 int i;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
314 GC *gcs;
92186
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
315 int xadvance;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
316
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
317 n[0] = n[1] = n[2] = n[3] = n[4] = n[5] = n[6] = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
318
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
319 BLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
320 if (with_background)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
321 ftxfont_draw_backgrond (f, font, s->gc, x, y, s->width);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
322 code = alloca (sizeof (unsigned) * len);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
323 for (i = 0; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
324 code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
325 | XCHAR2B_BYTE2 (s->char2b + from + i));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
326
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
327 if (face->gc == s->gc)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
328 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
329 gcs = ftxfont_get_gcs (f, face->foreground, face->background);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
330 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
331 else
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
332 {
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
333 XGCValues xgcv;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
334 unsigned long mask = GCForeground | GCBackground;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
335
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
336 XGetGCValues (FRAME_X_DISPLAY (f), s->gc, mask, &xgcv);
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
337 gcs = ftxfont_get_gcs (f, xgcv.foreground, xgcv.background);
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
338 }
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
339
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
340 if (gcs)
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
341 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
342 if (s->num_clips)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
343 for (i = 0; i < 6; i++)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
344 XSetClipRectangles (FRAME_X_DISPLAY (f), gcs[i], 0, 0,
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
345 s->clip, s->num_clips, Unsorted);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
346
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
347 for (i = 0; i < len; i++)
92186
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
348 {
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
349 xadvance = ftxfont_draw_bitmap (f, s->gc, gcs, font, code[i], x, y,
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
350 p, 0x100, n, i + 1 == len);
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
351 x += (s->padding_p ? 1 : xadvance);
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
352 }
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
353 if (s->num_clips)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
354 for (i = 0; i < 6; i++)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
355 XSetClipMask (FRAME_X_DISPLAY (f), gcs[i], None);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
356 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
357 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
358 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
359 /* We can't draw with antialiasing.
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
360 s->gc should already have a proper clipping setting. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
361 for (i = 0; i < len; i++)
92186
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
362 {
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
363 xadvance = ftxfont_draw_bitmap (f, s->gc, NULL, font, code[i], x, y,
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
364 p, 0x700, n, i + 1 == len);
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
365 x += (s->padding_p ? 1 : xadvance);
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
366 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
367 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
368
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
369 UNBLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
370
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
371 return len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
372 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
373
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
374 static int
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
375 ftxfont_end_for_frame (f)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
376 FRAME_PTR f;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
377 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
378 struct ftxfont_frame_data *data = font_get_frame_data (f, &ftxfont_driver);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
379
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
380 BLOCK_INPUT;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
381 while (data)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
382 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
383 struct ftxfont_frame_data *next = data->next;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
384 int i;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
385
91127
785637bd05d0 (ftxfont_end_for_frame): Fix array indexing error.
Kenichi Handa <handa@m17n.org>
parents: 91109
diff changeset
386 for (i = 0; i < 6; i++)
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
387 XFreeGC (FRAME_X_DISPLAY (f), data->gcs[i]);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
388 free (data);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
389 data = next;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
390 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
391 UNBLOCK_INPUT;
91906
a18321dbb8fa (ftxfont_default_fid): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 91605
diff changeset
392 font_put_frame_data (f, &ftxfont_driver, NULL);
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
393 return 0;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
394 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
395
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
396
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
397
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
398 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
399 syms_of_ftxfont ()
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
400 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
401 DEFSYM (Qftx, "ftx");
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
402
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
403 ftxfont_driver = ftfont_driver;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
404 ftxfont_driver.type = Qftx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
405 ftxfont_driver.list = ftxfont_list;
90560
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
406 ftxfont_driver.match = ftxfont_match;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
407 ftxfont_driver.open = ftxfont_open;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
408 ftxfont_driver.close = ftxfont_close;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
409 ftxfont_driver.draw = ftxfont_draw;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
410 ftxfont_driver.end_for_frame = ftxfont_end_for_frame;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
411 register_font_driver (&ftxfont_driver, NULL);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
412 }
90427
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
413
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
414 /* arch-tag: 59bd3469-5330-413f-b29d-1aa36492abe8
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
415 (do not change this comment) */