annotate src/ftxfont.c @ 110693:754df5a0efe9

Modify url-retrieve and related functions and structures to respect a `silent' flag to signal that the operation should be silent.
author Lars Magne Ingebrigtsen <larsi@gnus.org>
date Sat, 02 Oct 2010 04:04:20 +0200
parents aec1143e8d85
children 417b1e4d63cd
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. */
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
42 static GC *ftxfont_get_gcs (FRAME_PTR, unsigned long, unsigned long);
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
43 static int ftxfont_draw_bitmap (FRAME_PTR, GC, GC *, struct font *,
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
44 unsigned, int, int, XPoint *, int, int *,
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
45 int);
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
46 static void ftxfont_draw_backgrond (FRAME_PTR, struct font *, GC,
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
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 *
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
64 ftxfont_get_gcs (FRAME_PTR f, long unsigned int foreground, long unsigned int background)
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
65 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
66 XColor color;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
67 XGCValues xgcv;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
68 int i;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
69 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
70 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
71
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
72 if (data)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
73 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
74 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
75 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
76 if (this->colors[0].pixel < background)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
77 continue;
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 break;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
80 if (this->colors[1].pixel < foreground)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
81 continue;
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 break;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
84 return this->gcs;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
85 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
86 }
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 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
89 if (! new)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
90 return NULL;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
91 new->next = this;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
92 if (prev)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
93 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
94 prev->next = new;
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 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
97 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
98 free (new);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
99 return NULL;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
100 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
101
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
102 new->colors[0].pixel = background;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
103 new->colors[1].pixel = foreground;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
104
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
105 BLOCK_INPUT;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
106 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
107 for (i = 1; i < 7; i++)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
108 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
109 /* Interpolate colors linearly. Any better algorithm? */
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
110 color.red
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
111 = (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
112 color.green
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
113 = (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
114 color.blue
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
115 = (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
116 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
117 break;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
118 xgcv.foreground = color.pixel;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
119 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
120 GCForeground, &xgcv);
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
121 }
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
122 UNBLOCK_INPUT;
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 if (i < 7)
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 BLOCK_INPUT;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
127 for (i--; i >= 0; i--)
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
128 XFreeGC (FRAME_X_DISPLAY (f), new->gcs[i]);
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
129 UNBLOCK_INPUT;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
130 if (prev)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
131 prev->next = new->next;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
132 else if (data)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
133 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
134 free (new);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
135 return NULL;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
136 }
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
137 return new->gcs;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
138 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
139
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
140 static int
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
141 ftxfont_draw_bitmap (FRAME_PTR f, GC gc_fore, GC *gcs, struct font *font, unsigned int code, int x, int y, XPoint *p, int size, int *n, int flush)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
142 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
143 struct font_bitmap bitmap;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
144 unsigned char *b;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
145 int i, j;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
146
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
147 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
148 return 0;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
149 if (size > 0x100)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
150 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
151 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
152 i++, b += bitmap.pitch)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
153 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
154 for (j = 0; j < bitmap.width; j++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
155 if (b[j / 8] & (1 << (7 - (j % 8))))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
156 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
157 p[n[0]].x = x + bitmap.left + j;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
158 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
159 if (++n[0] == size)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
160 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
161 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
162 gc_fore, p, size, CoordModeOrigin);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
163 n[0] = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
164 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
165 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
166 }
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
167 if (flush && n[0] > 0)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
168 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
169 gc_fore, p, n[0], CoordModeOrigin);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
170 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
171 else
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
172 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
173 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
174 i++, b += bitmap.pitch)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
175 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
176 for (j = 0; j < bitmap.width; j++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
177 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
178 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
179 ? ((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
180 : (b[j] >> 5) - 1);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
181
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
182 if (idx >= 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
183 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
184 XPoint *pp = p + size * idx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
185
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
186 pp[n[idx]].x = x + bitmap.left + j;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
187 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
188 if (++(n[idx]) == size)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
189 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
190 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
191 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
192 CoordModeOrigin);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
193 n[idx] = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
194 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
195 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
196 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
197 }
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
198 if (flush)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
199 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
200 for (i = 0; i < 6; i++)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
201 if (n[i] > 0)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
202 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
203 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
204 if (n[6] > 0)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
205 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
206 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
207 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
208 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
209
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
210 if (ftfont_driver.free_bitmap)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
211 ftfont_driver.free_bitmap (font, &bitmap);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
212
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
213 return bitmap.advance;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
214 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
215
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
216 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
217 ftxfont_draw_backgrond (FRAME_PTR f, struct font *font, GC gc, int x, int y, int width)
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 XGCValues xgcv;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
220
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
221 XGetGCValues (FRAME_X_DISPLAY (f), gc,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
222 GCForeground | GCBackground, &xgcv);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
223 XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.background);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
224 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
225 x, y - FONT_BASE (font), width, FONT_HEIGHT (font));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
226 XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.foreground);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
227 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
228
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
229 /* Prototypes for font-driver methods. */
109100
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
230 static Lisp_Object ftxfont_list (Lisp_Object, Lisp_Object);
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
231 static Lisp_Object ftxfont_match (Lisp_Object, Lisp_Object);
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
232 static Lisp_Object ftxfont_open (FRAME_PTR, Lisp_Object, int);
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
233 static void ftxfont_close (FRAME_PTR, struct font *);
2bc9a0c04c87 Remove __P and P_ from .c and .m files and definition of P_
Jan D <jan.h.d@swipnet.se>
parents: 106815
diff changeset
234 static int ftxfont_draw (struct glyph_string *, int, int, int, int, int);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
235
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
236 struct font_driver ftxfont_driver;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
237
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
238 static Lisp_Object
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
239 ftxfont_list (Lisp_Object frame, Lisp_Object spec)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
240 {
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
241 Lisp_Object list = ftfont_driver.list (frame, spec), tail;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
242
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
243 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
244 ASET (XCAR (tail), FONT_TYPE_INDEX, Qftx);
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
245 return list;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
246 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
247
90560
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
248 static Lisp_Object
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
249 ftxfont_match (Lisp_Object frame, Lisp_Object spec)
90560
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
250 {
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
251 Lisp_Object entity = ftfont_driver.match (frame, spec);
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
252
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
253 if (VECTORP (entity))
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
254 ASET (entity, FONT_TYPE_INDEX, Qftx);
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
255 return entity;
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
256 }
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
257
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
258 static Lisp_Object
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
259 ftxfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
260 {
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
261 Lisp_Object font_object;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
262 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
263
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
264 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
265 if (NILP (font_object))
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
266 return Qnil;
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
267 font = XFONT_OBJECT (font_object);
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
268 font->driver = &ftxfont_driver;
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
269 return font_object;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
270 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
271
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
272 static void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
273 ftxfont_close (FRAME_PTR f, struct font *font)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
274 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
275 ftfont_driver.close (f, font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
276 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
277
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
278 static int
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
279 ftxfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_background)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
280 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
281 FRAME_PTR f = s->f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
282 struct face *face = s->face;
94932
4ac20761f264 (ftxfont_list): Return a list, not vector.
Kenichi Handa <handa@m17n.org>
parents: 92186
diff changeset
283 struct font *font = s->font;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
284 XPoint p[0x700];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
285 int n[7];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
286 unsigned *code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
287 int len = to - from;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
288 int i;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
289 GC *gcs;
92186
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
290 int xadvance;
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 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
293
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
294 BLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
295 if (with_background)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
296 ftxfont_draw_backgrond (f, font, s->gc, x, y, s->width);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
297 code = alloca (sizeof (unsigned) * len);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
298 for (i = 0; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
299 code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
300 | XCHAR2B_BYTE2 (s->char2b + from + i));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
301
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
302 if (face->gc == s->gc)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
303 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
304 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
305 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
306 else
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
307 {
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
308 XGCValues xgcv;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
309 unsigned long mask = GCForeground | GCBackground;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
310
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
311 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
312 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
313 }
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
314
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
315 if (gcs)
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
316 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
317 if (s->num_clips)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
318 for (i = 0; i < 6; i++)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
319 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
320 s->clip, s->num_clips, Unsorted);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
321
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
322 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
323 {
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
324 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
325 p, 0x100, n, i + 1 == len);
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
326 x += (s->padding_p ? 1 : xadvance);
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
327 }
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
328 if (s->num_clips)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
329 for (i = 0; i < 6; i++)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
330 XSetClipMask (FRAME_X_DISPLAY (f), gcs[i], None);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
331 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
332 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
333 {
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
334 /* We can't draw with antialiasing.
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
335 s->gc should already have a proper clipping setting. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
336 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
337 {
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
338 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
339 p, 0x700, n, i + 1 == len);
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
340 x += (s->padding_p ? 1 : xadvance);
919240e47747 (ftxfont_draw): Pay attention to s->padding_p.
Kenichi Handa <handa@m17n.org>
parents: 91906
diff changeset
341 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
342 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
343
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
344 UNBLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
345
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
346 return len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
347 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
348
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
349 static int
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
350 ftxfont_end_for_frame (FRAME_PTR f)
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
351 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
352 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
353
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
354 BLOCK_INPUT;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
355 while (data)
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
356 {
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
357 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
358 int i;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
359
91127
785637bd05d0 (ftxfont_end_for_frame): Fix array indexing error.
Kenichi Handa <handa@m17n.org>
parents: 91109
diff changeset
360 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
361 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
362 free (data);
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
363 data = next;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
364 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
365 UNBLOCK_INPUT;
91906
a18321dbb8fa (ftxfont_default_fid): Delete it.
Kenichi Handa <handa@m17n.org>
parents: 91605
diff changeset
366 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
367 return 0;
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
368 }
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
369
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
370
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
371
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
372 void
109126
aec1143e8d85 Convert (most) functions in src to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 109100
diff changeset
373 syms_of_ftxfont (void)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
374 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
375 DEFSYM (Qftx, "ftx");
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
376
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
377 ftxfont_driver = ftfont_driver;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
378 ftxfont_driver.type = Qftx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
379 ftxfont_driver.list = ftxfont_list;
90560
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
380 ftxfont_driver.match = ftxfont_match;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
381 ftxfont_driver.open = ftxfont_open;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
382 ftxfont_driver.close = ftxfont_close;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
383 ftxfont_driver.draw = ftxfont_draw;
91109
5ed0717083a1 (ftxfont_get_gcs): Renamed from ftxfont_create_gcs.
Kenichi Handa <handa@m17n.org>
parents: 90560
diff changeset
384 ftxfont_driver.end_for_frame = ftxfont_end_for_frame;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
385 register_font_driver (&ftxfont_driver, NULL);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
386 }
90427
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
387
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
388 /* arch-tag: 59bd3469-5330-413f-b29d-1aa36492abe8
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
389 (do not change this comment) */