aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2008-08-29 07:55:35 +0000
committerKenichi Handa2008-08-29 07:55:35 +0000
commit514cf2188b48b2bacc5ec35dca0643aa82d7ff1a (patch)
tree45fce8c9b26d9a0e55917c3334ab5b33fff98c14
parent8057d3c0149f7ee04a46825e94bee5c9247624a0 (diff)
downloademacs-514cf2188b48b2bacc5ec35dca0643aa82d7ff1a.tar.gz
emacs-514cf2188b48b2bacc5ec35dca0643aa82d7ff1a.zip
(font_for_char): New function.
-rw-r--r--src/fontset.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/fontset.c b/src/fontset.c
index 77d603ad4ea..2979afe55fb 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -934,6 +934,56 @@ face_for_char (f, face, c, pos, object)
934} 934}
935 935
936 936
937Lisp_Object
938font_for_char (face, c, pos, object)
939 struct face *face;
940 int c, pos;
941 Lisp_Object object;
942{
943 Lisp_Object fontset, rfont_def, charset;
944 int face_id;
945 int id;
946
947 if (ASCII_CHAR_P (c))
948 {
949 Lisp_Object font_object;
950
951 XSETFONT (font_object, face->ascii_face->font);
952 return font_object;
953 }
954
955 xassert (fontset_id_valid_p (face->fontset));
956 fontset = FONTSET_FROM_ID (face->fontset);
957 xassert (!BASE_FONTSET_P (fontset));
958 if (pos < 0)
959 {
960 id = -1;
961 charset = Qnil;
962 }
963 else
964 {
965 charset = Fget_char_property (make_number (pos), Qcharset, object);
966 if (NILP (charset))
967 id = -1;
968 else if (CHARSETP (charset))
969 {
970 Lisp_Object val;
971
972 val = assoc_no_quit (charset, Vfont_encoding_charset_alist);
973 if (CONSP (val) && CHARSETP (XCDR (val)))
974 charset = XCDR (val);
975 id = XINT (CHARSET_SYMBOL_ID (charset));
976 }
977 }
978
979 font_deferred_log ("font for", Fcons (make_number (c), charset), Qnil);
980 rfont_def = fontset_font (fontset, c, face, id);
981 return (VECTORP (rfont_def)
982 ? RFONT_DEF_OBJECT (rfont_def)
983 : Qnil);
984}
985
986
937/* Make a realized fontset for ASCII face FACE on frame F from the 987/* Make a realized fontset for ASCII face FACE on frame F from the
938 base fontset BASE_FONTSET_ID. If BASE_FONTSET_ID is -1, use the 988 base fontset BASE_FONTSET_ID. If BASE_FONTSET_ID is -1, use the
939 default fontset as the base. Value is the id of the new fontset. 989 default fontset as the base. Value is the id of the new fontset.