comparison src/ftfont.c @ 97908:464a00cca3cf

(ftfont_spec_pattern): Don't create a charset of the representative chars of the script is a vector. (ftfont_list): Handle the case the representative chars of the script is a vector.
author Kenichi Handa <handa@m17n.org>
date Mon, 01 Sep 2008 02:46:23 +0000
parents f1d6d439f960
children 809fdcf44233
comparison
equal deleted inserted replaced
97907:3a2d65dc9abc 97908:464a00cca3cf
671 671
672 if (! NILP (script) && ! charset) 672 if (! NILP (script) && ! charset)
673 { 673 {
674 Lisp_Object chars = assq_no_quit (script, Vscript_representative_chars); 674 Lisp_Object chars = assq_no_quit (script, Vscript_representative_chars);
675 675
676 if (CONSP (chars)) 676 if (CONSP (chars) && CONSP (CDR (chars)))
677 { 677 {
678 charset = FcCharSetCreate (); 678 charset = FcCharSetCreate ();
679 if (! charset) 679 if (! charset)
680 goto err; 680 goto err;
681 for (chars = XCDR (chars); CONSP (chars); chars = XCDR (chars)) 681 for (chars = XCDR (chars); CONSP (chars); chars = XCDR (chars))
742 Lisp_Object val = Qnil, family; 742 Lisp_Object val = Qnil, family;
743 int i; 743 int i;
744 FcPattern *pattern; 744 FcPattern *pattern;
745 FcFontSet *fontset = NULL; 745 FcFontSet *fontset = NULL;
746 FcObjectSet *objset = NULL; 746 FcObjectSet *objset = NULL;
747 FcCharSet *charset;
748 Lisp_Object chars = Qnil;
749 FcResult result;
747 char otlayout[15]; /* For "otlayout:XXXX" */ 750 char otlayout[15]; /* For "otlayout:XXXX" */
748 struct OpenTypeSpec *otspec = NULL; 751 struct OpenTypeSpec *otspec = NULL;
749 int spacing = -1; 752 int spacing = -1;
750 753
751 if (! fc_initialized) 754 if (! fc_initialized)
755 } 758 }
756 759
757 pattern = ftfont_spec_pattern (spec, otlayout, &otspec); 760 pattern = ftfont_spec_pattern (spec, otlayout, &otspec);
758 if (! pattern) 761 if (! pattern)
759 return Qnil; 762 return Qnil;
763 if (FcPatternGetCharSet (pattern, FC_CHARSET, 0, &charset) != FcResultMatch)
764 {
765 val = assq_no_quit (QCscript, AREF (spec, FONT_EXTRA_INDEX));
766 if (! NILP (val))
767 {
768 val = assq_no_quit (XCDR (val), Vscript_representative_chars);
769 if (CONSP (val) && VECTORP (XCDR (val)))
770 chars = XCDR (val);
771 }
772 val = Qnil;
773 }
760 if (INTEGERP (AREF (spec, FONT_SPACING_INDEX))) 774 if (INTEGERP (AREF (spec, FONT_SPACING_INDEX)))
761 spacing = XINT (AREF (spec, FONT_SPACING_INDEX)); 775 spacing = XINT (AREF (spec, FONT_SPACING_INDEX));
762 family = AREF (spec, FONT_FAMILY_INDEX); 776 family = AREF (spec, FONT_FAMILY_INDEX);
763 if (! NILP (family)) 777 if (! NILP (family))
764 { 778 {
784 FC_FONTFORMAT, 798 FC_FONTFORMAT,
785 #endif 799 #endif
786 NULL); 800 NULL);
787 if (! objset) 801 if (! objset)
788 goto err; 802 goto err;
803 if (! NILP (chars))
804 FcObjectSetAdd (objset, FC_CHARSET);
789 805
790 fontset = FcFontList (NULL, pattern, objset); 806 fontset = FcFontList (NULL, pattern, objset);
791 if (! fontset) 807 if (! fontset || fontset->nfont == 0)
792 goto err; 808 goto finish;
793 #if 0 809 #if 0
794 /* Need fix because this finds any fonts. */ 810 /* Need fix because this finds any fonts. */
795 if (fontset->nfont == 0 && ! NILP (family)) 811 if (fontset->nfont == 0 && ! NILP (family))
796 { 812 {
797 /* Try maching with configuration. For instance, the 813 /* Try maching with configuration. For instance, the
834 #ifdef FC_CAPABILITY 850 #ifdef FC_CAPABILITY
835 if (otlayout[0]) 851 if (otlayout[0])
836 { 852 {
837 FcChar8 *this; 853 FcChar8 *this;
838 854
839 if (FcPatternGetString (fontset->fonts[i], FC_CAPABILITY, 0, 855 if (FcPatternGetString (fontset->fonts[i], FC_CAPABILITY, 0, &this)
840 &this) != FcResultMatch 856 != FcResultMatch
841 || ! strstr ((char *) this, otlayout)) 857 || ! strstr ((char *) this, otlayout))
842 continue; 858 continue;
843 } 859 }
844 #endif /* FC_CAPABILITY */ 860 #endif /* FC_CAPABILITY */
845 #ifdef HAVE_LIBOTF 861 #ifdef HAVE_LIBOTF
863 otspec->features[1], 879 otspec->features[1],
864 otspec->nfeatures[1]) != 1) 880 otspec->nfeatures[1]) != 1)
865 continue; 881 continue;
866 } 882 }
867 #endif /* HAVE_LIBOTF */ 883 #endif /* HAVE_LIBOTF */
884 if (VECTORP (chars))
885 {
886 int j;
887
888 if (FcPatternGetCharSet (fontset->fonts[i], FC_CHARSET, 0, &charset)
889 != FcResultMatch)
890 continue;
891 for (j = 0; j < ASIZE (chars); j++)
892 if (NATNUMP (AREF (chars, j))
893 && FcCharSetHasChar (charset, XFASTINT (AREF (chars, j))))
894 break;
895 if (j == ASIZE (chars))
896 continue;
897 }
868 entity = ftfont_pattern_entity (fontset->fonts[i], 898 entity = ftfont_pattern_entity (fontset->fonts[i],
869 AREF (spec, FONT_EXTRA_INDEX)); 899 AREF (spec, FONT_EXTRA_INDEX));
870 if (! NILP (entity)) 900 if (! NILP (entity))
871 val = Fcons (entity, val); 901 val = Fcons (entity, val);
872 } 902 }
873 font_add_log ("ftfont-list", spec, val); 903 val = Fnreverse (val);
874 goto finish; 904 goto finish;
875 905
876 err: 906 err:
877 /* We come here because of unexpected error in fontconfig API call 907 /* We come here because of unexpected error in fontconfig API call
878 (usually insufficient memory). */ 908 (usually insufficient memory). */
879 val = Qnil; 909 val = Qnil;
880 910
881 finish: 911 finish:
912 font_add_log ("ftfont-list", spec, val);
882 if (objset) FcObjectSetDestroy (objset); 913 if (objset) FcObjectSetDestroy (objset);
883 if (fontset) FcFontSetDestroy (fontset); 914 if (fontset) FcFontSetDestroy (fontset);
884 if (pattern) FcPatternDestroy (pattern); 915 if (pattern) FcPatternDestroy (pattern);
885 return val; 916 return val;
886 } 917 }