Mercurial > emacs
comparison src/ftfont.c @ 96076:bd3f48456ac7
(ftfont_pattern_entity): New arg extra. Caller changed.
(ftfont_spec_pattern): Don't check QCfc_unknown_spec and QCname.
(ftfont_list) [FC_FONTFORMAT]: Include FC_FONTFORMAT in objset.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 19 Jun 2008 00:42:11 +0000 |
parents | dc8b6f0d85e8 |
children | 5ee216cdf0e3 |
comparison
equal
deleted
inserted
replaced
96075:3376493a3ad4 | 96076:bd3f48456ac7 |
---|---|
66 int maybe_otf; /* Flag to tell if this may be OTF or not. */ | 66 int maybe_otf; /* Flag to tell if this may be OTF or not. */ |
67 OTF *otf; | 67 OTF *otf; |
68 #endif /* HAVE_LIBOTF */ | 68 #endif /* HAVE_LIBOTF */ |
69 }; | 69 }; |
70 | 70 |
71 static Lisp_Object ftfont_pattern_entity P_ ((FcPattern *, Lisp_Object, int)); | 71 static Lisp_Object ftfont_pattern_entity P_ ((FcPattern *, Lisp_Object, |
72 Lisp_Object, int)); | |
72 | 73 |
73 static Lisp_Object ftfont_resolve_generic_family P_ ((Lisp_Object)); | 74 static Lisp_Object ftfont_resolve_generic_family P_ ((Lisp_Object)); |
74 Lisp_Object ftfont_font_format P_ ((FcPattern *)); | 75 Lisp_Object ftfont_font_format P_ ((FcPattern *)); |
75 | 76 |
76 #define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM)) | 77 #define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM)) |
126 }; | 127 }; |
127 | 128 |
128 extern Lisp_Object Qc, Qm, Qp, Qd; | 129 extern Lisp_Object Qc, Qm, Qp, Qd; |
129 | 130 |
130 static Lisp_Object | 131 static Lisp_Object |
131 ftfont_pattern_entity (p, registry, fc_charset_idx) | 132 ftfont_pattern_entity (p, registry, extra, fc_charset_idx) |
132 FcPattern *p; | 133 FcPattern *p; |
133 Lisp_Object registry; | 134 Lisp_Object registry, extra; |
134 int fc_charset_idx; | 135 int fc_charset_idx; |
135 { | 136 { |
136 Lisp_Object entity; | 137 Lisp_Object entity; |
137 char *file, *str; | 138 char *file, *str; |
138 int numeric; | 139 int numeric; |
179 } | 180 } |
180 if (FcPatternGetBool (p, FC_SCALABLE, 0, &b) == FcResultMatch | 181 if (FcPatternGetBool (p, FC_SCALABLE, 0, &b) == FcResultMatch |
181 && b == FcTrue) | 182 && b == FcTrue) |
182 ASET (entity, FONT_AVGWIDTH_INDEX, make_number (0)); | 183 ASET (entity, FONT_AVGWIDTH_INDEX, make_number (0)); |
183 | 184 |
185 ASET (entity, FONT_EXTRA_INDEX, Fcopy_sequence (extra)); | |
184 font_put_extra (entity, QCfont_entity, | 186 font_put_extra (entity, QCfont_entity, |
185 Fcons (make_unibyte_string ((char *) file, | 187 Fcons (make_unibyte_string ((char *) file, |
186 strlen ((char *) file)), | 188 strlen ((char *) file)), |
187 make_number (fc_charset_idx))); | 189 make_number (fc_charset_idx))); |
188 return entity; | 190 return entity; |
467 FcCharSet *charset = NULL; | 469 FcCharSet *charset = NULL; |
468 FcLangSet *langset = NULL; | 470 FcLangSet *langset = NULL; |
469 int n; | 471 int n; |
470 int dpi = -1; | 472 int dpi = -1; |
471 int scalable = -1; | 473 int scalable = -1; |
472 Lisp_Object name = Qnil; | |
473 Lisp_Object script = Qnil; | 474 Lisp_Object script = Qnil; |
474 Lisp_Object registry; | 475 Lisp_Object registry; |
475 | 476 |
476 if (! NILP (AREF (spec, FONT_ADSTYLE_INDEX)) | 477 if (! NILP (AREF (spec, FONT_ADSTYLE_INDEX)) |
477 && SBYTES (SYMBOL_NAME (AREF (spec, FONT_ADSTYLE_INDEX))) > 0) | 478 && SBYTES (SYMBOL_NAME (AREF (spec, FONT_ADSTYLE_INDEX))) > 0) |
510 Lisp_Object key, val; | 511 Lisp_Object key, val; |
511 | 512 |
512 key = XCAR (XCAR (extra)), val = XCDR (XCAR (extra)); | 513 key = XCAR (XCAR (extra)), val = XCDR (XCAR (extra)); |
513 if (EQ (key, QCdpi)) | 514 if (EQ (key, QCdpi)) |
514 dpi = XINT (val); | 515 dpi = XINT (val); |
515 else if (EQ (key, QCfc_unknown_spec)) | |
516 name = val; | |
517 else if (EQ (key, QClang)) | 516 else if (EQ (key, QClang)) |
518 { | 517 { |
519 langset = FcLangSetCreate (); | 518 langset = FcLangSetCreate (); |
520 if (! langset) | 519 if (! langset) |
521 goto err; | 520 goto err; |
528 for (; CONSP (val); val = XCDR (val)) | 527 for (; CONSP (val); val = XCDR (val)) |
529 if (SYMBOLP (XCAR (val)) | 528 if (SYMBOLP (XCAR (val)) |
530 && ! FcLangSetAdd (langset, SYMBOL_FcChar8 (XCAR (val)))) | 529 && ! FcLangSetAdd (langset, SYMBOL_FcChar8 (XCAR (val)))) |
531 goto err; | 530 goto err; |
532 } | 531 } |
533 else if (EQ (key, QCname)) | |
534 name = val; | |
535 else if (EQ (key, QCotf)) | 532 else if (EQ (key, QCotf)) |
536 { | 533 { |
537 *otspec = ftfont_get_open_type_spec (val); | 534 *otspec = ftfont_get_open_type_spec (val); |
538 if (! *otspec) | 535 if (! *otspec) |
539 return NULL; | 536 return NULL; |
561 && ! FcCharSetAddChar (charset, XUINT (XCAR (chars)))) | 558 && ! FcCharSetAddChar (charset, XUINT (XCAR (chars)))) |
562 goto err; | 559 goto err; |
563 } | 560 } |
564 } | 561 } |
565 | 562 |
566 pattern = NILP (name) ? FcPatternCreate () : FcNameParse (SDATA (name)); | 563 pattern = FcPatternCreate (); |
567 if (! pattern) | 564 if (! pattern) |
568 goto err; | 565 goto err; |
569 FcPatternDel (pattern, FC_SIZE); | |
570 FcPatternDel (pattern, FC_PIXEL_SIZE); | |
571 FcPatternDel (pattern, FC_FOUNDRY); | |
572 FcPatternDel (pattern, FC_FAMILY); | |
573 tmp = AREF (spec, FONT_FOUNDRY_INDEX); | 566 tmp = AREF (spec, FONT_FOUNDRY_INDEX); |
574 if (! NILP (tmp) | 567 if (! NILP (tmp) |
575 && ! FcPatternAddString (pattern, FC_FOUNDRY, SYMBOL_FcChar8 (tmp))) | 568 && ! FcPatternAddString (pattern, FC_FOUNDRY, SYMBOL_FcChar8 (tmp))) |
576 goto err; | 569 goto err; |
577 tmp = AREF (spec, FONT_FAMILY_INDEX); | 570 tmp = AREF (spec, FONT_FAMILY_INDEX); |
661 FC_WIDTH, FC_PIXEL_SIZE, FC_SPACING, FC_SCALABLE, | 654 FC_WIDTH, FC_PIXEL_SIZE, FC_SPACING, FC_SCALABLE, |
662 FC_FILE, | 655 FC_FILE, |
663 #ifdef FC_CAPABILITY | 656 #ifdef FC_CAPABILITY |
664 FC_CAPABILITY, | 657 FC_CAPABILITY, |
665 #endif /* FC_CAPABILITY */ | 658 #endif /* FC_CAPABILITY */ |
659 #ifdef FC_FONTFORMAT | |
660 FC_FONTFORMAT, | |
661 #endif | |
666 NULL); | 662 NULL); |
667 if (! objset) | 663 if (! objset) |
668 goto err; | 664 goto err; |
669 | 665 |
670 fontset = FcFontList (NULL, pattern, objset); | 666 fontset = FcFontList (NULL, pattern, objset); |
744 otspec->nfeatures[1]) != 1) | 740 otspec->nfeatures[1]) != 1) |
745 continue; | 741 continue; |
746 } | 742 } |
747 #endif /* HAVE_LIBOTF */ | 743 #endif /* HAVE_LIBOTF */ |
748 entity = ftfont_pattern_entity (fontset->fonts[i], registry, | 744 entity = ftfont_pattern_entity (fontset->fonts[i], registry, |
745 AREF (spec, FONT_EXTRA_INDEX), | |
749 fc_charset_idx); | 746 fc_charset_idx); |
750 if (! NILP (entity)) | 747 if (! NILP (entity)) |
751 val = Fcons (entity, val); | 748 val = Fcons (entity, val); |
752 } | 749 } |
753 font_add_log ("ftfont-list", spec, val); | 750 font_add_log ("ftfont-list", spec, val); |
798 { | 795 { |
799 FcDefaultSubstitute (pattern); | 796 FcDefaultSubstitute (pattern); |
800 match = FcFontMatch (NULL, pattern, &result); | 797 match = FcFontMatch (NULL, pattern, &result); |
801 if (match) | 798 if (match) |
802 { | 799 { |
803 entity = ftfont_pattern_entity (match, Qunicode_bmp, fc_charset_idx); | 800 entity = ftfont_pattern_entity (match, Qunicode_bmp, |
801 AREF (spec, FONT_EXTRA_INDEX), | |
802 fc_charset_idx); | |
804 FcPatternDestroy (match); | 803 FcPatternDestroy (match); |
805 if (! NILP (AREF (spec, FONT_FAMILY_INDEX)) | 804 if (! NILP (AREF (spec, FONT_FAMILY_INDEX)) |
806 && NILP (assq_no_quit (AREF (spec, FONT_FAMILY_INDEX), | 805 && NILP (assq_no_quit (AREF (spec, FONT_FAMILY_INDEX), |
807 ftfont_generic_family_list)) | 806 ftfont_generic_family_list)) |
808 && NILP (Fstring_equal (AREF (spec, FONT_FAMILY_INDEX), | 807 && NILP (Fstring_equal (AREF (spec, FONT_FAMILY_INDEX), |