aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2008-05-22 02:27:17 +0000
committerKenichi Handa2008-05-22 02:27:17 +0000
commit318548bef00c4228063e46c2e310fc8660abd84d (patch)
tree37b37384d8ba4586dadaec7a4a707ab667a09d00 /src
parentf6a651cb77278f11a6183f25c995a2e16fd6e2a6 (diff)
downloademacs-318548bef00c4228063e46c2e310fc8660abd84d.tar.gz
emacs-318548bef00c4228063e46c2e310fc8660abd84d.zip
(ftfont_resolve_generic_family): Renamed from
ftfont_list_generic_family. Return a single family for each generic family. (ftfont_spec_pattern): Add FC_FAMILY to pattern. (ftfont_list): Adjusted for the change of ftfont_resolve_generic_family. Call font_add_log. (ftfont_match): Call font_add_log.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog54
-rw-r--r--src/ftfont.c184
2 files changed, 137 insertions, 101 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ad780f7a7b0..0a0130c71cb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,57 @@
12008-05-22 Kenichi Handa <handa@m17n.org>
2
3 * ftfont.c (ftfont_resolve_generic_family): Renamed from
4 ftfont_list_generic_family. Return a single family for each
5 generic family.
6 (ftfont_spec_pattern): Add FC_FAMILY to pattern.
7 (ftfont_list): Adjusted for the change of
8 ftfont_resolve_generic_family. Call font_add_log.
9 (ftfont_match): Call font_add_log.
10
11 * font.h (Ffont_xlfd_name): EXFUN adjusted.
12 (FONT_DEBUG): Define it.
13 (font_add_log): Extern it.
14 (font_assert): Renamed from xassert.
15
16 * xfont.c (xfont_get_pcm): Change xassert to font_assert.
17 (xfont_list_family): Call font_add_log.
18 (xfont_match): Likewise.
19 (memq_no_quit): Deleted.
20
21 * fontset.c (fontset_from_font, Ffontset_info): Add the 2nd arg in
22 call of Ffont_xlfd_name.
23
24 * xfaces.c (struct table_entry, slant_table, weight_table)
25 (swidth_table): Moved to font.c.
26
27 * font.c: Checking of FONT_DEBUG is moved to font.h. All calls of
28 xassert are changed to font_assert. Many unused variables
29 deleted.
30 (Vfont_weight_table, Vfont_slant_table, Vfont_width_table): New
31 variables.
32 (struct table_entry): Moved from xfaces.c and modified.
33 (weight_table, slant_table, width_table): Moved from xfaces.c and
34 contents adjusted for the change of struct table_entry.
35 (font_style_to_value, font_style_symbolic): Adjuted for the format
36 change of font_style_table.
37 (font_parse_family_registry): Don't overwrite existing foundry and
38 family of font_spec.
39 (font_score): Fix calculation of diff for sizes.
40 (font_sort_entites): Call font_add_log.
41 (font_delete_unmatched): Return a newly created list.
42 (font_list_entities): Fix previous change. Call font_add_log.
43 (font_matching_entity, font_open_entity, font_close_entity): Call
44 font_add_log.
45 (Ffont_xlfd_name): New arg FOLD-WILDCARDS.
46 (Finternal_set_font_style_table): Deleted.
47 (BUILD_STYLE_TABLE): New macro.
48 (build_style_table): New function.
49 (Vfont_log, font_log_env_checked): New variables.
50 (font_add_log): New function.
51 (syms_of_font): Delete defsubr Sinternal_set_font_style_table.
52 Declare Lisp variables "font-weight-table", "font-slant-table",
53 "font-width-table", and "font-log". Initialize font_style_table.
54
12008-05-21 Dan Nicolaescu <dann@ics.uci.edu> 552008-05-21 Dan Nicolaescu <dann@ics.uci.edu>
2 56
3 * xterm.c (x_set_frame_alpha): Move declarations before statements. 57 * xterm.c (x_set_frame_alpha): Move declarations before statements.
diff --git a/src/ftfont.c b/src/ftfont.c
index 6c86a7872e9..72deedd73c3 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -70,7 +70,7 @@ struct ftfont_info
70 70
71static Lisp_Object ftfont_pattern_entity P_ ((FcPattern *, Lisp_Object, int)); 71static Lisp_Object ftfont_pattern_entity P_ ((FcPattern *, Lisp_Object, int));
72 72
73static Lisp_Object ftfont_list_generic_family P_ ((Lisp_Object)); 73static Lisp_Object ftfont_resolve_generic_family P_ ((Lisp_Object));
74Lisp_Object ftfont_font_format P_ ((FcPattern *)); 74Lisp_Object ftfont_font_format P_ ((FcPattern *));
75 75
76#define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM)) 76#define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM))
@@ -192,16 +192,14 @@ ftfont_pattern_entity (p, registry, fc_charset_idx)
192static Lisp_Object ftfont_generic_family_list; 192static Lisp_Object ftfont_generic_family_list;
193 193
194static Lisp_Object 194static Lisp_Object
195ftfont_list_generic_family (family) 195ftfont_resolve_generic_family (family)
196 Lisp_Object family; 196 Lisp_Object family;
197{ 197{
198 Lisp_Object slot, list; 198 Lisp_Object slot;
199 FcObjectSet *objset = NULL; 199 FcPattern *pattern = NULL, *match;
200 FcPattern *pattern = NULL, *pat = NULL; 200 FcResult result;
201 FcFontSet *fontset = NULL;
202 FcChar8 *fam;
203 int i;
204 201
202 family = Fintern (Fdowncase (SYMBOL_NAME (family)), Qnil);
205 if (EQ (family, Qmono)) 203 if (EQ (family, Qmono))
206 family = Qmonospace; 204 family = Qmonospace;
207 else if (EQ (family, Qsans) || EQ (family, Qsans__serif)) 205 else if (EQ (family, Qsans) || EQ (family, Qsans__serif))
@@ -209,45 +207,29 @@ ftfont_list_generic_family (family)
209 slot = assq_no_quit (family, ftfont_generic_family_list); 207 slot = assq_no_quit (family, ftfont_generic_family_list);
210 if (! CONSP (slot)) 208 if (! CONSP (slot))
211 return Qnil; 209 return Qnil;
212 list = XCDR (slot); 210 if (! EQ (XCDR (slot), Qt))
213 if (! EQ (list, Qt)) 211 return XCDR (slot);
214 return list;
215
216 objset = FcObjectSetBuild (FC_FAMILY, NULL);
217 if (! objset)
218 goto err;
219 pattern = FcPatternBuild (NULL, FC_FAMILY, FcTypeString, 212 pattern = FcPatternBuild (NULL, FC_FAMILY, FcTypeString,
220 SYMBOL_FcChar8 (family), (char *) 0); 213 SYMBOL_FcChar8 (family), (char *) 0);
221 if (! pattern) 214 if (! pattern)
222 goto err; 215 goto err;
223 pat = FcPatternCreate ();
224 if (! pat)
225 goto err;
226 FcConfigSubstitute (NULL, pattern, FcMatchPattern); 216 FcConfigSubstitute (NULL, pattern, FcMatchPattern);
227 for (i = 0, list = Qnil; 217 FcDefaultSubstitute (pattern);
228 FcPatternGetString (pattern, FC_FAMILY, i, &fam) == FcResultMatch; 218 match = FcFontMatch (NULL, pattern, &result);
229 i++) 219 if (match)
230 { 220 {
231 if (strcmp ((char *) fam, (char *) SYMBOL_FcChar8 (family)) == 0) 221 FcChar8 *fam;
232 continue; 222
233 if (! FcPatternAddString (pat, FC_FAMILY, fam)) 223 if (FcPatternGetString (match, FC_FAMILY, 0, &fam) == FcResultMatch)
234 goto err; 224 family = intern ((char *) fam);
235 fontset = FcFontList (NULL, pat, objset);
236 if (! fontset)
237 goto err;
238 if (fontset->nfont > 0)
239 list = Fcons (intern ((char *) fam), list);
240 FcFontSetDestroy (fontset);
241 fontset = NULL;
242 FcPatternDel (pat, FC_FAMILY);
243 } 225 }
244 XSETCDR (slot, list); 226 else
227 family = Qnil;
228 XSETCDR (slot, family);
245 err: 229 err:
246 if (pat) FcPatternDestroy (pat); 230 if (match) FcPatternDestroy (match);
247 if (pattern) FcPatternDestroy (pattern); 231 if (pattern) FcPatternDestroy (pattern);
248 if (fontset) FcFontSetDestroy (fontset); 232 return family;
249 if (objset) FcObjectSetDestroy (objset);
250 return list;
251} 233}
252 234
253Lisp_Object 235Lisp_Object
@@ -588,10 +570,16 @@ ftfont_spec_pattern (spec, fc_charset_idx, otlayout, otspec)
588 goto err; 570 goto err;
589 FcPatternDel (pattern, FC_SIZE); 571 FcPatternDel (pattern, FC_SIZE);
590 FcPatternDel (pattern, FC_PIXEL_SIZE); 572 FcPatternDel (pattern, FC_PIXEL_SIZE);
573 FcPatternDel (pattern, FC_FOUNDRY);
574 FcPatternDel (pattern, FC_FAMILY);
591 tmp = AREF (spec, FONT_FOUNDRY_INDEX); 575 tmp = AREF (spec, FONT_FOUNDRY_INDEX);
592 if (! NILP (tmp) 576 if (! NILP (tmp)
593 && ! FcPatternAddString (pattern, FC_FOUNDRY, SYMBOL_FcChar8 (tmp))) 577 && ! FcPatternAddString (pattern, FC_FOUNDRY, SYMBOL_FcChar8 (tmp)))
594 goto err; 578 goto err;
579 tmp = AREF (spec, FONT_FAMILY_INDEX);
580 if (! NILP (tmp)
581 && ! FcPatternAddString (pattern, FC_FAMILY, SYMBOL_FcChar8 (tmp)))
582 goto err;
595 if (charset 583 if (charset
596 && ! FcPatternAddCharSet (pattern, FC_CHARSET, charset)) 584 && ! FcPatternAddCharSet (pattern, FC_CHARSET, charset))
597 goto err; 585 goto err;
@@ -636,7 +624,7 @@ static Lisp_Object
636ftfont_list (frame, spec) 624ftfont_list (frame, spec)
637 Lisp_Object frame, spec; 625 Lisp_Object frame, spec;
638{ 626{
639 Lisp_Object val, registry, family, family_list; 627 Lisp_Object val = Qnil, registry, family;
640 int i; 628 int i;
641 FcPattern *pattern; 629 FcPattern *pattern;
642 FcFontSet *fontset = NULL; 630 FcFontSet *fontset = NULL;
@@ -654,6 +642,22 @@ ftfont_list (frame, spec)
654 pattern = ftfont_spec_pattern (spec, &fc_charset_idx, otlayout, &otspec); 642 pattern = ftfont_spec_pattern (spec, &fc_charset_idx, otlayout, &otspec);
655 if (! pattern) 643 if (! pattern)
656 return Qnil; 644 return Qnil;
645 registry = AREF (spec, FONT_REGISTRY_INDEX);
646 family = AREF (spec, FONT_FAMILY_INDEX);
647 if (! NILP (family))
648 {
649 Lisp_Object resolved;
650
651 resolved = ftfont_resolve_generic_family (family);
652 if (! NILP (resolved))
653 {
654 FcPatternDel (pattern, FC_FAMILY);
655 if (! FcPatternAddString (pattern, FC_FAMILY,
656 SYMBOL_FcChar8 (resolved)))
657 goto err;
658 }
659 }
660
657 objset = FcObjectSetBuild (FC_FOUNDRY, FC_FAMILY, FC_WEIGHT, FC_SLANT, 661 objset = FcObjectSetBuild (FC_FOUNDRY, FC_FAMILY, FC_WEIGHT, FC_SLANT,
658 FC_WIDTH, FC_PIXEL_SIZE, FC_SPACING, FC_SCALABLE, 662 FC_WIDTH, FC_PIXEL_SIZE, FC_SPACING, FC_SCALABLE,
659 FC_CHARSET, FC_FILE, 663 FC_CHARSET, FC_FILE,
@@ -664,76 +668,53 @@ ftfont_list (frame, spec)
664 if (! objset) 668 if (! objset)
665 goto err; 669 goto err;
666 670
667 registry = AREF (spec, FONT_REGISTRY_INDEX); 671 fontset = FcFontList (NULL, pattern, objset);
668 family = AREF (spec, FONT_FAMILY_INDEX); 672 if (! fontset)
669 if (NILP (family)) 673 goto err;
670 family_list = Fcons (Qnil, Qnil); 674 for (i = 0; i < fontset->nfont; i++)
671 else
672 {
673 family = Fintern (Fdowncase (SYMBOL_NAME (family)), Qnil);
674 family_list = ftfont_list_generic_family (family);
675 if (NILP (family_list))
676 family_list = Fcons (family, Qnil);
677 }
678
679 for (val = Qnil; CONSP (family_list); family_list = XCDR (family_list))
680 { 675 {
681 family = XCAR (family_list); 676 Lisp_Object entity;
682 if (! NILP (family))
683 {
684 FcPatternDel (pattern, FC_FAMILY);
685 if (! FcPatternAddString (pattern, FC_FAMILY, SYMBOL_FcChar8 (family)))
686 goto err;
687 }
688 fontset = FcFontList (NULL, pattern, objset);
689 if (! fontset)
690 goto err;
691 for (i = 0; i < fontset->nfont; i++)
692 {
693 Lisp_Object entity;
694 677
695#ifdef FC_CAPABILITY 678#ifdef FC_CAPABILITY
696 if (otlayout[0]) 679 if (otlayout[0])
697 { 680 {
698 FcChar8 *this; 681 FcChar8 *this;
699 682
700 if (FcPatternGetString (fontset->fonts[i], FC_CAPABILITY, 0, 683 if (FcPatternGetString (fontset->fonts[i], FC_CAPABILITY, 0,
701 &this) != FcResultMatch 684 &this) != FcResultMatch
702 || ! strstr ((char *) this, otlayout)) 685 || ! strstr ((char *) this, otlayout))
703 continue; 686 continue;
704 } 687 }
705#endif /* FC_CAPABILITY */ 688#endif /* FC_CAPABILITY */
706#ifdef HAVE_LIBOTF 689#ifdef HAVE_LIBOTF
707 if (otspec) 690 if (otspec)
708 { 691 {
709 FcChar8 *file; 692 FcChar8 *file;
710 OTF *otf; 693 OTF *otf;
711 694
712 if (FcPatternGetString (fontset->fonts[i], FC_FILE, 0, &file) 695 if (FcPatternGetString (fontset->fonts[i], FC_FILE, 0, &file)
713 != FcResultMatch) 696 != FcResultMatch)
714 continue; 697 continue;
715 otf = OTF_open ((char *) file); 698 otf = OTF_open ((char *) file);
716 if (! otf) 699 if (! otf)
717 continue; 700 continue;
718 if (OTF_check_features (otf, 1, 701 if (OTF_check_features (otf, 1,
719 otspec->script_tag, otspec->langsys_tag, 702 otspec->script_tag, otspec->langsys_tag,
720 otspec->features[0], 703 otspec->features[0],
721 otspec->nfeatures[0]) != 1 704 otspec->nfeatures[0]) != 1
722 || OTF_check_features (otf, 0, 705 || OTF_check_features (otf, 0,
723 otspec->script_tag, otspec->langsys_tag, 706 otspec->script_tag, otspec->langsys_tag,
724 otspec->features[1], 707 otspec->features[1],
725 otspec->nfeatures[1]) != 1) 708 otspec->nfeatures[1]) != 1)
726 continue; 709 continue;
727 }
728#endif /* HAVE_LIBOTF */
729 entity = ftfont_pattern_entity (fontset->fonts[i], registry,
730 fc_charset_idx);
731 if (! NILP (entity))
732 val = Fcons (entity, val);
733 } 710 }
734 FcFontSetDestroy (fontset); 711#endif /* HAVE_LIBOTF */
735 fontset = NULL; 712 entity = ftfont_pattern_entity (fontset->fonts[i], registry,
713 fc_charset_idx);
714 if (! NILP (entity))
715 val = Fcons (entity, val);
736 } 716 }
717 font_add_log ("ftfont-list", spec, val);
737 goto finish; 718 goto finish;
738 719
739 err: 720 err:
@@ -795,6 +776,7 @@ ftfont_match (frame, spec)
795 } 776 }
796 FcPatternDestroy (pattern); 777 FcPatternDestroy (pattern);
797 778
779 font_add_log ("ftfont-match", spec, entity);
798 return entity; 780 return entity;
799} 781}
800 782