aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2002-03-01 01:49:55 +0000
committerKenichi Handa2002-03-01 01:49:55 +0000
commit81b39386f6522ac95b329270ba72d733958baa46 (patch)
tree70c3b40fdd8ab3412159cfeb8e2b9d22edceedb4 /src
parentea0ffe21113b62bd672671858912c99e0842370d (diff)
downloademacs-81b39386f6522ac95b329270ba72d733958baa46.tar.gz
emacs-81b39386f6522ac95b329270ba72d733958baa46.zip
Include "character.h" instead of "charset.h".
(load_face_font): Adjusted for the change of choose_face_font and FS_LOAD_FONT. (generate_ascii_font): New function. (set_lface_from_font_name): Adjusted for the change of FS_LOAD_FONT. (set_font_frame_param): Adjusted for the change of choose_face_font. (free_realized_face): Make it public. (free_realized_faces_for_fontset): Renamed from free_realized_multibyte_face. Free also faces realized for ASCII. (choose_face_font): Argments changed. Adjusted for the change of fontset_font_pattern and FS_LOAD_FONT.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c138
1 files changed, 107 insertions, 31 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index c1d736eeb2e..d02602515fe 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -196,7 +196,7 @@ Boston, MA 02111-1307, USA. */
196#include <sys/stat.h> 196#include <sys/stat.h>
197 197
198#include "lisp.h" 198#include "lisp.h"
199#include "charset.h" 199#include "character.h"
200#include "keyboard.h" 200#include "keyboard.h"
201#include "frame.h" 201#include "frame.h"
202 202
@@ -550,14 +550,14 @@ static unsigned hash_string_case_insensitive P_ ((Lisp_Object));
550static unsigned lface_hash P_ ((Lisp_Object *)); 550static unsigned lface_hash P_ ((Lisp_Object *));
551static int lface_same_font_attributes_p P_ ((Lisp_Object *, Lisp_Object *)); 551static int lface_same_font_attributes_p P_ ((Lisp_Object *, Lisp_Object *));
552static struct face_cache *make_face_cache P_ ((struct frame *)); 552static struct face_cache *make_face_cache P_ ((struct frame *));
553static void free_realized_face P_ ((struct frame *, struct face *));
554static void clear_face_gcs P_ ((struct face_cache *)); 553static void clear_face_gcs P_ ((struct face_cache *));
555static void free_face_cache P_ ((struct face_cache *)); 554static void free_face_cache P_ ((struct face_cache *));
556static int face_numeric_weight P_ ((Lisp_Object)); 555static int face_numeric_weight P_ ((Lisp_Object));
557static int face_numeric_slant P_ ((Lisp_Object)); 556static int face_numeric_slant P_ ((Lisp_Object));
558static int face_numeric_swidth P_ ((Lisp_Object)); 557static int face_numeric_swidth P_ ((Lisp_Object));
559static int face_fontset P_ ((Lisp_Object *)); 558static int face_fontset P_ ((Lisp_Object *));
560static char *choose_face_font P_ ((struct frame *, Lisp_Object *, int, int)); 559static char *choose_face_font P_ ((struct frame *, Lisp_Object *,
560 struct face *, int));
561static void merge_face_vectors P_ ((struct frame *, Lisp_Object *, Lisp_Object*, Lisp_Object)); 561static void merge_face_vectors P_ ((struct frame *, Lisp_Object *, Lisp_Object*, Lisp_Object));
562static void merge_face_inheritance P_ ((struct frame *f, Lisp_Object, 562static void merge_face_inheritance P_ ((struct frame *f, Lisp_Object,
563 Lisp_Object *, Lisp_Object)); 563 Lisp_Object *, Lisp_Object));
@@ -567,7 +567,6 @@ static int set_lface_from_font_name P_ ((struct frame *, Lisp_Object,
567 Lisp_Object, int, int)); 567 Lisp_Object, int, int));
568static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int)); 568static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int));
569static struct face *make_realized_face P_ ((Lisp_Object *)); 569static struct face *make_realized_face P_ ((Lisp_Object *));
570static void free_realized_faces P_ ((struct face_cache *));
571static char *best_matching_font P_ ((struct frame *, Lisp_Object *, 570static char *best_matching_font P_ ((struct frame *, Lisp_Object *,
572 struct font_name *, int, int)); 571 struct font_name *, int, int));
573static void cache_face P_ ((struct face_cache *, struct face *, unsigned)); 572static void cache_face P_ ((struct face_cache *, struct face *, unsigned));
@@ -1268,12 +1267,13 @@ load_face_font (f, face, c)
1268 face->font_info_id = -1; 1267 face->font_info_id = -1;
1269 face->font = NULL; 1268 face->font = NULL;
1270 1269
1271 font_name = choose_face_font (f, face->lface, face->fontset, c); 1270 font_name = choose_face_font (f, face->lface, face, c);
1271
1272 if (!font_name) 1272 if (!font_name)
1273 return; 1273 return;
1274 1274
1275 BLOCK_INPUT; 1275 BLOCK_INPUT;
1276 font_info = FS_LOAD_FACE_FONT (f, c, font_name, face); 1276 font_info = FS_LOAD_FONT (f, font_name);
1277 UNBLOCK_INPUT; 1277 UNBLOCK_INPUT;
1278 1278
1279 if (font_info) 1279 if (font_info)
@@ -2112,6 +2112,61 @@ face_numeric_swidth (width)
2112} 2112}
2113 2113
2114 2114
2115Lisp_Object
2116generate_ascii_font (name, ascii_spec)
2117 Lisp_Object name;
2118{
2119 struct font_name font;
2120 char *p;
2121
2122 font.name = LSTRDUPA (name);
2123 if (! split_font_name (NULL, &font, 0))
2124 return Qnil;
2125
2126 if (STRINGP (AREF (ascii_spec, FONT_SPEC_FAMILY_INDEX)))
2127 {
2128 p = LSTRDUPA (AREF (ascii_spec, FONT_SPEC_FAMILY_INDEX));
2129 font.fields[XLFD_FOUNDRY] = p;
2130 while (*p != '-') p++;
2131 if (*p)
2132 {
2133 *p++ = 0;
2134 font.fields[XLFD_FAMILY] = p;
2135 }
2136 else
2137 {
2138 font.fields[XLFD_FAMILY] = font.fields[XLFD_FOUNDRY];
2139 font.fields[XLFD_FOUNDRY] = "*";
2140 }
2141 }
2142 if (STRINGP (AREF (ascii_spec, FONT_SPEC_WEIGHT_INDEX)))
2143 font.fields[XLFD_WEIGHT]
2144 = XSTRING (AREF (ascii_spec, FONT_SPEC_WEIGHT_INDEX))->data;
2145 if (STRINGP (AREF (ascii_spec, FONT_SPEC_SLANT_INDEX)))
2146 font.fields[XLFD_SLANT]
2147 = XSTRING (AREF (ascii_spec, FONT_SPEC_SLANT_INDEX))->data;
2148 if (STRINGP (AREF (ascii_spec, FONT_SPEC_SWIDTH_INDEX)))
2149 font.fields[XLFD_SWIDTH]
2150 = XSTRING (AREF (ascii_spec, FONT_SPEC_SWIDTH_INDEX))->data;
2151 if (STRINGP (AREF (ascii_spec, FONT_SPEC_ADSTYLE_INDEX)))
2152 font.fields[XLFD_ADSTYLE]
2153 = XSTRING (AREF (ascii_spec, FONT_SPEC_ADSTYLE_INDEX))->data;
2154 p = LSTRDUPA (AREF (ascii_spec, FONT_SPEC_REGISTRY_INDEX));
2155 font.fields[XLFD_REGISTRY] = p;
2156 while (*p != '-') p++;
2157 if (*p)
2158 *p++ = 0;
2159 else
2160 p = "*";
2161 font.fields[XLFD_ENCODING] = p;
2162
2163 p = build_font_name (&font);
2164 name = build_string (p);
2165 xfree (p);
2166 return name;
2167}
2168
2169
2115#ifdef HAVE_WINDOW_SYSTEM 2170#ifdef HAVE_WINDOW_SYSTEM
2116 2171
2117/* Return non-zero if FONT is the name of a fixed-pitch font. */ 2172/* Return non-zero if FONT is the name of a fixed-pitch font. */
@@ -3149,7 +3204,7 @@ set_lface_from_font_name (f, lface, fontname, force_p, may_fail_p)
3149 caching it now is not futail because we anyway load the font 3204 caching it now is not futail because we anyway load the font
3150 later. */ 3205 later. */
3151 BLOCK_INPUT; 3206 BLOCK_INPUT;
3152 font_info = FS_LOAD_FONT (f, 0, font_name, -1); 3207 font_info = FS_LOAD_FONT (f, font_name);
3153 UNBLOCK_INPUT; 3208 UNBLOCK_INPUT;
3154 3209
3155 if (!font_info) 3210 if (!font_info)
@@ -4252,7 +4307,7 @@ set_font_frame_param (frame, lface)
4252 /* Choose a font name that reflects LFACE's attributes and has 4307 /* Choose a font name that reflects LFACE's attributes and has
4253 the registry and encoding pattern specified in the default 4308 the registry and encoding pattern specified in the default
4254 fontset (3rd arg: -1) for ASCII characters (4th arg: 0). */ 4309 fontset (3rd arg: -1) for ASCII characters (4th arg: 0). */
4255 font = choose_face_font (f, XVECTOR (lface)->contents, -1, 0); 4310 font = choose_face_font (f, XVECTOR (lface)->contents, NULL, 0);
4256 if (!font) 4311 if (!font)
4257 error ("No font matches the specified attribute"); 4312 error ("No font matches the specified attribute");
4258 font_name = build_string (font); 4313 font_name = build_string (font);
@@ -4938,7 +4993,7 @@ make_realized_face (attr)
4938/* Free realized face FACE, including its X resources. FACE may 4993/* Free realized face FACE, including its X resources. FACE may
4939 be null. */ 4994 be null. */
4940 4995
4941static void 4996void
4942free_realized_face (f, face) 4997free_realized_face (f, face)
4943 struct frame *f; 4998 struct frame *f;
4944 struct face *face; 4999 struct face *face;
@@ -5116,11 +5171,10 @@ free_realized_faces (c)
5116} 5171}
5117 5172
5118 5173
5119/* Free all faces realized for multibyte characters on frame F that 5174/* Free all realized faces that are using FONTSET on frame F. */
5120 has FONTSET. */
5121 5175
5122void 5176void
5123free_realized_multibyte_face (f, fontset) 5177free_realized_faces_for_fontset (f, fontset)
5124 struct frame *f; 5178 struct frame *f;
5125 int fontset; 5179 int fontset;
5126{ 5180{
@@ -5137,7 +5191,6 @@ free_realized_multibyte_face (f, fontset)
5137 { 5191 {
5138 face = cache->faces_by_id[i]; 5192 face = cache->faces_by_id[i];
5139 if (face 5193 if (face
5140 && face != face->ascii_face
5141 && face->fontset == fontset) 5194 && face->fontset == fontset)
5142 { 5195 {
5143 uncache_face (cache, face); 5196 uncache_face (cache, face);
@@ -6064,26 +6117,28 @@ face_fontset (attrs)
6064/* Choose a name of font to use on frame F to display character C with 6117/* Choose a name of font to use on frame F to display character C with
6065 Lisp face attributes specified by ATTRS. The font name is 6118 Lisp face attributes specified by ATTRS. The font name is
6066 determined by the font-related attributes in ATTRS and the name 6119 determined by the font-related attributes in ATTRS and the name
6067 pattern for C in FONTSET. Value is the font name which is 6120 pattern for C in FACE->fontset (or Vdefault_fontset if FACE is
6068 allocated from the heap and must be freed by the caller, or NULL if 6121 null). Value is the font name which is allocated from the heap and
6069 we can get no information about the font name of C. It is assured 6122 must be freed by the caller, or NULL if we can get no information
6070 that we always get some information for a single byte 6123 about the font name of C. It is assured that we always get some
6071 character. */ 6124 information for a single byte character. */
6072 6125
6073static char * 6126static char *
6074choose_face_font (f, attrs, fontset, c) 6127choose_face_font (f, attrs, face, c)
6075 struct frame *f; 6128 struct frame *f;
6076 Lisp_Object *attrs; 6129 Lisp_Object *attrs;
6077 int fontset, c; 6130 struct face *face;
6131 int c;
6078{ 6132{
6079 Lisp_Object pattern; 6133 Lisp_Object val;
6134 Lisp_Object pattern, family, registry;
6135 Lisp_Object new_attrs[LFACE_VECTOR_SIZE];
6080 char *font_name = NULL; 6136 char *font_name = NULL;
6081 struct font_name *fonts; 6137 struct font_name *fonts;
6082 int nfonts, width_ratio; 6138 int nfonts, width_ratio;
6083 6139
6084 /* Get (foundry and) family name and registry (and encoding) name of 6140 /* Get font spec of a font for C. */
6085 a font for C. */ 6141 pattern = fontset_font_pattern (f, face, c);
6086 pattern = fontset_font_pattern (f, fontset, c);
6087 if (NILP (pattern)) 6142 if (NILP (pattern))
6088 { 6143 {
6089 xassert (!SINGLE_BYTE_CHAR_P (c)); 6144 xassert (!SINGLE_BYTE_CHAR_P (c));
@@ -6094,13 +6149,34 @@ choose_face_font (f, attrs, fontset, c)
6094 if (STRINGP (pattern)) 6149 if (STRINGP (pattern))
6095 return xstrdup (XSTRING (pattern)->data); 6150 return xstrdup (XSTRING (pattern)->data);
6096 6151
6152 family = AREF (pattern, FONT_SPEC_FAMILY_INDEX);
6153 registry = AREF (pattern, FONT_SPEC_REGISTRY_INDEX);
6154
6155 bcopy (attrs, new_attrs, sizeof (Lisp_Object) * LFACE_VECTOR_SIZE);
6156
6157#if 0
6158 /* This doesn't work well for the moment. */
6159 if (! NILP (AREF (pattern, FONT_SPEC_WEIGHT_INDEX)))
6160 new_attrs[LFACE_WEIGHT_INDEX] = AREF (pattern, FONT_SPEC_WEIGHT_INDEX);
6161 if (! NILP (AREF (pattern, FONT_SPEC_SLANT_INDEX)))
6162 new_attrs[LFACE_SLANT_INDEX] = AREF (pattern, FONT_SPEC_SLANT_INDEX);
6163 if (! NILP (AREF (pattern, FONT_SPEC_SWIDTH_INDEX)))
6164 new_attrs[LFACE_SWIDTH_INDEX] = AREF (pattern, FONT_SPEC_SWIDTH_INDEX);
6165#endif
6166
6167 /* If C is an ASCII character, family name in ATTRS has higher
6168 priority than what specified in the fontset. */
6169 if (STRINGP (attrs[LFACE_FAMILY_INDEX])
6170 && ASCII_CHAR_P (c))
6171 family = Qnil;
6172
6097 /* Get a list of fonts matching that pattern and choose the 6173 /* Get a list of fonts matching that pattern and choose the
6098 best match for the specified face attributes from it. */ 6174 best match for the specified face attributes from it. */
6099 nfonts = try_font_list (f, attrs, XCAR (pattern), XCDR (pattern), &fonts); 6175 nfonts = try_font_list (f, new_attrs, family, registry, &fonts);
6100 width_ratio = (SINGLE_BYTE_CHAR_P (c) 6176 width_ratio = (ASCII_CHAR_P (c)
6101 ? 1 6177 ? 1
6102 : CHARSET_WIDTH (CHAR_CHARSET (c))); 6178 : CHAR_WIDTH (c));
6103 font_name = best_matching_font (f, attrs, fonts, nfonts, width_ratio); 6179 font_name = best_matching_font (f, new_attrs, fonts, nfonts, width_ratio);
6104 return font_name; 6180 return font_name;
6105} 6181}
6106 6182
@@ -6377,10 +6453,10 @@ realize_x_face (cache, attrs, c, base_face)
6377 6453
6378 f = cache->f; 6454 f = cache->f;
6379 6455
6380 /* If C is a multibyte character, we share all face attirbutes with 6456 /* If C is a non-ASCII character, we share all face attirbutes with
6381 BASE_FACE including the realized fontset. But, we must load a 6457 BASE_FACE including the realized fontset. But, we must load a
6382 different font. */ 6458 different font. */
6383 if (!SINGLE_BYTE_CHAR_P (c)) 6459 if (! ASCII_CHAR_P (c))
6384 { 6460 {
6385 bcopy (base_face, face, sizeof *face); 6461 bcopy (base_face, face, sizeof *face);
6386 face->gc = 0; 6462 face->gc = 0;
@@ -6435,7 +6511,7 @@ realize_x_face (cache, attrs, c, base_face)
6435 if (STRINGP (attrs[LFACE_FONT_INDEX])) 6511 if (STRINGP (attrs[LFACE_FONT_INDEX]))
6436 { 6512 {
6437 struct font_info *font_info = 6513 struct font_info *font_info =
6438 FS_LOAD_FONT (f, 0, XSTRING (attrs[LFACE_FONT_INDEX])->data, -1); 6514 FS_LOAD_FONT (f, XSTRING (attrs[LFACE_FONT_INDEX])->data);
6439 if (font_info) 6515 if (font_info)
6440 face->font = font_info->font; 6516 face->font = font_info->font;
6441 } 6517 }