comparison src/fontset.c @ 41987:34952771ae85

Fix typos, remove unnecessary space.
author Pavel Janík <Pavel@Janik.cz>
date Wed, 12 Dec 2001 20:06:10 +0000
parents c0f330e36e98
children 01b93e5e53a7 8ae0d0693ed9
comparison
equal deleted inserted replaced
41986:90840766f5fb 41987:34952771ae85
53 new-fontset from Emacs Lisp explicitly. A realized fontset is 53 new-fontset from Emacs Lisp explicitly. A realized fontset is
54 created implicitly when a face is realized for ASCII characters. A 54 created implicitly when a face is realized for ASCII characters. A
55 face is also realized for multibyte characters based on an ASCII 55 face is also realized for multibyte characters based on an ASCII
56 face. All of the multibyte faces based on the same ASCII face 56 face. All of the multibyte faces based on the same ASCII face
57 share the same realized fontset. 57 share the same realized fontset.
58 58
59 A fontset object is implemented by a char-table. 59 A fontset object is implemented by a char-table.
60 60
61 An element of a base fontset is: 61 An element of a base fontset is:
62 (INDEX . FONTNAME) or 62 (INDEX . FONTNAME) or
63 (INDEX . (FOUNDRY . REGISTRY )) 63 (INDEX . (FOUNDRY . REGISTRY ))
64 FONTNAME is a font name pattern for the corresponding character. 64 FONTNAME is a font name pattern for the corresponding character.
65 FOUNDRY and REGISTRY are respectively foundy and regisry fields of 65 FOUNDRY and REGISTRY are respectively foundry and registry fields of
66 a font name for the corresponding character. INDEX specifies for 66 a font name for the corresponding character. INDEX specifies for
67 which character (or generic character) the element is defined. It 67 which character (or generic character) the element is defined. It
68 may be different from an index to access this element. For 68 may be different from an index to access this element. For
69 instance, if a fontset defines some font for all characters of 69 instance, if a fontset defines some font for all characters of
70 charset `japanese-jisx0208', INDEX is the generic character of this 70 charset `japanese-jisx0208', INDEX is the generic character of this
71 charset. REGISTRY is the 71 charset. REGISTRY is the
72 72
73 An element of a realized fontset is FACE-ID which is a face to use 73 An element of a realized fontset is FACE-ID which is a face to use
74 for displaying the correspnding character. 74 for displaying the corresponding character.
75 75
76 All single byte charaters (ASCII and 8bit-unibyte) share the same 76 All single byte characters (ASCII and 8bit-unibyte) share the same
77 element in a fontset. The element is stored in the first element 77 element in a fontset. The element is stored in the first element
78 of the fontset. 78 of the fontset.
79 79
80 To access or set each element, use macros FONTSET_REF and 80 To access or set each element, use macros FONTSET_REF and
81 FONTSET_SET respectively for efficiency. 81 FONTSET_SET respectively for efficiency.
108 108
109 109
110 These structures are hidden from the other codes than this file. 110 These structures are hidden from the other codes than this file.
111 The other codes handle fontsets only by their ID numbers. They 111 The other codes handle fontsets only by their ID numbers. They
112 usually use variable name `fontset' for IDs. But, in this file, we 112 usually use variable name `fontset' for IDs. But, in this file, we
113 always use varialbe name `id' for IDs, and name `fontset' for the 113 always use variable name `id' for IDs, and name `fontset' for the
114 actual fontset objects. 114 actual fontset objects.
115 115
116 */ 116 */
117 117
118 /********** VARIABLES and FUNCTION PROTOTYPES **********/ 118 /********** VARIABLES and FUNCTION PROTOTYPES **********/
121 Lisp_Object Qfontset; 121 Lisp_Object Qfontset;
122 122
123 /* Vector containing all fontsets. */ 123 /* Vector containing all fontsets. */
124 static Lisp_Object Vfontset_table; 124 static Lisp_Object Vfontset_table;
125 125
126 /* Next possibly free fontset ID. Usually this keeps the mininum 126 /* Next possibly free fontset ID. Usually this keeps the minimum
127 fontset ID not yet used. */ 127 fontset ID not yet used. */
128 static int next_fontset_id; 128 static int next_fontset_id;
129 129
130 /* The default fontset. This gives default FAMILY and REGISTRY of 130 /* The default fontset. This gives default FAMILY and REGISTRY of
131 font for each characters. */ 131 font for each characters. */
143 detail. */ 143 detail. */
144 144
145 /* Return a pointer to struct font_info of font FONT_IDX of frame F. */ 145 /* Return a pointer to struct font_info of font FONT_IDX of frame F. */
146 struct font_info *(*get_font_info_func) P_ ((FRAME_PTR f, int font_idx)); 146 struct font_info *(*get_font_info_func) P_ ((FRAME_PTR f, int font_idx));
147 147
148 /* Return a list of font names which matches PATTERN. See the document of 148 /* Return a list of font names which matches PATTERN. See the documentation
149 `x-list-fonts' for more detail. */ 149 of `x-list-fonts' for more details. */
150 Lisp_Object (*list_fonts_func) P_ ((struct frame *f, 150 Lisp_Object (*list_fonts_func) P_ ((struct frame *f,
151 Lisp_Object pattern, 151 Lisp_Object pattern,
152 int size, 152 int size,
153 int maxnames)); 153 int maxnames));
154 154
164 void (*set_frame_fontset_func) P_ ((FRAME_PTR f, Lisp_Object arg, 164 void (*set_frame_fontset_func) P_ ((FRAME_PTR f, Lisp_Object arg,
165 Lisp_Object oldval)); 165 Lisp_Object oldval));
166 166
167 /* To find a CCL program, fs_load_font calls this function. 167 /* To find a CCL program, fs_load_font calls this function.
168 The argument is a pointer to the struct font_info. 168 The argument is a pointer to the struct font_info.
169 This function set the memer `encoder' of the structure. */ 169 This function set the member `encoder' of the structure. */
170 void (*find_ccl_program_func) P_ ((struct font_info *)); 170 void (*find_ccl_program_func) P_ ((struct font_info *));
171 171
172 /* Check if any window system is used now. */ 172 /* Check if any window system is used now. */
173 void (*check_window_system_func) P_ ((void)); 173 void (*check_window_system_func) P_ ((void));
174 174
316 int id = next_fontset_id; 316 int id = next_fontset_id;
317 317
318 /* Find a free slot in Vfontset_table. Usually, next_fontset_id is 318 /* Find a free slot in Vfontset_table. Usually, next_fontset_id is
319 the next available fontset ID. So it is expected that this loop 319 the next available fontset ID. So it is expected that this loop
320 terminates quickly. In addition, as the last element of 320 terminates quickly. In addition, as the last element of
321 Vfotnset_table is always nil, we don't have to check the range of 321 Vfontset_table is always nil, we don't have to check the range of
322 id. */ 322 id. */
323 while (!NILP (AREF (Vfontset_table, id))) id++; 323 while (!NILP (AREF (Vfontset_table, id))) id++;
324 324
325 if (id + 1 == size) 325 if (id + 1 == size)
326 { 326 {
327 Lisp_Object tem; 327 Lisp_Object tem;
328 int i; 328 int i;
329 329
330 tem = Fmake_vector (make_number (size + 8), Qnil); 330 tem = Fmake_vector (make_number (size + 8), Qnil);
331 for (i = 0; i < size; i++) 331 for (i = 0; i < size; i++)
332 AREF (tem, i) = AREF (Vfontset_table, i); 332 AREF (tem, i) = AREF (Vfontset_table, i);
333 Vfontset_table = tem; 333 Vfontset_table = tem;
371 { 371 {
372 Lisp_Object family, registry; 372 Lisp_Object family, registry;
373 char *p = XSTRING (fontname)->data; 373 char *p = XSTRING (fontname)->data;
374 char *sep[15]; 374 char *sep[15];
375 int i = 0; 375 int i = 0;
376 376
377 while (*p && i < 15) 377 while (*p && i < 15)
378 if (*p++ == '-') 378 if (*p++ == '-')
379 { 379 {
380 if (!force && i >= 2 && i <= 11 && *p != '*' && p[1] != '-') 380 if (!force && i >= 2 && i <= 11 && *p != '*' && p[1] != '-')
381 return fontname; 381 return fontname;
388 registry = make_unibyte_string (sep[12], p - sep[12]); 388 registry = make_unibyte_string (sep[12], p - sep[12]);
389 return Fcons (family, registry); 389 return Fcons (family, registry);
390 } 390 }
391 391
392 392
393 /********** INTERFACES TO xfaces.c and dispextern.h **********/ 393 /********** INTERFACES TO xfaces.c and dispextern.h **********/
394 394
395 /* Return name of the fontset with ID. */ 395 /* Return name of the fontset with ID. */
396 396
397 Lisp_Object 397 Lisp_Object
398 fontset_name (id) 398 fontset_name (id)
479 return XINT (elt); 479 return XINT (elt);
480 480
481 /* No face is recorded for C in the fontset of FACE. Make a new 481 /* No face is recorded for C in the fontset of FACE. Make a new
482 realized face for C that has the same fontset. */ 482 realized face for C that has the same fontset. */
483 face_id = lookup_face (f, face->lface, c, face); 483 face_id = lookup_face (f, face->lface, c, face);
484 484
485 /* Record the face ID in FONTSET at the same index as the 485 /* Record the face ID in FONTSET at the same index as the
486 information in the base fontset. */ 486 information in the base fontset. */
487 FONTSET_SET (fontset, c, make_number (face_id)); 487 FONTSET_SET (fontset, c, make_number (face_id));
488 return face_id; 488 return face_id;
489 } 489 }
530 FRAME_PTR f; 530 FRAME_PTR f;
531 int id, c; 531 int id, c;
532 { 532 {
533 Lisp_Object fontset, elt; 533 Lisp_Object fontset, elt;
534 struct font_info *fontp; 534 struct font_info *fontp;
535 535
536 elt = Qnil; 536 elt = Qnil;
537 if (fontset_id_valid_p (id)) 537 if (fontset_id_valid_p (id))
538 { 538 {
539 fontset = FONTSET_FROM_ID (id); 539 fontset = FONTSET_FROM_ID (id);
540 xassert (!BASE_FONTSET_P (fontset)); 540 xassert (!BASE_FONTSET_P (fontset));
632 font_info structure that are not set by (*load_font_func). */ 632 font_info structure that are not set by (*load_font_func). */
633 fontp->charset = charset; 633 fontp->charset = charset;
634 634
635 fontp->vertical_centering 635 fontp->vertical_centering
636 = (STRINGP (Vvertical_centering_font_regexp) 636 = (STRINGP (Vvertical_centering_font_regexp)
637 && (fast_c_string_match_ignore_case 637 && (fast_c_string_match_ignore_case
638 (Vvertical_centering_font_regexp, fontp->full_name) >= 0)); 638 (Vvertical_centering_font_regexp, fontp->full_name) >= 0));
639 639
640 if (fontp->encoding[1] != FONT_ENCODING_NOT_DECIDED) 640 if (fontp->encoding[1] != FONT_ENCODING_NOT_DECIDED)
641 { 641 {
642 /* The font itself tells which code points to be used. Use this 642 /* The font itself tells which code points to be used. Use this
826 return FONTSET_NAME (fontset); 826 return FONTSET_NAME (fontset);
827 } 827 }
828 828
829 /* Return a list of base fontset names matching PATTERN on frame F. 829 /* Return a list of base fontset names matching PATTERN on frame F.
830 If SIZE is not 0, it is the size (maximum bound width) of fontsets 830 If SIZE is not 0, it is the size (maximum bound width) of fontsets
831 to be listed. */ 831 to be listed. */
832 832
833 Lisp_Object 833 Lisp_Object
834 list_fontsets (f, pattern, size) 834 list_fontsets (f, pattern, size)
835 FRAME_PTR f; 835 FRAME_PTR f;
836 Lisp_Object pattern; 836 Lisp_Object pattern;
981 for all characters in the range FROM and TO (inclusive). 981 for all characters in the range FROM and TO (inclusive).
982 CHARACTER may be a charset. In that case, use FONTNAME 982 CHARACTER may be a charset. In that case, use FONTNAME
983 for all character in the charsets. 983 for all character in the charsets.
984 984
985 FONTNAME may be a cons; (FAMILY . REGISTRY), where FAMILY is a family 985 FONTNAME may be a cons; (FAMILY . REGISTRY), where FAMILY is a family
986 name of a font, REGSITRY is a registry name of a font. */) 986 name of a font, REGISTRY is a registry name of a font. */)
987 (name, character, fontname, frame) 987 (name, character, fontname, frame)
988 Lisp_Object name, character, fontname, frame; 988 Lisp_Object name, character, fontname, frame;
989 { 989 {
990 Lisp_Object fontset, elt; 990 Lisp_Object fontset, elt;
991 Lisp_Object realized; 991 Lisp_Object realized;
1245 HEIGHT is the maximum bound height of ASCII font in the fontset, 1245 HEIGHT is the maximum bound height of ASCII font in the fontset,
1246 CHARSET-OR-RANGE is a charset, a character (may be a generic character) 1246 CHARSET-OR-RANGE is a charset, a character (may be a generic character)
1247 or a cons of two characters specifying the range of characters. 1247 or a cons of two characters specifying the range of characters.
1248 FONT-SPEC is a fontname pattern string or a cons (FAMILY . REGISTRY), 1248 FONT-SPEC is a fontname pattern string or a cons (FAMILY . REGISTRY),
1249 where FAMILY is a `FAMILY' field of a XLFD font name, 1249 where FAMILY is a `FAMILY' field of a XLFD font name,
1250 REGISTRY is a `CHARSET_REGISTRY' field of a XLDF font name. 1250 REGISTRY is a `CHARSET_REGISTRY' field of a XLFD font name.
1251 FAMILY may contain a `FOUNDARY' field at the head. 1251 FAMILY may contain a `FOUNDRY' field at the head.
1252 REGISTRY may contain a `CHARSET_ENCODING' field at the tail. 1252 REGISTRY may contain a `CHARSET_ENCODING' field at the tail.
1253 OPENEDs are names of fonts actually opened. 1253 OPENEDs are names of fonts actually opened.
1254 If the ASCII font is not yet opened, SIZE and HEIGHT are 0. 1254 If the ASCII font is not yet opened, SIZE and HEIGHT are 0.
1255 If FRAME is omitted, it defaults to the currently selected frame. */) 1255 If FRAME is omitted, it defaults to the currently selected frame. */)
1256 (name, frame) 1256 (name, frame)
1262 Lisp_Object val, tail, elt; 1262 Lisp_Object val, tail, elt;
1263 Lisp_Object *realized; 1263 Lisp_Object *realized;
1264 struct font_info *fontp = NULL; 1264 struct font_info *fontp = NULL;
1265 int n_realized = 0; 1265 int n_realized = 0;
1266 int i; 1266 int i;
1267 1267
1268 (*check_window_system_func) (); 1268 (*check_window_system_func) ();
1269 1269
1270 fontset = check_fontset_name (name); 1270 fontset = check_fontset_name (name);
1271 1271
1272 if (NILP (frame)) 1272 if (NILP (frame))
1366 if (CONSP (elt)) 1366 if (CONSP (elt))
1367 elt = XCDR (elt); 1367 elt = XCDR (elt);
1368 1368
1369 return elt; 1369 return elt;
1370 } 1370 }
1371
1372 1371
1373 DEFUN ("fontset-list", Ffontset_list, Sfontset_list, 0, 0, 0, 1372 DEFUN ("fontset-list", Ffontset_list, Sfontset_list, 0, 0, 0,
1374 doc: /* Return a list of all defined fontset names. */) 1373 doc: /* Return a list of all defined fontset names. */)
1375 () 1374 ()
1376 { 1375 {
1469 1468
1470 DEFVAR_LISP ("vertical-centering-font-regexp", 1469 DEFVAR_LISP ("vertical-centering-font-regexp",
1471 &Vvertical_centering_font_regexp, 1470 &Vvertical_centering_font_regexp,
1472 doc: /* *Regexp matching font names that require vertical centering on display. 1471 doc: /* *Regexp matching font names that require vertical centering on display.
1473 When a character is displayed with such fonts, the character is displayed 1472 When a character is displayed with such fonts, the character is displayed
1474 at the vertival center of lines. */); 1473 at the vertical center of lines. */);
1475 Vvertical_centering_font_regexp = Qnil; 1474 Vvertical_centering_font_regexp = Qnil;
1476 1475
1477 defsubr (&Squery_fontset); 1476 defsubr (&Squery_fontset);
1478 defsubr (&Snew_fontset); 1477 defsubr (&Snew_fontset);
1479 defsubr (&Sset_fontset_font); 1478 defsubr (&Sset_fontset_font);