Mercurial > emacs
annotate src/ftfont.c @ 96058:7ca8fbd3c153
Remove an entry that does not apply.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 18 Jun 2008 02:50:11 +0000 |
parents | dc8b6f0d85e8 |
children | bd3f48456ac7 |
rev | line source |
---|---|
90400 | 1 /* ftfont.c -- FreeType font driver. |
91555
21d9f8ca293c
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
91308
diff
changeset
|
2 Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. |
21d9f8ca293c
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
91308
diff
changeset
|
3 Copyright (C) 2006, 2007, 2008 |
90400 | 4 National Institute of Advanced Industrial Science and Technology (AIST) |
5 Registration Number H13PRO009 | |
6 | |
7 This file is part of GNU Emacs. | |
8 | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94931
diff
changeset
|
9 GNU Emacs is free software: you can redistribute it and/or modify |
90400 | 10 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94931
diff
changeset
|
11 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94931
diff
changeset
|
12 (at your option) any later version. |
90400 | 13 |
14 GNU Emacs is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94931
diff
changeset
|
20 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
90400 | 21 |
22 #include <config.h> | |
23 #include <stdio.h> | |
24 | |
25 #include <fontconfig/fontconfig.h> | |
26 #include <fontconfig/fcfreetype.h> | |
27 | |
28 #include "lisp.h" | |
29 #include "dispextern.h" | |
30 #include "frame.h" | |
31 #include "blockinput.h" | |
32 #include "character.h" | |
33 #include "charset.h" | |
34 #include "coding.h" | |
35 #include "fontset.h" | |
36 #include "font.h" | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
37 #include "ftfont.h" |
90400 | 38 |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
39 /* Symbolic type of this font-driver. */ |
90400 | 40 Lisp_Object Qfreetype; |
41 | |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
42 /* Fontconfig's generic families and their aliases. */ |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
43 static Lisp_Object Qmonospace, Qsans_serif, Qserif, Qmono, Qsans, Qsans__serif; |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
44 |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
45 /* Flag to tell if FcInit is already called or not. */ |
90400 | 46 static int fc_initialized; |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
47 |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
48 /* Handle to a FreeType library instance. */ |
90400 | 49 static FT_Library ft_library; |
50 | |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
51 /* Cache for FreeType fonts. */ |
90400 | 52 static Lisp_Object freetype_font_cache; |
53 | |
95103 | 54 /* Cache for FT_Face */ |
55 static Lisp_Object ft_face_cache; | |
90400 | 56 |
57 /* The actual structure for FreeType font that can be casted to struct | |
58 font. */ | |
59 | |
60 struct ftfont_info | |
61 { | |
62 struct font font; | |
63 FT_Size ft_size; | |
95103 | 64 int fc_charset_idx; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
65 #ifdef HAVE_LIBOTF |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
66 int maybe_otf; /* Flag to tell if this may be OTF or not. */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
67 OTF *otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
68 #endif /* HAVE_LIBOTF */ |
90400 | 69 }; |
70 | |
95103 | 71 static Lisp_Object ftfont_pattern_entity P_ ((FcPattern *, Lisp_Object, int)); |
72 | |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
73 static Lisp_Object ftfont_resolve_generic_family P_ ((Lisp_Object)); |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
74 Lisp_Object ftfont_font_format P_ ((FcPattern *)); |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
75 |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
76 #define SYMBOL_FcChar8(SYM) (FcChar8 *) SDATA (SYMBOL_NAME (SYM)) |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
77 |
95103 | 78 static struct |
90400 | 79 { |
95103 | 80 /* charset name */ |
81 char *name; | |
82 /* characters to distinguish the charset from the others */ | |
83 int uniquifier[6]; | |
84 /* set in syms_of_ftfont */ | |
85 int charset_id; | |
86 /* set on demand */ | |
87 FcCharSet *fc_charset; | |
88 } fc_charset_table[] = | |
89 { { "iso-8859-1", { 0x00A0, 0x00A1, 0x00B4, 0x00BC, 0x00D0 }, -1 }, | |
90 { "iso-8859-2", { 0x00A0, 0x010E }}, | |
91 { "iso-8859-3", { 0x00A0, 0x0108 }}, | |
92 { "iso-8859-4", { 0x00A0, 0x00AF, 0x0128, 0x0156, 0x02C7 }}, | |
93 { "iso-8859-5", { 0x00A0, 0x0401 }}, | |
94 { "iso-8859-6", { 0x00A0, 0x060C }}, | |
95 { "iso-8859-7", { 0x00A0, 0x0384 }}, | |
96 { "iso-8859-8", { 0x00A0, 0x05D0 }}, | |
97 { "iso-8859-9", { 0x00A0, 0x00A1, 0x00BC, 0x011E }}, | |
98 { "iso-8859-10", { 0x00A0, 0x00D0, 0x0128, 0x2015 }}, | |
99 { "iso-8859-11", { 0x00A0, 0x0E01 }}, | |
100 { "iso-8859-13", { 0x00A0, 0x201C }}, | |
101 { "iso-8859-14", { 0x00A0, 0x0174 }}, | |
102 { "iso-8859-15", { 0x00A0, 0x00A1, 0x00D0, 0x0152 }}, | |
103 { "iso-8859-16", { 0x00A0, 0x0218}}, | |
104 { "chinese-gb2312", { 0x4E13 }}, | |
105 { "big5", { 0xF6B1 }}, | |
106 { "japanese-jisx0208", { 0x4E55 }}, | |
107 { "korean-ksc5601", { 0xAC00 }}, | |
108 { "chinese-cns11643-1", { 0xFE32 }}, | |
109 { "chinese-cns11643-2", { 0x4E33, 0x7934 }}, | |
110 { "chinese-cns11643-3", { 0x201A9 }}, | |
111 { "chinese-cns11643-4", { 0x20057 }}, | |
112 { "chinese-cns11643-5", { 0x20000 }}, | |
113 { "chinese-cns11643-6", { 0x20003 }}, | |
114 { "chinese-cns11643-7", { 0x20055 }}, | |
115 { "chinese-gbk", { 0x4E06 }}, | |
116 { "japanese-jisx0212", { 0x4E44 }}, | |
117 { "japanese-jisx0213-1", { 0xFA10 }}, | |
118 { "japanese-jisx0213-2", { 0xFA49 }}, | |
119 { "japanese-jisx0213.2004-1", { 0x20B9F }}, | |
120 { "viscii", { 0x1EA0, 0x1EAE, 0x1ED2 }}, | |
121 { "tis620", { 0x0E01 }}, | |
122 { "windows-1251", { 0x0401, 0x0490 }}, | |
123 { "koi8-r", { 0x0401, 0x2219 }}, | |
124 { "mule-lao", { 0x0E81 }}, | |
125 { NULL } | |
126 }; | |
90400 | 127 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
128 extern Lisp_Object Qc, Qm, Qp, Qd; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
129 |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
130 static Lisp_Object |
95103 | 131 ftfont_pattern_entity (p, registry, fc_charset_idx) |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
132 FcPattern *p; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
133 Lisp_Object registry; |
95103 | 134 int fc_charset_idx; |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
135 { |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
136 Lisp_Object entity; |
95103 | 137 char *file, *str; |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
138 int numeric; |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
139 double dbl; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
140 FcBool b; |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
141 |
95103 | 142 if (FcPatternGetString (p, FC_FILE, 0, (FcChar8 **) &file) != FcResultMatch) |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
143 return Qnil; |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
144 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
145 entity = font_make_entity (); |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
146 |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
147 ASET (entity, FONT_TYPE_INDEX, Qfreetype); |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
148 ASET (entity, FONT_REGISTRY_INDEX, registry); |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
149 |
95103 | 150 if (FcPatternGetString (p, FC_FOUNDRY, 0, (FcChar8 **) &str) == FcResultMatch) |
95745
bea43f586395
(ftfont_pattern_entity): Adjusted for the change of font_intern_prop.
Kenichi Handa <handa@m17n.org>
parents:
95698
diff
changeset
|
151 ASET (entity, FONT_FOUNDRY_INDEX, font_intern_prop (str, strlen (str), 1)); |
95103 | 152 if (FcPatternGetString (p, FC_FAMILY, 0, (FcChar8 **) &str) == FcResultMatch) |
95745
bea43f586395
(ftfont_pattern_entity): Adjusted for the change of font_intern_prop.
Kenichi Handa <handa@m17n.org>
parents:
95698
diff
changeset
|
153 ASET (entity, FONT_FAMILY_INDEX, font_intern_prop (str, strlen (str), 1)); |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
154 if (FcPatternGetInteger (p, FC_WEIGHT, 0, &numeric) == FcResultMatch) |
90474
8627c9321afb
(ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents:
90464
diff
changeset
|
155 { |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
156 if (numeric >= FC_WEIGHT_REGULAR && numeric < FC_WEIGHT_MEDIUM) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
157 numeric = FC_WEIGHT_MEDIUM; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
158 FONT_SET_STYLE (entity, FONT_WEIGHT_INDEX, make_number (numeric)); |
90474
8627c9321afb
(ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents:
90464
diff
changeset
|
159 } |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
160 if (FcPatternGetInteger (p, FC_SLANT, 0, &numeric) == FcResultMatch) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
161 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
162 numeric += 100; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
163 FONT_SET_STYLE (entity, FONT_SLANT_INDEX, make_number (numeric)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
164 } |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
165 if (FcPatternGetInteger (p, FC_WIDTH, 0, &numeric) == FcResultMatch) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
166 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
167 FONT_SET_STYLE (entity, FONT_WIDTH_INDEX, make_number (numeric)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
168 } |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
169 if (FcPatternGetDouble (p, FC_PIXEL_SIZE, 0, &dbl) == FcResultMatch) |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
170 ASET (entity, FONT_SIZE_INDEX, make_number (dbl)); |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
171 else |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
172 ASET (entity, FONT_SIZE_INDEX, make_number (0)); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
173 if (FcPatternGetInteger (p, FC_SPACING, 0, &numeric) == FcResultMatch) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
174 ASET (entity, FONT_SPACING_INDEX, make_number (numeric)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
175 if (FcPatternGetDouble (p, FC_DPI, 0, &dbl) == FcResultMatch) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
176 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
177 int dpi = dbl; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
178 ASET (entity, FONT_DPI_INDEX, make_number (dpi)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
179 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
180 if (FcPatternGetBool (p, FC_SCALABLE, 0, &b) == FcResultMatch |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
181 && b == FcTrue) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
182 ASET (entity, FONT_AVGWIDTH_INDEX, make_number (0)); |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
183 |
95103 | 184 font_put_extra (entity, QCfont_entity, |
185 Fcons (make_unibyte_string ((char *) file, | |
186 strlen ((char *) file)), | |
187 make_number (fc_charset_idx))); | |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
188 return entity; |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
189 } |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
190 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
191 |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
192 static Lisp_Object ftfont_generic_family_list; |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
193 |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
194 static Lisp_Object |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
195 ftfont_resolve_generic_family (family) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
196 Lisp_Object family; |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
197 { |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
198 Lisp_Object slot; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
199 FcPattern *pattern = NULL, *match; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
200 FcResult result; |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
201 |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
202 family = Fintern (Fdowncase (SYMBOL_NAME (family)), Qnil); |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
203 if (EQ (family, Qmono)) |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
204 family = Qmonospace; |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
205 else if (EQ (family, Qsans) || EQ (family, Qsans__serif)) |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
206 family = Qsans_serif; |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
207 slot = assq_no_quit (family, ftfont_generic_family_list); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
208 if (! CONSP (slot)) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
209 return Qnil; |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
210 if (! EQ (XCDR (slot), Qt)) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
211 return XCDR (slot); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
212 pattern = FcPatternBuild (NULL, FC_FAMILY, FcTypeString, |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
213 SYMBOL_FcChar8 (family), (char *) 0); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
214 if (! pattern) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
215 goto err; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
216 FcConfigSubstitute (NULL, pattern, FcMatchPattern); |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
217 FcDefaultSubstitute (pattern); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
218 match = FcFontMatch (NULL, pattern, &result); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
219 if (match) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
220 { |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
221 FcChar8 *fam; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
222 |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
223 if (FcPatternGetString (match, FC_FAMILY, 0, &fam) == FcResultMatch) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
224 family = intern ((char *) fam); |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
225 } |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
226 else |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
227 family = Qnil; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
228 XSETCDR (slot, family); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
229 err: |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
230 if (match) FcPatternDestroy (match); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
231 if (pattern) FcPatternDestroy (pattern); |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
232 return family; |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
233 } |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
234 |
95103 | 235 Lisp_Object |
236 ftfont_lookup_cache (filename) | |
237 Lisp_Object filename; | |
238 { | |
239 Lisp_Object cache, val; | |
240 | |
241 cache = assoc_no_quit (filename, ft_face_cache); | |
242 if (NILP (cache)) | |
243 { | |
244 val = make_save_value (NULL, 0); | |
245 cache = Fcons (filename, val); | |
246 ft_face_cache = Fcons (cache, ft_face_cache); | |
247 } | |
248 else | |
249 val = XCDR (cache); | |
250 if (! XSAVE_VALUE (val)->pointer) | |
251 { | |
252 FT_Face ft_face; | |
253 | |
254 if (! ft_library | |
255 && FT_Init_FreeType (&ft_library) != 0) | |
256 return Qnil; | |
257 if (FT_New_Face (ft_library, (char *) SDATA (filename), 0, &ft_face) != 0) | |
258 return Qnil; | |
259 XSAVE_VALUE (val)->pointer = ft_face; | |
260 } | |
261 return cache; | |
262 } | |
263 | |
91249
4f21471103e6
(ftfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91214
diff
changeset
|
264 static Lisp_Object ftfont_get_cache P_ ((FRAME_PTR)); |
90400 | 265 static Lisp_Object ftfont_list P_ ((Lisp_Object, Lisp_Object)); |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
266 static Lisp_Object ftfont_match P_ ((Lisp_Object, Lisp_Object)); |
90400 | 267 static Lisp_Object ftfont_list_family P_ ((Lisp_Object)); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
268 static Lisp_Object ftfont_open P_ ((FRAME_PTR, Lisp_Object, int)); |
90400 | 269 static void ftfont_close P_ ((FRAME_PTR, struct font *)); |
270 static int ftfont_has_char P_ ((Lisp_Object, int)); | |
271 static unsigned ftfont_encode_char P_ ((struct font *, int)); | |
272 static int ftfont_text_extents P_ ((struct font *, unsigned *, int, | |
273 struct font_metrics *)); | |
274 static int ftfont_get_bitmap P_ ((struct font *, unsigned, | |
275 struct font_bitmap *, int)); | |
276 static int ftfont_anchor_point P_ ((struct font *, unsigned, int, | |
277 int *, int *)); | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
278 static Lisp_Object ftfont_shape P_ ((Lisp_Object)); |
90400 | 279 |
280 struct font_driver ftfont_driver = | |
281 { | |
90697
444b40002533
(ftfont_driver): Initialize ftfont_driver.type by 0.
Kenichi Handa <handa@m17n.org>
parents:
90680
diff
changeset
|
282 0, /* Qfreetype */ |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
283 0, /* case insensitive */ |
90400 | 284 ftfont_get_cache, |
285 ftfont_list, | |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
286 ftfont_match, |
90400 | 287 ftfont_list_family, |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
288 NULL, |
90400 | 289 ftfont_open, |
290 ftfont_close, | |
291 /* We can't draw a text without device dependent functions. */ | |
292 NULL, | |
293 NULL, | |
294 ftfont_has_char, | |
295 ftfont_encode_char, | |
296 ftfont_text_extents, | |
297 /* We can't draw a text without device dependent functions. */ | |
298 NULL, | |
299 ftfont_get_bitmap, | |
300 NULL, | |
301 NULL, | |
302 NULL, | |
303 ftfont_anchor_point, | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
304 NULL, |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
305 NULL, |
90400 | 306 NULL, |
307 NULL, | |
91308
9b6270bcd1a7
(ftfont_driver): Set ftfont_shape in ftfont_driver only
Kenichi Handa <handa@m17n.org>
parents:
91294
diff
changeset
|
308 #if defined (HAVE_M17N_FLT) && defined (HAVE_LIBOTF) |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
309 ftfont_shape |
91308
9b6270bcd1a7
(ftfont_driver): Set ftfont_shape in ftfont_driver only
Kenichi Handa <handa@m17n.org>
parents:
91294
diff
changeset
|
310 #else /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */ |
90400 | 311 NULL |
91308
9b6270bcd1a7
(ftfont_driver): Set ftfont_shape in ftfont_driver only
Kenichi Handa <handa@m17n.org>
parents:
91294
diff
changeset
|
312 #endif /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */ |
90400 | 313 }; |
314 | |
315 extern Lisp_Object QCname; | |
316 | |
317 static Lisp_Object | |
91249
4f21471103e6
(ftfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91214
diff
changeset
|
318 ftfont_get_cache (f) |
4f21471103e6
(ftfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91214
diff
changeset
|
319 FRAME_PTR f; |
90400 | 320 { |
321 return freetype_font_cache; | |
322 } | |
323 | |
95103 | 324 static int |
325 ftfont_get_charset (registry) | |
326 Lisp_Object registry; | |
327 { | |
328 struct charset *encoding; | |
329 int i, j; | |
330 | |
331 if (font_registry_charsets (registry, &encoding, NULL) < 0) | |
332 return -1; | |
333 if (fc_charset_table[0].charset_id < 0) | |
334 /* Setup charset_id field of all elements. */ | |
335 for (i = 0; fc_charset_table[i].name; i++) | |
336 { | |
337 Lisp_Object sym = intern (fc_charset_table[i].name); | |
338 | |
339 if (CHARSETP (sym)) | |
340 fc_charset_table[i].charset_id = XINT (CHARSET_SYMBOL_ID (sym)); | |
341 else | |
342 fc_charset_table[i].charset_id = -1; | |
343 } | |
344 | |
345 for (i = 0; fc_charset_table[i].name; i++) | |
346 if (encoding->id == fc_charset_table[i].charset_id) | |
347 break; | |
348 if (! fc_charset_table[i].name) | |
349 return -1; | |
350 if (! fc_charset_table[i].fc_charset) | |
351 { | |
352 FcCharSet *charset = FcCharSetCreate (); | |
353 int *uniquifier = fc_charset_table[i].uniquifier; | |
354 | |
355 if (! charset) | |
356 return -1; | |
357 for (j = 0; uniquifier[j]; j++) | |
358 if (! FcCharSetAddChar (charset, uniquifier[j])) | |
359 { | |
360 FcCharSetDestroy (charset); | |
361 return -1; | |
362 } | |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
363 fc_charset_table[i].fc_charset = charset; |
95103 | 364 } |
365 return i; | |
366 } | |
367 | |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
368 struct OpenTypeSpec |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
369 { |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
370 Lisp_Object script; |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
371 unsigned int script_tag, langsys_tag; |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
372 int nfeatures[2]; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
373 unsigned int *features[2]; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
374 }; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
375 |
91191
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
376 #define OTF_SYM_TAG(SYM, TAG) \ |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
377 do { \ |
91191
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
378 unsigned char *p = SDATA (SYMBOL_NAME (SYM)); \ |
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
379 TAG = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]; \ |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
380 } while (0) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
381 |
91191
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
382 #define OTF_TAG_STR(TAG, P) \ |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
383 do { \ |
91191
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
384 (P)[0] = (char) (TAG >> 24); \ |
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
385 (P)[1] = (char) ((TAG >> 16) & 0xFF); \ |
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
386 (P)[2] = (char) ((TAG >> 8) & 0xFF); \ |
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
387 (P)[3] = (char) (TAG & 0xFF); \ |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
388 (P)[4] = '\0'; \ |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
389 } while (0) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
390 |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
391 static struct OpenTypeSpec * |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
392 ftfont_get_open_type_spec (Lisp_Object otf_spec) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
393 { |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
394 struct OpenTypeSpec *spec = malloc (sizeof (struct OpenTypeSpec)); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
395 Lisp_Object val; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
396 int i, j, negative; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
397 |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
398 if (! spec) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
399 return NULL; |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
400 spec->script = XCAR (otf_spec); |
93588
917824e47986
(ftfont_get_open_type_spec): Check spec->script, not val.
Jason Rumney <jasonr@gnu.org>
parents:
92407
diff
changeset
|
401 if (! NILP (spec->script)) |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
402 { |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
403 OTF_SYM_TAG (spec->script, spec->script_tag); |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
404 val = assq_no_quit (spec->script, Votf_script_alist); |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
405 if (CONSP (val) && SYMBOLP (XCDR (val))) |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
406 spec->script = XCDR (val); |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
407 else |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
408 spec->script = Qnil; |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
409 } |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
410 else |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
411 spec->script_tag = 0x44464C54; /* "DFLT" */ |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
412 otf_spec = XCDR (otf_spec); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
413 val = XCAR (otf_spec); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
414 if (! NILP (val)) |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
415 OTF_SYM_TAG (val, spec->langsys_tag); |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
416 else |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
417 spec->langsys_tag = 0; |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
418 spec->nfeatures[0] = spec->nfeatures[1] = 0; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
419 for (i = 0; i < 2; i++) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
420 { |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
421 Lisp_Object len; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
422 |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
423 otf_spec = XCDR (otf_spec); |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
424 if (NILP (otf_spec)) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
425 break; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
426 val = XCAR (otf_spec); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
427 if (NILP (val)) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
428 continue; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
429 len = Flength (val); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
430 spec->features[i] = malloc (sizeof (int) * XINT (len)); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
431 if (! spec->features[i]) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
432 { |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
433 if (i > 0 && spec->features[0]) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
434 free (spec->features[0]); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
435 free (spec); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
436 return NULL; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
437 } |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
438 for (j = 0, negative = 0; CONSP (val); val = XCDR (val)) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
439 { |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
440 if (NILP (XCAR (val))) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
441 negative = 1; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
442 else |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
443 { |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
444 unsigned int tag; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
445 |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
446 OTF_SYM_TAG (XCAR (val), tag); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
447 spec->features[i][j++] = negative ? tag & 0x80000000 : tag; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
448 } |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
449 } |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
450 spec->nfeatures[i] = j; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
451 } |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
452 return spec; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
453 } |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
454 |
95103 | 455 static FcPattern *ftfont_spec_pattern P_ ((Lisp_Object, int *, char *, |
456 struct OpenTypeSpec **)); | |
457 | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
458 static FcPattern * |
95103 | 459 ftfont_spec_pattern (spec, fc_charset_idx, otlayout, otspec) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
460 Lisp_Object spec; |
95103 | 461 int *fc_charset_idx; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
462 char *otlayout; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
463 struct OpenTypeSpec **otspec; |
90400 | 464 { |
95103 | 465 Lisp_Object tmp, extra; |
90400 | 466 FcPattern *pattern = NULL; |
467 FcCharSet *charset = NULL; | |
468 FcLangSet *langset = NULL; | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
469 int n; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
470 int dpi = -1; |
90500
60e0667ab709
(ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents:
90480
diff
changeset
|
471 int scalable = -1; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
472 Lisp_Object name = Qnil; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
473 Lisp_Object script = Qnil; |
95103 | 474 Lisp_Object registry; |
90400 | 475 |
90480
908d27653432
(ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents:
90474
diff
changeset
|
476 if (! NILP (AREF (spec, FONT_ADSTYLE_INDEX)) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
477 && SBYTES (SYMBOL_NAME (AREF (spec, FONT_ADSTYLE_INDEX))) > 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
478 /* Fontconfig doesn't support adstyle property. */ |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
479 return NULL; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
480 if ((n = FONT_SLANT_NUMERIC (spec)) >= 0 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
481 && n < 100) |
90480
908d27653432
(ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents:
90474
diff
changeset
|
482 /* Fontconfig doesn't support reverse-italic/obligue. */ |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
483 return NULL; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
484 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
485 if (INTEGERP (AREF (spec, FONT_DPI_INDEX))) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
486 dpi = XINT (AREF (spec, FONT_DPI_INDEX)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
487 if (INTEGERP (AREF (spec, FONT_AVGWIDTH_INDEX)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
488 && XINT (AREF (spec, FONT_AVGWIDTH_INDEX)) == 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
489 scalable = 1; |
90480
908d27653432
(ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents:
90474
diff
changeset
|
490 |
95103 | 491 registry = AREF (spec, FONT_REGISTRY_INDEX); |
492 if (NILP (registry) | |
95698
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
493 || EQ (registry, Qascii_0) |
95103 | 494 || EQ (registry, Qiso10646_1) |
495 || EQ (registry, Qunicode_bmp) | |
496 || EQ (registry, Qunicode_sip)) | |
497 *fc_charset_idx = -1; | |
498 else | |
90400 | 499 { |
95103 | 500 *fc_charset_idx = ftfont_get_charset (registry); |
501 if (*fc_charset_idx < 0) | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
502 return NULL; |
95103 | 503 charset = fc_charset_table[*fc_charset_idx].fc_charset; |
90400 | 504 } |
505 | |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
506 otlayout[0] = '\0'; |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
507 for (extra = AREF (spec, FONT_EXTRA_INDEX); |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
508 CONSP (extra); extra = XCDR (extra)) |
90400 | 509 { |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
510 Lisp_Object key, val; |
90510
69dc5ab6d693
(ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents:
90500
diff
changeset
|
511 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
512 key = XCAR (XCAR (extra)), val = XCDR (XCAR (extra)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
513 if (EQ (key, QCdpi)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
514 dpi = XINT (val); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
515 else if (EQ (key, QCfc_unknown_spec)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
516 name = val; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
517 else if (EQ (key, QClang)) |
90400 | 518 { |
519 langset = FcLangSetCreate (); | |
520 if (! langset) | |
521 goto err; | |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
522 if (SYMBOLP (val)) |
90400 | 523 { |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
524 if (! FcLangSetAdd (langset, SYMBOL_FcChar8 (val))) |
90400 | 525 goto err; |
526 } | |
527 else | |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
528 for (; CONSP (val); val = XCDR (val)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
529 if (SYMBOLP (XCAR (val)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
530 && ! FcLangSetAdd (langset, SYMBOL_FcChar8 (XCAR (val)))) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
531 goto err; |
90400 | 532 } |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
533 else if (EQ (key, QCname)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
534 name = val; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
535 else if (EQ (key, QCotf)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
536 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
537 *otspec = ftfont_get_open_type_spec (val); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
538 if (! *otspec) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
539 return NULL; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
540 strcat (otlayout, "otlayout:"); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
541 OTF_TAG_STR ((*otspec)->script_tag, otlayout + 9); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
542 script = (*otspec)->script; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
543 } |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
544 else if (EQ (key, QCscript)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
545 script = val; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
546 else if (EQ (key, QCscalable)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
547 scalable = ! NILP (val); |
90400 | 548 } |
549 | |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
550 if (! NILP (script) && ! charset) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
551 { |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
552 Lisp_Object chars = assq_no_quit (script, Vscript_representative_chars); |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
553 |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
554 if (CONSP (chars)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
555 { |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
556 charset = FcCharSetCreate (); |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
557 if (! charset) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
558 goto err; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
559 for (chars = XCDR (chars); CONSP (chars); chars = XCDR (chars)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
560 if (CHARACTERP (XCAR (chars)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
561 && ! FcCharSetAddChar (charset, XUINT (XCAR (chars)))) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
562 goto err; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
563 } |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
564 } |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
565 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
566 pattern = NILP (name) ? FcPatternCreate () : FcNameParse (SDATA (name)); |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
567 if (! pattern) |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
568 goto err; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
569 FcPatternDel (pattern, FC_SIZE); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
570 FcPatternDel (pattern, FC_PIXEL_SIZE); |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
571 FcPatternDel (pattern, FC_FOUNDRY); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
572 FcPatternDel (pattern, FC_FAMILY); |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
573 tmp = AREF (spec, FONT_FOUNDRY_INDEX); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
574 if (! NILP (tmp) |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
575 && ! FcPatternAddString (pattern, FC_FOUNDRY, SYMBOL_FcChar8 (tmp))) |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
576 goto err; |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
577 tmp = AREF (spec, FONT_FAMILY_INDEX); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
578 if (! NILP (tmp) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
579 && ! FcPatternAddString (pattern, FC_FAMILY, SYMBOL_FcChar8 (tmp))) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
580 goto err; |
90400 | 581 if (charset |
582 && ! FcPatternAddCharSet (pattern, FC_CHARSET, charset)) | |
583 goto err; | |
584 if (langset | |
585 && ! FcPatternAddLangSet (pattern, FC_LANG, langset)) | |
586 goto err; | |
90500
60e0667ab709
(ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents:
90480
diff
changeset
|
587 if (dpi >= 0 |
60e0667ab709
(ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents:
90480
diff
changeset
|
588 && ! FcPatternAddDouble (pattern, FC_DPI, dpi)) |
60e0667ab709
(ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents:
90480
diff
changeset
|
589 goto err; |
60e0667ab709
(ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents:
90480
diff
changeset
|
590 if (scalable >= 0 |
90522 | 591 && ! FcPatternAddBool (pattern, FC_SCALABLE, scalable ? FcTrue : FcFalse)) |
90500
60e0667ab709
(ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents:
90480
diff
changeset
|
592 goto err; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
593 goto finish; |
90400 | 594 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
595 err: |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
596 /* We come here because of unexpected error in fontconfig API call |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
597 (usually insufficient memory). */ |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
598 if (pattern) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
599 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
600 FcPatternDestroy (pattern); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
601 pattern = NULL; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
602 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
603 if (*otspec) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
604 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
605 if ((*otspec)->nfeatures[0] > 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
606 free ((*otspec)->features[0]); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
607 if ((*otspec)->nfeatures[1] > 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
608 free ((*otspec)->features[1]); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
609 free (*otspec); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
610 *otspec = NULL; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
611 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
612 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
613 finish: |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
614 if (langset) FcLangSetDestroy (langset); |
95229
38cbd89dd626
(ftfont_spec_pattern): Free charset if necessary.
Kenichi Handa <handa@m17n.org>
parents:
95182
diff
changeset
|
615 if (charset && *fc_charset_idx < 0) FcCharSetDestroy (charset); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
616 return pattern; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
617 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
618 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
619 static Lisp_Object |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
620 ftfont_list (frame, spec) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
621 Lisp_Object frame, spec; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
622 { |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
623 Lisp_Object val = Qnil, registry, family; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
624 int i; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
625 FcPattern *pattern; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
626 FcFontSet *fontset = NULL; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
627 FcObjectSet *objset = NULL; |
95103 | 628 int fc_charset_idx; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
629 char otlayout[15]; /* For "otlayout:XXXX" */ |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
630 struct OpenTypeSpec *otspec = NULL; |
95358
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
631 int spacing = -1; |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
632 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
633 if (! fc_initialized) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
634 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
635 FcInit (); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
636 fc_initialized = 1; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
637 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
638 |
95103 | 639 pattern = ftfont_spec_pattern (spec, &fc_charset_idx, otlayout, &otspec); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
640 if (! pattern) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
641 return Qnil; |
95358
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
642 if (INTEGERP (AREF (spec, FONT_SPACING_INDEX))) |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
643 spacing = XINT (AREF (spec, FONT_SPACING_INDEX)); |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
644 registry = AREF (spec, FONT_REGISTRY_INDEX); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
645 family = AREF (spec, FONT_FAMILY_INDEX); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
646 if (! NILP (family)) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
647 { |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
648 Lisp_Object resolved; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
649 |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
650 resolved = ftfont_resolve_generic_family (family); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
651 if (! NILP (resolved)) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
652 { |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
653 FcPatternDel (pattern, FC_FAMILY); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
654 if (! FcPatternAddString (pattern, FC_FAMILY, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
655 SYMBOL_FcChar8 (resolved))) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
656 goto err; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
657 } |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
658 } |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
659 |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
660 objset = FcObjectSetBuild (FC_FOUNDRY, FC_FAMILY, FC_WEIGHT, FC_SLANT, |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
661 FC_WIDTH, FC_PIXEL_SIZE, FC_SPACING, FC_SCALABLE, |
95358
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
662 FC_FILE, |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
663 #ifdef FC_CAPABILITY |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
664 FC_CAPABILITY, |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
665 #endif /* FC_CAPABILITY */ |
90680
254cfd053f9c
(ftfont_pattern_entity): Check if FC_FONTFORMAT is
Kenichi Handa <handa@m17n.org>
parents:
90676
diff
changeset
|
666 NULL); |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
667 if (! objset) |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
668 goto err; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
669 |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
670 fontset = FcFontList (NULL, pattern, objset); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
671 if (! fontset) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
672 goto err; |
95698
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
673 #if 0 |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
674 /* Need fix because this finds any fonts. */ |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
675 if (fontset->nfont == 0 && ! NILP (family)) |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
676 { |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
677 /* Try maching with configuration. For instance, the |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
678 configuration may specify "Nimbus Mono L" as an alias of |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
679 "Courier". */ |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
680 FcPattern *pat = FcPatternBuild (0, FC_FAMILY, FcTypeString, |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
681 SYMBOL_FcChar8 (family), NULL); |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
682 FcChar8 *fam; |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
683 |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
684 if (FcConfigSubstitute (NULL, pat, FcMatchPattern) == FcTrue) |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
685 { |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
686 for (i = 0; |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
687 FcPatternGetString (pat, FC_FAMILY, i, &fam) == FcResultMatch; |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
688 i++) |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
689 { |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
690 FcPatternDel (pattern, FC_FAMILY); |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
691 FcPatternAddString (pattern, FC_FAMILY, fam); |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
692 FcFontSetDestroy (fontset); |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
693 fontset = FcFontList (NULL, pattern, objset); |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
694 if (fontset->nfont > 0) |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
695 break; |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
696 } |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
697 } |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
698 } |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
699 #endif |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
700 for (i = 0; i < fontset->nfont; i++) |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
701 { |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
702 Lisp_Object entity; |
90474
8627c9321afb
(ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents:
90464
diff
changeset
|
703 |
95358
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
704 if (spacing >= 0) |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
705 { |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
706 int this; |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
707 |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
708 if ((FcPatternGetInteger (fontset->fonts[i], FC_SPACING, 0, &this) |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
709 == FcResultMatch) |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
710 && spacing != this) |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
711 continue; |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
712 } |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
713 |
90516
43ea66432bf9
(ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
90514
diff
changeset
|
714 #ifdef FC_CAPABILITY |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
715 if (otlayout[0]) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
716 { |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
717 FcChar8 *this; |
90510
69dc5ab6d693
(ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents:
90500
diff
changeset
|
718 |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
719 if (FcPatternGetString (fontset->fonts[i], FC_CAPABILITY, 0, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
720 &this) != FcResultMatch |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
721 || ! strstr ((char *) this, otlayout)) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
722 continue; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
723 } |
90516
43ea66432bf9
(ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
90514
diff
changeset
|
724 #endif /* FC_CAPABILITY */ |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
725 #ifdef HAVE_LIBOTF |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
726 if (otspec) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
727 { |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
728 FcChar8 *file; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
729 OTF *otf; |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
730 |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
731 if (FcPatternGetString (fontset->fonts[i], FC_FILE, 0, &file) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
732 != FcResultMatch) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
733 continue; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
734 otf = OTF_open ((char *) file); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
735 if (! otf) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
736 continue; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
737 if (OTF_check_features (otf, 1, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
738 otspec->script_tag, otspec->langsys_tag, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
739 otspec->features[0], |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
740 otspec->nfeatures[0]) != 1 |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
741 || OTF_check_features (otf, 0, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
742 otspec->script_tag, otspec->langsys_tag, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
743 otspec->features[1], |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
744 otspec->nfeatures[1]) != 1) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
745 continue; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
746 } |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
747 #endif /* HAVE_LIBOTF */ |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
748 entity = ftfont_pattern_entity (fontset->fonts[i], registry, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
749 fc_charset_idx); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
750 if (! NILP (entity)) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
751 val = Fcons (entity, val); |
90400 | 752 } |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
753 font_add_log ("ftfont-list", spec, val); |
90400 | 754 goto finish; |
755 | |
756 err: | |
757 /* We come here because of unexpected error in fontconfig API call | |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
758 (usually insufficient memory). */ |
90400 | 759 val = Qnil; |
760 | |
761 finish: | |
762 if (objset) FcObjectSetDestroy (objset); | |
763 if (fontset) FcFontSetDestroy (fontset); | |
764 if (pattern) FcPatternDestroy (pattern); | |
765 return val; | |
766 } | |
767 | |
768 static Lisp_Object | |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
769 ftfont_match (frame, spec) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
770 Lisp_Object frame, spec; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
771 { |
95103 | 772 Lisp_Object entity; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
773 FcPattern *pattern, *match = NULL; |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
774 FcResult result; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
775 char otlayout[15]; /* For "otlayout:XXXX" */ |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
776 struct OpenTypeSpec *otspec = NULL; |
95103 | 777 int fc_charset_idx; |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
778 |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
779 if (! fc_initialized) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
780 { |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
781 FcInit (); |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
782 fc_initialized = 1; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
783 } |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
784 |
95103 | 785 pattern = ftfont_spec_pattern (spec, &fc_charset_idx, otlayout, &otspec); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
786 if (! pattern) |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
787 return Qnil; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
788 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
789 if (INTEGERP (AREF (spec, FONT_SIZE_INDEX))) |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
790 { |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
791 FcValue value; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
792 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
793 value.type = FcTypeDouble; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
794 value.u.d = XINT (AREF (spec, FONT_SIZE_INDEX)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
795 FcPatternAdd (pattern, FC_PIXEL_SIZE, value, FcFalse); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
796 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
797 if (FcConfigSubstitute (NULL, pattern, FcMatchPattern) == FcTrue) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
798 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
799 FcDefaultSubstitute (pattern); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
800 match = FcFontMatch (NULL, pattern, &result); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
801 if (match) |
92301
c10a8c811515
(ftfont_match): Explicitly set pixelsize in pattern.
Kenichi Handa <handa@m17n.org>
parents:
91870
diff
changeset
|
802 { |
95103 | 803 entity = ftfont_pattern_entity (match, Qunicode_bmp, fc_charset_idx); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
804 FcPatternDestroy (match); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
805 if (! NILP (AREF (spec, FONT_FAMILY_INDEX)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
806 && NILP (assq_no_quit (AREF (spec, FONT_FAMILY_INDEX), |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
807 ftfont_generic_family_list)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
808 && NILP (Fstring_equal (AREF (spec, FONT_FAMILY_INDEX), |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
809 AREF (entity, FONT_FAMILY_INDEX)))) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
810 entity = Qnil; |
92301
c10a8c811515
(ftfont_match): Explicitly set pixelsize in pattern.
Kenichi Handa <handa@m17n.org>
parents:
91870
diff
changeset
|
811 } |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
812 } |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
813 FcPatternDestroy (pattern); |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
814 |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
815 font_add_log ("ftfont-match", spec, entity); |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
816 return entity; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
817 } |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
818 |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
819 static Lisp_Object |
90400 | 820 ftfont_list_family (frame) |
821 Lisp_Object frame; | |
822 { | |
823 Lisp_Object list; | |
824 FcPattern *pattern = NULL; | |
825 FcFontSet *fontset = NULL; | |
826 FcObjectSet *objset = NULL; | |
827 int i; | |
828 | |
829 if (! fc_initialized) | |
830 { | |
831 FcInit (); | |
832 fc_initialized = 1; | |
833 } | |
834 | |
835 pattern = FcPatternCreate (); | |
836 if (! pattern) | |
837 goto finish; | |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
838 objset = FcObjectSetBuild (FC_FAMILY, NULL); |
90400 | 839 if (! objset) |
840 goto finish; | |
841 fontset = FcFontList (NULL, pattern, objset); | |
842 if (! fontset) | |
843 goto finish; | |
844 | |
845 list = Qnil; | |
846 for (i = 0; i < fontset->nfont; i++) | |
847 { | |
848 FcPattern *pat = fontset->fonts[i]; | |
849 FcChar8 *str; | |
850 | |
851 if (FcPatternGetString (pat, FC_FAMILY, 0, &str) == FcResultMatch) | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
852 list = Fcons (intern ((char *) str), list); |
90400 | 853 } |
854 | |
855 finish: | |
856 if (objset) FcObjectSetDestroy (objset); | |
857 if (fontset) FcFontSetDestroy (fontset); | |
858 if (pattern) FcPatternDestroy (pattern); | |
859 | |
860 return list; | |
861 } | |
862 | |
863 | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
864 static Lisp_Object |
90400 | 865 ftfont_open (f, entity, pixel_size) |
866 FRAME_PTR f; | |
867 Lisp_Object entity; | |
868 int pixel_size; | |
869 { | |
870 struct ftfont_info *ftfont_info; | |
871 struct font *font; | |
872 FT_Face ft_face; | |
873 FT_Size ft_size; | |
874 FT_UInt size; | |
95103 | 875 Lisp_Object val, filename, cache, font_object; |
876 int fc_charset_idx; | |
90400 | 877 FcPattern *pattern; |
95103 | 878 int scalable; |
90400 | 879 int spacing; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
880 char name[256]; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
881 int i, len; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
882 int upEM; |
90400 | 883 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
884 val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
885 if (! CONSP (val)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
886 return Qnil; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
887 val = XCDR (val); |
95103 | 888 filename = XCAR (val); |
889 fc_charset_idx = XINT (XCDR (val)); | |
890 cache = ftfont_lookup_cache (filename); | |
891 if (NILP (cache)) | |
892 return Qnil; | |
893 filename = XCAR (cache); | |
894 val = XCDR (cache); | |
895 ft_face = XSAVE_VALUE (val)->pointer; | |
896 if (XSAVE_VALUE (val)->integer > 0) | |
90400 | 897 { |
95103 | 898 /* FT_Face in this cache is already used by the different size. */ |
90400 | 899 if (FT_New_Size (ft_face, &ft_size) != 0) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
900 return Qnil; |
90400 | 901 if (FT_Activate_Size (ft_size) != 0) |
902 { | |
903 FT_Done_Size (ft_size); | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
904 return Qnil; |
90400 | 905 } |
95103 | 906 } |
907 XSAVE_VALUE (val)->integer++; | |
90400 | 908 size = XINT (AREF (entity, FONT_SIZE_INDEX)); |
909 if (size == 0) | |
910 size = pixel_size; | |
911 if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0) | |
912 { | |
913 if (XSAVE_VALUE (val)->integer == 0) | |
914 FT_Done_Face (ft_face); | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
915 return Qnil; |
90400 | 916 } |
917 | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
918 font_object = font_make_object (VECSIZE (struct ftfont_info)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
919 ASET (font_object, FONT_TYPE_INDEX, Qfreetype); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
920 for (i = 1;i < FONT_ENTITY_MAX; i++) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
921 ASET (font_object, i, AREF (entity, i)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
922 ASET (font_object, FONT_SIZE_INDEX, make_number (size)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
923 len = font_unparse_xlfd (entity, size, name, 256); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
924 if (len > 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
925 ASET (font_object, FONT_NAME_INDEX, make_unibyte_string (name, len)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
926 len = font_unparse_fcname (entity, size, name, 256); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
927 if (len > 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
928 ASET (font_object, FONT_FULLNAME_INDEX, make_unibyte_string (name, len)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
929 else |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
930 ASET (font_object, FONT_FULLNAME_INDEX, |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
931 AREF (font_object, FONT_NAME_INDEX)); |
95103 | 932 ASET (font_object, FONT_FILE_INDEX, filename); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
933 ASET (font_object, FONT_FORMAT_INDEX, ftfont_font_format (pattern)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
934 font = XFONT_OBJECT (font_object); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
935 ftfont_info = (struct ftfont_info *) font; |
95103 | 936 ftfont_info->ft_size = ft_face->size; |
937 ftfont_info->fc_charset_idx = fc_charset_idx; | |
91162
2b263ef46651
(ftfont_open): Set members maybe_otf and otf of
Kenichi Handa <handa@m17n.org>
parents:
91137
diff
changeset
|
938 #ifdef HAVE_LIBOTF |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
939 ftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
940 ftfont_info->otf = NULL; |
91162
2b263ef46651
(ftfont_open): Set members maybe_otf and otf of
Kenichi Handa <handa@m17n.org>
parents:
91137
diff
changeset
|
941 #endif /* HAVE_LIBOTF */ |
90400 | 942 font->pixel_size = size; |
943 font->driver = &ftfont_driver; | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
944 font->encoding_charset = font->repertory_charset = -1; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
945 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
946 upEM = ft_face->units_per_EM; |
95103 | 947 scalable = (INTEGERP (AREF (entity, FONT_AVGWIDTH_INDEX)) |
948 && XINT (AREF (entity, FONT_AVGWIDTH_INDEX)) == 0); | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
949 if (scalable) |
90555
45553626fa76
(ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents:
90524
diff
changeset
|
950 { |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
951 font->ascent = ft_face->ascender * size / upEM; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
952 font->descent = - ft_face->descender * size / upEM; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
953 font->height = ft_face->height * size / upEM; |
90555
45553626fa76
(ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents:
90524
diff
changeset
|
954 } |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
955 else |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
956 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
957 font->ascent = ft_face->size->metrics.ascender >> 6; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
958 font->descent = - ft_face->size->metrics.descender >> 6; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
959 font->height = ft_face->size->metrics.height >> 6; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
960 } |
95103 | 961 if (INTEGERP (AREF (entity, FONT_SPACING_INDEX))) |
962 spacing = XINT (AREF (entity, FONT_SPACING_INDEX)); | |
963 else | |
90555
45553626fa76
(ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents:
90524
diff
changeset
|
964 spacing = FC_PROPORTIONAL; |
45553626fa76
(ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents:
90524
diff
changeset
|
965 if (spacing != FC_PROPORTIONAL) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
966 font->min_width = font->average_width = font->space_width |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
967 = (scalable ? ft_face->max_advance_width * size / upEM |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
968 : ft_face->size->metrics.max_advance >> 6); |
90400 | 969 else |
970 { | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
971 int n; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
972 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
973 font->min_width = font->average_width = font->space_width = 0; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
974 for (i = 32, n = 0; i < 127; i++) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
975 if (FT_Load_Char (ft_face, i, FT_LOAD_DEFAULT) != 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
976 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
977 int this_width = ft_face->glyph->metrics.horiAdvance >> 6; |
90400 | 978 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
979 if (this_width > 0 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
980 && (! font->min_width || font->min_width > this_width)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
981 font->min_width = this_width; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
982 if (i == 32) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
983 font->space_width = this_width; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
984 font->average_width += this_width; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
985 n++; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
986 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
987 if (n > 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
988 font->average_width /= n; |
90400 | 989 } |
990 | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
991 font->baseline_offset = 0; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
992 font->relative_compose = 0; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
993 font->default_ascent = 0; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
994 font->vertical_centering = 0; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
995 if (scalable) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
996 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
997 font->underline_position = -ft_face->underline_position * size / upEM; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
998 font->underline_thickness = -ft_face->underline_thickness * size / upEM; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
999 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1000 else |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1001 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1002 font->underline_position = -1; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1003 font->underline_thickness = 0; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1004 } |
90555
45553626fa76
(ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents:
90524
diff
changeset
|
1005 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1006 return font_object; |
90400 | 1007 } |
1008 | |
1009 static void | |
1010 ftfont_close (f, font) | |
1011 FRAME_PTR f; | |
1012 struct font *font; | |
1013 { | |
1014 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | |
95103 | 1015 Lisp_Object val, cache; |
90400 | 1016 |
95103 | 1017 cache = ftfont_lookup_cache (font->props[FONT_FILE_INDEX]); |
1018 val = XCDR (cache); | |
90400 | 1019 (XSAVE_VALUE (val)->integer)--; |
1020 if (XSAVE_VALUE (val)->integer == 0) | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1021 { |
95103 | 1022 FT_Face ft_face = XSAVE_VALUE (val)->pointer; |
1023 | |
1024 FT_Done_Face (ft_face); | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1025 #ifdef HAVE_LIBOTF |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1026 if (ftfont_info->otf) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1027 OTF_close (ftfont_info->otf); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1028 #endif |
95103 | 1029 XSAVE_VALUE (val)->pointer = NULL; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1030 } |
90400 | 1031 else |
1032 FT_Done_Size (ftfont_info->ft_size); | |
1033 } | |
1034 | |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
1035 static int |
90400 | 1036 ftfont_has_char (entity, c) |
1037 Lisp_Object entity; | |
1038 int c; | |
1039 { | |
1040 Lisp_Object val; | |
95103 | 1041 int fc_charset_idx; |
1042 struct charset *charset; | |
90400 | 1043 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1044 val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX)); |
95103 | 1045 fc_charset_idx = XINT (XCDR (XCDR (val))); |
1046 if (fc_charset_idx < 0) | |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1047 return -1; |
95103 | 1048 charset = CHARSET_FROM_ID (fc_charset_table[fc_charset_idx].charset_id); |
1049 return (ENCODE_CHAR (charset, c) != CHARSET_INVALID_CODE (charset)); | |
90400 | 1050 } |
1051 | |
1052 static unsigned | |
1053 ftfont_encode_char (font, c) | |
1054 struct font *font; | |
1055 int c; | |
1056 { | |
1057 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | |
1058 FT_Face ft_face = ftfont_info->ft_size->face; | |
1059 FT_ULong charcode = c; | |
1060 FT_UInt code = FT_Get_Char_Index (ft_face, charcode); | |
1061 | |
91271
fed5211f4809
(ftfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91249
diff
changeset
|
1062 return (code > 0 ? code : FONT_INVALID_CODE); |
90400 | 1063 } |
1064 | |
1065 static int | |
1066 ftfont_text_extents (font, code, nglyphs, metrics) | |
1067 struct font *font; | |
1068 unsigned *code; | |
1069 int nglyphs; | |
1070 struct font_metrics *metrics; | |
1071 { | |
1072 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | |
1073 FT_Face ft_face = ftfont_info->ft_size->face; | |
1074 int width = 0; | |
1075 int i; | |
1076 | |
1077 if (ftfont_info->ft_size != ft_face->size) | |
1078 FT_Activate_Size (ftfont_info->ft_size); | |
1079 if (metrics) | |
1080 bzero (metrics, sizeof (struct font_metrics)); | |
1081 for (i = 0; i < nglyphs; i++) | |
1082 { | |
1083 if (FT_Load_Glyph (ft_face, code[i], FT_LOAD_DEFAULT) == 0) | |
1084 { | |
1085 FT_Glyph_Metrics *m = &ft_face->glyph->metrics; | |
1086 | |
1087 if (metrics) | |
1088 { | |
1089 if (metrics->lbearing > width + (m->horiBearingX >> 6)) | |
1090 metrics->lbearing = width + (m->horiBearingX >> 6); | |
1091 if (metrics->rbearing | |
1092 < width + ((m->horiBearingX + m->width) >> 6)) | |
1093 metrics->rbearing | |
1094 = width + ((m->horiBearingX + m->width) >> 6); | |
1095 if (metrics->ascent < (m->horiBearingY >> 6)) | |
1096 metrics->ascent = m->horiBearingY >> 6; | |
1097 if (metrics->descent > ((m->horiBearingY + m->height) >> 6)) | |
1098 metrics->descent = (m->horiBearingY + m->height) >> 6; | |
1099 } | |
1100 width += m->horiAdvance >> 6; | |
1101 } | |
1102 else | |
1103 { | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1104 width += font->space_width; |
90400 | 1105 } |
1106 } | |
1107 if (metrics) | |
1108 metrics->width = width; | |
1109 | |
1110 return width; | |
1111 } | |
1112 | |
1113 static int | |
1114 ftfont_get_bitmap (font, code, bitmap, bits_per_pixel) | |
1115 struct font *font; | |
1116 unsigned code; | |
1117 struct font_bitmap *bitmap; | |
1118 int bits_per_pixel; | |
1119 { | |
1120 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | |
1121 FT_Face ft_face = ftfont_info->ft_size->face; | |
1122 FT_Int32 load_flags = FT_LOAD_RENDER; | |
1123 | |
1124 if (ftfont_info->ft_size != ft_face->size) | |
1125 FT_Activate_Size (ftfont_info->ft_size); | |
1126 if (bits_per_pixel == 1) | |
1127 { | |
1128 #ifdef FT_LOAD_TARGET_MONO | |
1129 load_flags |= FT_LOAD_TARGET_MONO; | |
1130 #else | |
1131 load_flags |= FT_LOAD_MONOCHROME; | |
1132 #endif | |
1133 } | |
1134 else if (bits_per_pixel != 8) | |
1135 /* We don't support such a rendering. */ | |
1136 return -1; | |
1137 | |
1138 if (FT_Load_Glyph (ft_face, code, load_flags) != 0) | |
1139 return -1; | |
91108
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1140 bitmap->bits_per_pixel |
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1141 = (ft_face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_MONO ? 1 |
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1142 : ft_face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_GRAY ? 8 |
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1143 : ft_face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_LCD ? 8 |
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1144 : ft_face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_LCD_V ? 8 |
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1145 : -1); |
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1146 if (bitmap->bits_per_pixel < 0) |
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1147 /* We don't suport that kind of pixel mode. */ |
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1148 return -1; |
90400 | 1149 bitmap->rows = ft_face->glyph->bitmap.rows; |
1150 bitmap->width = ft_face->glyph->bitmap.width; | |
1151 bitmap->pitch = ft_face->glyph->bitmap.pitch; | |
1152 bitmap->buffer = ft_face->glyph->bitmap.buffer; | |
1153 bitmap->left = ft_face->glyph->bitmap_left; | |
1154 bitmap->top = ft_face->glyph->bitmap_top; | |
1155 bitmap->advance = ft_face->glyph->metrics.horiAdvance >> 6; | |
1156 bitmap->extra = NULL; | |
1157 | |
1158 return 0; | |
1159 } | |
1160 | |
1161 static int | |
1162 ftfont_anchor_point (font, code, index, x, y) | |
1163 struct font *font; | |
1164 unsigned code; | |
1165 int index; | |
1166 int *x, *y; | |
1167 { | |
1168 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | |
1169 FT_Face ft_face = ftfont_info->ft_size->face; | |
1170 | |
1171 if (ftfont_info->ft_size != ft_face->size) | |
1172 FT_Activate_Size (ftfont_info->ft_size); | |
1173 if (FT_Load_Glyph (ft_face, code, FT_LOAD_DEFAULT) != 0) | |
1174 return -1; | |
1175 if (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE) | |
1176 return -1; | |
1177 if (index >= ft_face->glyph->outline.n_points) | |
1178 return -1; | |
1179 *x = ft_face->glyph->outline.points[index].x; | |
1180 *y = ft_face->glyph->outline.points[index].y; | |
1181 return 0; | |
1182 } | |
1183 | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1184 #ifdef HAVE_LIBOTF |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1185 #ifdef HAVE_M17N_FLT |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1186 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1187 struct MFLTFontFT |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1188 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1189 MFLTFont flt_font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1190 struct font *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1191 FT_Face ft_face; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1192 OTF *otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1193 }; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1194 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1195 static int |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1196 ftfont_get_glyph_id (font, gstring, from, to) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1197 MFLTFont *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1198 MFLTGlyphString *gstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1199 int from, to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1200 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1201 struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1202 FT_Face ft_face = flt_font_ft->ft_face; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1203 MFLTGlyph *g; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1204 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1205 for (g = gstring->glyphs + from; from < to; g++, from++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1206 if (! g->encoded) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1207 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1208 FT_UInt code = FT_Get_Char_Index (ft_face, g->code); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1209 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1210 g->code = code > 0 ? code : FONT_INVALID_CODE; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1211 g->encoded = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1212 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1213 return 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1214 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1215 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1216 static int |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1217 ftfont_get_metrics (font, gstring, from, to) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1218 MFLTFont *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1219 MFLTGlyphString *gstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1220 int from, to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1221 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1222 struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1223 FT_Face ft_face = flt_font_ft->ft_face; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1224 MFLTGlyph *g; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1225 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1226 for (g = gstring->glyphs + from; from < to; g++, from++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1227 if (! g->measured) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1228 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1229 if (g->code != FONT_INVALID_CODE) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1230 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1231 FT_Glyph_Metrics *m; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1232 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1233 if (FT_Load_Glyph (ft_face, g->code, FT_LOAD_DEFAULT) != 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1234 abort (); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1235 m = &ft_face->glyph->metrics; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1236 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1237 g->lbearing = m->horiBearingX; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1238 g->rbearing = m->horiBearingX + m->width; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1239 g->ascent = m->horiBearingY; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1240 g->descent = m->height - m->horiBearingY; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1241 g->xadv = m->horiAdvance; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1242 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1243 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1244 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1245 g->lbearing = 0; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1246 g->rbearing = g->xadv = flt_font_ft->font->space_width << 6; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1247 g->ascent = flt_font_ft->font->ascent << 6; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1248 g->descent = flt_font_ft->font->descent << 6; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1249 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1250 g->yadv = 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1251 g->measured = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1252 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1253 return 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1254 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1255 |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
1256 static int |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1257 ftfont_check_otf (MFLTFont *font, MFLTOtfSpec *spec) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1258 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1259 struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1260 OTF *otf = flt_font_ft->otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1261 OTF_Tag *tags; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1262 int i, n, negative; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1263 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1264 for (i = 0; i < 2; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1265 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1266 if (! spec->features[i]) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1267 continue; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1268 for (n = 0; spec->features[i][n]; n++); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1269 tags = alloca (sizeof (OTF_Tag) * n); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1270 for (n = 0, negative = 0; spec->features[i][n]; n++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1271 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1272 if (spec->features[i][n] == 0xFFFFFFFF) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1273 negative = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1274 else if (negative) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1275 tags[n - 1] = spec->features[i][n] | 0x80000000; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1276 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1277 tags[n] = spec->features[i][n]; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1278 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1279 if (n - negative > 0 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1280 && OTF_check_features (otf, i == 0, spec->script, spec->langsys, |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1281 tags, n - negative) != 1) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1282 return 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1283 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1284 return 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1285 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1286 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1287 #define DEVICE_DELTA(table, size) \ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1288 (((size) >= (table).StartSize && (size) <= (table).EndSize) \ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1289 ? (table).DeltaValue[(size) - (table).StartSize] << 6 \ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1290 : 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1291 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1292 static void |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1293 adjust_anchor (FT_Face ft_face, OTF_Anchor *anchor, |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1294 unsigned code, int x_ppem, int y_ppem, int *x, int *y) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1295 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1296 if (anchor->AnchorFormat == 2) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1297 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1298 FT_Outline *outline; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1299 int ap = anchor->f.f1.AnchorPoint; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1300 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1301 FT_Load_Glyph (ft_face, (FT_UInt) code, FT_LOAD_MONOCHROME); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1302 outline = &ft_face->glyph->outline; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1303 if (ap < outline->n_points) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1304 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1305 *x = outline->points[ap].x << 6; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1306 *y = outline->points[ap].y << 6; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1307 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1308 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1309 else if (anchor->AnchorFormat == 3) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1310 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1311 if (anchor->f.f2.XDeviceTable.offset) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1312 *x += DEVICE_DELTA (anchor->f.f2.XDeviceTable, x_ppem); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1313 if (anchor->f.f2.YDeviceTable.offset) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1314 *y += DEVICE_DELTA (anchor->f.f2.YDeviceTable, y_ppem); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1315 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1316 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1317 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1318 static OTF_GlyphString otf_gstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1319 |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
1320 static int |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1321 ftfont_drive_otf (font, spec, in, from, to, out, adjustment) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1322 MFLTFont *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1323 MFLTOtfSpec *spec; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1324 MFLTGlyphString *in; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1325 int from, to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1326 MFLTGlyphString *out; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1327 MFLTGlyphAdjustment *adjustment; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1328 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1329 struct MFLTFontFT *flt_font_ft = (struct MFLTFontFT *) font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1330 FT_Face ft_face = flt_font_ft->ft_face; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1331 OTF *otf = flt_font_ft->otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1332 int len = to - from; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1333 int i, j, gidx; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1334 OTF_Glyph *otfg; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1335 char script[5], *langsys = NULL; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1336 char *gsub_features = NULL, *gpos_features = NULL; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1337 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1338 if (len == 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1339 return from; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1340 OTF_tag_name (spec->script, script); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1341 if (spec->langsys) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1342 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1343 langsys = alloca (5); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1344 OTF_tag_name (spec->langsys, langsys); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1345 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1346 for (i = 0; i < 2; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1347 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1348 char *p; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1349 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1350 if (spec->features[i] && spec->features[i][1] != 0xFFFFFFFF) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1351 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1352 for (j = 0; spec->features[i][j]; j++); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1353 if (i == 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1354 p = gsub_features = alloca (6 * j); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1355 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1356 p = gpos_features = alloca (6 * j); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1357 for (j = 0; spec->features[i][j]; j++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1358 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1359 if (spec->features[i][j] == 0xFFFFFFFF) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1360 *p++ = '*', *p++ = ','; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1361 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1362 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1363 OTF_tag_name (spec->features[i][j], p); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1364 p[4] = ','; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1365 p += 5; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1366 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1367 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1368 *--p = '\0'; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1369 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1370 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1371 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1372 if (otf_gstring.size == 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1373 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1374 otf_gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * len); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1375 otf_gstring.size = len; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1376 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1377 else if (otf_gstring.size < len) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1378 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1379 otf_gstring.glyphs = (OTF_Glyph *) realloc (otf_gstring.glyphs, |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1380 sizeof (OTF_Glyph) * len); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1381 otf_gstring.size = len; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1382 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1383 otf_gstring.used = len; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1384 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * len); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1385 for (i = 0; i < len; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1386 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1387 otf_gstring.glyphs[i].c = in->glyphs[from + i].c; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1388 otf_gstring.glyphs[i].glyph_id = in->glyphs[from + i].code; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1389 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1390 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1391 OTF_drive_gdef (otf, &otf_gstring); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1392 gidx = out->used; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1393 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1394 if (gsub_features) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1395 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1396 if (OTF_drive_gsub (otf, &otf_gstring, script, langsys, gsub_features) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1397 < 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1398 goto simple_copy; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1399 if (out->allocated < out->used + otf_gstring.used) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1400 return -2; |
91294
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1401 for (i = 0, otfg = otf_gstring.glyphs; i < otf_gstring.used; ) |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1402 { |
91294
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1403 MFLTGlyph *g; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1404 int min_from, max_to; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1405 int j; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1406 |
91294
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1407 g = out->glyphs + out->used; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1408 *g = in->glyphs[from + otfg->f.index.from]; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1409 if (g->code != otfg->glyph_id) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1410 { |
91294
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1411 g->c = 0; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1412 g->code = otfg->glyph_id; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1413 g->measured = 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1414 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1415 out->used++; |
91294
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1416 min_from = g->from; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1417 max_to = g->to; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1418 if (otfg->f.index.from < otfg->f.index.to) |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1419 { |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1420 /* OTFG substitutes multiple glyphs in IN. */ |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1421 for (j = from + otfg->f.index.from + 1; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1422 j <= from + otfg->f.index.to; j++) |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1423 { |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1424 if (min_from > in->glyphs[j].from) |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1425 min_from = in->glyphs[j].from; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1426 if (max_to < in->glyphs[j].to) |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1427 max_to = in->glyphs[j].to; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1428 } |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1429 g->from = min_from; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1430 g->to = max_to; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1431 } |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1432 for (i++, otfg++; (i < otf_gstring.used |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1433 && otfg->f.index.from == otfg[-1].f.index.from); |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1434 i++, otfg++) |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1435 { |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1436 g = out->glyphs + out->used; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1437 *g = in->glyphs[from + otfg->f.index.to]; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1438 if (g->code != otfg->glyph_id) |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1439 { |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1440 g->c = 0; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1441 g->code = otfg->glyph_id; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1442 g->measured = 0; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1443 } |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1444 out->used++; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1445 } |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1446 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1447 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1448 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1449 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1450 if (out->allocated < out->used + len) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1451 return -2; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1452 for (i = 0; i < len; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1453 out->glyphs[out->used++] = in->glyphs[from + i]; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1454 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1455 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1456 if (gpos_features) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1457 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1458 MFLTGlyph *base = NULL, *mark = NULL, *g; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1459 int x_ppem, y_ppem, x_scale, y_scale; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1460 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1461 if (OTF_drive_gpos (otf, &otf_gstring, script, langsys, gpos_features) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1462 < 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1463 return to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1464 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1465 x_ppem = ft_face->size->metrics.x_ppem; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1466 y_ppem = ft_face->size->metrics.y_ppem; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1467 x_scale = ft_face->size->metrics.x_scale; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1468 y_scale = ft_face->size->metrics.y_scale; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1469 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1470 for (i = 0, otfg = otf_gstring.glyphs, g = out->glyphs + gidx; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1471 i < otf_gstring.used; i++, otfg++, g++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1472 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1473 MFLTGlyph *prev; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1474 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1475 if (! otfg->glyph_id) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1476 continue; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1477 switch (otfg->positioning_type) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1478 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1479 case 0: |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1480 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1481 case 1: /* Single */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1482 case 2: /* Pair */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1483 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1484 int format = otfg->f.f1.format; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1485 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1486 if (format & OTF_XPlacement) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1487 adjustment[i].xoff |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1488 = otfg->f.f1.value->XPlacement * x_scale / 0x10000; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1489 if (format & OTF_XPlaDevice) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1490 adjustment[i].xoff |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1491 += DEVICE_DELTA (otfg->f.f1.value->XPlaDevice, x_ppem); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1492 if (format & OTF_YPlacement) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1493 adjustment[i].yoff |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1494 = - (otfg->f.f1.value->YPlacement * y_scale / 0x10000); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1495 if (format & OTF_YPlaDevice) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1496 adjustment[i].yoff |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1497 -= DEVICE_DELTA (otfg->f.f1.value->YPlaDevice, y_ppem); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1498 if (format & OTF_XAdvance) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1499 adjustment[i].xadv |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1500 += otfg->f.f1.value->XAdvance * x_scale / 0x10000; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1501 if (format & OTF_XAdvDevice) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1502 adjustment[i].xadv |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1503 += DEVICE_DELTA (otfg->f.f1.value->XAdvDevice, x_ppem); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1504 if (format & OTF_YAdvance) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1505 adjustment[i].yadv |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1506 += otfg->f.f1.value->YAdvance * y_scale / 0x10000; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1507 if (format & OTF_YAdvDevice) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1508 adjustment[i].yadv |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1509 += DEVICE_DELTA (otfg->f.f1.value->YAdvDevice, y_ppem); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1510 adjustment[i].set = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1511 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1512 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1513 case 3: /* Cursive */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1514 /* Not yet supported. */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1515 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1516 case 4: /* Mark-to-Base */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1517 case 5: /* Mark-to-Ligature */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1518 if (! base) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1519 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1520 prev = base; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1521 goto label_adjust_anchor; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1522 default: /* i.e. case 6 Mark-to-Mark */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1523 if (! mark) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1524 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1525 prev = mark; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1526 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1527 label_adjust_anchor: |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1528 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1529 int base_x, base_y, mark_x, mark_y; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1530 int this_from, this_to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1531 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1532 base_x = otfg->f.f4.base_anchor->XCoordinate * x_scale / 0x10000; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1533 base_y = otfg->f.f4.base_anchor->YCoordinate * y_scale / 0x10000; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1534 mark_x = otfg->f.f4.mark_anchor->XCoordinate * x_scale / 0x10000; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1535 mark_y = otfg->f.f4.mark_anchor->YCoordinate * y_scale / 0x10000;; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1536 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1537 if (otfg->f.f4.base_anchor->AnchorFormat != 1) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1538 adjust_anchor (ft_face, otfg->f.f4.base_anchor, |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1539 prev->code, x_ppem, y_ppem, &base_x, &base_y); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1540 if (otfg->f.f4.mark_anchor->AnchorFormat != 1) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1541 adjust_anchor (ft_face, otfg->f.f4.mark_anchor, g->code, |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1542 x_ppem, y_ppem, &mark_x, &mark_y); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1543 adjustment[i].xoff = (base_x - mark_x); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1544 adjustment[i].yoff = - (base_y - mark_y); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1545 adjustment[i].back = (g - prev); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1546 adjustment[i].xadv = 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1547 adjustment[i].advance_is_absolute = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1548 adjustment[i].set = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1549 this_from = g->from; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1550 this_to = g->to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1551 for (j = 0; prev + j < g; j++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1552 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1553 if (this_from > prev[j].from) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1554 this_from = prev[j].from; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1555 if (this_to < prev[j].to) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1556 this_to = prev[j].to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1557 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1558 for (; prev <= g; prev++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1559 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1560 prev->from = this_from; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1561 prev->to = this_to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1562 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1563 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1564 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1565 if (otfg->GlyphClass == OTF_GlyphClass0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1566 base = mark = g; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1567 else if (otfg->GlyphClass == OTF_GlyphClassMark) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1568 mark = g; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1569 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1570 base = g; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1571 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1572 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1573 return to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1574 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1575 simple_copy: |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1576 if (out->allocated < out->used + len) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1577 return -2; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1578 font->get_metrics (font, in, from, to); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1579 memcpy (out->glyphs + out->used, in->glyphs + from, |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1580 sizeof (MFLTGlyph) * len); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1581 out->used += len; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1582 return to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1583 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1584 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1585 static MFLTGlyphString gstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1586 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1587 static int m17n_flt_initialized; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1588 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1589 extern Lisp_Object QCfamily; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1590 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1591 Lisp_Object |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1592 ftfont_shape_by_flt (lgstring, font, ft_face, otf) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1593 Lisp_Object lgstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1594 struct font *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1595 FT_Face ft_face; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1596 OTF *otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1597 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1598 EMACS_UINT len = LGSTRING_LENGTH (lgstring); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1599 EMACS_UINT i; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1600 struct MFLTFontFT flt_font_ft; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1601 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1602 if (! m17n_flt_initialized) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1603 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1604 M17N_INIT (); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1605 m17n_flt_initialized = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1606 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1607 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1608 for (i = 0; i < len; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1609 if (NILP (LGSTRING_GLYPH (lgstring, i))) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1610 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1611 len = i; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1612 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1613 if (gstring.allocated == 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1614 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1615 gstring.allocated = len * 2; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1616 gstring.glyph_size = sizeof (MFLTGlyph); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1617 gstring.glyphs = malloc (sizeof (MFLTGlyph) * gstring.allocated); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1618 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1619 else if (gstring.allocated < len * 2) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1620 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1621 gstring.allocated = len * 2; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1622 gstring.glyphs = realloc (gstring.glyphs, |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1623 sizeof (MFLTGlyph) * gstring.allocated); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1624 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1625 for (i = 0; i < len; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1626 gstring.glyphs[i].c = LGLYPH_CHAR (LGSTRING_GLYPH (lgstring, i)); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1627 gstring.used = len; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1628 gstring.r2l = 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1629 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1630 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1631 Lisp_Object family = Ffont_get (LGSTRING_FONT (lgstring), QCfamily); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1632 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1633 if (NILP (family)) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1634 flt_font_ft.flt_font.family = Mnil; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1635 else |
95103 | 1636 flt_font_ft.flt_font.family |
1637 = msymbol ((char *) SDATA (SYMBOL_NAME (family))); | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1638 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1639 flt_font_ft.flt_font.x_ppem = ft_face->size->metrics.x_ppem; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1640 flt_font_ft.flt_font.y_ppem = ft_face->size->metrics.y_ppem; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1641 flt_font_ft.flt_font.get_glyph_id = ftfont_get_glyph_id; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1642 flt_font_ft.flt_font.get_metrics = ftfont_get_metrics; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1643 flt_font_ft.flt_font.check_otf = ftfont_check_otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1644 flt_font_ft.flt_font.drive_otf = ftfont_drive_otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1645 flt_font_ft.flt_font.internal = NULL; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1646 flt_font_ft.font = font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1647 flt_font_ft.ft_face = ft_face; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1648 flt_font_ft.otf = otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1649 for (i = 0; i < 3; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1650 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1651 int result = mflt_run (&gstring, 0, len, &flt_font_ft.flt_font, NULL); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1652 if (result != -2) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1653 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1654 gstring.allocated += gstring.allocated; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1655 gstring.glyphs = realloc (gstring.glyphs, |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1656 sizeof (MFLTGlyph) * gstring.allocated); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1657 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1658 if (gstring.used > LGSTRING_LENGTH (lgstring)) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1659 return Qnil; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1660 for (i = 0; i < gstring.used; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1661 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1662 MFLTGlyph *g = gstring.glyphs + i; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1663 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1664 g->from = LGLYPH_FROM (LGSTRING_GLYPH (lgstring, g->from)); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1665 g->to = LGLYPH_TO (LGSTRING_GLYPH (lgstring, g->to)); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1666 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1667 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1668 for (i = 0; i < gstring.used; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1669 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1670 Lisp_Object lglyph = LGSTRING_GLYPH (lgstring, i); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1671 MFLTGlyph *g = gstring.glyphs + i; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1672 |
91271
fed5211f4809
(ftfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91249
diff
changeset
|
1673 if (NILP (lglyph)) |
fed5211f4809
(ftfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91249
diff
changeset
|
1674 { |
fed5211f4809
(ftfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91249
diff
changeset
|
1675 lglyph = Fmake_vector (make_number (LGLYPH_SIZE), Qnil); |
fed5211f4809
(ftfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91249
diff
changeset
|
1676 LGSTRING_SET_GLYPH (lgstring, i, lglyph); |
fed5211f4809
(ftfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91249
diff
changeset
|
1677 } |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1678 LGLYPH_SET_FROM (lglyph, g->from); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1679 LGLYPH_SET_TO (lglyph, g->to); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1680 LGLYPH_SET_CHAR (lglyph, g->c); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1681 LGLYPH_SET_CODE (lglyph, g->code); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1682 LGLYPH_SET_WIDTH (lglyph, g->xadv >> 6); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1683 LGLYPH_SET_LBEARING (lglyph, g->lbearing >> 6); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1684 LGLYPH_SET_RBEARING (lglyph, g->rbearing >> 6); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1685 LGLYPH_SET_ASCENT (lglyph, g->ascent >> 6); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1686 LGLYPH_SET_DESCENT (lglyph, g->descent >> 6); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1687 if (g->adjusted) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1688 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1689 Lisp_Object vec; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1690 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1691 vec = Fmake_vector (make_number (3), Qnil); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1692 ASET (vec, 0, make_number (g->xoff >> 6)); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1693 ASET (vec, 1, make_number (g->yoff >> 6)); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1694 ASET (vec, 2, make_number (g->xadv >> 6)); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1695 LGLYPH_SET_ADJUSTMENT (lglyph, vec); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1696 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1697 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1698 return make_number (i); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1699 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1700 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1701 Lisp_Object |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1702 ftfont_shape (lgstring) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1703 Lisp_Object lgstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1704 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1705 struct font *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1706 struct ftfont_info *ftfont_info; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1707 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1708 CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1709 ftfont_info = (struct ftfont_info *) font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1710 if (! ftfont_info->maybe_otf) |
91870
5348213975e3
(ftfont_shape): Return Lispy number.
Kenichi Handa <handa@m17n.org>
parents:
91604
diff
changeset
|
1711 return make_number (0); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1712 if (! ftfont_info->otf) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1713 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1714 OTF *otf = OTF_open_ft_face (ftfont_info->ft_size->face); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1715 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1716 if (! otf || OTF_get_table (otf, "head") < 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1717 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1718 if (otf) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1719 OTF_close (otf); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1720 ftfont_info->maybe_otf = 0; |
91870
5348213975e3
(ftfont_shape): Return Lispy number.
Kenichi Handa <handa@m17n.org>
parents:
91604
diff
changeset
|
1721 return make_number (0); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1722 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1723 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1724 ftfont_info->otf = otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1725 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1726 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1727 return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1728 ftfont_info->otf); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1729 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1730 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1731 #endif /* HAVE_M17N_FLT */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1732 #endif /* HAVE_LIBOTF */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1733 |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1734 Lisp_Object |
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1735 ftfont_font_format (FcPattern *pattern) |
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1736 { |
90680
254cfd053f9c
(ftfont_pattern_entity): Check if FC_FONTFORMAT is
Kenichi Handa <handa@m17n.org>
parents:
90676
diff
changeset
|
1737 FcChar8 *str; |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1738 |
90680
254cfd053f9c
(ftfont_pattern_entity): Check if FC_FONTFORMAT is
Kenichi Handa <handa@m17n.org>
parents:
90676
diff
changeset
|
1739 #ifdef FC_FONTFORMAT |
254cfd053f9c
(ftfont_pattern_entity): Check if FC_FONTFORMAT is
Kenichi Handa <handa@m17n.org>
parents:
90676
diff
changeset
|
1740 if (FcPatternGetString (pattern, FC_FONTFORMAT, 0, &str) != FcResultMatch) |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1741 return Qnil; |
90680
254cfd053f9c
(ftfont_pattern_entity): Check if FC_FONTFORMAT is
Kenichi Handa <handa@m17n.org>
parents:
90676
diff
changeset
|
1742 if (strcmp ((char *) str, "TrueType") == 0) |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1743 return intern ("truetype"); |
90963
28e2fa3c7ca3
(ftfont_font_format): Typo fix.
Jason Rumney <jasonr@gnu.org>
parents:
90819
diff
changeset
|
1744 if (strcmp ((char *) str, "Type 1") == 0) |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1745 return intern ("type1"); |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
1746 if (strcmp ((char *) str, "PCF") == 0) |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1747 return intern ("pcf"); |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
1748 if (strcmp ((char *) str, "BDF") == 0) |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1749 return intern ("bdf"); |
90680
254cfd053f9c
(ftfont_pattern_entity): Check if FC_FONTFORMAT is
Kenichi Handa <handa@m17n.org>
parents:
90676
diff
changeset
|
1750 #else /* not FC_FONTFORMAT */ |
95805
dc8b6f0d85e8
(ftfont_font_format) [! FC_FONTFORMAT]: Declare "int len;".
Kenichi Handa <handa@m17n.org>
parents:
95745
diff
changeset
|
1751 int len; |
dc8b6f0d85e8
(ftfont_font_format) [! FC_FONTFORMAT]: Declare "int len;".
Kenichi Handa <handa@m17n.org>
parents:
95745
diff
changeset
|
1752 |
90697
444b40002533
(ftfont_driver): Initialize ftfont_driver.type by 0.
Kenichi Handa <handa@m17n.org>
parents:
90680
diff
changeset
|
1753 if (FcPatternGetString (pattern, FC_FILE, 0, &str) != FcResultMatch) |
90680
254cfd053f9c
(ftfont_pattern_entity): Check if FC_FONTFORMAT is
Kenichi Handa <handa@m17n.org>
parents:
90676
diff
changeset
|
1754 return Qnil; |
95433
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
1755 len = strlen ((char *) str); |
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
1756 if (len >= 4) |
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
1757 { |
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
1758 str += len - 4; |
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
1759 if (xstrcasecmp ((char *) str, ".ttf") == 0) |
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
1760 return intern ("truetype"); |
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
1761 if (xstrcasecmp ((char *) str, "pfb") == 0) |
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
1762 return intern ("type1"); |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
1763 if (xstrcasecmp ((char *) str, "pcf") == 0) |
95433
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
1764 return intern ("pcf"); |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
1765 if (xstrcasecmp ((char *) str, "bdf") == 0) |
95433
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
1766 return intern ("bdf"); |
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
1767 } |
90680
254cfd053f9c
(ftfont_pattern_entity): Check if FC_FONTFORMAT is
Kenichi Handa <handa@m17n.org>
parents:
90676
diff
changeset
|
1768 #endif /* not FC_FONTFORMAT */ |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1769 return intern ("unknown"); |
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1770 } |
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
1771 |
90400 | 1772 |
1773 void | |
1774 syms_of_ftfont () | |
1775 { | |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1776 DEFSYM (Qfreetype, "freetype"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1777 DEFSYM (Qmonospace, "monospace"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1778 DEFSYM (Qsans_serif, "sans-serif"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1779 DEFSYM (Qserif, "serif"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1780 DEFSYM (Qmono, "mono"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1781 DEFSYM (Qsans, "sans"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1782 DEFSYM (Qsans__serif, "sans serif"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1783 |
90400 | 1784 staticpro (&freetype_font_cache); |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
1785 freetype_font_cache = Fcons (Qt, Qnil); |
90400 | 1786 |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1787 staticpro (&ftfont_generic_family_list); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1788 ftfont_generic_family_list |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1789 = Fcons (Fcons (Qmonospace, Qt), |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1790 Fcons (Fcons (Qsans_serif, Qt), |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1791 Fcons (Fcons (Qsans, Qt), Qnil))); |
90400 | 1792 |
95103 | 1793 staticpro (&ft_face_cache); |
1794 ft_face_cache = Qnil; | |
1795 | |
90400 | 1796 ftfont_driver.type = Qfreetype; |
1797 register_font_driver (&ftfont_driver, NULL); | |
1798 } | |
90427 | 1799 |
1800 /* arch-tag: 7cfa432c-33a6-4988-83d2-a82ed8604aca | |
1801 (do not change this comment) */ |