aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2007-12-21 01:37:31 +0000
committerKenichi Handa2007-12-21 01:37:31 +0000
commit28e2436abf38747725cf50c7b7967c66dfa5f883 (patch)
tree63a8a8d97bb98e768bfb376a1734cd1c05f46cfd /src
parent8cce6b2d94f96bd9d5ee4f434da8f26b50dcc820 (diff)
downloademacs-28e2436abf38747725cf50c7b7967c66dfa5f883.tar.gz
emacs-28e2436abf38747725cf50c7b7967c66dfa5f883.zip
(Vfont_encoding_charset_alist): New variable.
(syms_of_fontset): DEFVAR it. (reorder_font_vector): Optimize for the case of no need of reordring. (fontset_find_font): Likewise. (face_for_char): Map the charset property by Vfont_encoding_charset_alist.
Diffstat (limited to 'src')
-rw-r--r--src/fontset.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/fontset.c b/src/fontset.c
index 1c13c4e8a60..085aadb1f0d 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -214,6 +214,7 @@ static int next_fontset_id;
214static Lisp_Object Vdefault_fontset; 214static Lisp_Object Vdefault_fontset;
215 215
216Lisp_Object Vfont_encoding_alist; 216Lisp_Object Vfont_encoding_alist;
217Lisp_Object Vfont_encoding_charset_alist;
217Lisp_Object Vuse_default_ascent; 218Lisp_Object Vuse_default_ascent;
218Lisp_Object Vignore_relative_composition; 219Lisp_Object Vignore_relative_composition;
219Lisp_Object Valternate_fontname_alist; 220Lisp_Object Valternate_fontname_alist;
@@ -450,13 +451,7 @@ reorder_font_vector (font_group, charset_id, family)
450 int i, idx; 451 int i, idx;
451 Lisp_Object preferred_by_charset, preferred_by_family; 452 Lisp_Object preferred_by_charset, preferred_by_family;
452 453
453 ASET (font_group, 0, make_number (charset_ordered_list_tick));
454 ASET (font_group, 1, make_number (charset_id));
455 ASET (font_group, 2, family);
456 size = ASIZE (font_group) - 3; 454 size = ASIZE (font_group) - 3;
457 if (size <= 1)
458 /* No need to reorder VEC. */
459 return;
460 charset_id_table = (int *) alloca (sizeof (int) * size); 455 charset_id_table = (int *) alloca (sizeof (int) * size);
461 new_vec = (Lisp_Object *) alloca (sizeof (Lisp_Object) * size); 456 new_vec = (Lisp_Object *) alloca (sizeof (Lisp_Object) * size);
462 457
@@ -493,6 +488,15 @@ reorder_font_vector (font_group, charset_id, family)
493 charset_id_table[i] = id; 488 charset_id_table[i] = id;
494 } 489 }
495 490
491 if (idx == 0
492 && (XINT (AREF (font_group, 0)) == charset_ordered_list_tick))
493 /* No need of reordering. */
494 return;
495
496 ASET (font_group, 0, make_number (charset_ordered_list_tick));
497 ASET (font_group, 1, make_number (charset_id));
498 ASET (font_group, 2, family);
499
496 /* Then, store the remaining RFONT-DEFs in NEW_VEC in the correct 500 /* Then, store the remaining RFONT-DEFs in NEW_VEC in the correct
497 order. */ 501 order. */
498 for (list = Vcharset_ordered_list; idx < size; list = XCDR (list)) 502 for (list = Vcharset_ordered_list; idx < size; list = XCDR (list))
@@ -664,7 +668,7 @@ fontset_find_font (fontset, c, face, id, fallback)
664 668
665 if (ASIZE (vec) > 4 669 if (ASIZE (vec) > 4
666 && (XINT (AREF (vec, 0)) != charset_ordered_list_tick 670 && (XINT (AREF (vec, 0)) != charset_ordered_list_tick
667 || XINT (AREF (vec, 1)) != id 671 || (id >= 0 && XINT (AREF (vec, 1)) != id)
668 || NILP (Fequal (AREF (vec, 2), face->lface[LFACE_FAMILY_INDEX])))) 672 || NILP (Fequal (AREF (vec, 2), face->lface[LFACE_FAMILY_INDEX]))))
669 /* We have just created VEC, 673 /* We have just created VEC,
670 or the charset priorities were changed, 674 or the charset priorities were changed,
@@ -1032,7 +1036,14 @@ face_for_char (f, face, c, pos, object)
1032 if (NILP (charset)) 1036 if (NILP (charset))
1033 id = -1; 1037 id = -1;
1034 else if (CHARSETP (charset)) 1038 else if (CHARSETP (charset))
1035 id = XINT (CHARSET_SYMBOL_ID (charset)); 1039 {
1040 Lisp_Object val;
1041
1042 val = assoc_no_quit (charset, Vfont_encoding_charset_alist);
1043 if (CONSP (val) && CHARSETP (XCDR (val)))
1044 charset = XCDR (val);
1045 id = XINT (CHARSET_SYMBOL_ID (charset));
1046 }
1036 } 1047 }
1037 rfont_def = fontset_font (fontset, c, face, id); 1048 rfont_def = fontset_font (fontset, c, face, id);
1038 if (VECTORP (rfont_def)) 1049 if (VECTORP (rfont_def))
@@ -2465,6 +2476,9 @@ Each element looks like (REGEXP . (ENCODING . REPERTORY)),
2465where ENCODING is a charset or a char-table, 2476where ENCODING is a charset or a char-table,
2466and REPERTORY is a charset, a char-table, or nil. 2477and REPERTORY is a charset, a char-table, or nil.
2467 2478
2479If ENCDING and REPERTORY are the same, the element can have the form
2480\(REGEXP . ENCODING).
2481
2468ENCODING is for converting a character to a glyph code of the font. 2482ENCODING is for converting a character to a glyph code of the font.
2469If ENCODING is a charset, encoding a character by the charset gives 2483If ENCODING is a charset, encoding a character by the charset gives
2470the corresponding glyph code. If ENCODING is a char-table, looking up 2484the corresponding glyph code. If ENCODING is a char-table, looking up
@@ -2477,6 +2491,17 @@ non-nil value in the table are supported. It REPERTORY is nil, Emacs
2477gets the repertory information by an opened font and ENCODING. */); 2491gets the repertory information by an opened font and ENCODING. */);
2478 Vfont_encoding_alist = Qnil; 2492 Vfont_encoding_alist = Qnil;
2479 2493
2494 DEFVAR_LISP ("font-encoding-charset-alist", &Vfont_encoding_charset_alist,
2495 doc: /*
2496Alist of charsets vs the charsets to determine the preferred font encoding.
2497Each element looks like (CHARSET . ENCDOING-CHARSET),
2498where ENCODING-CHARSET is a charset registered in the variable
2499`font-encoding-alist' as ENCODING.
2500
2501When a text has a property `charset' and the value is CHARSET, a font
2502whose encoding corresponds to ENCODING-CHARSET is preferred. */);
2503 Vfont_encoding_charset_alist = Qnil;
2504
2480 DEFVAR_LISP ("use-default-ascent", &Vuse_default_ascent, 2505 DEFVAR_LISP ("use-default-ascent", &Vuse_default_ascent,
2481 doc: /* 2506 doc: /*
2482Char table of characters whose ascent values should be ignored. 2507Char table of characters whose ascent values should be ignored.