aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2008-06-30 07:39:14 +0000
committerKenichi Handa2008-06-30 07:39:14 +0000
commit7d7ad10e334f29d603fd1fdc3c6c92cb918def94 (patch)
tree571e388485d646cb8b583b2ff89ce4c78f87e1fd /src
parent811029d313a339ac0840a475a570367342b34fa7 (diff)
downloademacs-7d7ad10e334f29d603fd1fdc3c6c92cb918def94.tar.gz
emacs-7d7ad10e334f29d603fd1fdc3c6c92cb918def94.zip
(fc_charset_table): New member lang.
(ftfont_resolve_generic_family): New arg pattern. (ftfont_spec_pattern): Check fc_cahrset_table[]->lang. (ftfont_list): Call ftfont_resolve_generic_family with `pattern'. (ftfont_open): Fix args to ftfont_font_format. (ftfont_font_format): New arg filename.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog13
-rw-r--r--src/ftfont.c111
2 files changed, 78 insertions, 46 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1d82db5fd7f..bafff3510b5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
12008-06-30 Kenichi Handa <handa@m17n.org>
2
3 * xftfont.c (xftfont_open): Don't call FcConfigSubstitute and
4 XftDefaultSubstitute (they are called in XftFontMatch).
5 (xftfont_open): Fix args to ftfont_font_format.
6
7 * ftfont.c (fc_charset_table): New member lang.
8 (ftfont_resolve_generic_family): New arg pattern.
9 (ftfont_spec_pattern): Check fc_cahrset_table[]->lang.
10 (ftfont_list): Call ftfont_resolve_generic_family with `pattern'.
11 (ftfont_open): Fix args to ftfont_font_format.
12 (ftfont_font_format): New arg filename.
13
12008-06-30 Chong Yidong <cyd@stupidchicken.com> 142008-06-30 Chong Yidong <cyd@stupidchicken.com>
2 15
3 * xfaces.c (Finternal_merge_in_global_face): If default face was 16 * xfaces.c (Finternal_merge_in_global_face): If default face was
diff --git a/src/ftfont.c b/src/ftfont.c
index 92bbec707a2..62bbb9bca4c 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -71,8 +71,9 @@ struct ftfont_info
71static Lisp_Object ftfont_pattern_entity P_ ((FcPattern *, Lisp_Object, 71static Lisp_Object ftfont_pattern_entity P_ ((FcPattern *, Lisp_Object,
72 Lisp_Object, int)); 72 Lisp_Object, int));
73 73
74static Lisp_Object ftfont_resolve_generic_family P_ ((Lisp_Object)); 74static Lisp_Object ftfont_resolve_generic_family P_ ((Lisp_Object,
75Lisp_Object ftfont_font_format P_ ((FcPattern *)); 75 FcPattern *));
76Lisp_Object ftfont_font_format P_ ((FcPattern *, Lisp_Object));
76 77
77#define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM)) 78#define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM))
78 79
@@ -82,12 +83,14 @@ static struct
82 char *name; 83 char *name;
83 /* characters to distinguish the charset from the others */ 84 /* characters to distinguish the charset from the others */
84 int uniquifier[6]; 85 int uniquifier[6];
86 /* additional constraint by language */
87 char *lang;
85 /* set in syms_of_ftfont */ 88 /* set in syms_of_ftfont */
86 int charset_id; 89 int charset_id;
87 /* set on demand */ 90 /* set on demand */
88 FcCharSet *fc_charset; 91 FcCharSet *fc_charset;
89} fc_charset_table[] = 92} fc_charset_table[] =
90 { { "iso-8859-1", { 0x00A0, 0x00A1, 0x00B4, 0x00BC, 0x00D0 }, -1 }, 93 { { "iso-8859-1", { 0x00A0, 0x00A1, 0x00B4, 0x00BC, 0x00D0 }, "en", -1 },
91 { "iso-8859-2", { 0x00A0, 0x010E }}, 94 { "iso-8859-2", { 0x00A0, 0x010E }},
92 { "iso-8859-3", { 0x00A0, 0x0108 }}, 95 { "iso-8859-3", { 0x00A0, 0x0108 }},
93 { "iso-8859-4", { 0x00A0, 0x00AF, 0x0128, 0x0156, 0x02C7 }}, 96 { "iso-8859-4", { 0x00A0, 0x00AF, 0x0128, 0x0156, 0x02C7 }},
@@ -102,27 +105,27 @@ static struct
102 { "iso-8859-14", { 0x00A0, 0x0174 }}, 105 { "iso-8859-14", { 0x00A0, 0x0174 }},
103 { "iso-8859-15", { 0x00A0, 0x00A1, 0x00D0, 0x0152 }}, 106 { "iso-8859-15", { 0x00A0, 0x00A1, 0x00D0, 0x0152 }},
104 { "iso-8859-16", { 0x00A0, 0x0218}}, 107 { "iso-8859-16", { 0x00A0, 0x0218}},
105 { "chinese-gb2312", { 0x4E13 }}, 108 { "chinese-gb2312", { 0x4E13 }, "zh-cn"},
106 { "big5", { 0xF6B1 }}, 109 { "big5", { 0xF6B1 }, "zh-tw" },
107 { "japanese-jisx0208", { 0x4E55 }}, 110 { "japanese-jisx0208", { 0x4E55 }, "ja"},
108 { "korean-ksc5601", { 0xAC00 }}, 111 { "korean-ksc5601", { 0xAC00 }, "ko"},
109 { "chinese-cns11643-1", { 0xFE32 }}, 112 { "chinese-cns11643-1", { 0xFE32 }, "zh-tw"},
110 { "chinese-cns11643-2", { 0x4E33, 0x7934 }}, 113 { "chinese-cns11643-2", { 0x4E33, 0x7934 }},
111 { "chinese-cns11643-3", { 0x201A9 }}, 114 { "chinese-cns11643-3", { 0x201A9 }},
112 { "chinese-cns11643-4", { 0x20057 }}, 115 { "chinese-cns11643-4", { 0x20057 }},
113 { "chinese-cns11643-5", { 0x20000 }}, 116 { "chinese-cns11643-5", { 0x20000 }},
114 { "chinese-cns11643-6", { 0x20003 }}, 117 { "chinese-cns11643-6", { 0x20003 }},
115 { "chinese-cns11643-7", { 0x20055 }}, 118 { "chinese-cns11643-7", { 0x20055 }},
116 { "chinese-gbk", { 0x4E06 }}, 119 { "chinese-gbk", { 0x4E06 }, "zh-cn"},
117 { "japanese-jisx0212", { 0x4E44 }}, 120 { "japanese-jisx0212", { 0x4E44 }},
118 { "japanese-jisx0213-1", { 0xFA10 }}, 121 { "japanese-jisx0213-1", { 0xFA10 }, "ja"},
119 { "japanese-jisx0213-2", { 0xFA49 }}, 122 { "japanese-jisx0213-2", { 0xFA49 }},
120 { "japanese-jisx0213.2004-1", { 0x20B9F }}, 123 { "japanese-jisx0213.2004-1", { 0x20B9F }},
121 { "viscii", { 0x1EA0, 0x1EAE, 0x1ED2 }}, 124 { "viscii", { 0x1EA0, 0x1EAE, 0x1ED2 }, "vi"},
122 { "tis620", { 0x0E01 }}, 125 { "tis620", { 0x0E01 }, "th"},
123 { "windows-1251", { 0x0401, 0x0490 }}, 126 { "windows-1251", { 0x0401, 0x0490 }, "ru"},
124 { "koi8-r", { 0x0401, 0x2219 }}, 127 { "koi8-r", { 0x0401, 0x2219 }, "ru"},
125 { "mule-lao", { 0x0E81 }}, 128 { "mule-lao", { 0x0E81 }, "lo"},
126 { NULL } 129 { NULL }
127 }; 130 };
128 131
@@ -194,11 +197,12 @@ ftfont_pattern_entity (p, registry, extra, fc_charset_idx)
194static Lisp_Object ftfont_generic_family_list; 197static Lisp_Object ftfont_generic_family_list;
195 198
196static Lisp_Object 199static Lisp_Object
197ftfont_resolve_generic_family (family) 200ftfont_resolve_generic_family (family, pattern)
198 Lisp_Object family; 201 Lisp_Object family;
202 FcPattern *pattern;
199{ 203{
200 Lisp_Object slot; 204 Lisp_Object slot;
201 FcPattern *pattern = NULL, *match; 205 FcPattern *match;
202 FcResult result; 206 FcResult result;
203 207
204 family = Fintern (Fdowncase (SYMBOL_NAME (family)), Qnil); 208 family = Fintern (Fdowncase (SYMBOL_NAME (family)), Qnil);
@@ -211,10 +215,11 @@ ftfont_resolve_generic_family (family)
211 return Qnil; 215 return Qnil;
212 if (! EQ (XCDR (slot), Qt)) 216 if (! EQ (XCDR (slot), Qt))
213 return XCDR (slot); 217 return XCDR (slot);
214 pattern = FcPatternBuild (NULL, FC_FAMILY, FcTypeString, 218 pattern = FcPatternDuplicate (pattern);
215 SYMBOL_FcChar8 (family), (char *) 0);
216 if (! pattern) 219 if (! pattern)
217 goto err; 220 goto err;
221 FcPatternDel (pattern, FC_FAMILY);
222 FcPatternAddString (pattern, FC_FAMILY, SYMBOL_FcChar8 (family));
218 FcConfigSubstitute (NULL, pattern, FcMatchPattern); 223 FcConfigSubstitute (NULL, pattern, FcMatchPattern);
219 FcDefaultSubstitute (pattern); 224 FcDefaultSubstitute (pattern);
220 match = FcFontMatch (NULL, pattern, &result); 225 match = FcFontMatch (NULL, pattern, &result);
@@ -498,10 +503,20 @@ ftfont_spec_pattern (spec, fc_charset_idx, otlayout, otspec)
498 *fc_charset_idx = -1; 503 *fc_charset_idx = -1;
499 else 504 else
500 { 505 {
506 FcChar8 *lang;
507
501 *fc_charset_idx = ftfont_get_charset (registry); 508 *fc_charset_idx = ftfont_get_charset (registry);
502 if (*fc_charset_idx < 0) 509 if (*fc_charset_idx < 0)
503 return NULL; 510 return NULL;
504 charset = fc_charset_table[*fc_charset_idx].fc_charset; 511 charset = fc_charset_table[*fc_charset_idx].fc_charset;
512 lang = (FcChar8 *) fc_charset_table[*fc_charset_idx].lang;
513 if (lang)
514 {
515 langset = FcLangSetCreate ();
516 if (! langset)
517 goto err;
518 FcLangSetAdd (langset, lang);
519 }
505 } 520 }
506 521
507 otlayout[0] = '\0'; 522 otlayout[0] = '\0';
@@ -515,7 +530,8 @@ ftfont_spec_pattern (spec, fc_charset_idx, otlayout, otspec)
515 dpi = XINT (val); 530 dpi = XINT (val);
516 else if (EQ (key, QClang)) 531 else if (EQ (key, QClang))
517 { 532 {
518 langset = FcLangSetCreate (); 533 if (! langset)
534 langset = FcLangSetCreate ();
519 if (! langset) 535 if (! langset)
520 goto err; 536 goto err;
521 if (SYMBOLP (val)) 537 if (SYMBOLP (val))
@@ -583,6 +599,7 @@ ftfont_spec_pattern (spec, fc_charset_idx, otlayout, otspec)
583 if (scalable >= 0 599 if (scalable >= 0
584 && ! FcPatternAddBool (pattern, FC_SCALABLE, scalable ? FcTrue : FcFalse)) 600 && ! FcPatternAddBool (pattern, FC_SCALABLE, scalable ? FcTrue : FcFalse))
585 goto err; 601 goto err;
602
586 goto finish; 603 goto finish;
587 604
588 err: 605 err:
@@ -640,7 +657,7 @@ ftfont_list (frame, spec)
640 { 657 {
641 Lisp_Object resolved; 658 Lisp_Object resolved;
642 659
643 resolved = ftfont_resolve_generic_family (family); 660 resolved = ftfont_resolve_generic_family (family, pattern);
644 if (! NILP (resolved)) 661 if (! NILP (resolved))
645 { 662 {
646 FcPatternDel (pattern, FC_FAMILY); 663 FcPatternDel (pattern, FC_FAMILY);
@@ -929,7 +946,7 @@ ftfont_open (f, entity, pixel_size)
929 ASET (font_object, FONT_FULLNAME_INDEX, 946 ASET (font_object, FONT_FULLNAME_INDEX,
930 AREF (font_object, FONT_NAME_INDEX)); 947 AREF (font_object, FONT_NAME_INDEX));
931 ASET (font_object, FONT_FILE_INDEX, filename); 948 ASET (font_object, FONT_FILE_INDEX, filename);
932 ASET (font_object, FONT_FORMAT_INDEX, ftfont_font_format (pattern)); 949 ASET (font_object, FONT_FORMAT_INDEX, ftfont_font_format (NULL, filename));
933 font = XFONT_OBJECT (font_object); 950 font = XFONT_OBJECT (font_object);
934 ftfont_info = (struct ftfont_info *) font; 951 ftfont_info = (struct ftfont_info *) font;
935 ftfont_info->ft_size = ft_face->size; 952 ftfont_info->ft_size = ft_face->size;
@@ -1731,40 +1748,42 @@ ftfont_shape (lgstring)
1731#endif /* HAVE_LIBOTF */ 1748#endif /* HAVE_LIBOTF */
1732 1749
1733Lisp_Object 1750Lisp_Object
1734ftfont_font_format (FcPattern *pattern) 1751ftfont_font_format (FcPattern *pattern, Lisp_Object filename)
1735{ 1752{
1736 FcChar8 *str; 1753 FcChar8 *str;
1737 1754
1738#ifdef FC_FONTFORMAT 1755#ifdef FC_FONTFORMAT
1739 if (FcPatternGetString (pattern, FC_FONTFORMAT, 0, &str) != FcResultMatch) 1756 if (pattern)
1740 return Qnil;
1741 if (strcmp ((char *) str, "TrueType") == 0)
1742 return intern ("truetype");
1743 if (strcmp ((char *) str, "Type 1") == 0)
1744 return intern ("type1");
1745 if (strcmp ((char *) str, "PCF") == 0)
1746 return intern ("pcf");
1747 if (strcmp ((char *) str, "BDF") == 0)
1748 return intern ("bdf");
1749#else /* not FC_FONTFORMAT */
1750 int len;
1751
1752 if (FcPatternGetString (pattern, FC_FILE, 0, &str) != FcResultMatch)
1753 return Qnil;
1754 len = strlen ((char *) str);
1755 if (len >= 4)
1756 { 1757 {
1757 str += len - 4; 1758 if (FcPatternGetString (pattern, FC_FONTFORMAT, 0, &str) != FcResultMatch)
1758 if (xstrcasecmp ((char *) str, ".ttf") == 0) 1759 return Qnil;
1760 if (strcmp ((char *) str, "TrueType") == 0)
1759 return intern ("truetype"); 1761 return intern ("truetype");
1760 if (xstrcasecmp ((char *) str, "pfb") == 0) 1762 if (strcmp ((char *) str, "Type 1") == 0)
1761 return intern ("type1"); 1763 return intern ("type1");
1762 if (xstrcasecmp ((char *) str, "pcf") == 0) 1764 if (strcmp ((char *) str, "PCF") == 0)
1763 return intern ("pcf"); 1765 return intern ("pcf");
1764 if (xstrcasecmp ((char *) str, "bdf") == 0) 1766 if (strcmp ((char *) str, "BDF") == 0)
1765 return intern ("bdf"); 1767 return intern ("bdf");
1766 } 1768 }
1767#endif /* not FC_FONTFORMAT */ 1769#endif /* FC_FONTFORMAT */
1770 if (STRINGP (filename))
1771 {
1772 int len = SBYTES (filename);
1773
1774 if (len >= 4)
1775 {
1776 str = (FcChar8 *) (SDATA (filename) + len - 4);
1777 if (xstrcasecmp ((char *) str, ".ttf") == 0)
1778 return intern ("truetype");
1779 if (xstrcasecmp ((char *) str, ".pfb") == 0)
1780 return intern ("type1");
1781 if (xstrcasecmp ((char *) str, ".pcf") == 0)
1782 return intern ("pcf");
1783 if (xstrcasecmp ((char *) str, ".bdf") == 0)
1784 return intern ("bdf");
1785 }
1786 }
1768 return intern ("unknown"); 1787 return intern ("unknown");
1769} 1788}
1770 1789