diff options
| author | Kenichi Handa | 2009-07-08 03:49:31 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2009-07-08 03:49:31 +0000 |
| commit | 374bf7e4347e785727a992e2eca4ddacce9ced32 (patch) | |
| tree | e9eb844bfacf073ee8f6d8a609fc1a5eae2cb159 /src | |
| parent | 678bc1f5248f0cf513e2306555564881355a6825 (diff) | |
| download | emacs-374bf7e4347e785727a992e2eca4ddacce9ced32.tar.gz emacs-374bf7e4347e785727a992e2eca4ddacce9ced32.zip | |
(fontset_find_font): Fix the logic of handling
charset_matched.
(font_for_char): Delete unused var.
(generate_ascii_font_name): Delete it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/fontset.c | 88 |
2 files changed, 48 insertions, 45 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 94c71a92176..c39e73a39b3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2009-07-08 Kenichi Handa <handa@m17n.org> | 1 | 2009-07-08 Kenichi Handa <handa@m17n.org> |
| 2 | 2 | ||
| 3 | * fontset.c (fontset_find_font): Fix the logic of handling | ||
| 4 | charset_matched. | ||
| 5 | (font_for_char): Delete unused var. | ||
| 6 | (generate_ascii_font_name): Delete it. | ||
| 7 | |||
| 3 | * coding.h (JIS_TO_SJIS2): Fix the code range check. | 8 | * coding.h (JIS_TO_SJIS2): Fix the code range check. |
| 4 | 9 | ||
| 5 | * coding.c (detect_coding_sjis): Handle shift_jis-2004 correctly. | 10 | * coding.c (detect_coding_sjis): Handle shift_jis-2004 correctly. |
diff --git a/src/fontset.c b/src/fontset.c index d7e61d54408..20b7c1a2565 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -531,7 +531,7 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 531 | int id, fallback; | 531 | int id, fallback; |
| 532 | { | 532 | { |
| 533 | Lisp_Object vec, font_group; | 533 | Lisp_Object vec, font_group; |
| 534 | int i, charset_matched = -1, found_index; | 534 | int i, charset_matched = 0, found_index; |
| 535 | FRAME_PTR f = (FRAMEP (FONTSET_FRAME (fontset))) | 535 | FRAME_PTR f = (FRAMEP (FONTSET_FRAME (fontset))) |
| 536 | ? XFRAME (selected_frame) : XFRAME (FONTSET_FRAME (fontset)); | 536 | ? XFRAME (selected_frame) : XFRAME (FONTSET_FRAME (fontset)); |
| 537 | Lisp_Object rfont_def; | 537 | Lisp_Object rfont_def; |
| @@ -575,25 +575,46 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 575 | Lisp_Object font_def; | 575 | Lisp_Object font_def; |
| 576 | Lisp_Object font_entity, font_object; | 576 | Lisp_Object font_entity, font_object; |
| 577 | 577 | ||
| 578 | if (i == 0 && charset_matched >= 0) | 578 | if (i == 0) |
| 579 | { | 579 | { |
| 580 | /* Try the element matching with the charset ID at first. */ | 580 | /* Try the element matching with the charset ID at first. */ |
| 581 | rfont_def = AREF (vec, charset_matched); | ||
| 582 | found_index = charset_matched; | 581 | found_index = charset_matched; |
| 583 | charset_matched = -1; | 582 | if (charset_matched > 0) |
| 584 | i--; | 583 | { |
| 584 | charset_matched = - charset_matched; | ||
| 585 | i--; | ||
| 586 | } | ||
| 585 | } | 587 | } |
| 586 | else if (i != charset_matched) | 588 | else if (i != - charset_matched) |
| 587 | { | 589 | { |
| 588 | rfont_def = AREF (vec, i); | ||
| 589 | found_index = i; | 590 | found_index = i; |
| 590 | } | 591 | } |
| 591 | else | 592 | else |
| 592 | continue; | 593 | { |
| 594 | /* We have already tried this element and the followings | ||
| 595 | that have the same font specifications. So, skip them | ||
| 596 | all. */ | ||
| 597 | rfont_def = AREF (vec, i); | ||
| 598 | font_def = RFONT_DEF_FONT_DEF (rfont_def); | ||
| 599 | for (; i + 1 < ASIZE (vec); i++) | ||
| 600 | { | ||
| 601 | rfont_def = AREF (vec, i + 1); | ||
| 602 | if (NILP (rfont_def)) | ||
| 603 | break; | ||
| 604 | if (! EQ (RFONT_DEF_FONT_DEF (rfont_def), font_def)) | ||
| 605 | break; | ||
| 606 | } | ||
| 607 | continue; | ||
| 608 | } | ||
| 593 | 609 | ||
| 610 | rfont_def = AREF (vec, found_index); | ||
| 594 | if (NILP (rfont_def)) | 611 | if (NILP (rfont_def)) |
| 595 | /* This is a sign of not to try the other fonts. */ | 612 | { |
| 596 | return Qt; | 613 | if (charset_matched < 0) |
| 614 | continue; | ||
| 615 | /* This is a sign of not to try the other fonts. */ | ||
| 616 | return Qt; | ||
| 617 | } | ||
| 597 | if (INTEGERP (RFONT_DEF_FACE (rfont_def)) | 618 | if (INTEGERP (RFONT_DEF_FACE (rfont_def)) |
| 598 | && XINT (RFONT_DEF_FACE (rfont_def)) < 0) | 619 | && XINT (RFONT_DEF_FACE (rfont_def)) < 0) |
| 599 | /* We couldn't open this font last time. */ | 620 | /* We couldn't open this font last time. */ |
| @@ -640,16 +661,19 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 640 | /* Find a font already opened, maching with the current spec, | 661 | /* Find a font already opened, maching with the current spec, |
| 641 | and supporting C. */ | 662 | and supporting C. */ |
| 642 | font_def = RFONT_DEF_FONT_DEF (rfont_def); | 663 | font_def = RFONT_DEF_FONT_DEF (rfont_def); |
| 643 | for (i++; i < ASIZE (vec); i++) | 664 | for (; found_index + 1 < ASIZE (vec); found_index++) |
| 644 | { | 665 | { |
| 645 | rfont_def = AREF (vec, i); | 666 | rfont_def = AREF (vec, found_index + 1); |
| 646 | if (NILP (rfont_def)) | 667 | if (NILP (rfont_def)) |
| 647 | return Qt; | 668 | break; |
| 648 | if (! EQ (RFONT_DEF_FONT_DEF (rfont_def), font_def)) | 669 | if (! EQ (RFONT_DEF_FONT_DEF (rfont_def), font_def)) |
| 649 | break; | 670 | break; |
| 650 | font_object = RFONT_DEF_OBJECT (AREF (vec, i)); | 671 | font_object = RFONT_DEF_OBJECT (rfont_def); |
| 651 | if (! NILP (font_object) && font_has_char (f, font_object, c)) | 672 | if (! NILP (font_object) && font_has_char (f, font_object, c)) |
| 652 | goto found; | 673 | { |
| 674 | found_index++; | ||
| 675 | goto found; | ||
| 676 | } | ||
| 653 | } | 677 | } |
| 654 | 678 | ||
| 655 | /* Find a font-entity with the current spec and supporting C. */ | 679 | /* Find a font-entity with the current spec and supporting C. */ |
| @@ -666,24 +690,22 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 666 | Qnil); | 690 | Qnil); |
| 667 | if (NILP (font_object)) | 691 | if (NILP (font_object)) |
| 668 | continue; | 692 | continue; |
| 669 | found_index = i; | ||
| 670 | RFONT_DEF_NEW (rfont_def, font_def); | 693 | RFONT_DEF_NEW (rfont_def, font_def); |
| 671 | RFONT_DEF_SET_OBJECT (rfont_def, font_object); | 694 | RFONT_DEF_SET_OBJECT (rfont_def, font_object); |
| 672 | RFONT_DEF_SET_SCORE (rfont_def, RFONT_DEF_SCORE (rfont_def)); | 695 | RFONT_DEF_SET_SCORE (rfont_def, RFONT_DEF_SCORE (rfont_def)); |
| 673 | new_vec = Fmake_vector (make_number (ASIZE (vec) + 1), Qnil); | 696 | new_vec = Fmake_vector (make_number (ASIZE (vec) + 1), Qnil); |
| 674 | for (j = 0; j < i; j++) | 697 | found_index++; |
| 698 | for (j = 0; j < found_index; j++) | ||
| 675 | ASET (new_vec, j, AREF (vec, j)); | 699 | ASET (new_vec, j, AREF (vec, j)); |
| 676 | ASET (new_vec, j, rfont_def); | 700 | ASET (new_vec, j, rfont_def); |
| 677 | found_index = j; | ||
| 678 | for (j++; j < ASIZE (new_vec); j++) | 701 | for (j++; j < ASIZE (new_vec); j++) |
| 679 | ASET (new_vec, j, AREF (vec, j - 1)); | 702 | ASET (new_vec, j, AREF (vec, j - 1)); |
| 680 | XSETCDR (font_group, new_vec); | 703 | XSETCDR (font_group, new_vec); |
| 681 | vec = new_vec; | 704 | vec = new_vec; |
| 682 | goto found; | 705 | goto found; |
| 683 | } | 706 | } |
| 684 | 707 | if (i >= 0) | |
| 685 | /* No font of the current spec for C. Try the next spec. */ | 708 | i = found_index; |
| 686 | i--; | ||
| 687 | } | 709 | } |
| 688 | 710 | ||
| 689 | FONTSET_SET (fontset, make_number (c), make_number (0)); | 711 | FONTSET_SET (fontset, make_number (c), make_number (0)); |
| @@ -989,7 +1011,6 @@ font_for_char (face, c, pos, object) | |||
| 989 | Lisp_Object object; | 1011 | Lisp_Object object; |
| 990 | { | 1012 | { |
| 991 | Lisp_Object fontset, rfont_def, charset; | 1013 | Lisp_Object fontset, rfont_def, charset; |
| 992 | int face_id; | ||
| 993 | int id; | 1014 | int id; |
| 994 | 1015 | ||
| 995 | if (ASCII_CHAR_P (c)) | 1016 | if (ASCII_CHAR_P (c)) |
| @@ -1364,28 +1385,6 @@ accumulate_script_ranges (arg, range, val) | |||
| 1364 | } | 1385 | } |
| 1365 | 1386 | ||
| 1366 | 1387 | ||
| 1367 | /* Return an ASCII font name generated from fontset name NAME and | ||
| 1368 | font-spec ASCII_SPEC. NAME is a string conforming to XLFD. */ | ||
| 1369 | |||
| 1370 | static INLINE Lisp_Object | ||
| 1371 | generate_ascii_font_name (name, ascii_spec) | ||
| 1372 | Lisp_Object name, ascii_spec; | ||
| 1373 | { | ||
| 1374 | Lisp_Object font_spec = Ffont_spec (0, NULL); | ||
| 1375 | int i; | ||
| 1376 | char xlfd[256]; | ||
| 1377 | |||
| 1378 | if (font_parse_xlfd ((char *) SDATA (name), font_spec) < 0) | ||
| 1379 | error ("Not an XLFD font name: %s", SDATA (name)); | ||
| 1380 | for (i = FONT_FOUNDRY_INDEX; i < FONT_EXTRA_INDEX; i++) | ||
| 1381 | if (! NILP (AREF (ascii_spec, i))) | ||
| 1382 | ASET (font_spec, i, AREF (ascii_spec, i)); | ||
| 1383 | i = font_unparse_xlfd (font_spec, 0, xlfd, 256); | ||
| 1384 | if (i < 0) | ||
| 1385 | error ("Not an XLFD font name: %s", SDATA (name)); | ||
| 1386 | return make_unibyte_string (xlfd, i); | ||
| 1387 | } | ||
| 1388 | |||
| 1389 | /* Callback function for map_charset_chars in Fset_fontset_font. | 1388 | /* Callback function for map_charset_chars in Fset_fontset_font. |
| 1390 | ARG is a vector [ FONTSET FONT_DEF ADD ASCII SCRIPT_RANGE_LIST ]. | 1389 | ARG is a vector [ FONTSET FONT_DEF ADD ASCII SCRIPT_RANGE_LIST ]. |
| 1391 | 1390 | ||
| @@ -1770,7 +1769,6 @@ fontset_from_font (font_object) | |||
| 1770 | Lisp_Object registry = AREF (font_spec, FONT_REGISTRY_INDEX); | 1769 | Lisp_Object registry = AREF (font_spec, FONT_REGISTRY_INDEX); |
| 1771 | Lisp_Object fontset_spec, alias, name, fontset; | 1770 | Lisp_Object fontset_spec, alias, name, fontset; |
| 1772 | Lisp_Object val; | 1771 | Lisp_Object val; |
| 1773 | int i; | ||
| 1774 | 1772 | ||
| 1775 | val = assoc_no_quit (font_spec, auto_fontset_alist); | 1773 | val = assoc_no_quit (font_spec, auto_fontset_alist); |
| 1776 | if (CONSP (val)) | 1774 | if (CONSP (val)) |