annotate src/fontset.c @ 26921:090205cad78a

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Thu, 16 Dec 1999 15:05:06 +0000
parents 7cc081b4e084
children b888c69e8bf0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 /* Fontset handler.
18341
33e78cc7f058 Change copyright notices.
Richard M. Stallman <rms@gnu.org>
parents: 18192
diff changeset
2 Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
33e78cc7f058 Change copyright notices.
Richard M. Stallman <rms@gnu.org>
parents: 18192
diff changeset
3 Licensed to the Free Software Foundation.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
4
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
5 This file is part of GNU Emacs.
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
6
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
7 GNU Emacs is free software; you can redistribute it and/or modify
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
8 it under the terms of the GNU General Public License as published by
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
10 any later version.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
15 GNU General Public License for more details.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16
17071
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
17 You should have received a copy of the GNU General Public License
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
18 along with GNU Emacs; see the file COPYING. If not, write to
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
70194012fb3a Fix FSF address in comment.
Karl Heuer <kwzh@gnu.org>
parents: 17052
diff changeset
20 Boston, MA 02111-1307, USA. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
21
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
22 #include <config.h>
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23 #if HAVE_ALLOCA_H
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24 #include <alloca.h>
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
25 #endif /* HAVE_ALLOCA_H */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26 #include "lisp.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27 #include "charset.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 #include "ccl.h"
23517
73f09e7bc96e Include frame.h before fontset.h.
Kenichi Handa <handa@m17n.org>
parents: 22719
diff changeset
29 #include "frame.h"
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 #include "fontset.h"
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 Lisp_Object Vglobal_fontset_alist;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 Lisp_Object Vfont_encoding_alist;
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
34 Lisp_Object Vuse_default_ascent;
19282
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
35 Lisp_Object Vignore_relative_composition;
19450
895dc2520755 (Valternate_fontname_alist): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19282
diff changeset
36 Lisp_Object Valternate_fontname_alist;
17730
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
37 Lisp_Object Vfontset_alias_alist;
17331
f91b4d582897 (Vhighlight_wrong_size_font, Vclip_large_size_font):
Kenichi Handa <handa@m17n.org>
parents: 17193
diff changeset
38 Lisp_Object Vhighlight_wrong_size_font;
f91b4d582897 (Vhighlight_wrong_size_font, Vclip_large_size_font):
Kenichi Handa <handa@m17n.org>
parents: 17193
diff changeset
39 Lisp_Object Vclip_large_size_font;
26858
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
40 Lisp_Object Vvertical_centering_font_regexp;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41
18346
c46e9f750033 (font_idx_temp): New temprary variable used in FS_LOAD_FONT.
Kenichi Handa <handa@m17n.org>
parents: 18341
diff changeset
42 /* Used as a temporary in macro FS_LOAD_FONT. */
c46e9f750033 (font_idx_temp): New temprary variable used in FS_LOAD_FONT.
Kenichi Handa <handa@m17n.org>
parents: 18341
diff changeset
43 int font_idx_temp;
c46e9f750033 (font_idx_temp): New temprary variable used in FS_LOAD_FONT.
Kenichi Handa <handa@m17n.org>
parents: 18341
diff changeset
44
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 /* We had better have our own strcasecmp function because some system
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 doesn't have it. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 static char my_strcasetbl[256];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 /* Compare two strings S0 and S1 while ignoring differences in case.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 Return 1 if they differ, else return 0. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 static int
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 my_strcasecmp (s0, s1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 unsigned char *s0, *s1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 while (*s0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 if (my_strcasetbl[*s0++] != my_strcasetbl[*s1++]) return 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 return (int) *s1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60 /* The following six are window system dependent functions. See
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 the comments in src/fontset.h for more detail. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 /* Return a pointer to struct font_info of font FONT_IDX of frame F. */
20315
931b4ddf7966 Protoize functions declarations.
Andreas Schwab <schwab@suse.de>
parents: 19450
diff changeset
64 struct font_info *(*get_font_info_func) P_ ((FRAME_PTR f, int font_idx));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 /* Return a list of font names which matches PATTERN. See the document of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 `x-list-fonts' for more detail. */
23517
73f09e7bc96e Include frame.h before fontset.h.
Kenichi Handa <handa@m17n.org>
parents: 22719
diff changeset
68 Lisp_Object (*list_fonts_func) P_ ((struct frame *f,
73f09e7bc96e Include frame.h before fontset.h.
Kenichi Handa <handa@m17n.org>
parents: 22719
diff changeset
69 Lisp_Object pattern,
73f09e7bc96e Include frame.h before fontset.h.
Kenichi Handa <handa@m17n.org>
parents: 22719
diff changeset
70 int size,
73f09e7bc96e Include frame.h before fontset.h.
Kenichi Handa <handa@m17n.org>
parents: 22719
diff changeset
71 int maxnames));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 /* Load a font named NAME for frame F and return a pointer to the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 information of the loaded font. If loading is failed, return 0. */
20315
931b4ddf7966 Protoize functions declarations.
Andreas Schwab <schwab@suse.de>
parents: 19450
diff changeset
75 struct font_info *(*load_font_func) P_ ((FRAME_PTR f, char *name, int));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 /* Return a pointer to struct font_info of a font named NAME for frame F. */
20315
931b4ddf7966 Protoize functions declarations.
Andreas Schwab <schwab@suse.de>
parents: 19450
diff changeset
78 struct font_info *(*query_font_func) P_ ((FRAME_PTR f, char *name));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80 /* Additional function for setting fontset or changing fontset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 contents of frame F. */
20315
931b4ddf7966 Protoize functions declarations.
Andreas Schwab <schwab@suse.de>
parents: 19450
diff changeset
82 void (*set_frame_fontset_func) P_ ((FRAME_PTR f, Lisp_Object arg,
931b4ddf7966 Protoize functions declarations.
Andreas Schwab <schwab@suse.de>
parents: 19450
diff changeset
83 Lisp_Object oldval));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84
21553
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
85 /* To find a CCL program, fs_load_font calls this function.
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
86 The argument is a pointer to the struct font_info.
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
87 This function set the memer `encoder' of the structure. */
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
88 void (*find_ccl_program_func) P_ ((struct font_info *));
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
89
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90 /* Check if any window system is used now. */
20315
931b4ddf7966 Protoize functions declarations.
Andreas Schwab <schwab@suse.de>
parents: 19450
diff changeset
91 void (*check_window_system_func) P_ ((void));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 struct fontset_data *
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 alloc_fontset_data ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 struct fontset_data *fontset_data
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 = (struct fontset_data *) xmalloc (sizeof (struct fontset_data));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99 bzero (fontset_data, sizeof (struct fontset_data));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 return fontset_data;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 void
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 free_fontset_data (fontset_data)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106 struct fontset_data *fontset_data;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 {
20346
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
108 if (fontset_data->fontset_table)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109 {
20346
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
110 int i;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111
20346
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
112 for (i = 0; i < fontset_data->n_fontsets; i++)
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
113 {
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
114 int j;
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
115
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
116 xfree (fontset_data->fontset_table[i]->name);
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
117 for (j = 0; j <= MAX_CHARSET; j++)
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
118 if (fontset_data->fontset_table[i]->fontname[j])
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
119 xfree (fontset_data->fontset_table[i]->fontname[j]);
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
120 xfree (fontset_data->fontset_table[i]);
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
121 }
97e5f74f6bc1 (free_fontset_data): Don't free null pointer.
Richard M. Stallman <rms@gnu.org>
parents: 20315
diff changeset
122 xfree (fontset_data->fontset_table);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 xfree (fontset_data);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 /* Load a font named FONTNAME for displaying CHARSET on frame F.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 All fonts for frame F is stored in a table pointed by FONT_TABLE.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 Return a pointer to the struct font_info of the loaded font.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 If loading fails, return 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 If FONTNAME is NULL, the name is taken from the information of FONTSET.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 If FONTSET is given, try to load a font whose size matches that of
18346
c46e9f750033 (font_idx_temp): New temprary variable used in FS_LOAD_FONT.
Kenichi Handa <handa@m17n.org>
parents: 18341
diff changeset
134 FONTSET, and, the font index is stored in the table for FONTSET.
c46e9f750033 (font_idx_temp): New temprary variable used in FS_LOAD_FONT.
Kenichi Handa <handa@m17n.org>
parents: 18341
diff changeset
135
c46e9f750033 (font_idx_temp): New temprary variable used in FS_LOAD_FONT.
Kenichi Handa <handa@m17n.org>
parents: 18341
diff changeset
136 If you give FONTSET argument, don't call this function directry,
c46e9f750033 (font_idx_temp): New temprary variable used in FS_LOAD_FONT.
Kenichi Handa <handa@m17n.org>
parents: 18341
diff changeset
137 instead call macro FS_LOAD_FONT with the same argument. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 struct font_info *
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 fs_load_font (f, font_table, charset, fontname, fontset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 FRAME_PTR f;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 struct font_info *font_table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 int charset, fontset;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 char *fontname;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 Lisp_Object font_list;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 Lisp_Object list, elt;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 int font_idx;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 int size = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 struct fontset_info *fontsetp = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 struct font_info *fontp;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 if (fontset >= 0 && fontset < FRAME_FONTSET_DATA (f)->n_fontsets)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 fontsetp = FRAME_FONTSET_DATA (f)->fontset_table[fontset];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 font_idx = fontsetp->font_indexes[charset];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 if (font_idx >= 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 /* We have already loaded a font. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 return font_table + font_idx;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 else if (font_idx == FONT_NOT_FOUND)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 /* We have already tried loading a font and failed. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 return 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 if (!fontname)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 fontname = fontsetp->fontname[charset];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 if (!fontname)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 /* No way to get fontname. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 return 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170
17999
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
171 /* If CHARSET is not ASCII and FONTSET is specified, we must load a
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
172 font of appropriate size to be used with other fonts in this
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
173 fontset. */
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
174 if (charset != CHARSET_ASCII && fontsetp)
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
175 {
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
176 /* If we have not yet loaded ASCII font of FONTSET, we must load
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
177 it now to decided the size and height of this fontset. */
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
178 if (fontsetp->size == 0)
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
179 {
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
180 fontp = fs_load_font (f, font_table, CHARSET_ASCII, 0, fontset);
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
181 if (!fontp)
22719
d6f6ac5a5df3 (fs_load_font): Typo in comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 21553
diff changeset
182 /* Any fontset should contain available ASCII. */
17999
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
183 return 0;
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
184 }
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
185 /* Now we have surely decided the size of this fontset. */
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
186 size = fontsetp->size * CHARSET_WIDTH (charset);
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
187 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189 fontp = (*load_font_func) (f, fontname, size);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 if (!fontp)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193 if (fontsetp)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194 fontsetp->font_indexes[charset] = FONT_NOT_FOUND;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 return 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
197
26858
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
198 /* Fill in fields (charset, vertical_centering, encoding, and
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
199 font_encoder) which are not set by (*load_font_func). */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200 fontp->charset = charset;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201
26858
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
202 fontp->vertical_centering
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
203 = (STRINGP (Vvertical_centering_font_regexp)
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
204 && (fast_c_string_match_ignore_case
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
205 (Vvertical_centering_font_regexp, fontp->full_name) >= 0));
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
206
17999
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
207 if (fontp->encoding[1] != FONT_ENCODING_NOT_DECIDED)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
209 /* The font itself tells which code points to be used. Use this
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210 encoding for all other charsets. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
213 fontp->encoding[0] = fontp->encoding[1];
17190
6637001cdb4b Adjusted for the change of MAX_CHARSET.
Kenichi Handa <handa@m17n.org>
parents: 17112
diff changeset
214 for (i = MIN_CHARSET_OFFICIAL_DIMENSION1; i <= MAX_CHARSET; i++)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215 fontp->encoding[i] = fontp->encoding[1];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
219 /* The font itself doesn't tell which code points to be used. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
220 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222 /* At first, set 1 (means 0xA0..0xFF) as the default. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
223 fontp->encoding[0] = 1;
17190
6637001cdb4b Adjusted for the change of MAX_CHARSET.
Kenichi Handa <handa@m17n.org>
parents: 17112
diff changeset
224 for (i = MIN_CHARSET_OFFICIAL_DIMENSION1; i <= MAX_CHARSET; i++)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
225 fontp->encoding[i] = 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
226 /* Then override them by a specification in Vfont_encoding_alist. */
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
227 for (list = Vfont_encoding_alist; CONSP (list); list = XCDR (list))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
228 {
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
229 elt = XCAR (list);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
230 if (CONSP (elt)
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
231 && STRINGP (XCAR (elt)) && CONSP (XCDR (elt))
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
232 && (fast_c_string_match_ignore_case (XCAR (elt), fontname)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
233 >= 0))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
234 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
235 Lisp_Object tmp;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
236
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
237 for (tmp = XCDR (elt); CONSP (tmp); tmp = XCDR (tmp))
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
238 if (CONSP (XCAR (tmp))
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
239 && ((i = get_charset_id (XCAR (XCAR (tmp))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
240 >= 0)
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
241 && INTEGERP (XCDR (XCAR (tmp)))
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
242 && XFASTINT (XCDR (XCAR (tmp))) < 4)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
243 fontp->encoding[i]
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
244 = XFASTINT (XCDR (XCAR (tmp)));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
245 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
246 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
247 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
248
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
249 fontp->font_encoder = (struct ccl_program *) 0;
21553
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
250
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
251 if (find_ccl_program_func)
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
252 (*find_ccl_program_func) (fontp);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
253
17999
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
254 /* If FONTSET is specified, setup various fields of it. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
255 if (fontsetp)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
256 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
257 fontsetp->font_indexes[charset] = fontp->font_idx;
17999
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
258 if (charset == CHARSET_ASCII)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
259 {
17999
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
260 /* Decide or change the size and height of this fontset. */
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
261 if (fontsetp->size == 0)
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
262 {
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
263 fontsetp->size = fontp->size;
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
264 fontsetp->height = fontp->height;
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
265 }
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
266 else if (fontsetp->size != fontp->size
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
267 || fontsetp->height != fontp->height)
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
268 {
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
269 /* When loading ASCII font of the different size from
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
270 the size of FONTSET, we have to update the size of
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
271 FONTSET. Since changing the size of FONTSET may make
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
272 some fonts already loaded inappropriate to be used in
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
273 FONTSET, we must delete the record of such fonts. In
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
274 that case, we also have to calculate the height of
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
275 FONTSET from the remaining fonts. */
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
276 int i;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277
17999
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
278 fontsetp->size = fontp->size;
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
279 fontsetp->height = fontp->height;
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
280 for (i = CHARSET_ASCII + 1; i <= MAX_CHARSET; i++)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 {
17999
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
282 font_idx = fontsetp->font_indexes[i];
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
283 if (font_idx >= 0)
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
284 {
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
285 struct font_info *fontp2 = font_table + font_idx;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286
17999
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
287 if (fontp2->size != fontp->size * CHARSET_WIDTH (i))
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
288 fontsetp->font_indexes[i] = FONT_NOT_OPENED;
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
289 /* The following code should be disabled until
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
290 Emacs supports variable height lines. */
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
291 #if 0
17999
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
292 else if (fontsetp->height < fontp->height)
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
293 fontsetp->height = fontp->height;
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
294 #endif
17999
5e325c8057c8 (fs_load_font): Before using a fontset, be sure to
Kenichi Handa <handa@m17n.org>
parents: 17882
diff changeset
295 }
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
299 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
300
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301 return fontp;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
302 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
303
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304 /* Return ID of the fontset named NAME on frame F. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
305
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 int
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307 fs_query_fontset (f, name)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
308 FRAME_PTR f;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309 char *name;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311 struct fontset_data *fontset_data = FRAME_FONTSET_DATA (f);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
312 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
313
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314 for (i = 0; i < fontset_data->n_fontsets; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
315 if (!my_strcasecmp(name, fontset_data->fontset_table[i]->name))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
316 return i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
317 return -1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
319
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
320 /* Register a fontset specified by FONTSET_INFO for frame FRAME.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321 Return the fontset ID if successfully registered, else return -1.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
322 FONTSET_INFO is a cons of name of the fontset and FONTLIST, where
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323 FONTLIST is an alist of charsets vs fontnames. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325 int
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
326 fs_register_fontset (f, fontset_info)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
327 FRAME_PTR f;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328 Lisp_Object fontset_info;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
330 struct fontset_data *fontset_data = FRAME_FONTSET_DATA (f);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
331 Lisp_Object name, fontlist;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
332 int fontset;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
333 struct fontset_info *fontsetp;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
334 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
335
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
336 if (!CONSP (fontset_info)
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
337 || !STRINGP (XCAR (fontset_info))
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
338 || !CONSP (XCDR (fontset_info)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 /* Invalid data in FONTSET_INFO. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340 return -1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
342 name = XCAR (fontset_info);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 if ((fontset = fs_query_fontset (f, XSTRING (name)->data)) >= 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 /* This fontset already exists on frame F. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 return fontset;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347 fontsetp = (struct fontset_info *) xmalloc (sizeof (struct fontset_info));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
348
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349 fontsetp->name = (char *) xmalloc (XSTRING (name)->size + 1);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 bcopy(XSTRING (name)->data, fontsetp->name, XSTRING (name)->size + 1);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 fontsetp->size = fontsetp->height = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353
17190
6637001cdb4b Adjusted for the change of MAX_CHARSET.
Kenichi Handa <handa@m17n.org>
parents: 17112
diff changeset
354 for (i = 0; i <= MAX_CHARSET; i++)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 fontsetp->fontname[i] = (char *) 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357 fontsetp->font_indexes[i] = FONT_NOT_OPENED;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
360 for (fontlist = XCDR (fontset_info); CONSP (fontlist);
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
361 fontlist = XCDR (fontlist))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363 Lisp_Object tem = Fcar (fontlist);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 int charset;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
365
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366 if (CONSP (tem)
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
367 && (charset = get_charset_id (XCAR (tem))) >= 0
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
368 && STRINGP (XCDR (tem)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
369 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 fontsetp->fontname[charset]
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
371 = (char *) xmalloc (XSTRING (XCDR (tem))->size + 1);
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
372 bcopy (XSTRING (XCDR (tem))->data,
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
373 fontsetp->fontname[charset],
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
374 XSTRING (XCDR (tem))->size + 1);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377 /* Broken or invalid data structure. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
378 return -1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
379 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
380
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
381 /* Do we need to create the table? */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382 if (fontset_data->fontset_table_size == 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
383 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
384 fontset_data->fontset_table_size = 8;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
385 fontset_data->fontset_table
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
386 = (struct fontset_info **) xmalloc (fontset_data->fontset_table_size
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
387 * sizeof (struct fontset_info *));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389 /* Do we need to grow the table? */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390 else if (fontset_data->n_fontsets >= fontset_data->fontset_table_size)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392 fontset_data->fontset_table_size += 8;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
393 fontset_data->fontset_table
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 = (struct fontset_info **) xrealloc (fontset_data->fontset_table,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395 fontset_data->fontset_table_size
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396 * sizeof (struct fontset_info *));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
397 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
398 fontset = fontset_data->n_fontsets++;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
399 fontset_data->fontset_table[fontset] = fontsetp;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
400
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
401 return fontset;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
402 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
403
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
404 /* Cache data used by fontset_pattern_regexp. The car part is a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
405 pattern string containing at least one wild card, the cdr part is
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
406 the corresponding regular expression. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
407 static Lisp_Object Vcached_fontset_data;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
408
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
409 #define CACHED_FONTSET_NAME (XSTRING (XCAR (Vcached_fontset_data))->data)
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
410 #define CACHED_FONTSET_REGEX (XCDR (Vcached_fontset_data))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
411
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
412 /* If fontset name PATTERN contains any wild card, return regular
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
413 expression corresponding to PATTERN. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
414
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
415 Lisp_Object
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
416 fontset_pattern_regexp (pattern)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
417 Lisp_Object pattern;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
418 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
419 if (!index (XSTRING (pattern)->data, '*')
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
420 && !index (XSTRING (pattern)->data, '?'))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
421 /* PATTERN does not contain any wild cards. */
17730
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
422 return Qnil;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
423
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
424 if (!CONSP (Vcached_fontset_data)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
425 || strcmp (XSTRING (pattern)->data, CACHED_FONTSET_NAME))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
426 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
427 /* We must at first update the cached data. */
17730
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
428 char *regex = (char *) alloca (XSTRING (pattern)->size * 2);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
429 char *p0, *p1 = regex;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
430
17730
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
431 /* Convert "*" to ".*", "?" to ".". */
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
432 *p1++ = '^';
17827
95010205f916 (fontset_pattern_regexp): Cast to (char *) before
Kenichi Handa <handa@m17n.org>
parents: 17730
diff changeset
433 for (p0 = (char *) XSTRING (pattern)->data; *p0; p0++)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
434 {
17730
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
435 if (*p0 == '*')
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
436 {
17730
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
437 *p1++ = '.';
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
438 *p1++ = '*';
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
439 }
17730
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
440 else if (*p0 == '?')
21127
577865651099 (fontset_pattern_regexp): `==' was used instead of `='.
Richard M. Stallman <rms@gnu.org>
parents: 20346
diff changeset
441 *p1++ = '.';
17730
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
442 else
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
443 *p1++ = *p0;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
444 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
445 *p1++ = '$';
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
446 *p1++ = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
447
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
448 Vcached_fontset_data = Fcons (build_string (XSTRING (pattern)->data),
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
449 build_string (regex));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
450 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
451
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
452 return CACHED_FONTSET_REGEX;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
453 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
454
21553
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
455 DEFUN ("query-fontset", Fquery_fontset, Squery_fontset, 1, 2, 0,
24585
6810d6fb639f (Fquery_fontset): Don't check for fontset aliases here.
Richard M. Stallman <rms@gnu.org>
parents: 23517
diff changeset
456 "Return the name of an existing fontset which matches PATTERN.\n\
6810d6fb639f (Fquery_fontset): Don't check for fontset aliases here.
Richard M. Stallman <rms@gnu.org>
parents: 23517
diff changeset
457 The value is nil if there is no matching fontset.\n\
6810d6fb639f (Fquery_fontset): Don't check for fontset aliases here.
Richard M. Stallman <rms@gnu.org>
parents: 23517
diff changeset
458 PATTERN can contain `*' or `?' as a wildcard\n\
6810d6fb639f (Fquery_fontset): Don't check for fontset aliases here.
Richard M. Stallman <rms@gnu.org>
parents: 23517
diff changeset
459 just as X font name matching algorithm allows.\n\
6810d6fb639f (Fquery_fontset): Don't check for fontset aliases here.
Richard M. Stallman <rms@gnu.org>
parents: 23517
diff changeset
460 If REGEXPP is non-nil, PATTERN is a regular expression.")
21553
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
461 (pattern, regexpp)
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
462 Lisp_Object pattern, regexpp;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
463 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
464 Lisp_Object regexp, tem;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
465
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
466 (*check_window_system_func) ();
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
467
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
468 CHECK_STRING (pattern, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
469
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
470 if (XSTRING (pattern)->size == 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
471 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
472
24608
a16dadaa425d (Fquery_fontset): Check for fontset aliases here.
Kenichi Handa <handa@m17n.org>
parents: 24585
diff changeset
473 tem = Frassoc (pattern, Vfontset_alias_alist);
a16dadaa425d (Fquery_fontset): Check for fontset aliases here.
Kenichi Handa <handa@m17n.org>
parents: 24585
diff changeset
474 if (!NILP (tem))
a16dadaa425d (Fquery_fontset): Check for fontset aliases here.
Kenichi Handa <handa@m17n.org>
parents: 24585
diff changeset
475 return Fcar (tem);
a16dadaa425d (Fquery_fontset): Check for fontset aliases here.
Kenichi Handa <handa@m17n.org>
parents: 24585
diff changeset
476
21553
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
477 if (NILP (regexpp))
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
478 regexp = fontset_pattern_regexp (pattern);
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
479 else
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
480 regexp = pattern;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
481
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
482 for (tem = Vglobal_fontset_alist; CONSP (tem); tem = XCDR (tem))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
483 {
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
484 Lisp_Object fontset_name = XCAR (XCAR (tem));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
485 if (!NILP (regexp))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
486 {
18192
a3f50c636d81 (list_fontsets, fs_load_font): fast_c_string_match_ignore_case renamed.
Richard M. Stallman <rms@gnu.org>
parents: 17999
diff changeset
487 if (fast_c_string_match_ignore_case (regexp,
a3f50c636d81 (list_fontsets, fs_load_font): fast_c_string_match_ignore_case renamed.
Richard M. Stallman <rms@gnu.org>
parents: 17999
diff changeset
488 XSTRING (fontset_name)->data)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
489 >= 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
490 return fontset_name;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
491 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
492 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
493 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
494 if (!my_strcasecmp (XSTRING (pattern)->data,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
495 XSTRING (fontset_name)->data))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
496 return fontset_name;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
497 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
498 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
499
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
500 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
501 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
502
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
503 /* Return a list of names of available fontsets matching PATTERN on
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
504 frame F. If SIZE is not 0, it is the size (maximum bound width) of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
505 fontsets to be listed. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
506
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
507 Lisp_Object
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
508 list_fontsets (f, pattern, size)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
509 FRAME_PTR f;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
510 Lisp_Object pattern;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
511 int size;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
512 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
513 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
514 Lisp_Object regexp, val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
515
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
516 regexp = fontset_pattern_regexp (pattern);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
517
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
518 val = Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
519 for (i = 0; i < FRAME_FONTSET_DATA (f)->n_fontsets; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
520 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
521 struct fontset_info *fontsetp = FRAME_FONTSET_DATA (f)->fontset_table[i];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 int name_matched = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
523 int size_matched = 0;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
524
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
525 if (!NILP (regexp))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
526 {
18192
a3f50c636d81 (list_fontsets, fs_load_font): fast_c_string_match_ignore_case renamed.
Richard M. Stallman <rms@gnu.org>
parents: 17999
diff changeset
527 if (fast_c_string_match_ignore_case (regexp, fontsetp->name) >= 0)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
528 name_matched = 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
529 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
530 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
531 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
532 if (!my_strcasecmp (XSTRING (pattern)->data, fontsetp->name))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
533 name_matched = 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
534 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
535
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
536 if (name_matched)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
537 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
538 if (!size || fontsetp->size == size)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
539 size_matched = 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
540 else if (fontsetp->size == 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
541 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
542 /* No font of this fontset has loaded yet. Try loading
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
543 one with SIZE. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
544 int j;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
545
17190
6637001cdb4b Adjusted for the change of MAX_CHARSET.
Kenichi Handa <handa@m17n.org>
parents: 17112
diff changeset
546 for (j = 0; j <= MAX_CHARSET; j++)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
547 if (fontsetp->fontname[j])
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
548 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
549 if ((*load_font_func) (f, fontsetp->fontname[j], size))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
550 size_matched = 1;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
551 break;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
552 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
553 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
554
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
555 if (size_matched)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
556 val = Fcons (build_string (fontsetp->name), val);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
557 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
558 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
559
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
560 return val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
561 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
562
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
563 DEFUN ("new-fontset", Fnew_fontset, Snew_fontset, 2, 2, 0,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
564 "Create a new fontset NAME which contains fonts in FONTLIST.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
565 FONTLIST is an alist of charsets vs corresponding font names.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
566 (name, fontlist)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
567 Lisp_Object name, fontlist;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
568 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
569 Lisp_Object fullname, fontset_info;
24608
a16dadaa425d (Fquery_fontset): Check for fontset aliases here.
Kenichi Handa <handa@m17n.org>
parents: 24585
diff changeset
570 Lisp_Object tail;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
571
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
572 (*check_window_system_func) ();
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
573
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
574 CHECK_STRING (name, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
575 CHECK_LIST (fontlist, 1);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
576
21553
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
577 fullname = Fquery_fontset (name, Qnil);
24608
a16dadaa425d (Fquery_fontset): Check for fontset aliases here.
Kenichi Handa <handa@m17n.org>
parents: 24585
diff changeset
578 if (!NILP (fullname))
24585
6810d6fb639f (Fquery_fontset): Don't check for fontset aliases here.
Richard M. Stallman <rms@gnu.org>
parents: 23517
diff changeset
579 error ("Fontset `%s' matches the existing fontset `%s'",
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
580 XSTRING (name)->data, XSTRING (fullname)->data);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
581
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
582 /* Check the validity of FONTLIST. */
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
583 for (tail = fontlist; CONSP (tail); tail = XCDR (tail))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
584 {
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
585 Lisp_Object tem = XCAR (tail);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
586 int charset;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
587
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
588 if (!CONSP (tem)
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
589 || (charset = get_charset_id (XCAR (tem))) < 0
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
590 || !STRINGP (XCDR (tem)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
591 error ("Elements of fontlist must be a cons of charset and font name");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
592 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
593
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
594 fontset_info = Fcons (name, fontlist);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
595 Vglobal_fontset_alist = Fcons (fontset_info, Vglobal_fontset_alist);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
596
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
597 /* Register this fontset for all existing frames. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
598 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
599 Lisp_Object framelist, frame;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
600
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
601 FOR_EACH_FRAME (framelist, frame)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
602 if (!FRAME_TERMCAP_P (XFRAME (frame)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
603 fs_register_fontset (XFRAME (frame), fontset_info);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
604 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
605
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
606 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
607 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
608
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
609 extern Lisp_Object Qfont;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
610 Lisp_Object Qfontset;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
611
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
612 DEFUN ("set-fontset-font", Fset_fontset_font, Sset_fontset_font, 3, 4, 0,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
613 "Set FONTNAME for a font of CHARSET in fontset NAME on frame FRAME.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
614 If FRAME is omitted or nil, all frames are affected.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
615 (name, charset_symbol, fontname, frame)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
616 Lisp_Object name, charset_symbol, fontname, frame;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
617 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
618 int charset;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
619 Lisp_Object fullname, fontlist;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
620
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
621 (*check_window_system_func) ();
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
622
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
623 CHECK_STRING (name, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
624 CHECK_SYMBOL (charset_symbol, 1);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
625 CHECK_STRING (fontname, 2);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
626 if (!NILP (frame))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
627 CHECK_LIVE_FRAME (frame, 3);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
628
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
629 if ((charset = get_charset_id (charset_symbol)) < 0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
630 error ("Invalid charset: %s", XSYMBOL (charset_symbol)->name->data);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
631
21553
2d7afcd11b72 (find_ccl_program_func): New variable.
Kenichi Handa <handa@m17n.org>
parents: 21514
diff changeset
632 fullname = Fquery_fontset (name, Qnil);
24611
a1e836728879 (Fset_fontset_font): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 24608
diff changeset
633 if (NILP (fullname))
24585
6810d6fb639f (Fquery_fontset): Don't check for fontset aliases here.
Richard M. Stallman <rms@gnu.org>
parents: 23517
diff changeset
634 error ("Fontset `%s' does not exist", XSTRING (name)->data);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
635
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
636 /* If FRAME is not specified, we must, at first, update contents of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
637 `global-fontset-alist' for a frame created in the future. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
638 if (NILP (frame))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
639 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
640 Lisp_Object fontset_info = Fassoc (fullname, Vglobal_fontset_alist);
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
641 Lisp_Object tem = Fassq (charset_symbol, XCDR (fontset_info));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
642
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
643 if (NILP (tem))
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
644 XCDR (fontset_info)
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
645 = Fcons (Fcons (charset_symbol, fontname),
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
646 XCDR (fontset_info));
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
647 else
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
648 XCDR (tem) = fontname;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
649 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
650
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
651 /* Then, update information in the specified frame or all existing
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
652 frames. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
653 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
654 Lisp_Object framelist, tem;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
655
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
656 FOR_EACH_FRAME (framelist, tem)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
657 if (!FRAME_TERMCAP_P (XFRAME (tem))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
658 && (NILP (frame) || EQ (frame, tem)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
659 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
660 FRAME_PTR f = XFRAME (tem);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
661 int fontset = fs_query_fontset (f, XSTRING (fullname)->data);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
662 struct fontset_info *fontsetp
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
663 = FRAME_FONTSET_DATA (f)->fontset_table[fontset];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
664
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
665 if (fontsetp->fontname[charset])
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
666 xfree (fontsetp->fontname[charset]);
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
667 fontsetp->fontname[charset]
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
668 = (char *) xmalloc (XSTRING (fontname)->size + 1);
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
669 bcopy (XSTRING (fontname)->data, fontsetp->fontname[charset],
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
670 XSTRING (fontname)->size + 1);
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
671 fontsetp->font_indexes[charset] = FONT_NOT_OPENED;
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
672
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
673 if (charset == CHARSET_ASCII)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
674 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
675 Lisp_Object font_param = Fassq (Qfont, Fframe_parameters (tem));
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
676
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
677 if (set_frame_fontset_func
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
678 && !NILP (font_param)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
679 && !strcmp (XSTRING (fullname)->data,
26164
d39ec0a27081 more XCAR/XCDR/XFLOAT_DATA uses, to help isolete lisp engine
Ken Raeburn <raeburn@raeburn.org>
parents: 25668
diff changeset
680 XSTRING (XCDR (font_param))->data))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
681 /* This fontset is the default fontset on frame TEM.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
682 We may have to resize this frame because of new
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
683 ASCII font. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
684 (*set_frame_fontset_func) (f, fullname, Qnil);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
685 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
686 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
687 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
688
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
689 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
690 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
691
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
692 DEFUN ("font-info", Ffont_info, Sfont_info, 1, 2, 0,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693 "Return information about a font named NAME on frame FRAME.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
694 If FRAME is omitted or nil, use the selected frame.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
695 The returned value is a vector of OPENED-NAME, FULL-NAME, CHARSET, SIZE,\n\
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
696 HEIGHT, BASELINE-OFFSET, RELATIVE-COMPOSE, and DEFAULT-ASCENT,\n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
697 where\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
698 OPENED-NAME is the name used for opening the font,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
699 FULL-NAME is the full name of the font,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
700 CHARSET is the charset displayed by the font,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
701 SIZE is the minimum bound width of the font,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
702 HEIGHT is the height of the font,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
703 BASELINE-OFFSET is the upward offset pixels from ASCII baseline,\n\
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
704 RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling\n\
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
705 how to compose characters.\n\
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
706 If the named font is not yet loaded, return nil.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
707 (name, frame)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
708 Lisp_Object name, frame;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
709 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
710 FRAME_PTR f;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
711 struct font_info *fontp;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
712 Lisp_Object info;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
713
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
714 (*check_window_system_func) ();
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
715
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
716 CHECK_STRING (name, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
717 if (NILP (frame))
25668
99290b59352d (Ffont_info): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents: 24611
diff changeset
718 frame = selected_frame;
99290b59352d (Ffont_info): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents: 24611
diff changeset
719 CHECK_LIVE_FRAME (frame, 1);
99290b59352d (Ffont_info): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents: 24611
diff changeset
720 f = XFRAME (frame);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
721
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
722 if (!query_font_func)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
723 error ("Font query function is not supported");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
724
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
725 fontp = (*query_font_func) (f, XSTRING (name)->data);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
726 if (!fontp)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
727 return Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
728
18694
f54bacc800e5 (Ffont_info): Make vector of correct size.
Kenichi Handa <handa@m17n.org>
parents: 18346
diff changeset
729 info = Fmake_vector (make_number (8), Qnil);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
730
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
731 XVECTOR (info)->contents[0] = build_string (fontp->name);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
732 XVECTOR (info)->contents[1] = build_string (fontp->full_name);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
733 XVECTOR (info)->contents[2] = CHARSET_SYMBOL (fontp->charset);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
734 XVECTOR (info)->contents[3] = make_number (fontp->size);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
735 XVECTOR (info)->contents[4] = make_number (fontp->height);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
736 XVECTOR (info)->contents[5] = make_number (fontp->baseline_offset);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
737 XVECTOR (info)->contents[6] = make_number (fontp->relative_compose);
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
738 XVECTOR (info)->contents[7] = make_number (fontp->default_ascent);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
739
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
740 return info;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
741 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
742
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
743 DEFUN ("fontset-info", Ffontset_info, Sfontset_info, 1, 2, 0,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
744 "Return information about a fontset named NAME on frame FRAME.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
745 If FRAME is omitted or nil, use the selected frame.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
746 The returned value is a vector of SIZE, HEIGHT, and FONT-LIST,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
747 where\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
748 SIZE is the minimum bound width of ASCII font of the fontset,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
749 HEIGHT is the height of the tallest font in the fontset, and\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
750 FONT-LIST is an alist of the format:\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
751 (CHARSET REQUESTED-FONT-NAME LOADED-FONT-NAME).\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
752 LOADED-FONT-NAME t means the font is not yet loaded, nil means the\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
753 loading failed.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
754 (name, frame)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
755 Lisp_Object name, frame;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
756 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
757 FRAME_PTR f;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
758 int fontset;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
759 struct fontset_info *fontsetp;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
760 Lisp_Object info, val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
761 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
762
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
763 (*check_window_system_func) ();
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
764
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
765 CHECK_STRING(name, 0);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
766 if (NILP (frame))
25668
99290b59352d (Ffont_info): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents: 24611
diff changeset
767 frame = selected_frame;
99290b59352d (Ffont_info): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents: 24611
diff changeset
768 CHECK_LIVE_FRAME (frame, 1);
99290b59352d (Ffont_info): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents: 24611
diff changeset
769 f = XFRAME (frame);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
770
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
771 fontset = fs_query_fontset (f, XSTRING (name)->data);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
772 if (fontset < 0)
24585
6810d6fb639f (Fquery_fontset): Don't check for fontset aliases here.
Richard M. Stallman <rms@gnu.org>
parents: 23517
diff changeset
773 error ("Fontset `%s' does not exist", XSTRING (name)->data);
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
774
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
775 info = Fmake_vector (make_number (3), Qnil);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
776
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
777 fontsetp = FRAME_FONTSET_DATA (f)->fontset_table[fontset];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
778
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
779 XVECTOR (info)->contents[0] = make_number (fontsetp->size);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
780 XVECTOR (info)->contents[1] = make_number (fontsetp->height);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
781 val = Qnil;
17190
6637001cdb4b Adjusted for the change of MAX_CHARSET.
Kenichi Handa <handa@m17n.org>
parents: 17112
diff changeset
782 for (i = 0; i <= MAX_CHARSET; i++)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
783 if (fontsetp->fontname[i])
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
784 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
785 int font_idx = fontsetp->font_indexes[i];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
786 Lisp_Object loaded;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
787
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
788 if (font_idx == FONT_NOT_OPENED)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
789 loaded = Qt;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
790 else if (font_idx == FONT_NOT_FOUND)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
791 loaded = Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
792 else
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
793 loaded
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
794 = build_string ((*get_font_info_func) (f, font_idx)->full_name);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
795 val = Fcons (Fcons (CHARSET_SYMBOL (i),
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
796 Fcons (build_string (fontsetp->fontname[i]),
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
797 Fcons (loaded, Qnil))),
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
798 val);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
799 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
800 XVECTOR (info)->contents[2] = val;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
801 return info;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
802 }
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
803
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21127
diff changeset
804 void
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
805 syms_of_fontset ()
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
806 {
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
807 int i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
808
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
809 for (i = 0; i < 256; i++)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
810 my_strcasetbl[i] = (i >= 'A' && i <= 'Z') ? i + 'a' - 'A' : i;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
811
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
812 if (!load_font_func)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
813 /* Window system initializer should have set proper functions. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
814 abort ();
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
815
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
816 Qfontset = intern ("fontset");
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
817 staticpro (&Qfontset);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
818
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
819 Vcached_fontset_data = Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
820 staticpro (&Vcached_fontset_data);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
821
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
822 DEFVAR_LISP ("global-fontset-alist", &Vglobal_fontset_alist,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
823 "Internal data for fontset. Not for external use.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
824 This is an alist associating fontset names with the lists of fonts\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
825 contained in them.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
826 Newly created frames make their own fontset database from here.");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
827 Vglobal_fontset_alist = Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
828
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
829 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
830 "Alist of fontname patterns vs corresponding encoding info.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
831 Each element looks like (REGEXP . ENCODING-INFO),\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
832 where ENCODING-INFO is an alist of CHARSET vs ENCODING.\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
833 ENCODING is one of the following integer values:\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
834 0: code points 0x20..0x7F or 0x2020..0x7F7F are used,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
835 1: code points 0xA0..0xFF or 0xA0A0..0xFFFF are used,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
836 2: code points 0x20A0..0x7FFF are used,\n\
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
837 3: code points 0xA020..0xFF7F are used.");
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
838 Vfont_encoding_alist = Qnil;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
839
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
840 DEFVAR_LISP ("use-default-ascent", &Vuse_default_ascent,
19172
f3580f4e3587 (syms_of_fontset): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18976
diff changeset
841 "Char table of characters whose ascent values should be ignored.\n\
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
842 If an entry for a character is non-nil, the ascent value of the glyph\n\
19282
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
843 is assumed to be what specified by _MULE_DEFAULT_ASCENT property of a font.\n\
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
844 \n\
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
845 This affects how a composite character which contains\n\
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
846 such a character is displayed on screen.");
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
847 Vuse_default_ascent = Qnil;
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
848
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
849 DEFVAR_LISP ("ignore-relative-composition", &Vignore_relative_composition,
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
850 "Char table of characters which is not composed relatively.\n\
26858
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
851 If an entry for a character is non-nil, a composition sequence\n\
19282
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
852 which contains that character is displayed so that\n\
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
853 the glyph of that character is put without considering\n\
09a1536debb4 (Vignore_relative_composition): New variable.
Kenichi Handa <handa@m17n.org>
parents: 19172
diff changeset
854 an ascent and descent value of a previous character.");
26858
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
855 Vignore_relative_composition = Qnil;
17112
5c48ff325655 (syms_of_fontset): Intern Qfontset. Declare new lisp
Kenichi Handa <handa@m17n.org>
parents: 17071
diff changeset
856
19450
895dc2520755 (Valternate_fontname_alist): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19282
diff changeset
857 DEFVAR_LISP ("alternate-fontname-alist", &Valternate_fontname_alist,
895dc2520755 (Valternate_fontname_alist): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19282
diff changeset
858 "Alist of fontname vs list of the alternate fontnames.\n\
19172
f3580f4e3587 (syms_of_fontset): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18976
diff changeset
859 When a specified font name is not found, the corresponding\n\
19450
895dc2520755 (Valternate_fontname_alist): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19282
diff changeset
860 alternate fontnames (if any) are tried instead.");
895dc2520755 (Valternate_fontname_alist): Name changed from
Kenichi Handa <handa@m17n.org>
parents: 19282
diff changeset
861 Valternate_fontname_alist = Qnil;
17193
dc4562b0152a (Valternative_fontname_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17190
diff changeset
862
17730
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
863 DEFVAR_LISP ("fontset-alias-alist", &Vfontset_alias_alist,
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
864 "Alist of fontset names vs the aliases.");
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
865 Vfontset_alias_alist = Qnil;
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
866
17331
f91b4d582897 (Vhighlight_wrong_size_font, Vclip_large_size_font):
Kenichi Handa <handa@m17n.org>
parents: 17193
diff changeset
867 DEFVAR_LISP ("highlight-wrong-size-font", &Vhighlight_wrong_size_font,
f91b4d582897 (Vhighlight_wrong_size_font, Vclip_large_size_font):
Kenichi Handa <handa@m17n.org>
parents: 17193
diff changeset
868 "*Non-nil means highlight characters shown in wrong size fonts somehow.\n\
f91b4d582897 (Vhighlight_wrong_size_font, Vclip_large_size_font):
Kenichi Handa <handa@m17n.org>
parents: 17193
diff changeset
869 The way to highlight them depends on window system on which Emacs runs.\n\
19172
f3580f4e3587 (syms_of_fontset): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18976
diff changeset
870 On X11, a rectangle is shown around each such character.");
18976
ebb3e71c6dfd (syms_of_fontset): Set Vhighlight_wrong_size_font to Qnil.
Kenichi Handa <handa@m17n.org>
parents: 18694
diff changeset
871 Vhighlight_wrong_size_font = Qnil;
17331
f91b4d582897 (Vhighlight_wrong_size_font, Vclip_large_size_font):
Kenichi Handa <handa@m17n.org>
parents: 17193
diff changeset
872
f91b4d582897 (Vhighlight_wrong_size_font, Vclip_large_size_font):
Kenichi Handa <handa@m17n.org>
parents: 17193
diff changeset
873 DEFVAR_LISP ("clip-large-size-font", &Vclip_large_size_font,
19172
f3580f4e3587 (syms_of_fontset): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18976
diff changeset
874 "*Non-nil means characters shown in overlarge fonts are clipped.\n\
17730
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
875 The height of clipping area is the same as that of an ASCII character.\n\
19172
f3580f4e3587 (syms_of_fontset): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18976
diff changeset
876 The width of the area is the same as that of an ASCII character,\n\
f3580f4e3587 (syms_of_fontset): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18976
diff changeset
877 or twice as wide, depending on the character set's column-width.\n\
17730
4bbcc6804b5d (Vfontset_alias_alist): New variable.
Kenichi Handa <handa@m17n.org>
parents: 17331
diff changeset
878 \n\
19172
f3580f4e3587 (syms_of_fontset): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18976
diff changeset
879 If the only font you have for a specific character set is too large,\n\
f3580f4e3587 (syms_of_fontset): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18976
diff changeset
880 and clipping these characters makes them hard to read,\n\
f3580f4e3587 (syms_of_fontset): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18976
diff changeset
881 you can set this variable to nil to display the characters without clipping.\n\
f3580f4e3587 (syms_of_fontset): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 18976
diff changeset
882 The drawback is that you will get some garbage left on your screen.");
17331
f91b4d582897 (Vhighlight_wrong_size_font, Vclip_large_size_font):
Kenichi Handa <handa@m17n.org>
parents: 17193
diff changeset
883 Vclip_large_size_font = Qt;
f91b4d582897 (Vhighlight_wrong_size_font, Vclip_large_size_font):
Kenichi Handa <handa@m17n.org>
parents: 17193
diff changeset
884
26858
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
885 DEFVAR_LISP ("vertical-centering-font-regexp",
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
886 &Vvertical_centering_font_regexp,
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
887 "*Regexp matching font names that require vertical centering on display.\n\
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
888 When a character is displayed with such fonts, the character is displayed\n\
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
889 at the vertival center of lines.");
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
890 Vvertical_centering_font_regexp = Qnil;
7cc081b4e084 (Vvertical_centering_font_regexp): New variable.
Kenichi Handa <handa@m17n.org>
parents: 26164
diff changeset
891
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
892 defsubr (&Squery_fontset);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
893 defsubr (&Snew_fontset);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
894 defsubr (&Sset_fontset_font);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
895 defsubr (&Sfont_info);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
896 defsubr (&Sfontset_info);
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
897 }