comparison src/xterm.c @ 8291:9c6ddd14996b

(struct font_info): New field full_name. (x_new_font): Record, and return, the full name of the font.
author Richard M. Stallman <rms@gnu.org>
date Tue, 19 Jul 1994 23:54:02 +0000
parents 4cde734c20e8
children 525e990ca9d2
comparison
equal deleted inserted replaced
8290:f95e050e272f 8291:9c6ddd14996b
5074 5074
5075 struct font_info 5075 struct font_info
5076 { 5076 {
5077 XFontStruct *font; 5077 XFontStruct *font;
5078 char *name; 5078 char *name;
5079 char *full_name;
5079 }; 5080 };
5080 5081
5081 /* A table of all the fonts we have already loaded. */ 5082 /* A table of all the fonts we have already loaded. */
5082 static struct font_info *x_font_table; 5083 static struct font_info *x_font_table;
5083 5084
5086 5087
5087 /* The number of fonts actually stored in x_font_table. 5088 /* The number of fonts actually stored in x_font_table.
5088 x_font_table[n] is used and valid iff 0 <= n < n_fonts. 5089 x_font_table[n] is used and valid iff 0 <= n < n_fonts.
5089 0 <= n_fonts <= x_font_table_size. */ 5090 0 <= n_fonts <= x_font_table_size. */
5090 static int n_fonts; 5091 static int n_fonts;
5092
5093 /* Give frame F the font named FONTNAME as its default font, and
5094 return the full name of that font. FONTNAME may be a wildcard
5095 pattern; in that case, we choose some font that fits the pattern.
5096 The return value shows which font we chose. */
5091 5097
5092 Lisp_Object 5098 Lisp_Object
5093 x_new_font (f, fontname) 5099 x_new_font (f, fontname)
5094 struct frame *f; 5100 struct frame *f;
5095 register char *fontname; 5101 register char *fontname;
5119 { 5125 {
5120 int i, j; 5126 int i, j;
5121 5127
5122 for (i = 0; i < n_fonts; i++) 5128 for (i = 0; i < n_fonts; i++)
5123 for (j = 0; j < n_matching_fonts; j++) 5129 for (j = 0; j < n_matching_fonts; j++)
5124 if (!strcmp (x_font_table[i].name, font_names[j])) 5130 if (!strcmp (x_font_table[i].name, font_names[j])
5131 || !strcmp (x_font_table[i].full_name, font_names[j]))
5125 { 5132 {
5126 already_loaded = i; 5133 already_loaded = i;
5127 fontname = font_names[j]; 5134 fontname = x_font_table[i].full_name;
5128 goto found_font; 5135 goto found_font;
5129 } 5136 }
5130 } 5137 }
5131 found_font: 5138 found_font:
5132 5139
5136 5143
5137 /* Otherwise, load the font and add it to the table. */ 5144 /* Otherwise, load the font and add it to the table. */
5138 else 5145 else
5139 { 5146 {
5140 int i; 5147 int i;
5148 char *full_name;
5141 XFontStruct *font; 5149 XFontStruct *font;
5142 5150
5143 /* Try to find a character-cell font in the list. */ 5151 /* Try to find a character-cell font in the list. */
5144 #if 0 5152 #if 0
5145 /* A laudable goal, but this isn't how to do it. */ 5153 /* A laudable goal, but this isn't how to do it. */
5179 = (struct font_info *) xrealloc (x_font_table, 5187 = (struct font_info *) xrealloc (x_font_table,
5180 (x_font_table_size 5188 (x_font_table_size
5181 * sizeof (x_font_table[0]))); 5189 * sizeof (x_font_table[0])));
5182 } 5190 }
5183 5191
5192 /* Try to get the full name of FONT. Put it in full_name. */
5193 full_name = 0;
5194 for (i = 0; i < font->n_properties; i++)
5195 {
5196 char *atom
5197 = XGetAtomName (x_current_display, font->properties[i].name);
5198 if (!strcmp (atom, "FONT"))
5199 full_name = XGetAtomName (x_current_display,
5200 (Atom) (font->properties[i].card32));
5201 XFree (atom);
5202 }
5203
5184 x_font_table[n_fonts].name = (char *) xmalloc (strlen (fontname) + 1); 5204 x_font_table[n_fonts].name = (char *) xmalloc (strlen (fontname) + 1);
5185 bcopy (fontname, x_font_table[n_fonts].name, strlen (fontname) + 1); 5205 bcopy (fontname, x_font_table[n_fonts].name, strlen (fontname) + 1);
5206 if (full_name != 0)
5207 x_font_table[n_fonts].full_name = full_name;
5208 else
5209 x_font_table[n_fonts].full_name = x_font_table[n_fonts].name;
5186 f->display.x->font = x_font_table[n_fonts++].font = font; 5210 f->display.x->font = x_font_table[n_fonts++].font = font;
5211
5212 fontname = full_name;
5187 } 5213 }
5188 5214
5189 /* Now make the frame display the given font. */ 5215 /* Now make the frame display the given font. */
5190 if (FRAME_X_WINDOW (f) != 0) 5216 if (FRAME_X_WINDOW (f) != 0)
5191 { 5217 {