annotate src/ftxfont.c @ 90609:bb0e318b7c53

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 447-459) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 141-144) - Merge from emacs--devo--0 - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-115
author Miles Bader <miles@gnu.org>
date Tue, 03 Oct 2006 05:04:21 +0000
parents c443c8a56b84
children 5ed0717083a1
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).
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2 Copyright (C) 2006 Free Software Foundation, Inc.
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3 Copyright (C) 2006
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
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9 GNU Emacs is free software; you can redistribute it and/or modify
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
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2, or (at your option)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
12 any later version.
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
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20 along with GNU Emacs; see the file COPYING. If not, write to
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 Boston, MA 02110-1301, USA. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
24 #include <config.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25 #include <stdio.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26 #include <X11/Xlib.h>
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28 #include "lisp.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 #include "dispextern.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 #include "xterm.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 #include "frame.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 #include "blockinput.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 #include "character.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 #include "charset.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 #include "fontset.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36 #include "font.h"
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38 /* FTX font driver. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40 static Lisp_Object Qftx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42 /* Prototypes for helper function. */
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
43 static int ftxfont_create_gcs P_ ((FRAME_PTR, GC *,
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
44 unsigned long, unsigned long));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 static int ftxfont_draw_bitmap P_ ((FRAME_PTR, GC *, struct font *, unsigned,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46 int, int, XPoint *, int, int *n));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47 static void ftxfont_draw_backgrond P_ ((FRAME_PTR, struct font *, GC,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 int, int, int));
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
49 static Font ftxfont_default_fid P_ ((FRAME_PTR));
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
50
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
51 /* Create 6 GCs for antialiasing by interpolating colors FOREGROUND
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
52 and BACKGROUND. GCS[0] is closest to BACKGROUND, and GCS[5] is
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
53 closest to FOREGROUND. */
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
54
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
55 static int
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
56 ftxfont_create_gcs (f, gcs, foreground, background)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
57 FRAME_PTR f;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
58 GC *gcs;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
59 unsigned long foreground, background;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
60 {
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
61 XColor colors[3];
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
62 XGCValues xgcv;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
63 int i;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
64
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
65 colors[0].pixel = foreground;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
66 colors[1].pixel = background;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
67
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
68 BLOCK_INPUT;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
69 XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors, 2);
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
70 for (i = 1; i < 7; i++)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
71 {
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
72 colors[2].red = (colors[0].red * i + colors[1].red * (8 - i)) / 8;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
73 colors[2].green = (colors[0].green * i + colors[1].green * (8 - i)) / 8;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
74 colors[2].blue = (colors[0].blue * i + colors[1].blue * (8 - i)) / 8;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
75 if (! x_alloc_nearest_color (f, FRAME_X_COLORMAP (f), &colors[2]))
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
76 break;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
77 xgcv.foreground = colors[2].pixel;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
78 gcs[i - 1] = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
79 GCForeground, &xgcv);
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
80 }
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
81 UNBLOCK_INPUT;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
82
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
83 if (i < 7)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
84 {
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
85 BLOCK_INPUT;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
86 for (i--; i >= 0; i--)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
87 XFreeGC (FRAME_X_DISPLAY (f), gcs[i]);
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
88 UNBLOCK_INPUT;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
89 return -1;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
90 }
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
91 return 0;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
92 }
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95 ftxfont_draw_bitmap (f, gc, font, code, x, y, p, size, n)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 GC *gc;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 unsigned code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
100 int x, y;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101 XPoint *p;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
102 int size, *n;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
103 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
104 struct font_bitmap bitmap;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
105 unsigned char *b;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
106 int i, j;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
107
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
108 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
109 return 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
110 for (i = 0, b = bitmap.buffer; i < bitmap.rows;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
111 i++, b += bitmap.pitch)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
112 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
113 if (size > 0x100)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
114 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
115 for (j = 0; j < bitmap.width; j++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
116 if (b[j / 8] & (1 << (7 - (j % 8))))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
117 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
118 p[n[0]].x = x + bitmap.left + j;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
119 p[n[0]].y = y - bitmap.top + i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
120 if (++n[0] == 0x400)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
121 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
122 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
123 gc[0], p, size, CoordModeOrigin);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
124 n[0] = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
125 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
126 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
127 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
128 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
129 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
130 for (j = 0; j < bitmap.width; j++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
131 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
132 int idx = (b[j] >> 5) - 1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
133
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
134 if (idx >= 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
135 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
136 XPoint *pp = p + size * idx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
137
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
138 pp[n[idx]].x = x + bitmap.left + j;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
139 pp[n[idx]].y = y - bitmap.top + i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
140 if (++(n[idx]) == 0x100)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
141 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
142 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
143 gc[idx], pp, size, CoordModeOrigin);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
144 n[idx] = 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
145 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
146 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
147 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
148 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
149 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
150
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
151 if (ftfont_driver.free_bitmap)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
152 ftfont_driver.free_bitmap (font, &bitmap);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
153
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
154 return bitmap.advance;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
155 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
156
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
157 static void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
158 ftxfont_draw_backgrond (f, font, gc, x, y, width)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
159 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
160 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
161 GC gc;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
162 int x, y, width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
163 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
164 XGCValues xgcv;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
165
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
166 XGetGCValues (FRAME_X_DISPLAY (f), gc,
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
167 GCForeground | GCBackground, &xgcv);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
168 XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.background);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
169 XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), gc,
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
170 x, y - font->ascent, width, y + font->descent);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
171 XSetForeground (FRAME_X_DISPLAY (f), gc, xgcv.foreground);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
172 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
173
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
174 /* Return the default Font ID on frame F. */
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
175
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
176 static Font
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
177 ftxfont_default_fid (f)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
178 FRAME_PTR f;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
179 {
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
180 static int fid_known;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
181 static Font fid;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
182
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
183 if (! fid_known)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
184 {
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
185 fid = XLoadFont (FRAME_X_DISPLAY (f), "fixed");
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
186 if (! fid)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
187 {
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
188 fid = XLoadFont (FRAME_X_DISPLAY (f), "*");
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
189 if (! fid)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
190 abort ();
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
191 }
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
192 fid_known = 1;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
193 }
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
194 return fid;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
195 }
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
196
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
197 /* Prototypes for font-driver methods. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
198 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
199 static Lisp_Object ftxfont_match P_ ((Lisp_Object, Lisp_Object));
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
200 static struct font *ftxfont_open P_ ((FRAME_PTR, Lisp_Object, int));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
201 static void ftxfont_close P_ ((FRAME_PTR, struct font *));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
202 static int ftxfont_prepare_face (FRAME_PTR, struct face *);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
203 static void ftxfont_done_face (FRAME_PTR, struct face *);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
204
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
205 static int ftxfont_draw P_ ((struct glyph_string *, int, int, int, int, int));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
206
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
207 struct font_driver ftxfont_driver;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
208
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
209 static Lisp_Object
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
210 ftxfont_list (frame, spec)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
211 Lisp_Object frame;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
212 Lisp_Object spec;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
213 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
214 Lisp_Object val = ftfont_driver.list (frame, spec);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
215
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
216 if (! NILP (val))
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
217 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
218 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
219
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
220 for (i = 0; i < ASIZE (val); i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
221 ASET (AREF (val, i), FONT_TYPE_INDEX, Qftx);
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 val;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
224 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
225
90560
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
226 static Lisp_Object
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
227 ftxfont_match (frame, spec)
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
228 Lisp_Object frame;
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
229 Lisp_Object spec;
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
230 {
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
231 Lisp_Object entity = ftfont_driver.match (frame, spec);
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
232
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
233 if (VECTORP (entity))
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
234 ASET (entity, FONT_TYPE_INDEX, Qftx);
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
235 return entity;
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
236 }
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
237
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
238 static struct font *
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
239 ftxfont_open (f, entity, pixel_size)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
240 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
241 Lisp_Object entity;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
242 int pixel_size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
243 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
244 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
245 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
246 XFontStruct *xfont = malloc (sizeof (XFontStruct));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
247
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
248 if (! xfont)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
249 return NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
250 font = ftfont_driver.open (f, entity, pixel_size);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
251 if (! font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
252 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
253 free (xfont);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
254 return NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
255 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
256
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
257 xfont->fid = ftxfont_default_fid (f);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
258 xfont->ascent = font->ascent;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
259 xfont->descent = font->descent;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
260 xfont->max_bounds.width = font->font.size;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
261 xfont->min_bounds.width = font->min_width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
262 font->font.font = xfont;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
263 font->driver = &ftxfont_driver;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
264
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
265 dpyinfo->n_fonts++;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
266
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
267 /* Set global flag fonts_changed_p to non-zero if the font loaded
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
268 has a character with a smaller width than any other character
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
269 before, or if the font loaded has a smaller height than any other
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
270 font loaded before. If this happens, it will make a glyph matrix
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
271 reallocation necessary. */
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
272 if (dpyinfo->n_fonts == 1)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
273 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
274 dpyinfo->smallest_font_height = font->font.height;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
275 dpyinfo->smallest_char_width = font->min_width;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
276 fonts_changed_p = 1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
277 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
278 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
279 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
280 if (dpyinfo->smallest_font_height > font->font.height)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
281 dpyinfo->smallest_font_height = font->font.height, fonts_changed_p |= 1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
282 if (dpyinfo->smallest_char_width > font->min_width)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
283 dpyinfo->smallest_char_width = font->min_width, fonts_changed_p |= 1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
284 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
285
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
286 return font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
287 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
288
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
289 static void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
290 ftxfont_close (f, font)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
291 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
292 struct font *font;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
293 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
294 ftfont_driver.close (f, font);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
295 FRAME_X_DISPLAY_INFO (f)->n_fonts--;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
296 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
297
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
298 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
299 ftxfont_prepare_face (f, face)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
300 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
301 struct face *face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
302 {
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
303 struct font *font = (struct font *) face->font_info;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
304 GC gcs[6];
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
305 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
306
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
307 face->extra = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
308
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
309 if (! font->scalable)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
310 return 0;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
311
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
312 if (ftxfont_create_gcs (f, gcs, face->foreground, face->background) < 0)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
313 /* Give up antialiasing. */
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
314 return 0;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
315
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
316 face->extra = malloc (sizeof (GC) * 7);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
317 if (! face->extra)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
318 return -1;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
319 for (i = 0; i < 6; i++)
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
320 ((GC *) face->extra)[i] = gcs[i];
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
321 ((GC *) face->extra)[i] = face->gc;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
322 return 0;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
323 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
324
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
325 static void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
326 ftxfont_done_face (f, face)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
327 FRAME_PTR f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
328 struct face *face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
329 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
330 if (face->extra)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
331 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
332 int i;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
333
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
334 BLOCK_INPUT;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
335 for (i = 0; i < 6; i++)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
336 XFreeGC (FRAME_X_DISPLAY (f), ((GC *) face->extra)[i]);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
337 UNBLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
338 free (face->extra);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
339 face->extra = NULL;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
340 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
341 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
342
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
343 static int
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
344 ftxfont_draw (s, from, to, x, y, with_background)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
345 struct glyph_string *s;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
346 int from, to, x, y, with_background;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
347 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
348 FRAME_PTR f = s->f;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
349 struct face *face = s->face;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
350 struct font *font = (struct font *) face->font_info;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
351 XPoint p[0x700];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
352 int n[7];
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
353 unsigned *code;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
354 int len = to - from;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
355 int i;
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
356 GC *gcs;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
357
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
358 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
359
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
360 BLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
361
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
362 if (with_background)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
363 ftxfont_draw_backgrond (f, font, s->gc, x, y, s->width);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
364 code = alloca (sizeof (unsigned) * len);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
365 for (i = 0; i < len; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
366 code[i] = ((XCHAR2B_BYTE1 (s->char2b + from + i) << 8)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
367 | XCHAR2B_BYTE2 (s->char2b + from + i));
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
368
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
369 gcs = face->extra;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
370 if (gcs && face->gc != s->gc)
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
371 {
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
372 /* We are drawing for cursor or for mouse highlighting, and
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
373 can't use the prepared GCs. */
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
374 XGCValues xgcv;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
375 unsigned long mask = GCForeground | GCBackground;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
376
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
377 gcs = alloca (sizeof (GC) * 7);
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
378 XGetGCValues (FRAME_X_DISPLAY (f), s->gc, mask, &xgcv);
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
379 if (ftxfont_create_gcs (f, gcs, xgcv.foreground, xgcv.background) < 0)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
380 gcs = NULL;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
381 gcs[6] = s->gc;
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
382 }
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
383
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
384 if (! gcs)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
385 {
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
386 /* We are drawing with a bitmap font which doesn't use
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
387 antialiasing. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
388 for (i = 0; i < len; i++)
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
389 x += ftxfont_draw_bitmap (f, &s->gc, font, code[i], x, y,
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
390 p, 0x700, n);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
391 if (n[0] > 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
392 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
393 s->gc, p, n[0], CoordModeOrigin);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
394 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
395 else
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
396 {
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
397 /* We are drawing with a scalable font which use
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
398 antialiasing. */
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
399 for (i = 0; i < len; i++)
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
400 x += ftxfont_draw_bitmap (f, gcs, font, code[i], x, y,
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
401 p, 0x100, n);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
402 for (i = 0; i < 7; i++)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
403 if (n[i] > 0)
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
404 XDrawPoints (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
90554
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
405 gcs[i], p + 0x100 * i, n[i], CoordModeOrigin);
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
406 if (face->gc != s->gc)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
407 for (i = 0; i < 6; i++)
d0351223b22a (ftxfont_create_gcs): New function.
Kenichi Handa <handa@m17n.org>
parents: 90427
diff changeset
408 XFreeGC (FRAME_X_DISPLAY (f), gcs[i]);
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
409 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
410
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
411 UNBLOCK_INPUT;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
412
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
413 return len;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
414 }
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
415
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
416
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
417
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
418 void
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
419 syms_of_ftxfont ()
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
420 {
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
421 DEFSYM (Qftx, "ftx");
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
422
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
423 ftxfont_driver = ftfont_driver;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
424 ftxfont_driver.type = Qftx;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
425 ftxfont_driver.list = ftxfont_list;
90560
c443c8a56b84 (ftxfont_match): New function.
Kenichi Handa <handa@m17n.org>
parents: 90554
diff changeset
426 ftxfont_driver.match = ftxfont_match;
90400
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
427 ftxfont_driver.open = ftxfont_open;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
428 ftxfont_driver.close = ftxfont_close;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
429 ftxfont_driver.prepare_face = ftxfont_prepare_face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
430 ftxfont_driver.done_face = ftxfont_done_face;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
431 ftxfont_driver.draw = ftxfont_draw;
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
432
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
433 register_font_driver (&ftxfont_driver, NULL);
80fff33f74f5 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
434 }
90427
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
435
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
436 /* arch-tag: 59bd3469-5330-413f-b29d-1aa36492abe8
ddb25860d044 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90400
diff changeset
437 (do not change this comment) */