diff options
| author | Kenichi Handa | 2006-07-03 00:48:34 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2006-07-03 00:48:34 +0000 |
| commit | fe5ddfbcd333f4437ae6ae65830dae36ae69f2b5 (patch) | |
| tree | f0e099e761a8fb5db85e1af11435f2262a17eabc /src | |
| parent | 64c9fe5436b86e3b6981698fb2b5f73ae7ad4564 (diff) | |
| download | emacs-fe5ddfbcd333f4437ae6ae65830dae36ae69f2b5.tar.gz emacs-fe5ddfbcd333f4437ae6ae65830dae36ae69f2b5.zip | |
(font_find_for_lface): Code optimized.
Diffstat (limited to 'src')
| -rw-r--r-- | src/font.c | 80 |
1 files changed, 37 insertions, 43 deletions
diff --git a/src/font.c b/src/font.c index 5540702b562..d423b1804c7 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -2426,60 +2426,54 @@ font_find_for_lface (f, lface, spec) | |||
| 2426 | Lisp_Object frame, entities; | 2426 | Lisp_Object frame, entities; |
| 2427 | int i; | 2427 | int i; |
| 2428 | 2428 | ||
| 2429 | if (NILP (spec)) | 2429 | XSETFRAME (frame, f); |
| 2430 | for (i = 0; i < FONT_SPEC_MAX; i++) | ||
| 2431 | ASET (scratch_font_spec, i, Qnil); | ||
| 2432 | else | ||
| 2433 | for (i = 0; i < FONT_SPEC_MAX; i++) | ||
| 2434 | ASET (scratch_font_spec, i, AREF (spec, i)); | ||
| 2435 | |||
| 2436 | if (NILP (AREF (scratch_font_spec, FONT_FAMILY_INDEX)) | ||
| 2437 | && ! NILP (lface[LFACE_FAMILY_INDEX])) | ||
| 2438 | font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil, | ||
| 2439 | scratch_font_spec); | ||
| 2440 | if (NILP (AREF (scratch_font_spec, FONT_REGISTRY_INDEX))) | ||
| 2441 | ASET (scratch_font_spec, FONT_REGISTRY_INDEX, intern ("iso8859-1")); | ||
| 2442 | 2430 | ||
| 2443 | if (NILP (AREF (scratch_font_spec, FONT_SIZE_INDEX)) | 2431 | if (NILP (spec)) |
| 2444 | && ! NILP (lface[LFACE_HEIGHT_INDEX])) | ||
| 2445 | { | 2432 | { |
| 2446 | double pt = XINT (lface[LFACE_HEIGHT_INDEX]); | 2433 | for (i = 0; i < FONT_SPEC_MAX; i++) |
| 2447 | int pixel_size = POINT_TO_PIXEL (pt / 10, f->resy); | 2434 | ASET (scratch_font_spec, i, Qnil); |
| 2448 | 2435 | ASET (scratch_font_spec, FONT_REGISTRY_INDEX, Qiso8859_1); | |
| 2449 | ASET (scratch_font_spec, FONT_SIZE_INDEX, make_number (pixel_size)); | ||
| 2450 | } | ||
| 2451 | 2436 | ||
| 2452 | XSETFRAME (frame, f); | 2437 | if (! NILP (lface[LFACE_FAMILY_INDEX])) |
| 2453 | entities = font_list_entities (frame, scratch_font_spec); | 2438 | font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil, |
| 2454 | while (ASIZE (entities) == 0) | 2439 | scratch_font_spec); |
| 2455 | { | 2440 | entities = font_list_entities (frame, scratch_font_spec); |
| 2456 | if (! NILP (AREF (scratch_font_spec, FONT_SIZE_INDEX)) | 2441 | while (ASIZE (entities) == 0) |
| 2457 | && (NILP (spec) || NILP (AREF (spec, FONT_SIZE_INDEX)))) | ||
| 2458 | { | ||
| 2459 | ASET (scratch_font_spec, FONT_SIZE_INDEX, Qnil); | ||
| 2460 | entities = font_list_entities (frame, scratch_font_spec); | ||
| 2461 | } | ||
| 2462 | else if (! NILP (AREF (scratch_font_spec, FONT_FOUNDRY_INDEX)) | ||
| 2463 | && (NILP (spec) || NILP (AREF (spec, FONT_FOUNDRY_INDEX)))) | ||
| 2464 | { | ||
| 2465 | ASET (scratch_font_spec, FONT_FOUNDRY_INDEX, Qnil); | ||
| 2466 | entities = font_list_entities (frame, scratch_font_spec); | ||
| 2467 | } | ||
| 2468 | else if (! NILP (AREF (scratch_font_spec, FONT_FAMILY_INDEX)) | ||
| 2469 | && (NILP (spec) || NILP (AREF (spec, FONT_FAMILY_INDEX)))) | ||
| 2470 | { | 2442 | { |
| 2471 | ASET (scratch_font_spec, FONT_FAMILY_INDEX, Qnil); | 2443 | /* Try without FOUNDRY or FAMILY. */ |
| 2472 | entities = font_list_entities (frame, scratch_font_spec); | 2444 | if (! NILP (AREF (scratch_font_spec, FONT_FOUNDRY_INDEX))) |
| 2445 | { | ||
| 2446 | ASET (scratch_font_spec, FONT_FOUNDRY_INDEX, Qnil); | ||
| 2447 | entities = font_list_entities (frame, scratch_font_spec); | ||
| 2448 | } | ||
| 2449 | else if (! NILP (AREF (scratch_font_spec, FONT_FAMILY_INDEX))) | ||
| 2450 | { | ||
| 2451 | ASET (scratch_font_spec, FONT_FAMILY_INDEX, Qnil); | ||
| 2452 | entities = font_list_entities (frame, scratch_font_spec); | ||
| 2453 | } | ||
| 2454 | else | ||
| 2455 | break; | ||
| 2473 | } | 2456 | } |
| 2474 | else | 2457 | } |
| 2475 | return Qnil; | 2458 | else |
| 2459 | { | ||
| 2460 | for (i = 0; i < FONT_SPEC_MAX; i++) | ||
| 2461 | ASET (scratch_font_spec, i, AREF (spec, i)); | ||
| 2462 | if (NILP (AREF (spec, FONT_REGISTRY_INDEX))) | ||
| 2463 | ASET (scratch_font_spec, FONT_REGISTRY_INDEX, Qiso8859_1); | ||
| 2464 | entities = font_list_entities (frame, scratch_font_spec); | ||
| 2476 | } | 2465 | } |
| 2477 | 2466 | ||
| 2467 | if (ASIZE (entities) == 0) | ||
| 2468 | return Qnil; | ||
| 2478 | if (ASIZE (entities) > 1) | 2469 | if (ASIZE (entities) > 1) |
| 2479 | { | 2470 | { |
| 2471 | /* Sort fonts by properties specified in LFACE. */ | ||
| 2480 | Lisp_Object prefer = scratch_font_prefer; | 2472 | Lisp_Object prefer = scratch_font_prefer; |
| 2481 | double pt; | 2473 | double pt; |
| 2482 | 2474 | ||
| 2475 | if (! NILP (lface[LFACE_FAMILY_INDEX])) | ||
| 2476 | font_merge_old_spec (Qnil, lface[LFACE_FAMILY_INDEX], Qnil, prefer); | ||
| 2483 | ASET (prefer, FONT_WEIGHT_INDEX, | 2477 | ASET (prefer, FONT_WEIGHT_INDEX, |
| 2484 | font_prop_validate_style (FONT_WEIGHT_INDEX, QCweight, | 2478 | font_prop_validate_style (FONT_WEIGHT_INDEX, QCweight, |
| 2485 | lface[LFACE_WEIGHT_INDEX])); | 2479 | lface[LFACE_WEIGHT_INDEX])); |
| @@ -3259,7 +3253,7 @@ syms_of_font () | |||
| 3259 | sort_shift_bits[FONT_FOUNDRY_INDEX] = 29; | 3253 | sort_shift_bits[FONT_FOUNDRY_INDEX] = 29; |
| 3260 | sort_shift_bits[FONT_FAMILY_INDEX] = 30; | 3254 | sort_shift_bits[FONT_FAMILY_INDEX] = 30; |
| 3261 | sort_shift_bits[FONT_REGISTRY_INDEX] = 31; | 3255 | sort_shift_bits[FONT_REGISTRY_INDEX] = 31; |
| 3262 | /* Note that sort_shift_bits[FONT_SLANT_TYPE] is never used. */ | 3256 | /* Note that sort_shift_bits[FONT_TYPE_INDEX] is never used. */ |
| 3263 | 3257 | ||
| 3264 | staticpro (&font_style_table); | 3258 | staticpro (&font_style_table); |
| 3265 | font_style_table = Fmake_vector (make_number (3), Qnil); | 3259 | font_style_table = Fmake_vector (make_number (3), Qnil); |