Mercurial > emacs
comparison src/fontset.c @ 17999:5e325c8057c8
(fs_load_font): Before using a fontset, be sure to
load the ASCII font of the fontset. Size and height of a fontset
is set to the same as those of the ASCII font of the fontset. Use
macro FONT_ENCODING_NOT_DECIDED.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 28 May 1997 04:36:21 +0000 |
parents | 46f958bf3348 |
children | a3f50c636d81 |
comparison
equal
deleted
inserted
replaced
17998:9b98ddd07fe5 | 17999:5e325c8057c8 |
---|---|
147 | 147 |
148 if (!fontname) | 148 if (!fontname) |
149 /* No way to get fontname. */ | 149 /* No way to get fontname. */ |
150 return 0; | 150 return 0; |
151 | 151 |
152 /* If a fontset is specified and we have already loaded some fonts | 152 /* If CHARSET is not ASCII and FONTSET is specified, we must load a |
153 in the fontset, we need a font of appropriate size to be used | 153 font of appropriate size to be used with other fonts in this |
154 with the fonts. */ | 154 fontset. */ |
155 if (fontsetp && fontsetp->size) | 155 if (charset != CHARSET_ASCII && fontsetp) |
156 size = fontsetp->size * CHARSET_WIDTH (charset); | 156 { |
157 /* If we have not yet loaded ASCII font of FONTSET, we must load | |
158 it now to decided the size and height of this fontset. */ | |
159 if (fontsetp->size == 0) | |
160 { | |
161 fontp = fs_load_font (f, font_table, CHARSET_ASCII, 0, fontset); | |
162 if (!fontp) | |
163 /* Any fontset should contain avairable ASCII. */ | |
164 return 0; | |
165 } | |
166 /* Now we have surely decided the size of this fontset. */ | |
167 size = fontsetp->size * CHARSET_WIDTH (charset); | |
168 } | |
157 | 169 |
158 fontp = (*load_font_func) (f, fontname, size); | 170 fontp = (*load_font_func) (f, fontname, size); |
159 | 171 |
160 if (!fontp) | 172 if (!fontp) |
161 { | 173 { |
166 | 178 |
167 /* Fill in fields (CHARSET, ENCODING, and FONT_ENCODER) which are | 179 /* Fill in fields (CHARSET, ENCODING, and FONT_ENCODER) which are |
168 not set by (*load_font_func). */ | 180 not set by (*load_font_func). */ |
169 fontp->charset = charset; | 181 fontp->charset = charset; |
170 | 182 |
171 if (fontp->encoding[1] != 4) | 183 if (fontp->encoding[1] != FONT_ENCODING_NOT_DECIDED) |
172 { | 184 { |
173 /* The font itself tells which code points to be used. Use this | 185 /* The font itself tells which code points to be used. Use this |
174 encoding for all other charsets. */ | 186 encoding for all other charsets. */ |
175 int i; | 187 int i; |
176 | 188 |
223 setup_ccl_program (fontp->font_encoder, XCONS (elt)->cdr); | 235 setup_ccl_program (fontp->font_encoder, XCONS (elt)->cdr); |
224 break; | 236 break; |
225 } | 237 } |
226 } | 238 } |
227 | 239 |
240 /* If FONTSET is specified, setup various fields of it. */ | |
228 if (fontsetp) | 241 if (fontsetp) |
229 { | 242 { |
230 fontsetp->font_indexes[charset] = fontp->font_idx; | 243 fontsetp->font_indexes[charset] = fontp->font_idx; |
231 if (fontsetp->size == 0) | 244 if (charset == CHARSET_ASCII) |
232 fontsetp->size = fontp->size / CHARSET_WIDTH (charset); | 245 { |
233 | 246 /* Decide or change the size and height of this fontset. */ |
234 if (charset == CHARSET_ASCII | 247 if (fontsetp->size == 0) |
235 && fontsetp->size != fontp->size) | |
236 { | |
237 /* When loading ASCII font of the different size from the | |
238 size of FONTSET, we have to update the size of FONTSET. | |
239 Since changing the size of FONTSET may make some fonts | |
240 already loaded inappropriate to be used in FONTSET, we | |
241 must delete the record of such fonts. In that case, we | |
242 also have to calculate the height of FONTSET from the | |
243 remaining fonts. */ | |
244 int i; | |
245 | |
246 fontsetp->size = fontp->size; | |
247 fontsetp->height = fontp->height; | |
248 for (i = CHARSET_ASCII + 1; i <= MAX_CHARSET; i++) | |
249 { | 248 { |
250 font_idx = fontsetp->font_indexes[i]; | 249 fontsetp->size = fontp->size; |
251 if (font_idx >= 0) | 250 fontsetp->height = fontp->height; |
251 } | |
252 else if (fontsetp->size != fontp->size | |
253 || fontsetp->height != fontp->height) | |
254 { | |
255 /* When loading ASCII font of the different size from | |
256 the size of FONTSET, we have to update the size of | |
257 FONTSET. Since changing the size of FONTSET may make | |
258 some fonts already loaded inappropriate to be used in | |
259 FONTSET, we must delete the record of such fonts. In | |
260 that case, we also have to calculate the height of | |
261 FONTSET from the remaining fonts. */ | |
262 int i; | |
263 | |
264 fontsetp->size = fontp->size; | |
265 fontsetp->height = fontp->height; | |
266 for (i = CHARSET_ASCII + 1; i <= MAX_CHARSET; i++) | |
252 { | 267 { |
253 struct font_info *fontp2 = font_table + font_idx; | 268 font_idx = fontsetp->font_indexes[i]; |
254 | 269 if (font_idx >= 0) |
255 if (fontp2->size != fontp->size * CHARSET_WIDTH (i)) | 270 { |
256 fontsetp->font_indexes[i] = FONT_NOT_OPENED; | 271 struct font_info *fontp2 = font_table + font_idx; |
257 /* The following code should be disabled until Emacs | 272 |
258 supports variable height lines. */ | 273 if (fontp2->size != fontp->size * CHARSET_WIDTH (i)) |
274 fontsetp->font_indexes[i] = FONT_NOT_OPENED; | |
275 /* The following code should be disabled until | |
276 Emacs supports variable height lines. */ | |
259 #if 0 | 277 #if 0 |
260 else if (fontsetp->height < fontp->height) | 278 else if (fontsetp->height < fontp->height) |
261 fontsetp->height = fontp->height; | 279 fontsetp->height = fontp->height; |
262 #endif | 280 #endif |
281 } | |
263 } | 282 } |
264 } | 283 } |
265 } | 284 } |
266 else if (fontsetp->height < fontp->height) | |
267 fontsetp->height = fontp->height; | |
268 } | 285 } |
269 | 286 |
270 return fontp; | 287 return fontp; |
271 } | 288 } |
272 | 289 |