Mercurial > emacs
annotate src/ftfont.c @ 105754:2313ef258869
Add arch tagline
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 24 Oct 2009 21:31:16 +0000 |
parents | 68dd71358159 |
children | cd4cbab8bb21 |
rev | line source |
---|---|
90400 | 1 /* ftfont.c -- FreeType font driver. |
100951 | 2 Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
3 Copyright (C) 2006, 2007, 2008, 2009 | |
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> | |
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103887
diff
changeset
|
24 #include <setjmp.h> |
90400 | 25 |
26 #include <fontconfig/fontconfig.h> | |
27 #include <fontconfig/fcfreetype.h> | |
28 | |
29 #include "lisp.h" | |
30 #include "dispextern.h" | |
31 #include "frame.h" | |
32 #include "blockinput.h" | |
33 #include "character.h" | |
34 #include "charset.h" | |
35 #include "coding.h" | |
97826 | 36 #include "composite.h" |
90400 | 37 #include "fontset.h" |
38 #include "font.h" | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
39 #include "ftfont.h" |
90400 | 40 |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
41 /* Symbolic type of this font-driver. */ |
90400 | 42 Lisp_Object Qfreetype; |
43 | |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
44 /* Fontconfig's generic families and their aliases. */ |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
45 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
|
46 |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
47 /* Flag to tell if FcInit is already called or not. */ |
90400 | 48 static int fc_initialized; |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
49 |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
50 /* Handle to a FreeType library instance. */ |
90400 | 51 static FT_Library ft_library; |
52 | |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
53 /* Cache for FreeType fonts. */ |
90400 | 54 static Lisp_Object freetype_font_cache; |
55 | |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
56 /* Cache for FT_Face and FcCharSet. */ |
95103 | 57 static Lisp_Object ft_face_cache; |
90400 | 58 |
59 /* The actual structure for FreeType font that can be casted to struct | |
60 font. */ | |
61 | |
62 struct ftfont_info | |
63 { | |
64 struct font font; | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
65 #ifdef HAVE_LIBOTF |
101556
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
66 /* The following four members must be here in this order to be |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
67 compatible with struct xftfont_info (in xftfont.c). */ |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
68 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
|
69 OTF *otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
70 #endif /* HAVE_LIBOTF */ |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
71 FT_Size ft_size; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
72 int index; |
90400 | 73 }; |
74 | |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
75 enum ftfont_cache_for |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
76 { |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
77 FTFONT_CACHE_FOR_FACE, |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
78 FTFONT_CACHE_FOR_CHARSET, |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
79 FTFONT_CACHE_FOR_ENTITY |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
80 }; |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
81 |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
82 static Lisp_Object ftfont_pattern_entity P_ ((FcPattern *, Lisp_Object)); |
95103 | 83 |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
84 static Lisp_Object ftfont_resolve_generic_family P_ ((Lisp_Object, |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
85 FcPattern *)); |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
86 static Lisp_Object ftfont_lookup_cache P_ ((Lisp_Object, |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
87 enum ftfont_cache_for)); |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
88 |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
89 Lisp_Object ftfont_font_format P_ ((FcPattern *, Lisp_Object)); |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
90 |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
91 #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
|
92 |
95103 | 93 static struct |
90400 | 94 { |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
95 /* registry name */ |
95103 | 96 char *name; |
97 /* characters to distinguish the charset from the others */ | |
98 int uniquifier[6]; | |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
99 /* additional constraint by language */ |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
100 char *lang; |
95103 | 101 /* set on demand */ |
102 FcCharSet *fc_charset; | |
103 } fc_charset_table[] = | |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
104 { { "iso8859-1", { 0x00A0, 0x00A1, 0x00B4, 0x00BC, 0x00D0 } }, |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
105 { "iso8859-2", { 0x00A0, 0x010E }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
106 { "iso8859-3", { 0x00A0, 0x0108 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
107 { "iso8859-4", { 0x00A0, 0x00AF, 0x0128, 0x0156, 0x02C7 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
108 { "iso8859-5", { 0x00A0, 0x0401 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
109 { "iso8859-6", { 0x00A0, 0x060C }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
110 { "iso8859-7", { 0x00A0, 0x0384 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
111 { "iso8859-8", { 0x00A0, 0x05D0 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
112 { "iso8859-9", { 0x00A0, 0x00A1, 0x00BC, 0x011E }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
113 { "iso8859-10", { 0x00A0, 0x00D0, 0x0128, 0x2015 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
114 { "iso8859-11", { 0x00A0, 0x0E01 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
115 { "iso8859-13", { 0x00A0, 0x201C }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
116 { "iso8859-14", { 0x00A0, 0x0174 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
117 { "iso8859-15", { 0x00A0, 0x00A1, 0x00D0, 0x0152 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
118 { "iso8859-16", { 0x00A0, 0x0218}}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
119 { "gb2312.1980-0", { 0x4E13 }, "zh-cn"}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
120 { "big5-0", { 0xF6B1 }, "zh-tw" }, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
121 { "jisx0208.1983-0", { 0x4E55 }, "ja"}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
122 { "ksc5601.1985-0", { 0xAC00 }, "ko"}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
123 { "cns11643.1992-1", { 0xFE32 }, "zh-tw"}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
124 { "cns11643.1992-2", { 0x4E33, 0x7934 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
125 { "cns11643.1992-3", { 0x201A9 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
126 { "cns11643.1992-4", { 0x20057 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
127 { "cns11643.1992-5", { 0x20000 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
128 { "cns11643.1992-6", { 0x20003 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
129 { "cns11643.1992-7", { 0x20055 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
130 { "gbk-0", { 0x4E06 }, "zh-cn"}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
131 { "jisx0212.1990-0", { 0x4E44 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
132 { "jisx0213.2000-1", { 0xFA10 }, "ja"}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
133 { "jisx0213.2000-2", { 0xFA49 }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
134 { "jisx0213.2004-1", { 0x20B9F }}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
135 { "viscii1.1-1", { 0x1EA0, 0x1EAE, 0x1ED2 }, "vi"}, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
136 { "tis620.2529-1", { 0x0E01 }, "th"}, |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
137 { "windows-1251", { 0x0401, 0x0490 }, "ru"}, |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
138 { "koi8-r", { 0x0401, 0x2219 }, "ru"}, |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
139 { "mulelao-1", { 0x0E81 }, "lo"}, |
100308
611f0256259c
(fc_charset_table): Add "unicode-sip".
Kenichi Handa <handa@m17n.org>
parents:
100239
diff
changeset
|
140 { "unicode-sip", { 0x20000 }}, |
95103 | 141 { NULL } |
142 }; | |
90400 | 143 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
144 extern Lisp_Object Qc, Qm, Qp, Qd; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
145 |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
146 /* Dirty hack for handing ADSTYLE property. |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
147 |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
148 Fontconfig (actually the underlying FreeType) gives such ADSTYLE |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
149 font property of PCF/BDF fonts in FC_STYLE. And, "Bold", |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
150 "Oblique", "Italic", or any non-normal SWIDTH property names |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
151 (e.g. SemiCondensed) are appended. In addition, if there's no |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
152 ADSTYLE property nor non-normal WEIGHT/SLANT/SWIDTH properties, |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
153 "Regular" is used for FC_STYLE (see the function |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
154 pcf_interpret_style in src/pcf/pcfread.c of FreeType). |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
155 |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
156 Unfortunately this behavior is not documented, so the following |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
157 code may fail if FreeType changes the behavior in the future. */ |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
158 |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
159 static Lisp_Object |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
160 get_adstyle_property (FcPattern *p) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
161 { |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
162 char *str, *end; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
163 Lisp_Object adstyle; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
164 |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
165 if (FcPatternGetString (p, FC_STYLE, 0, (FcChar8 **) &str) != FcResultMatch) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
166 return Qnil; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
167 for (end = str; *end && *end != ' '; end++); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
168 if (*end) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
169 { |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
170 char *p = alloca (end - str + 1); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
171 memcpy (p, str, end - str); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
172 p[end - str] = '\0'; |
102945
f623dc25d37e
(get_adstyle_property): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
102944
diff
changeset
|
173 end = p + (end - str); |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
174 str = p; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
175 } |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
176 if (xstrcasecmp (str, "Regular") == 0 |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
177 || xstrcasecmp (str, "Bold") == 0 |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
178 || xstrcasecmp (str, "Oblique") == 0 |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
179 || xstrcasecmp (str, "Italic") == 0) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
180 return Qnil; |
103591
1e63d004a073
(get_adstyle_property): Call font_intern_prop with 1 as
Kenichi Handa <handa@m17n.org>
parents:
103556
diff
changeset
|
181 adstyle = font_intern_prop (str, end - str, 1); |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
182 if (font_style_to_value (FONT_WIDTH_INDEX, adstyle, 0) >= 0) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
183 return Qnil; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
184 return adstyle; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
185 } |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
186 |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
187 static Lisp_Object |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
188 ftfont_pattern_entity (p, extra) |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
189 FcPattern *p; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
190 Lisp_Object extra; |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
191 { |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
192 Lisp_Object key, cache, entity; |
95103 | 193 char *file, *str; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
194 int index; |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
195 int numeric; |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
196 double dbl; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
197 FcBool b; |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
198 |
95103 | 199 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
|
200 return Qnil; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
201 if (FcPatternGetInteger (p, FC_INDEX, 0, &index) != FcResultMatch) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
202 return Qnil; |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
203 |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
204 key = Fcons (make_unibyte_string ((char *) file, strlen ((char *) file)), |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
205 make_number (index)); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
206 cache = ftfont_lookup_cache (key, FTFONT_CACHE_FOR_ENTITY); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
207 entity = XCAR (cache); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
208 if (! NILP (entity)) |
103003
bf88e5d2f4af
(ftfont_pattern_entity): Return a newly allocated
Kenichi Handa <handa@m17n.org>
parents:
102991
diff
changeset
|
209 { |
bf88e5d2f4af
(ftfont_pattern_entity): Return a newly allocated
Kenichi Handa <handa@m17n.org>
parents:
102991
diff
changeset
|
210 Lisp_Object val = font_make_entity (); |
bf88e5d2f4af
(ftfont_pattern_entity): Return a newly allocated
Kenichi Handa <handa@m17n.org>
parents:
102991
diff
changeset
|
211 int i; |
bf88e5d2f4af
(ftfont_pattern_entity): Return a newly allocated
Kenichi Handa <handa@m17n.org>
parents:
102991
diff
changeset
|
212 |
bf88e5d2f4af
(ftfont_pattern_entity): Return a newly allocated
Kenichi Handa <handa@m17n.org>
parents:
102991
diff
changeset
|
213 for (i = 0; i < FONT_OBJLIST_INDEX; i++) |
bf88e5d2f4af
(ftfont_pattern_entity): Return a newly allocated
Kenichi Handa <handa@m17n.org>
parents:
102991
diff
changeset
|
214 ASET (val, i, AREF (entity, i)); |
bf88e5d2f4af
(ftfont_pattern_entity): Return a newly allocated
Kenichi Handa <handa@m17n.org>
parents:
102991
diff
changeset
|
215 return val; |
bf88e5d2f4af
(ftfont_pattern_entity): Return a newly allocated
Kenichi Handa <handa@m17n.org>
parents:
102991
diff
changeset
|
216 } |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
217 entity = font_make_entity (); |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
218 XSETCAR (cache, entity); |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
219 |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
220 ASET (entity, FONT_TYPE_INDEX, Qfreetype); |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
221 ASET (entity, FONT_REGISTRY_INDEX, Qiso10646_1); |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
222 |
95103 | 223 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
|
224 ASET (entity, FONT_FOUNDRY_INDEX, font_intern_prop (str, strlen (str), 1)); |
95103 | 225 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
|
226 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
|
227 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
|
228 { |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
229 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
|
230 numeric = FC_WEIGHT_MEDIUM; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
231 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
|
232 } |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
233 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
|
234 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
235 numeric += 100; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
236 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
|
237 } |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
238 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
|
239 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
240 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
|
241 } |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
242 if (FcPatternGetDouble (p, FC_PIXEL_SIZE, 0, &dbl) == FcResultMatch) |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
243 { |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
244 ASET (entity, FONT_SIZE_INDEX, make_number (dbl)); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
245 } |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
246 else |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
247 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
|
248 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
|
249 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
|
250 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
|
251 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
252 int dpi = dbl; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
253 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
|
254 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
255 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
|
256 && b == FcTrue) |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
257 { |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
258 ASET (entity, FONT_SIZE_INDEX, make_number (0)); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
259 ASET (entity, FONT_AVGWIDTH_INDEX, make_number (0)); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
260 } |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
261 else |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
262 { |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
263 /* As this font is not scalable, parhaps this is a BDF or PCF |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
264 font. */ |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
265 FT_Face ft_face; |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
266 |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
267 ASET (entity, FONT_ADSTYLE_INDEX, get_adstyle_property (p)); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
268 if ((ft_library || FT_Init_FreeType (&ft_library) == 0) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
269 && FT_New_Face (ft_library, file, index, &ft_face) == 0) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
270 { |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
271 BDF_PropertyRec rec; |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
272 |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
273 if (FT_Get_BDF_Property (ft_face, "AVERAGE_WIDTH", &rec) == 0 |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
274 && rec.type == BDF_PROPERTY_TYPE_INTEGER) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
275 ASET (entity, FONT_AVGWIDTH_INDEX, make_number (rec.u.integer)); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
276 FT_Done_Face (ft_face); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
277 } |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
278 } |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
279 |
96076
bd3f48456ac7
(ftfont_pattern_entity): New arg extra. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
95805
diff
changeset
|
280 ASET (entity, FONT_EXTRA_INDEX, Fcopy_sequence (extra)); |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
281 font_put_extra (entity, QCfont_entity, key); |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
282 return entity; |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
283 } |
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
284 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
285 |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
286 static Lisp_Object ftfont_generic_family_list; |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
287 |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
288 static Lisp_Object |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
289 ftfont_resolve_generic_family (family, pattern) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
290 Lisp_Object family; |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
291 FcPattern *pattern; |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
292 { |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
293 Lisp_Object slot; |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
294 FcPattern *match; |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
295 FcResult result; |
97826 | 296 FcLangSet *langset; |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
297 |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
298 family = Fintern (Fdowncase (SYMBOL_NAME (family)), Qnil); |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
299 if (EQ (family, Qmono)) |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
300 family = Qmonospace; |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
301 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
|
302 family = Qsans_serif; |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
303 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
|
304 if (! CONSP (slot)) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
305 return Qnil; |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
306 if (! EQ (XCDR (slot), Qt)) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
307 return XCDR (slot); |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
308 pattern = FcPatternDuplicate (pattern); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
309 if (! pattern) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
310 goto err; |
96592
0ef6933bf3bd
(ftfont_resolve_generic_family): Remove foundry from
Andreas Schwab <schwab@suse.de>
parents:
96568
diff
changeset
|
311 FcPatternDel (pattern, FC_FOUNDRY); |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
312 FcPatternDel (pattern, FC_FAMILY); |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
313 FcPatternAddString (pattern, FC_FAMILY, SYMBOL_FcChar8 (family)); |
97826 | 314 if (FcPatternGetLangSet (pattern, FC_LANG, 0, &langset) != FcResultMatch) |
315 { | |
316 /* This is to avoid the effect of locale. */ | |
317 langset = FcLangSetCreate (); | |
318 FcLangSetAdd (langset, "en"); | |
319 FcPatternAddLangSet (pattern, FC_LANG, langset); | |
320 FcLangSetDestroy (langset); | |
321 } | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
322 FcConfigSubstitute (NULL, pattern, FcMatchPattern); |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
323 FcDefaultSubstitute (pattern); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
324 match = FcFontMatch (NULL, pattern, &result); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
325 if (match) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
326 { |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
327 FcChar8 *fam; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
328 |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
329 if (FcPatternGetString (match, FC_FAMILY, 0, &fam) == FcResultMatch) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
330 family = intern ((char *) fam); |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
331 } |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
332 else |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
333 family = Qnil; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
334 XSETCDR (slot, family); |
100161
f26bd5948e57
(ftfont_resolve_generic_family): Avoid using uninitialized var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100159
diff
changeset
|
335 if (match) FcPatternDestroy (match); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
336 err: |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
337 if (pattern) FcPatternDestroy (pattern); |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
338 return family; |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
339 } |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
340 |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
341 struct ftfont_cache_data |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
342 { |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
343 FT_Face ft_face; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
344 FcCharSet *fc_charset; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
345 }; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
346 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
347 static Lisp_Object |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
348 ftfont_lookup_cache (key, cache_for) |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
349 Lisp_Object key; |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
350 enum ftfont_cache_for cache_for; |
95103 | 351 { |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
352 Lisp_Object cache, val, entity; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
353 struct ftfont_cache_data *cache_data; |
95103 | 354 |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
355 if (FONT_ENTITY_P (key)) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
356 { |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
357 entity = key; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
358 val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX)); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
359 xassert (CONSP (val)); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
360 key = XCDR (val); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
361 } |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
362 else |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
363 entity = Qnil; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
364 |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
365 if (NILP (ft_face_cache)) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
366 cache = Qnil; |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
367 else |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
368 cache = Fgethash (key, ft_face_cache, Qnil); |
95103 | 369 if (NILP (cache)) |
370 { | |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
371 if (NILP (ft_face_cache)) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
372 { |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
373 Lisp_Object args[2]; |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
374 |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
375 args[0] = QCtest; |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
376 args[1] = Qequal; |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
377 ft_face_cache = Fmake_hash_table (2, args); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
378 } |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
379 cache_data = xmalloc (sizeof (struct ftfont_cache_data)); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
380 cache_data->ft_face = NULL; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
381 cache_data->fc_charset = NULL; |
95103 | 382 val = make_save_value (NULL, 0); |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
383 XSAVE_VALUE (val)->integer = 0; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
384 XSAVE_VALUE (val)->pointer = cache_data; |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
385 cache = Fcons (Qnil, val); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
386 Fputhash (key, cache, ft_face_cache); |
95103 | 387 } |
388 else | |
389 { | |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
390 val = XCDR (cache); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
391 cache_data = XSAVE_VALUE (val)->pointer; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
392 } |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
393 |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
394 if (cache_for == FTFONT_CACHE_FOR_ENTITY) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
395 return cache; |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
396 |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
397 if (cache_for == FTFONT_CACHE_FOR_FACE |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
398 ? ! cache_data->ft_face : ! cache_data->fc_charset) |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
399 { |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
400 char *filename = (char *) SDATA (XCAR (key)); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
401 int index = XINT (XCDR (key)); |
95103 | 402 |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
403 if (cache_for == FTFONT_CACHE_FOR_FACE) |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
404 { |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
405 if (! ft_library |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
406 && FT_Init_FreeType (&ft_library) != 0) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
407 return Qnil; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
408 if (FT_New_Face (ft_library, filename, index, &cache_data->ft_face) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
409 != 0) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
410 return Qnil; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
411 } |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
412 else |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
413 { |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
414 FcPattern *pat = NULL; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
415 FcFontSet *fontset = NULL; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
416 FcObjectSet *objset = NULL; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
417 FcCharSet *charset = NULL; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
418 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
419 pat = FcPatternBuild (0, FC_FILE, FcTypeString, (FcChar8 *) filename, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
420 FC_INDEX, FcTypeInteger, index, NULL); |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
421 if (! pat) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
422 goto finish; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
423 objset = FcObjectSetBuild (FC_CHARSET, FC_STYLE, NULL); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
424 if (! objset) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
425 goto finish; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
426 fontset = FcFontList (NULL, pat, objset); |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
427 if (! fontset) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
428 goto finish; |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
429 if (fontset && fontset->nfont > 0 |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
430 && (FcPatternGetCharSet (fontset->fonts[0], FC_CHARSET, 0, |
101284
4c2b48d0a379
(ftfont_lookup_cache): Check the return value of FcFontList.
Kenichi Handa <handa@m17n.org>
parents:
100951
diff
changeset
|
431 &charset) |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
432 == FcResultMatch)) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
433 cache_data->fc_charset = FcCharSetCopy (charset); |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
434 else |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
435 cache_data->fc_charset = FcCharSetCreate (); |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
436 |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
437 finish: |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
438 if (fontset) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
439 FcFontSetDestroy (fontset); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
440 if (objset) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
441 FcObjectSetDestroy (objset); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
442 if (pat) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
443 FcPatternDestroy (pat); |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
444 } |
95103 | 445 } |
446 return cache; | |
447 } | |
448 | |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
449 FcCharSet * |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
450 ftfont_get_fc_charset (entity) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
451 Lisp_Object entity; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
452 { |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
453 Lisp_Object val, cache; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
454 struct ftfont_cache_data *cache_data; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
455 |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
456 cache = ftfont_lookup_cache (entity, FTFONT_CACHE_FOR_CHARSET); |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
457 val = XCDR (cache); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
458 cache_data = XSAVE_VALUE (val)->pointer; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
459 return cache_data->fc_charset; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
460 } |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
461 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
462 #ifdef HAVE_LIBOTF |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
463 static OTF * |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
464 ftfont_get_otf (ftfont_info) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
465 struct ftfont_info *ftfont_info; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
466 { |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
467 OTF *otf; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
468 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
469 if (ftfont_info->otf) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
470 return ftfont_info->otf; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
471 if (! ftfont_info->maybe_otf) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
472 return NULL; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
473 otf = OTF_open_ft_face (ftfont_info->ft_size->face); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
474 if (! otf || OTF_get_table (otf, "head") < 0) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
475 { |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
476 if (otf) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
477 OTF_close (otf); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
478 ftfont_info->maybe_otf = 0; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
479 return NULL; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
480 } |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
481 ftfont_info->otf = otf; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
482 return otf; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
483 } |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
484 #endif /* HAVE_LIBOTF */ |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
485 |
91249
4f21471103e6
(ftfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91214
diff
changeset
|
486 static Lisp_Object ftfont_get_cache P_ ((FRAME_PTR)); |
90400 | 487 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
|
488 static Lisp_Object ftfont_match P_ ((Lisp_Object, Lisp_Object)); |
90400 | 489 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
|
490 static Lisp_Object ftfont_open P_ ((FRAME_PTR, Lisp_Object, int)); |
90400 | 491 static void ftfont_close P_ ((FRAME_PTR, struct font *)); |
492 static int ftfont_has_char P_ ((Lisp_Object, int)); | |
493 static unsigned ftfont_encode_char P_ ((struct font *, int)); | |
494 static int ftfont_text_extents P_ ((struct font *, unsigned *, int, | |
495 struct font_metrics *)); | |
496 static int ftfont_get_bitmap P_ ((struct font *, unsigned, | |
497 struct font_bitmap *, int)); | |
498 static int ftfont_anchor_point P_ ((struct font *, unsigned, int, | |
499 int *, int *)); | |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
500 static Lisp_Object ftfont_otf_capability P_ ((struct font *)); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
501 static Lisp_Object ftfont_shape P_ ((Lisp_Object)); |
102773
b9b8c6b17d2d
Conditionalize prototyping and use of ftfont_variation_glyphs.
Chong Yidong <cyd@stupidchicken.com>
parents:
101943
diff
changeset
|
502 |
b9b8c6b17d2d
Conditionalize prototyping and use of ftfont_variation_glyphs.
Chong Yidong <cyd@stupidchicken.com>
parents:
101943
diff
changeset
|
503 #ifdef HAVE_OTF_GET_VARIATION_GLYPHS |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
504 static int ftfont_variation_glyphs P_ ((struct font *, int c, |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
505 unsigned variations[256])); |
102773
b9b8c6b17d2d
Conditionalize prototyping and use of ftfont_variation_glyphs.
Chong Yidong <cyd@stupidchicken.com>
parents:
101943
diff
changeset
|
506 #endif /* HAVE_OTF_GET_VARIATION_GLYPHS */ |
90400 | 507 |
508 struct font_driver ftfont_driver = | |
509 { | |
90697
444b40002533
(ftfont_driver): Initialize ftfont_driver.type by 0.
Kenichi Handa <handa@m17n.org>
parents:
90680
diff
changeset
|
510 0, /* Qfreetype */ |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
511 0, /* case insensitive */ |
90400 | 512 ftfont_get_cache, |
513 ftfont_list, | |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
514 ftfont_match, |
90400 | 515 ftfont_list_family, |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
516 NULL, /* free_entity */ |
90400 | 517 ftfont_open, |
518 ftfont_close, | |
519 /* We can't draw a text without device dependent functions. */ | |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
520 NULL, /* prepare_face */ |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
521 NULL, /* done_face */ |
90400 | 522 ftfont_has_char, |
523 ftfont_encode_char, | |
524 ftfont_text_extents, | |
525 /* We can't draw a text without device dependent functions. */ | |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
526 NULL, /* draw */ |
90400 | 527 ftfont_get_bitmap, |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
528 NULL, /* get_bitmap */ |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
529 NULL, /* free_bitmap */ |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
530 NULL, /* get_outline */ |
90400 | 531 ftfont_anchor_point, |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
532 #ifdef HAVE_LIBOTF |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
533 ftfont_otf_capability, |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
534 #else /* not HAVE_LIBOTF */ |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
535 NULL, |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
536 #endif /* not HAVE_LIBOTF */ |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
537 NULL, /* otf_drive */ |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
538 NULL, /* start_for_frame */ |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
539 NULL, /* end_for_frame */ |
91308
9b6270bcd1a7
(ftfont_driver): Set ftfont_shape in ftfont_driver only
Kenichi Handa <handa@m17n.org>
parents:
91294
diff
changeset
|
540 #if defined (HAVE_M17N_FLT) && defined (HAVE_LIBOTF) |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
541 ftfont_shape, |
91308
9b6270bcd1a7
(ftfont_driver): Set ftfont_shape in ftfont_driver only
Kenichi Handa <handa@m17n.org>
parents:
91294
diff
changeset
|
542 #else /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */ |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
543 NULL, |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
544 #endif /* not (HAVE_M17N_FLT && HAVE_LIBOTF) */ |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
545 NULL, /* check */ |
102773
b9b8c6b17d2d
Conditionalize prototyping and use of ftfont_variation_glyphs.
Chong Yidong <cyd@stupidchicken.com>
parents:
101943
diff
changeset
|
546 |
102791
9874a0083028
Fix previous change. Define ftfont_variation_glyphs
Kenichi Handa <handa@m17n.org>
parents:
102773
diff
changeset
|
547 #ifdef HAVE_OTF_GET_VARIATION_GLYPHS |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
548 ftfont_variation_glyphs |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
549 #else |
90400 | 550 NULL |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
551 #endif |
90400 | 552 }; |
553 | |
554 extern Lisp_Object QCname; | |
555 | |
556 static Lisp_Object | |
91249
4f21471103e6
(ftfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91214
diff
changeset
|
557 ftfont_get_cache (f) |
4f21471103e6
(ftfont_get_cache): Adjust the argument type.
Kenichi Handa <handa@m17n.org>
parents:
91214
diff
changeset
|
558 FRAME_PTR f; |
90400 | 559 { |
560 return freetype_font_cache; | |
561 } | |
562 | |
95103 | 563 static int |
564 ftfont_get_charset (registry) | |
565 Lisp_Object registry; | |
566 { | |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
567 char *str = (char *) SDATA (SYMBOL_NAME (registry)); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
568 char *re = alloca (SBYTES (SYMBOL_NAME (registry)) * 2 + 1); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
569 Lisp_Object regexp; |
95103 | 570 int i, j; |
571 | |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
572 for (i = j = 0; i < SBYTES (SYMBOL_NAME (registry)); i++, j++) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
573 { |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
574 if (str[i] == '.') |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
575 re[j++] = '\\'; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
576 else if (str[i] == '*') |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
577 re[j++] = '.'; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
578 re[j] = str[i]; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
579 if (re[j] == '?') |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
580 re[j] = '.'; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
581 } |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
582 re[j] = '\0'; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
583 regexp = make_unibyte_string (re, j); |
95103 | 584 for (i = 0; fc_charset_table[i].name; i++) |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
585 if (fast_c_string_match_ignore_case (regexp, fc_charset_table[i].name) >= 0) |
95103 | 586 break; |
587 if (! fc_charset_table[i].name) | |
588 return -1; | |
589 if (! fc_charset_table[i].fc_charset) | |
590 { | |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
591 FcCharSet *charset = FcCharSetCreate (); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
592 int *uniquifier = fc_charset_table[i].uniquifier; |
95103 | 593 |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
594 if (! charset) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
595 return -1; |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
596 for (j = 0; uniquifier[j]; j++) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
597 if (! FcCharSetAddChar (charset, uniquifier[j])) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
598 { |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
599 FcCharSetDestroy (charset); |
95103 | 600 return -1; |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
601 } |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
602 fc_charset_table[i].fc_charset = charset; |
95103 | 603 } |
604 return i; | |
605 } | |
606 | |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
607 struct OpenTypeSpec |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
608 { |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
609 Lisp_Object script; |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
610 unsigned int script_tag, langsys_tag; |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
611 int nfeatures[2]; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
612 unsigned int *features[2]; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
613 }; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
614 |
91191
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
615 #define OTF_SYM_TAG(SYM, TAG) \ |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
616 do { \ |
91191
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
617 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
|
618 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
|
619 } while (0) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
620 |
91191
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
621 #define OTF_TAG_STR(TAG, P) \ |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
622 do { \ |
91191
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
623 (P)[0] = (char) (TAG >> 24); \ |
5bce041b93dc
(OTF_SYM_TAG, OTF_TAG_STR): Fix argument names.
Kenichi Handa <handa@m17n.org>
parents:
91189
diff
changeset
|
624 (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
|
625 (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
|
626 (P)[3] = (char) (TAG & 0xFF); \ |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
627 (P)[4] = '\0'; \ |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
628 } while (0) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
629 |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
630 #define OTF_TAG_SYM(SYM, TAG) \ |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
631 do { \ |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
632 char str[5]; \ |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
633 \ |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
634 OTF_TAG_STR (TAG, str); \ |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
635 (SYM) = font_intern_prop (str, 4, 1); \ |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
636 } while (0) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
637 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
638 |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
639 static struct OpenTypeSpec * |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
640 ftfont_get_open_type_spec (Lisp_Object otf_spec) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
641 { |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
642 struct OpenTypeSpec *spec = malloc (sizeof (struct OpenTypeSpec)); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
643 Lisp_Object val; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
644 int i, j, negative; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
645 |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
646 if (! spec) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
647 return NULL; |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
648 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
|
649 if (! NILP (spec->script)) |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
650 { |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
651 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
|
652 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
|
653 if (CONSP (val) && SYMBOLP (XCDR (val))) |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
654 spec->script = XCDR (val); |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
655 else |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
656 spec->script = Qnil; |
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
657 } |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
658 else |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
659 spec->script_tag = 0x44464C54; /* "DFLT" */ |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
660 otf_spec = XCDR (otf_spec); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
661 val = XCAR (otf_spec); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
662 if (! NILP (val)) |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
663 OTF_SYM_TAG (val, spec->langsys_tag); |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
664 else |
91214
998b9da240f0
(struct OpenTypeSpec): Members script_tag renamed to
Kenichi Handa <handa@m17n.org>
parents:
91191
diff
changeset
|
665 spec->langsys_tag = 0; |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
666 spec->nfeatures[0] = spec->nfeatures[1] = 0; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
667 for (i = 0; i < 2; i++) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
668 { |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
669 Lisp_Object len; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
670 |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
671 otf_spec = XCDR (otf_spec); |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
672 if (NILP (otf_spec)) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
673 break; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
674 val = XCAR (otf_spec); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
675 if (NILP (val)) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
676 continue; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
677 len = Flength (val); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
678 spec->features[i] = malloc (sizeof (int) * XINT (len)); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
679 if (! spec->features[i]) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
680 { |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
681 if (i > 0 && spec->features[0]) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
682 free (spec->features[0]); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
683 free (spec); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
684 return NULL; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
685 } |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
686 for (j = 0, negative = 0; CONSP (val); val = XCDR (val)) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
687 { |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
688 if (NILP (XCAR (val))) |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
689 negative = 1; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
690 else |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
691 { |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
692 unsigned int tag; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
693 |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
694 OTF_SYM_TAG (XCAR (val), tag); |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
695 spec->features[i][j++] = negative ? tag & 0x80000000 : tag; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
696 } |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
697 } |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
698 spec->nfeatures[i] = j; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
699 } |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
700 return spec; |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
701 } |
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
702 |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
703 static FcPattern *ftfont_spec_pattern P_ ((Lisp_Object, char *, |
103887
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
704 struct OpenTypeSpec **, |
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
705 char **langname)); |
95103 | 706 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
707 static FcPattern * |
103887
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
708 ftfont_spec_pattern (spec, otlayout, otspec, langname) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
709 Lisp_Object spec; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
710 char *otlayout; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
711 struct OpenTypeSpec **otspec; |
103887
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
712 char **langname; |
90400 | 713 { |
95103 | 714 Lisp_Object tmp, extra; |
90400 | 715 FcPattern *pattern = NULL; |
716 FcCharSet *charset = NULL; | |
717 FcLangSet *langset = NULL; | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
718 int n; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
719 int dpi = -1; |
90500
60e0667ab709
(ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents:
90480
diff
changeset
|
720 int scalable = -1; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
721 Lisp_Object script = Qnil; |
95103 | 722 Lisp_Object registry; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
723 int fc_charset_idx; |
90400 | 724 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
725 if ((n = FONT_SLANT_NUMERIC (spec)) >= 0 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
726 && n < 100) |
90480
908d27653432
(ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents:
90474
diff
changeset
|
727 /* 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
|
728 return NULL; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
729 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
730 if (INTEGERP (AREF (spec, FONT_DPI_INDEX))) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
731 dpi = XINT (AREF (spec, FONT_DPI_INDEX)); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
732 if (INTEGERP (AREF (spec, FONT_AVGWIDTH_INDEX)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
733 && XINT (AREF (spec, FONT_AVGWIDTH_INDEX)) == 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
734 scalable = 1; |
90480
908d27653432
(ftfont_list): Use assq_no_quit, not Fassq. Don't
Kenichi Handa <handa@m17n.org>
parents:
90474
diff
changeset
|
735 |
95103 | 736 registry = AREF (spec, FONT_REGISTRY_INDEX); |
737 if (NILP (registry) | |
95698
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
738 || EQ (registry, Qascii_0) |
95103 | 739 || EQ (registry, Qiso10646_1) |
100308
611f0256259c
(fc_charset_table): Add "unicode-sip".
Kenichi Handa <handa@m17n.org>
parents:
100239
diff
changeset
|
740 || EQ (registry, Qunicode_bmp)) |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
741 fc_charset_idx = -1; |
95103 | 742 else |
90400 | 743 { |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
744 FcChar8 *lang; |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
745 |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
746 fc_charset_idx = ftfont_get_charset (registry); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
747 if (fc_charset_idx < 0) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
748 return NULL; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
749 charset = fc_charset_table[fc_charset_idx].fc_charset; |
103887
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
750 *langname = fc_charset_table[fc_charset_idx].lang; |
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
751 lang = (FcChar8 *) *langname; |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
752 if (lang) |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
753 { |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
754 langset = FcLangSetCreate (); |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
755 if (! langset) |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
756 goto err; |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
757 FcLangSetAdd (langset, lang); |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
758 } |
90400 | 759 } |
760 | |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
761 otlayout[0] = '\0'; |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
762 for (extra = AREF (spec, FONT_EXTRA_INDEX); |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
763 CONSP (extra); extra = XCDR (extra)) |
90400 | 764 { |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
765 Lisp_Object key, val; |
90510
69dc5ab6d693
(ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents:
90500
diff
changeset
|
766 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
767 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
|
768 if (EQ (key, QCdpi)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
769 dpi = XINT (val); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
770 else if (EQ (key, QClang)) |
90400 | 771 { |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
772 if (! langset) |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
773 langset = FcLangSetCreate (); |
90400 | 774 if (! langset) |
775 goto err; | |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
776 if (SYMBOLP (val)) |
90400 | 777 { |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
778 if (! FcLangSetAdd (langset, SYMBOL_FcChar8 (val))) |
90400 | 779 goto err; |
780 } | |
781 else | |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
782 for (; CONSP (val); val = XCDR (val)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
783 if (SYMBOLP (XCAR (val)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
784 && ! FcLangSetAdd (langset, SYMBOL_FcChar8 (XCAR (val)))) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
785 goto err; |
90400 | 786 } |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
787 else if (EQ (key, QCotf)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
788 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
789 *otspec = ftfont_get_open_type_spec (val); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
790 if (! *otspec) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
791 return NULL; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
792 strcat (otlayout, "otlayout:"); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
793 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
|
794 script = (*otspec)->script; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
795 } |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
796 else if (EQ (key, QCscript)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
797 script = val; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
798 else if (EQ (key, QCscalable)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
799 scalable = ! NILP (val); |
90400 | 800 } |
801 | |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
802 if (! NILP (script) && ! charset) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
803 { |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
804 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
|
805 |
97908
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
806 if (CONSP (chars) && CONSP (CDR (chars))) |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
807 { |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
808 charset = FcCharSetCreate (); |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
809 if (! charset) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
810 goto err; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
811 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
|
812 if (CHARACTERP (XCAR (chars)) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
813 && ! FcCharSetAddChar (charset, XUINT (XCAR (chars)))) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
814 goto err; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
815 } |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
816 } |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
817 |
96076
bd3f48456ac7
(ftfont_pattern_entity): New arg extra. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
95805
diff
changeset
|
818 pattern = FcPatternCreate (); |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
819 if (! pattern) |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
820 goto err; |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
821 tmp = AREF (spec, FONT_FOUNDRY_INDEX); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
822 if (! NILP (tmp) |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
823 && ! FcPatternAddString (pattern, FC_FOUNDRY, SYMBOL_FcChar8 (tmp))) |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
824 goto err; |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
825 tmp = AREF (spec, FONT_FAMILY_INDEX); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
826 if (! NILP (tmp) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
827 && ! FcPatternAddString (pattern, FC_FAMILY, SYMBOL_FcChar8 (tmp))) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
828 goto err; |
90400 | 829 if (charset |
830 && ! FcPatternAddCharSet (pattern, FC_CHARSET, charset)) | |
831 goto err; | |
832 if (langset | |
833 && ! FcPatternAddLangSet (pattern, FC_LANG, langset)) | |
834 goto err; | |
90500
60e0667ab709
(ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents:
90480
diff
changeset
|
835 if (dpi >= 0 |
60e0667ab709
(ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents:
90480
diff
changeset
|
836 && ! FcPatternAddDouble (pattern, FC_DPI, dpi)) |
60e0667ab709
(ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents:
90480
diff
changeset
|
837 goto err; |
60e0667ab709
(ftfont_list): Handle properties dpi, spacing, and
Kenichi Handa <handa@m17n.org>
parents:
90480
diff
changeset
|
838 if (scalable >= 0 |
90522 | 839 && ! 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
|
840 goto err; |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
841 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
842 goto finish; |
90400 | 843 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
844 err: |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
845 /* 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
|
846 (usually insufficient memory). */ |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
847 if (pattern) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
848 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
849 FcPatternDestroy (pattern); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
850 pattern = NULL; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
851 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
852 if (*otspec) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
853 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
854 if ((*otspec)->nfeatures[0] > 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
855 free ((*otspec)->features[0]); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
856 if ((*otspec)->nfeatures[1] > 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
857 free ((*otspec)->features[1]); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
858 free (*otspec); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
859 *otspec = NULL; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
860 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
861 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
862 finish: |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
863 if (langset) FcLangSetDestroy (langset); |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
864 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
|
865 return pattern; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
866 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
867 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
868 static Lisp_Object |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
869 ftfont_list (frame, spec) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
870 Lisp_Object frame, spec; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
871 { |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
872 Lisp_Object val = Qnil, family, adstyle; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
873 int i; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
874 FcPattern *pattern; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
875 FcFontSet *fontset = NULL; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
876 FcObjectSet *objset = NULL; |
97908
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
877 FcCharSet *charset; |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
878 Lisp_Object chars = Qnil; |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
879 FcResult result; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
880 char otlayout[15]; /* For "otlayout:XXXX" */ |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
881 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
|
882 int spacing = -1; |
103887
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
883 char *langname = NULL; |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
884 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
885 if (! fc_initialized) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
886 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
887 FcInit (); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
888 fc_initialized = 1; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
889 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
890 |
103887
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
891 pattern = ftfont_spec_pattern (spec, otlayout, &otspec, &langname); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
892 if (! pattern) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
893 return Qnil; |
97908
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
894 if (FcPatternGetCharSet (pattern, FC_CHARSET, 0, &charset) != FcResultMatch) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
895 { |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
896 val = assq_no_quit (QCscript, AREF (spec, FONT_EXTRA_INDEX)); |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
897 if (! NILP (val)) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
898 { |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
899 val = assq_no_quit (XCDR (val), Vscript_representative_chars); |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
900 if (CONSP (val) && VECTORP (XCDR (val))) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
901 chars = XCDR (val); |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
902 } |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
903 val = Qnil; |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
904 } |
95358
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
905 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
|
906 spacing = XINT (AREF (spec, FONT_SPACING_INDEX)); |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
907 family = AREF (spec, FONT_FAMILY_INDEX); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
908 if (! NILP (family)) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
909 { |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
910 Lisp_Object resolved; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
911 |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
912 resolved = ftfont_resolve_generic_family (family, pattern); |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
913 if (! NILP (resolved)) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
914 { |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
915 FcPatternDel (pattern, FC_FAMILY); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
916 if (! FcPatternAddString (pattern, FC_FAMILY, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
917 SYMBOL_FcChar8 (resolved))) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
918 goto err; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
919 } |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
920 } |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
921 adstyle = AREF (spec, FONT_ADSTYLE_INDEX); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
922 if (! NILP (adstyle) && SBYTES (SYMBOL_NAME (adstyle)) == 0) |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
923 adstyle = Qnil; |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
924 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
|
925 FC_WIDTH, FC_PIXEL_SIZE, FC_SPACING, FC_SCALABLE, |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
926 FC_STYLE, FC_FILE, FC_INDEX, |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
927 #ifdef FC_CAPABILITY |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
928 FC_CAPABILITY, |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
929 #endif /* FC_CAPABILITY */ |
96076
bd3f48456ac7
(ftfont_pattern_entity): New arg extra. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
95805
diff
changeset
|
930 #ifdef FC_FONTFORMAT |
bd3f48456ac7
(ftfont_pattern_entity): New arg extra. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
95805
diff
changeset
|
931 FC_FONTFORMAT, |
bd3f48456ac7
(ftfont_pattern_entity): New arg extra. Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
95805
diff
changeset
|
932 #endif |
90680
254cfd053f9c
(ftfont_pattern_entity): Check if FC_FONTFORMAT is
Kenichi Handa <handa@m17n.org>
parents:
90676
diff
changeset
|
933 NULL); |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
934 if (! objset) |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
935 goto err; |
97908
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
936 if (! NILP (chars)) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
937 FcObjectSetAdd (objset, FC_CHARSET); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
938 |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
939 fontset = FcFontList (NULL, pattern, objset); |
97908
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
940 if (! fontset || fontset->nfont == 0) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
941 goto finish; |
95698
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
942 #if 0 |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
943 /* 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
|
944 if (fontset->nfont == 0 && ! NILP (family)) |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
945 { |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
946 /* 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
|
947 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
|
948 "Courier". */ |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
949 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
|
950 SYMBOL_FcChar8 (family), NULL); |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
951 FcChar8 *fam; |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
952 |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
953 if (FcConfigSubstitute (NULL, pat, FcMatchPattern) == FcTrue) |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
954 { |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
955 for (i = 0; |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
956 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
|
957 i++) |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
958 { |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
959 FcPatternDel (pattern, FC_FAMILY); |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
960 FcPatternAddString (pattern, FC_FAMILY, fam); |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
961 FcFontSetDestroy (fontset); |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
962 fontset = FcFontList (NULL, pattern, objset); |
101284
4c2b48d0a379
(ftfont_lookup_cache): Check the return value of FcFontList.
Kenichi Handa <handa@m17n.org>
parents:
100951
diff
changeset
|
963 if (fontset && fontset->nfont > 0) |
95698
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
964 break; |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
965 } |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
966 } |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
967 } |
d87a51f8851f
(ftfont_spec_pattern): Accept the registry `ascii-0'.
Kenichi Handa <handa@m17n.org>
parents:
95464
diff
changeset
|
968 #endif |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
969 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
|
970 { |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
971 Lisp_Object entity; |
90474
8627c9321afb
(ftfont_pattern_entity): Use the numeric value 100 for
Kenichi Handa <handa@m17n.org>
parents:
90464
diff
changeset
|
972 |
95358
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
973 if (spacing >= 0) |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
974 { |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
975 int this; |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
976 |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
977 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
|
978 == FcResultMatch) |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
979 && spacing != this) |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
980 continue; |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
981 } |
9c54d4f00cf6
(ftfont_spec_pattern): Don't set FC_SPACING to pattern.
Kenichi Handa <handa@m17n.org>
parents:
95229
diff
changeset
|
982 |
90516
43ea66432bf9
(ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
90514
diff
changeset
|
983 #ifdef FC_CAPABILITY |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
984 if (otlayout[0]) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
985 { |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
986 FcChar8 *this; |
90510
69dc5ab6d693
(ftfont_list): Handle QCotf property.
Kenichi Handa <handa@m17n.org>
parents:
90500
diff
changeset
|
987 |
97908
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
988 if (FcPatternGetString (fontset->fonts[i], FC_CAPABILITY, 0, &this) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
989 != FcResultMatch |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
990 || ! strstr ((char *) this, otlayout)) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
991 continue; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
992 } |
90516
43ea66432bf9
(ftfont_list): Pay attention to the case that
Kenichi Handa <handa@m17n.org>
parents:
90514
diff
changeset
|
993 #endif /* FC_CAPABILITY */ |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
994 #ifdef HAVE_LIBOTF |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
995 if (otspec) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
996 { |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
997 FcChar8 *file; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
998 OTF *otf; |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
999 |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1000 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
|
1001 != FcResultMatch) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1002 continue; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1003 otf = OTF_open ((char *) file); |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1004 if (! otf) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1005 continue; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1006 if (OTF_check_features (otf, 1, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1007 otspec->script_tag, otspec->langsys_tag, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1008 otspec->features[0], |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1009 otspec->nfeatures[0]) != 1 |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1010 || OTF_check_features (otf, 0, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1011 otspec->script_tag, otspec->langsys_tag, |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1012 otspec->features[1], |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1013 otspec->nfeatures[1]) != 1) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1014 continue; |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1015 } |
91187
96e18e1645a1
(struct OpenTypeSpec): New struct.
Kenichi Handa <handa@m17n.org>
parents:
91162
diff
changeset
|
1016 #endif /* HAVE_LIBOTF */ |
97908
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1017 if (VECTORP (chars)) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1018 { |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1019 int j; |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1020 |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1021 if (FcPatternGetCharSet (fontset->fonts[i], FC_CHARSET, 0, &charset) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1022 != FcResultMatch) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1023 continue; |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1024 for (j = 0; j < ASIZE (chars); j++) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1025 if (NATNUMP (AREF (chars, j)) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1026 && FcCharSetHasChar (charset, XFASTINT (AREF (chars, j)))) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1027 break; |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1028 if (j == ASIZE (chars)) |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1029 continue; |
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1030 } |
103887
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
1031 if (! NILP (adstyle) || langname) |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
1032 { |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
1033 Lisp_Object this_adstyle = get_adstyle_property (fontset->fonts[i]); |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
1034 |
103887
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
1035 if (! NILP (adstyle) |
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
1036 && (NILP (this_adstyle) |
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
1037 || xstrcasecmp (SDATA (SYMBOL_NAME (adstyle)), |
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
1038 SDATA (SYMBOL_NAME (this_adstyle))) != 0)) |
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
1039 continue; |
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
1040 if (langname |
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
1041 && ! NILP (this_adstyle) |
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
1042 && xstrcasecmp (langname, SDATA (SYMBOL_NAME (this_adstyle)))) |
102944
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
1043 continue; |
44a517fa4d12
(Qja, Qko): New variables.
Kenichi Handa <handa@m17n.org>
parents:
102877
diff
changeset
|
1044 } |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1045 entity = ftfont_pattern_entity (fontset->fonts[i], |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1046 AREF (spec, FONT_EXTRA_INDEX)); |
95182
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1047 if (! NILP (entity)) |
06ff64b07841
(ftfont_resolve_generic_family): Renamed from
Kenichi Handa <handa@m17n.org>
parents:
95103
diff
changeset
|
1048 val = Fcons (entity, val); |
90400 | 1049 } |
97908
464a00cca3cf
(ftfont_spec_pattern): Don't create a charset of the
Kenichi Handa <handa@m17n.org>
parents:
97826
diff
changeset
|
1050 val = Fnreverse (val); |
90400 | 1051 goto finish; |
1052 | |
1053 err: | |
1054 /* 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
|
1055 (usually insufficient memory). */ |
90400 | 1056 val = Qnil; |
1057 | |
1058 finish: | |
103546
941b1ddcbe2e
Change font_add_log to FONT_ADD_LOG.
Kenichi Handa <handa@m17n.org>
parents:
103011
diff
changeset
|
1059 FONT_ADD_LOG ("ftfont-list", spec, val); |
90400 | 1060 if (objset) FcObjectSetDestroy (objset); |
1061 if (fontset) FcFontSetDestroy (fontset); | |
1062 if (pattern) FcPatternDestroy (pattern); | |
1063 return val; | |
1064 } | |
1065 | |
1066 static Lisp_Object | |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1067 ftfont_match (frame, spec) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1068 Lisp_Object frame, spec; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1069 { |
100159
9dae5597651b
(ftfont_match): Initialize entity variable.
Chong Yidong <cyd@stupidchicken.com>
parents:
99108
diff
changeset
|
1070 Lisp_Object entity = Qnil; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1071 FcPattern *pattern, *match = NULL; |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1072 FcResult result; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1073 char otlayout[15]; /* For "otlayout:XXXX" */ |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1074 struct OpenTypeSpec *otspec = NULL; |
103887
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
1075 char *langname = NULL; |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1076 |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1077 if (! fc_initialized) |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1078 { |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1079 FcInit (); |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1080 fc_initialized = 1; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1081 } |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1082 |
103887
427b644c9e3b
(ftfont_spec_pattern): New arg langname. Caller
Kenichi Handa <handa@m17n.org>
parents:
103591
diff
changeset
|
1083 pattern = ftfont_spec_pattern (spec, otlayout, &otspec, &langname); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1084 if (! pattern) |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1085 return Qnil; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1086 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1087 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
|
1088 { |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1089 FcValue value; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1090 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1091 value.type = FcTypeDouble; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1092 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
|
1093 FcPatternAdd (pattern, FC_PIXEL_SIZE, value, FcFalse); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1094 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1095 if (FcConfigSubstitute (NULL, pattern, FcMatchPattern) == FcTrue) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1096 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1097 FcDefaultSubstitute (pattern); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1098 match = FcFontMatch (NULL, pattern, &result); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1099 if (match) |
92301
c10a8c811515
(ftfont_match): Explicitly set pixelsize in pattern.
Kenichi Handa <handa@m17n.org>
parents:
91870
diff
changeset
|
1100 { |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1101 entity = ftfont_pattern_entity (match, AREF (spec, FONT_EXTRA_INDEX)); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1102 FcPatternDestroy (match); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1103 if (! NILP (AREF (spec, FONT_FAMILY_INDEX)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1104 && 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
|
1105 ftfont_generic_family_list)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1106 && 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
|
1107 AREF (entity, FONT_FAMILY_INDEX)))) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1108 entity = Qnil; |
92301
c10a8c811515
(ftfont_match): Explicitly set pixelsize in pattern.
Kenichi Handa <handa@m17n.org>
parents:
91870
diff
changeset
|
1109 } |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1110 } |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1111 FcPatternDestroy (pattern); |
90565
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1112 |
103546
941b1ddcbe2e
Change font_add_log to FONT_ADD_LOG.
Kenichi Handa <handa@m17n.org>
parents:
103011
diff
changeset
|
1113 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
|
1114 return entity; |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1115 } |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1116 |
258e759bcffa
(ftfont_driver): Set ftfont_driver.match to
Kenichi Handa <handa@m17n.org>
parents:
90555
diff
changeset
|
1117 static Lisp_Object |
90400 | 1118 ftfont_list_family (frame) |
1119 Lisp_Object frame; | |
1120 { | |
100163
88dfb64d3e71
(ftfont_list_family): Initialize list var earlier.
Chong Yidong <cyd@stupidchicken.com>
parents:
100161
diff
changeset
|
1121 Lisp_Object list = Qnil; |
90400 | 1122 FcPattern *pattern = NULL; |
1123 FcFontSet *fontset = NULL; | |
1124 FcObjectSet *objset = NULL; | |
1125 int i; | |
1126 | |
1127 if (! fc_initialized) | |
1128 { | |
1129 FcInit (); | |
1130 fc_initialized = 1; | |
1131 } | |
1132 | |
1133 pattern = FcPatternCreate (); | |
1134 if (! pattern) | |
1135 goto finish; | |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
1136 objset = FcObjectSetBuild (FC_FAMILY, NULL); |
90400 | 1137 if (! objset) |
1138 goto finish; | |
1139 fontset = FcFontList (NULL, pattern, objset); | |
1140 if (! fontset) | |
1141 goto finish; | |
1142 | |
1143 for (i = 0; i < fontset->nfont; i++) | |
1144 { | |
1145 FcPattern *pat = fontset->fonts[i]; | |
1146 FcChar8 *str; | |
1147 | |
1148 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
|
1149 list = Fcons (intern ((char *) str), list); |
90400 | 1150 } |
1151 | |
1152 finish: | |
1153 if (objset) FcObjectSetDestroy (objset); | |
1154 if (fontset) FcFontSetDestroy (fontset); | |
1155 if (pattern) FcPatternDestroy (pattern); | |
1156 | |
1157 return list; | |
1158 } | |
1159 | |
1160 | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1161 static Lisp_Object |
90400 | 1162 ftfont_open (f, entity, pixel_size) |
1163 FRAME_PTR f; | |
1164 Lisp_Object entity; | |
1165 int pixel_size; | |
1166 { | |
1167 struct ftfont_info *ftfont_info; | |
1168 struct font *font; | |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1169 struct ftfont_cache_data *cache_data; |
90400 | 1170 FT_Face ft_face; |
1171 FT_Size ft_size; | |
1172 FT_UInt size; | |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1173 Lisp_Object val, filename, index, cache, font_object; |
95103 | 1174 int scalable; |
90400 | 1175 int spacing; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1176 char name[256]; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1177 int i, len; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1178 int upEM; |
90400 | 1179 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1180 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
|
1181 if (! CONSP (val)) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1182 return Qnil; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1183 val = XCDR (val); |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1184 cache = ftfont_lookup_cache (entity, FTFONT_CACHE_FOR_FACE); |
95103 | 1185 if (NILP (cache)) |
1186 return Qnil; | |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1187 filename = XCAR (val); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1188 index = XCDR (val); |
95103 | 1189 val = XCDR (cache); |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1190 cache_data = XSAVE_VALUE (XCDR (cache))->pointer; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1191 ft_face = cache_data->ft_face; |
95103 | 1192 if (XSAVE_VALUE (val)->integer > 0) |
90400 | 1193 { |
95103 | 1194 /* FT_Face in this cache is already used by the different size. */ |
90400 | 1195 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
|
1196 return Qnil; |
90400 | 1197 if (FT_Activate_Size (ft_size) != 0) |
1198 { | |
1199 FT_Done_Size (ft_size); | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1200 return Qnil; |
90400 | 1201 } |
95103 | 1202 } |
1203 XSAVE_VALUE (val)->integer++; | |
90400 | 1204 size = XINT (AREF (entity, FONT_SIZE_INDEX)); |
1205 if (size == 0) | |
1206 size = pixel_size; | |
1207 if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0) | |
1208 { | |
1209 if (XSAVE_VALUE (val)->integer == 0) | |
1210 FT_Done_Face (ft_face); | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1211 return Qnil; |
90400 | 1212 } |
1213 | |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1214 font_object = font_make_object (VECSIZE (struct ftfont_info), entity, size); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1215 ASET (font_object, FONT_TYPE_INDEX, Qfreetype); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1216 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
|
1217 if (len > 0) |
100552
d8bfaced209a
(ftfont_open): Genarate a multibyte string if given
Kenichi Handa <handa@m17n.org>
parents:
100308
diff
changeset
|
1218 ASET (font_object, FONT_NAME_INDEX, make_string (name, len)); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1219 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
|
1220 if (len > 0) |
100552
d8bfaced209a
(ftfont_open): Genarate a multibyte string if given
Kenichi Handa <handa@m17n.org>
parents:
100308
diff
changeset
|
1221 ASET (font_object, FONT_FULLNAME_INDEX, make_string (name, len)); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1222 else |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1223 ASET (font_object, FONT_FULLNAME_INDEX, |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1224 AREF (font_object, FONT_NAME_INDEX)); |
95103 | 1225 ASET (font_object, FONT_FILE_INDEX, filename); |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
1226 ASET (font_object, FONT_FORMAT_INDEX, ftfont_font_format (NULL, filename)); |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1227 font = XFONT_OBJECT (font_object); |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1228 ftfont_info = (struct ftfont_info *) font; |
95103 | 1229 ftfont_info->ft_size = ft_face->size; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1230 ftfont_info->index = XINT (index); |
91162
2b263ef46651
(ftfont_open): Set members maybe_otf and otf of
Kenichi Handa <handa@m17n.org>
parents:
91137
diff
changeset
|
1231 #ifdef HAVE_LIBOTF |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1232 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
|
1233 ftfont_info->otf = NULL; |
91162
2b263ef46651
(ftfont_open): Set members maybe_otf and otf of
Kenichi Handa <handa@m17n.org>
parents:
91137
diff
changeset
|
1234 #endif /* HAVE_LIBOTF */ |
90400 | 1235 font->pixel_size = size; |
1236 font->driver = &ftfont_driver; | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1237 font->encoding_charset = font->repertory_charset = -1; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1238 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1239 upEM = ft_face->units_per_EM; |
95103 | 1240 scalable = (INTEGERP (AREF (entity, FONT_AVGWIDTH_INDEX)) |
1241 && 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
|
1242 if (scalable) |
90555
45553626fa76
(ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents:
90524
diff
changeset
|
1243 { |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1244 font->ascent = ft_face->ascender * size / upEM; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1245 font->descent = - ft_face->descender * size / upEM; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1246 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
|
1247 } |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1248 else |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1249 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1250 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
|
1251 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
|
1252 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
|
1253 } |
95103 | 1254 if (INTEGERP (AREF (entity, FONT_SPACING_INDEX))) |
1255 spacing = XINT (AREF (entity, FONT_SPACING_INDEX)); | |
1256 else | |
90555
45553626fa76
(ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents:
90524
diff
changeset
|
1257 spacing = FC_PROPORTIONAL; |
45553626fa76
(ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents:
90524
diff
changeset
|
1258 if (spacing != FC_PROPORTIONAL) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1259 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
|
1260 = (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
|
1261 : ft_face->size->metrics.max_advance >> 6); |
90400 | 1262 else |
1263 { | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1264 int n; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1265 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1266 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
|
1267 for (i = 32, n = 0; i < 127; i++) |
102859
c8428ec4532f
(ftfont_open): Fix checking of the return value of
Kenichi Handa <handa@m17n.org>
parents:
102791
diff
changeset
|
1268 if (FT_Load_Char (ft_face, i, FT_LOAD_DEFAULT) == 0) |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1269 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1270 int this_width = ft_face->glyph->metrics.horiAdvance >> 6; |
90400 | 1271 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1272 if (this_width > 0 |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1273 && (! 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
|
1274 font->min_width = this_width; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1275 if (i == 32) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1276 font->space_width = this_width; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1277 font->average_width += this_width; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1278 n++; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1279 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1280 if (n > 0) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1281 font->average_width /= n; |
90400 | 1282 } |
1283 | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1284 font->baseline_offset = 0; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1285 font->relative_compose = 0; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1286 font->default_ascent = 0; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1287 font->vertical_centering = 0; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1288 if (scalable) |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1289 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1290 font->underline_position = -ft_face->underline_position * size / upEM; |
102859
c8428ec4532f
(ftfont_open): Fix checking of the return value of
Kenichi Handa <handa@m17n.org>
parents:
102791
diff
changeset
|
1291 font->underline_thickness = ft_face->underline_thickness * size / upEM; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1292 } |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1293 else |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1294 { |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1295 font->underline_position = -1; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1296 font->underline_thickness = 0; |
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1297 } |
90555
45553626fa76
(ftfont_open): Set font->font.full_name and
Kenichi Handa <handa@m17n.org>
parents:
90524
diff
changeset
|
1298 |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1299 return font_object; |
90400 | 1300 } |
1301 | |
1302 static void | |
1303 ftfont_close (f, font) | |
1304 FRAME_PTR f; | |
1305 struct font *font; | |
1306 { | |
1307 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | |
95103 | 1308 Lisp_Object val, cache; |
90400 | 1309 |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1310 val = Fcons (font->props[FONT_FILE_INDEX], make_number (ftfont_info->index)); |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1311 cache = ftfont_lookup_cache (val, FTFONT_CACHE_FOR_FACE); |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1312 xassert (CONSP (cache)); |
95103 | 1313 val = XCDR (cache); |
90400 | 1314 (XSAVE_VALUE (val)->integer)--; |
1315 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
|
1316 { |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1317 struct ftfont_cache_data *cache_data = XSAVE_VALUE (val)->pointer; |
95103 | 1318 |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1319 FT_Done_Face (cache_data->ft_face); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1320 #ifdef HAVE_LIBOTF |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1321 if (ftfont_info->otf) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1322 OTF_close (ftfont_info->otf); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1323 #endif |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1324 cache_data->ft_face = NULL; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1325 } |
90400 | 1326 else |
1327 FT_Done_Size (ftfont_info->ft_size); | |
1328 } | |
1329 | |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
1330 static int |
101556
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1331 ftfont_has_char (font, c) |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1332 Lisp_Object font; |
90400 | 1333 int c; |
1334 { | |
102991
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1335 struct charset *cs = NULL; |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1336 |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1337 if (EQ (AREF (font, FONT_ADSTYLE_INDEX), Qja) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1338 && charset_jisx0208 >= 0) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1339 cs = CHARSET_FROM_ID (charset_jisx0208); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1340 else if (EQ (AREF (font, FONT_ADSTYLE_INDEX), Qko) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1341 && charset_ksc5601 >= 0) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1342 cs = CHARSET_FROM_ID (charset_ksc5601); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1343 if (cs) |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1344 return (ENCODE_CHAR (cs, c) != CHARSET_INVALID_CODE (cs)); |
18e317a87f12
(Qja, Qko): Don't make them static.
Kenichi Handa <handa@m17n.org>
parents:
102945
diff
changeset
|
1345 |
101556
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1346 if (FONT_ENTITY_P (font)) |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1347 { |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1348 FcCharSet *charset = ftfont_get_fc_charset (font); |
90400 | 1349 |
101556
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1350 return (FcCharSetHasChar (charset, c) == FcTrue); |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1351 } |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1352 else |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1353 { |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1354 struct ftfont_info *ftfont_info; |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1355 |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1356 ftfont_info = (struct ftfont_info *) XFONT_OBJECT (font); |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1357 return (FT_Get_Char_Index (ftfont_info->ft_size->face, (FT_ULong) c) |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1358 != 0); |
7f8b5730cfa5
(ftfont_has_char): If the arg FONT is a font-object,
Kenichi Handa <handa@m17n.org>
parents:
101284
diff
changeset
|
1359 } |
90400 | 1360 } |
1361 | |
1362 static unsigned | |
1363 ftfont_encode_char (font, c) | |
1364 struct font *font; | |
1365 int c; | |
1366 { | |
1367 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | |
1368 FT_Face ft_face = ftfont_info->ft_size->face; | |
1369 FT_ULong charcode = c; | |
1370 FT_UInt code = FT_Get_Char_Index (ft_face, charcode); | |
1371 | |
91271
fed5211f4809
(ftfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91249
diff
changeset
|
1372 return (code > 0 ? code : FONT_INVALID_CODE); |
90400 | 1373 } |
1374 | |
1375 static int | |
1376 ftfont_text_extents (font, code, nglyphs, metrics) | |
1377 struct font *font; | |
1378 unsigned *code; | |
1379 int nglyphs; | |
1380 struct font_metrics *metrics; | |
1381 { | |
1382 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | |
1383 FT_Face ft_face = ftfont_info->ft_size->face; | |
1384 int width = 0; | |
96568
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1385 int i, first; |
90400 | 1386 |
1387 if (ftfont_info->ft_size != ft_face->size) | |
1388 FT_Activate_Size (ftfont_info->ft_size); | |
1389 if (metrics) | |
1390 bzero (metrics, sizeof (struct font_metrics)); | |
96568
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1391 for (i = 0, first = 1; i < nglyphs; i++) |
90400 | 1392 { |
1393 if (FT_Load_Glyph (ft_face, code[i], FT_LOAD_DEFAULT) == 0) | |
1394 { | |
1395 FT_Glyph_Metrics *m = &ft_face->glyph->metrics; | |
1396 | |
96568
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1397 if (first) |
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1398 { |
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1399 if (metrics) |
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1400 { |
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1401 metrics->lbearing = m->horiBearingX >> 6; |
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1402 metrics->rbearing = (m->horiBearingX + m->width) >> 6; |
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1403 metrics->ascent = m->horiBearingY >> 6; |
102877
3f976a2deab1
(ftfont_text_extents): Fix calculation of metrics->descent.
Kenichi Handa <handa@m17n.org>
parents:
102859
diff
changeset
|
1404 metrics->descent = (m->height - m->horiBearingY) >> 6; |
96568
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1405 } |
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1406 first = 0; |
ff2262b8b0f2
(ftfont_text_extents): Fix initial setting of metrics.
Kenichi Handa <handa@m17n.org>
parents:
96561
diff
changeset
|
1407 } |
90400 | 1408 if (metrics) |
1409 { | |
1410 if (metrics->lbearing > width + (m->horiBearingX >> 6)) | |
1411 metrics->lbearing = width + (m->horiBearingX >> 6); | |
1412 if (metrics->rbearing | |
1413 < width + ((m->horiBearingX + m->width) >> 6)) | |
1414 metrics->rbearing | |
1415 = width + ((m->horiBearingX + m->width) >> 6); | |
1416 if (metrics->ascent < (m->horiBearingY >> 6)) | |
1417 metrics->ascent = m->horiBearingY >> 6; | |
102877
3f976a2deab1
(ftfont_text_extents): Fix calculation of metrics->descent.
Kenichi Handa <handa@m17n.org>
parents:
102859
diff
changeset
|
1418 if (metrics->descent > ((m->height - m->horiBearingY) >> 6)) |
3f976a2deab1
(ftfont_text_extents): Fix calculation of metrics->descent.
Kenichi Handa <handa@m17n.org>
parents:
102859
diff
changeset
|
1419 metrics->descent = (m->height - m->horiBearingY) >> 6; |
90400 | 1420 } |
1421 width += m->horiAdvance >> 6; | |
1422 } | |
1423 else | |
1424 { | |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1425 width += font->space_width; |
90400 | 1426 } |
1427 } | |
1428 if (metrics) | |
1429 metrics->width = width; | |
1430 | |
1431 return width; | |
1432 } | |
1433 | |
1434 static int | |
1435 ftfont_get_bitmap (font, code, bitmap, bits_per_pixel) | |
1436 struct font *font; | |
1437 unsigned code; | |
1438 struct font_bitmap *bitmap; | |
1439 int bits_per_pixel; | |
1440 { | |
1441 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | |
1442 FT_Face ft_face = ftfont_info->ft_size->face; | |
1443 FT_Int32 load_flags = FT_LOAD_RENDER; | |
1444 | |
1445 if (ftfont_info->ft_size != ft_face->size) | |
1446 FT_Activate_Size (ftfont_info->ft_size); | |
1447 if (bits_per_pixel == 1) | |
1448 { | |
1449 #ifdef FT_LOAD_TARGET_MONO | |
1450 load_flags |= FT_LOAD_TARGET_MONO; | |
1451 #else | |
1452 load_flags |= FT_LOAD_MONOCHROME; | |
1453 #endif | |
1454 } | |
1455 else if (bits_per_pixel != 8) | |
1456 /* We don't support such a rendering. */ | |
1457 return -1; | |
1458 | |
1459 if (FT_Load_Glyph (ft_face, code, load_flags) != 0) | |
1460 return -1; | |
91108
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1461 bitmap->bits_per_pixel |
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1462 = (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
|
1463 : 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
|
1464 : 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
|
1465 : 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
|
1466 : -1); |
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1467 if (bitmap->bits_per_pixel < 0) |
6da57551efb7
(ftfont_get_bitmap): Set bitmap->bits_per_pixel.
Kenichi Handa <handa@m17n.org>
parents:
90963
diff
changeset
|
1468 /* 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
|
1469 return -1; |
90400 | 1470 bitmap->rows = ft_face->glyph->bitmap.rows; |
1471 bitmap->width = ft_face->glyph->bitmap.width; | |
1472 bitmap->pitch = ft_face->glyph->bitmap.pitch; | |
1473 bitmap->buffer = ft_face->glyph->bitmap.buffer; | |
1474 bitmap->left = ft_face->glyph->bitmap_left; | |
1475 bitmap->top = ft_face->glyph->bitmap_top; | |
1476 bitmap->advance = ft_face->glyph->metrics.horiAdvance >> 6; | |
1477 bitmap->extra = NULL; | |
1478 | |
1479 return 0; | |
1480 } | |
1481 | |
1482 static int | |
1483 ftfont_anchor_point (font, code, index, x, y) | |
1484 struct font *font; | |
1485 unsigned code; | |
1486 int index; | |
1487 int *x, *y; | |
1488 { | |
1489 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | |
1490 FT_Face ft_face = ftfont_info->ft_size->face; | |
1491 | |
1492 if (ftfont_info->ft_size != ft_face->size) | |
1493 FT_Activate_Size (ftfont_info->ft_size); | |
1494 if (FT_Load_Glyph (ft_face, code, FT_LOAD_DEFAULT) != 0) | |
1495 return -1; | |
1496 if (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE) | |
1497 return -1; | |
1498 if (index >= ft_face->glyph->outline.n_points) | |
1499 return -1; | |
1500 *x = ft_face->glyph->outline.points[index].x; | |
1501 *y = ft_face->glyph->outline.points[index].y; | |
1502 return 0; | |
1503 } | |
1504 | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1505 #ifdef HAVE_LIBOTF |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1506 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1507 static Lisp_Object |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1508 ftfont_otf_features (gsub_gpos) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1509 OTF_GSUB_GPOS *gsub_gpos; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1510 { |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1511 Lisp_Object scripts, langsyses, features, sym; |
98787
22ff4ff011f4
(ftfont_otf_features): Fix indexing
Kenichi Handa <handa@m17n.org>
parents:
98656
diff
changeset
|
1512 int i, j, k, l; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1513 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1514 for (scripts = Qnil, i = gsub_gpos->ScriptList.ScriptCount - 1; i >= 0; i--) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1515 { |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1516 OTF_Script *otf_script = gsub_gpos->ScriptList.Script + i; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1517 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1518 for (langsyses = Qnil, j = otf_script->LangSysCount - 1; j >= -1; j--) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1519 { |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1520 OTF_LangSys *otf_langsys; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1521 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1522 if (j >= 0) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1523 otf_langsys = otf_script->LangSys + j; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1524 else if (otf_script->DefaultLangSysOffset) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1525 otf_langsys = &otf_script->DefaultLangSys; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1526 else |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1527 break; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1528 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1529 for (features = Qnil, k = otf_langsys->FeatureCount - 1; k >= 0; k--) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1530 { |
98787
22ff4ff011f4
(ftfont_otf_features): Fix indexing
Kenichi Handa <handa@m17n.org>
parents:
98656
diff
changeset
|
1531 l = otf_langsys->FeatureIndex[k]; |
99108
411ea0d5dade
(ftfont_otf_features): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
98787
diff
changeset
|
1532 if (l >= gsub_gpos->FeatureList.FeatureCount) |
98787
22ff4ff011f4
(ftfont_otf_features): Fix indexing
Kenichi Handa <handa@m17n.org>
parents:
98656
diff
changeset
|
1533 continue; |
22ff4ff011f4
(ftfont_otf_features): Fix indexing
Kenichi Handa <handa@m17n.org>
parents:
98656
diff
changeset
|
1534 OTF_TAG_SYM (sym, gsub_gpos->FeatureList.Feature[l].FeatureTag); |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1535 features = Fcons (sym, features); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1536 } |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1537 if (j >= 0) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1538 OTF_TAG_SYM (sym, otf_script->LangSysRecord[j].LangSysTag); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1539 else |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1540 sym = Qnil; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1541 langsyses = Fcons (Fcons (sym, features), langsyses); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1542 } |
101943
97c9e9322753
Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents:
101556
diff
changeset
|
1543 |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1544 OTF_TAG_SYM (sym, gsub_gpos->ScriptList.Script[i].ScriptTag); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1545 scripts = Fcons (Fcons (sym, langsyses), scripts); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1546 } |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1547 return scripts; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1548 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1549 } |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1550 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1551 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1552 static Lisp_Object |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1553 ftfont_otf_capability (font) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1554 struct font *font; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1555 { |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1556 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1557 OTF *otf = ftfont_get_otf (ftfont_info); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1558 Lisp_Object gsub_gpos; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1559 |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1560 if (! otf) |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1561 return Qnil; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1562 gsub_gpos = Fcons (Qnil, Qnil); |
99108
411ea0d5dade
(ftfont_otf_features): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
98787
diff
changeset
|
1563 if (OTF_get_table (otf, "GSUB") == 0 |
411ea0d5dade
(ftfont_otf_features): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
98787
diff
changeset
|
1564 && otf->gsub->FeatureList.FeatureCount > 0) |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1565 XSETCAR (gsub_gpos, ftfont_otf_features (otf->gsub)); |
99108
411ea0d5dade
(ftfont_otf_features): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
98787
diff
changeset
|
1566 if (OTF_get_table (otf, "GPOS") == 0 |
411ea0d5dade
(ftfont_otf_features): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents:
98787
diff
changeset
|
1567 && otf->gpos->FeatureList.FeatureCount > 0) |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1568 XSETCDR (gsub_gpos, ftfont_otf_features (otf->gpos)); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1569 return gsub_gpos; |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1570 } |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
1571 |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1572 #ifdef HAVE_M17N_FLT |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1573 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1574 struct MFLTFontFT |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1575 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1576 MFLTFont flt_font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1577 struct font *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1578 FT_Face ft_face; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1579 OTF *otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1580 }; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1581 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1582 static int |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1583 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
|
1584 MFLTFont *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1585 MFLTGlyphString *gstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1586 int from, to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1587 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1588 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
|
1589 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
|
1590 MFLTGlyph *g; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1591 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1592 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
|
1593 if (! g->encoded) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1594 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1595 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
|
1596 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1597 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
|
1598 g->encoded = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1599 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1600 return 0; |
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 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1603 static int |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1604 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
|
1605 MFLTFont *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1606 MFLTGlyphString *gstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1607 int from, to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1608 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1609 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
|
1610 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
|
1611 MFLTGlyph *g; |
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 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
|
1614 if (! g->measured) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1615 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1616 if (g->code != FONT_INVALID_CODE) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1617 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1618 FT_Glyph_Metrics *m; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1619 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1620 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
|
1621 abort (); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1622 m = &ft_face->glyph->metrics; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1623 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1624 g->lbearing = m->horiBearingX; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1625 g->rbearing = m->horiBearingX + m->width; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1626 g->ascent = m->horiBearingY; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1627 g->descent = m->height - m->horiBearingY; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1628 g->xadv = m->horiAdvance; |
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 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1631 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1632 g->lbearing = 0; |
94931
37f386db63ed
(ftfont_pattern_entity): Argument FRAME removed. Make
Kenichi Handa <handa@m17n.org>
parents:
93588
diff
changeset
|
1633 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
|
1634 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
|
1635 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
|
1636 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1637 g->yadv = 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1638 g->measured = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1639 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1640 return 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1641 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1642 |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
1643 static int |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1644 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
|
1645 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1646 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
|
1647 OTF *otf = flt_font_ft->otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1648 OTF_Tag *tags; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1649 int i, n, negative; |
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 for (i = 0; i < 2; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1652 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1653 if (! spec->features[i]) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1654 continue; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1655 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
|
1656 tags = alloca (sizeof (OTF_Tag) * n); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1657 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
|
1658 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1659 if (spec->features[i][n] == 0xFFFFFFFF) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1660 negative = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1661 else if (negative) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1662 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
|
1663 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1664 tags[n] = spec->features[i][n]; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1665 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1666 if (n - negative > 0 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1667 && 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
|
1668 tags, n - negative) != 1) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1669 return 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1670 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1671 return 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1672 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1673 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1674 #define DEVICE_DELTA(table, size) \ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1675 (((size) >= (table).StartSize && (size) <= (table).EndSize) \ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1676 ? (table).DeltaValue[(size) - (table).StartSize] << 6 \ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1677 : 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1678 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1679 static void |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1680 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
|
1681 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
|
1682 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1683 if (anchor->AnchorFormat == 2) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1684 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1685 FT_Outline *outline; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1686 int ap = anchor->f.f1.AnchorPoint; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1687 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1688 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
|
1689 outline = &ft_face->glyph->outline; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1690 if (ap < outline->n_points) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1691 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1692 *x = outline->points[ap].x << 6; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1693 *y = outline->points[ap].y << 6; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1694 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1695 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1696 else if (anchor->AnchorFormat == 3) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1697 { |
96840 | 1698 if (anchor->f.f2.XDeviceTable.offset |
1699 && anchor->f.f2.XDeviceTable.DeltaValue) | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1700 *x += DEVICE_DELTA (anchor->f.f2.XDeviceTable, x_ppem); |
96840 | 1701 if (anchor->f.f2.YDeviceTable.offset |
1702 && anchor->f.f2.YDeviceTable.DeltaValue) | |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1703 *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
|
1704 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1705 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1706 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1707 static OTF_GlyphString otf_gstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1708 |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1709 static void |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1710 setup_otf_gstring (int size) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1711 { |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1712 if (otf_gstring.size == 0) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1713 { |
103556
246d16550b8d
Don't dereference NULL upon failed malloc and realloc.
Jim Meyering <jim@meyering.net>
parents:
103546
diff
changeset
|
1714 otf_gstring.glyphs = (OTF_Glyph *) xmalloc (sizeof (OTF_Glyph) * size); |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1715 otf_gstring.size = size; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1716 } |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1717 else if (otf_gstring.size < size) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1718 { |
103556
246d16550b8d
Don't dereference NULL upon failed malloc and realloc.
Jim Meyering <jim@meyering.net>
parents:
103546
diff
changeset
|
1719 otf_gstring.glyphs = xrealloc (otf_gstring.glyphs, |
246d16550b8d
Don't dereference NULL upon failed malloc and realloc.
Jim Meyering <jim@meyering.net>
parents:
103546
diff
changeset
|
1720 sizeof (OTF_Glyph) * size); |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1721 otf_gstring.size = size; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1722 } |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1723 otf_gstring.used = size; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1724 memset (otf_gstring.glyphs, 0, sizeof (OTF_Glyph) * size); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1725 } |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1726 |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1727 |
95464
de4cb7ab40db
Fix typo in comment.
Juanma Barranquero <lekktu@gmail.com>
parents:
95433
diff
changeset
|
1728 static int |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1729 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
|
1730 MFLTFont *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1731 MFLTOtfSpec *spec; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1732 MFLTGlyphString *in; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1733 int from, to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1734 MFLTGlyphString *out; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1735 MFLTGlyphAdjustment *adjustment; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1736 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1737 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
|
1738 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
|
1739 OTF *otf = flt_font_ft->otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1740 int len = to - from; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1741 int i, j, gidx; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1742 OTF_Glyph *otfg; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1743 char script[5], *langsys = NULL; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1744 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
|
1745 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1746 if (len == 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1747 return from; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1748 OTF_tag_name (spec->script, script); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1749 if (spec->langsys) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1750 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1751 langsys = alloca (5); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1752 OTF_tag_name (spec->langsys, langsys); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1753 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1754 for (i = 0; i < 2; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1755 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1756 char *p; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1757 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1758 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
|
1759 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1760 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
|
1761 if (i == 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1762 p = gsub_features = alloca (6 * j); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1763 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1764 p = gpos_features = alloca (6 * j); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1765 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
|
1766 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1767 if (spec->features[i][j] == 0xFFFFFFFF) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1768 *p++ = '*', *p++ = ','; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1769 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1770 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1771 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
|
1772 p[4] = ','; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1773 p += 5; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1774 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1775 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1776 *--p = '\0'; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1777 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1778 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1779 |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1780 setup_otf_gstring (len); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1781 for (i = 0; i < len; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1782 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1783 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
|
1784 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
|
1785 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1786 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1787 OTF_drive_gdef (otf, &otf_gstring); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1788 gidx = out->used; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1789 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1790 if (gsub_features) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1791 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1792 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
|
1793 < 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1794 goto simple_copy; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1795 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
|
1796 return -2; |
91294
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1797 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
|
1798 { |
91294
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1799 MFLTGlyph *g; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1800 int min_from, max_to; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1801 int j; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1802 |
91294
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1803 g = out->glyphs + out->used; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1804 *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
|
1805 if (g->code != otfg->glyph_id) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1806 { |
91294
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1807 g->c = 0; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1808 g->code = otfg->glyph_id; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1809 g->measured = 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1810 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1811 out->used++; |
91294
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1812 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
|
1813 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
|
1814 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
|
1815 { |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1816 /* 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
|
1817 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
|
1818 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
|
1819 { |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1820 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
|
1821 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
|
1822 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
|
1823 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
|
1824 } |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1825 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
|
1826 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
|
1827 } |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1828 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
|
1829 && 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
|
1830 i++, otfg++) |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1831 { |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1832 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
|
1833 *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
|
1834 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
|
1835 { |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1836 g->c = 0; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1837 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
|
1838 g->measured = 0; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1839 } |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1840 out->used++; |
299c64a7a9fb
(ftfont_drive_otf): Fix setting of FROM and TO slots of
Kenichi Handa <handa@m17n.org>
parents:
91271
diff
changeset
|
1841 } |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1842 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1843 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1844 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1845 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1846 if (out->allocated < out->used + len) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1847 return -2; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1848 for (i = 0; i < len; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1849 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
|
1850 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1851 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1852 if (gpos_features) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1853 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1854 MFLTGlyph *base = NULL, *mark = NULL, *g; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1855 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
|
1856 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1857 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
|
1858 < 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1859 return to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1860 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1861 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
|
1862 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
|
1863 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
|
1864 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
|
1865 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1866 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
|
1867 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
|
1868 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1869 MFLTGlyph *prev; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1870 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1871 if (! otfg->glyph_id) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1872 continue; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1873 switch (otfg->positioning_type) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1874 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1875 case 0: |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1876 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1877 case 1: /* Single */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1878 case 2: /* Pair */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1879 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1880 int format = otfg->f.f1.format; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1881 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1882 if (format & OTF_XPlacement) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1883 adjustment[i].xoff |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1884 = 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
|
1885 if (format & OTF_XPlaDevice) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1886 adjustment[i].xoff |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1887 += 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
|
1888 if (format & OTF_YPlacement) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1889 adjustment[i].yoff |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1890 = - (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
|
1891 if (format & OTF_YPlaDevice) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1892 adjustment[i].yoff |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1893 -= 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
|
1894 if (format & OTF_XAdvance) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1895 adjustment[i].xadv |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1896 += 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
|
1897 if (format & OTF_XAdvDevice) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1898 adjustment[i].xadv |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1899 += 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
|
1900 if (format & OTF_YAdvance) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1901 adjustment[i].yadv |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1902 += 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
|
1903 if (format & OTF_YAdvDevice) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1904 adjustment[i].yadv |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1905 += 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
|
1906 adjustment[i].set = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1907 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1908 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1909 case 3: /* Cursive */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1910 /* Not yet supported. */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1911 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1912 case 4: /* Mark-to-Base */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1913 case 5: /* Mark-to-Ligature */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1914 if (! base) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1915 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1916 prev = base; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1917 goto label_adjust_anchor; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1918 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
|
1919 if (! mark) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1920 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1921 prev = mark; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1922 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1923 label_adjust_anchor: |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1924 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1925 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
|
1926 int this_from, this_to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1927 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1928 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
|
1929 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
|
1930 mark_x = otfg->f.f4.mark_anchor->XCoordinate * x_scale / 0x10000; |
101943
97c9e9322753
Remove spurious semicolons.
Juanma Barranquero <lekktu@gmail.com>
parents:
101556
diff
changeset
|
1931 mark_y = otfg->f.f4.mark_anchor->YCoordinate * y_scale / 0x10000; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1932 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1933 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
|
1934 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
|
1935 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
|
1936 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
|
1937 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
|
1938 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
|
1939 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
|
1940 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
|
1941 adjustment[i].back = (g - prev); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1942 adjustment[i].xadv = 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1943 adjustment[i].advance_is_absolute = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1944 adjustment[i].set = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1945 this_from = g->from; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1946 this_to = g->to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1947 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
|
1948 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1949 if (this_from > prev[j].from) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1950 this_from = prev[j].from; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1951 if (this_to < prev[j].to) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1952 this_to = prev[j].to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1953 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1954 for (; prev <= g; prev++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1955 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1956 prev->from = this_from; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1957 prev->to = this_to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1958 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1959 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1960 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1961 if (otfg->GlyphClass == OTF_GlyphClass0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1962 base = mark = g; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1963 else if (otfg->GlyphClass == OTF_GlyphClassMark) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1964 mark = g; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1965 else |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1966 base = g; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1967 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1968 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1969 return to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1970 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1971 simple_copy: |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1972 if (out->allocated < out->used + len) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1973 return -2; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1974 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
|
1975 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
|
1976 sizeof (MFLTGlyph) * len); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1977 out->used += len; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1978 return to; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1979 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1980 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1981 static MFLTGlyphString gstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1982 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1983 static int m17n_flt_initialized; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1984 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1985 extern Lisp_Object QCfamily; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1986 |
98656
f2f525a089e1
* ftfont.c (ftfont_shape_by_flt): Make static.
Andreas Schwab <schwab@suse.de>
parents:
98205
diff
changeset
|
1987 static Lisp_Object |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1988 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
|
1989 Lisp_Object lgstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1990 struct font *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1991 FT_Face ft_face; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1992 OTF *otf; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1993 { |
97826 | 1994 EMACS_UINT len = LGSTRING_GLYPH_LEN (lgstring); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1995 EMACS_UINT i; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1996 struct MFLTFontFT flt_font_ft; |
98103
809fdcf44233
(ftfont_shape_by_flt): Use "combining" FLT for ASCII characters.
Kenichi Handa <handa@m17n.org>
parents:
97908
diff
changeset
|
1997 MFLT *flt = NULL; |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
1998 int with_variation_selector = 0; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
1999 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2000 if (! m17n_flt_initialized) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2001 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2002 M17N_INIT (); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2003 m17n_flt_initialized = 1; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2004 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2005 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2006 for (i = 0; i < len; i++) |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2007 { |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2008 Lisp_Object g = LGSTRING_GLYPH (lgstring, i); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2009 int c; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2010 |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2011 if (NILP (g)) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2012 break; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2013 c = LGLYPH_CHAR (g); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2014 if (CHAR_VARIATION_SELECTOR_P (c)) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2015 with_variation_selector++; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2016 } |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2017 len = i; |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2018 if (with_variation_selector) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2019 { |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2020 setup_otf_gstring (len); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2021 for (i = 0; i < len; i++) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2022 { |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2023 Lisp_Object g = LGSTRING_GLYPH (lgstring, i); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2024 |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2025 otf_gstring.glyphs[i].c = LGLYPH_CHAR (g); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2026 otf_gstring.glyphs[i].f.index.from = LGLYPH_FROM (g); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2027 otf_gstring.glyphs[i].f.index.to = LGLYPH_TO (g); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2028 } |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2029 OTF_drive_cmap (otf, &otf_gstring); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2030 for (i = 0; i < otf_gstring.used; i++) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2031 { |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2032 OTF_Glyph *otfg = otf_gstring.glyphs + i; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2033 Lisp_Object g0 = LGSTRING_GLYPH (lgstring, otfg->f.index.from); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2034 Lisp_Object g1 = LGSTRING_GLYPH (lgstring, otfg->f.index.to); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2035 |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2036 LGLYPH_SET_CODE (g0, otfg->glyph_id); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2037 LGLYPH_SET_TO (g0, LGLYPH_TO (g1)); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2038 LGSTRING_SET_GLYPH (lgstring, i, g0); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2039 } |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2040 if (len > otf_gstring.used) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2041 { |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2042 len = otf_gstring.used; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2043 LGSTRING_SET_GLYPH (lgstring, len, Qnil); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2044 } |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2045 } |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2046 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2047 if (gstring.allocated == 0) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2048 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2049 gstring.allocated = len * 2; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2050 gstring.glyph_size = sizeof (MFLTGlyph); |
103556
246d16550b8d
Don't dereference NULL upon failed malloc and realloc.
Jim Meyering <jim@meyering.net>
parents:
103546
diff
changeset
|
2051 gstring.glyphs = xmalloc (sizeof (MFLTGlyph) * gstring.allocated); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2052 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2053 else if (gstring.allocated < len * 2) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2054 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2055 gstring.allocated = len * 2; |
103556
246d16550b8d
Don't dereference NULL upon failed malloc and realloc.
Jim Meyering <jim@meyering.net>
parents:
103546
diff
changeset
|
2056 gstring.glyphs = xrealloc (gstring.glyphs, |
246d16550b8d
Don't dereference NULL upon failed malloc and realloc.
Jim Meyering <jim@meyering.net>
parents:
103546
diff
changeset
|
2057 sizeof (MFLTGlyph) * gstring.allocated); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2058 } |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2059 memset (gstring.glyphs, 0, sizeof (MFLTGlyph) * len); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2060 for (i = 0; i < len; i++) |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2061 { |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2062 Lisp_Object g = LGSTRING_GLYPH (lgstring, i); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2063 |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2064 gstring.glyphs[i].c = LGLYPH_CHAR (g); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2065 if (with_variation_selector) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2066 { |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2067 gstring.glyphs[i].code = LGLYPH_CODE (g); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2068 gstring.glyphs[i].encoded = 1; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2069 } |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2070 } |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2071 |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2072 gstring.used = len; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2073 gstring.r2l = 0; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2074 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2075 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2076 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
|
2077 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2078 if (NILP (family)) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2079 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
|
2080 else |
95103 | 2081 flt_font_ft.flt_font.family |
98205
851824a732ae
(ftfont_shape_by_flt): Downcase family name.
Kenichi Handa <handa@m17n.org>
parents:
98103
diff
changeset
|
2082 = msymbol ((char *) SDATA (Fdowncase (SYMBOL_NAME (family)))); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2083 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2084 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
|
2085 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
|
2086 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
|
2087 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
|
2088 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
|
2089 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
|
2090 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
|
2091 flt_font_ft.font = font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2092 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
|
2093 flt_font_ft.otf = otf; |
100239
7d98fd5b3867
(ftfont_shape_by_flt): Use "combining" flt if the
Kenichi Handa <handa@m17n.org>
parents:
100163
diff
changeset
|
2094 if (len > 1 |
7d98fd5b3867
(ftfont_shape_by_flt): Use "combining" flt if the
Kenichi Handa <handa@m17n.org>
parents:
100163
diff
changeset
|
2095 && gstring.glyphs[1].c >= 0x300 && gstring.glyphs[1].c <= 0x36F) |
98103
809fdcf44233
(ftfont_shape_by_flt): Use "combining" FLT for ASCII characters.
Kenichi Handa <handa@m17n.org>
parents:
97908
diff
changeset
|
2096 /* A little bit ad hoc. Perhaps, shaper must get script and |
809fdcf44233
(ftfont_shape_by_flt): Use "combining" FLT for ASCII characters.
Kenichi Handa <handa@m17n.org>
parents:
97908
diff
changeset
|
2097 language information, and select a proper flt for them |
809fdcf44233
(ftfont_shape_by_flt): Use "combining" FLT for ASCII characters.
Kenichi Handa <handa@m17n.org>
parents:
97908
diff
changeset
|
2098 here. */ |
809fdcf44233
(ftfont_shape_by_flt): Use "combining" FLT for ASCII characters.
Kenichi Handa <handa@m17n.org>
parents:
97908
diff
changeset
|
2099 flt = mflt_get (msymbol ("combining")); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2100 for (i = 0; i < 3; i++) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2101 { |
98103
809fdcf44233
(ftfont_shape_by_flt): Use "combining" FLT for ASCII characters.
Kenichi Handa <handa@m17n.org>
parents:
97908
diff
changeset
|
2102 int result = mflt_run (&gstring, 0, len, &flt_font_ft.flt_font, flt); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2103 if (result != -2) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2104 break; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2105 gstring.allocated += gstring.allocated; |
103556
246d16550b8d
Don't dereference NULL upon failed malloc and realloc.
Jim Meyering <jim@meyering.net>
parents:
103546
diff
changeset
|
2106 gstring.glyphs = xrealloc (gstring.glyphs, |
246d16550b8d
Don't dereference NULL upon failed malloc and realloc.
Jim Meyering <jim@meyering.net>
parents:
103546
diff
changeset
|
2107 sizeof (MFLTGlyph) * gstring.allocated); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2108 } |
97826 | 2109 if (gstring.used > LGSTRING_GLYPH_LEN (lgstring)) |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2110 return Qnil; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2111 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
|
2112 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2113 MFLTGlyph *g = gstring.glyphs + i; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2114 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2115 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
|
2116 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
|
2117 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2118 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2119 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
|
2120 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2121 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
|
2122 MFLTGlyph *g = gstring.glyphs + i; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2123 |
91271
fed5211f4809
(ftfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91249
diff
changeset
|
2124 if (NILP (lglyph)) |
fed5211f4809
(ftfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91249
diff
changeset
|
2125 { |
fed5211f4809
(ftfont_encode_char): Use the macro FONT_INVALID_CODE.
Kenichi Handa <handa@m17n.org>
parents:
91249
diff
changeset
|
2126 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
|
2127 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
|
2128 } |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2129 LGLYPH_SET_FROM (lglyph, g->from); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2130 LGLYPH_SET_TO (lglyph, g->to); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2131 LGLYPH_SET_CHAR (lglyph, g->c); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2132 LGLYPH_SET_CODE (lglyph, g->code); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2133 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
|
2134 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
|
2135 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
|
2136 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
|
2137 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
|
2138 if (g->adjusted) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2139 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2140 Lisp_Object vec; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2141 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2142 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
|
2143 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
|
2144 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
|
2145 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
|
2146 LGLYPH_SET_ADJUSTMENT (lglyph, vec); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2147 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2148 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2149 return make_number (i); |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2150 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2151 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2152 Lisp_Object |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2153 ftfont_shape (lgstring) |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2154 Lisp_Object lgstring; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2155 { |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2156 struct font *font; |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2157 struct ftfont_info *ftfont_info; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
2158 OTF *otf; |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2159 |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2160 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
|
2161 ftfont_info = (struct ftfont_info *) font; |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
2162 otf = ftfont_get_otf (ftfont_info); |
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
2163 if (! otf) |
91870
5348213975e3
(ftfont_shape): Return Lispy number.
Kenichi Handa <handa@m17n.org>
parents:
91604
diff
changeset
|
2164 return make_number (0); |
96561
d7b47f09b693
(struct ftfont_info): New member index, delete member
Kenichi Handa <handa@m17n.org>
parents:
96429
diff
changeset
|
2165 return ftfont_shape_by_flt (lgstring, font, ftfont_info->ft_size->face, otf); |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2166 } |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2167 |
102791
9874a0083028
Fix previous change. Define ftfont_variation_glyphs
Kenichi Handa <handa@m17n.org>
parents:
102773
diff
changeset
|
2168 #endif /* HAVE_M17N_FLT */ |
9874a0083028
Fix previous change. Define ftfont_variation_glyphs
Kenichi Handa <handa@m17n.org>
parents:
102773
diff
changeset
|
2169 |
100792
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2170 #ifdef HAVE_OTF_GET_VARIATION_GLYPHS |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2171 |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2172 static int |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2173 ftfont_variation_glyphs (font, c, variations) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2174 struct font *font; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2175 int c; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2176 unsigned variations[256]; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2177 { |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2178 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2179 OTF *otf = ftfont_get_otf (ftfont_info); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2180 |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2181 if (! otf) |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2182 return 0; |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2183 return OTF_get_variation_glyphs (otf, c, variations); |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2184 } |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2185 |
e829a2083df5
(ftfont_driver): Set the member get_variation_glyphs to
Kenichi Handa <handa@m17n.org>
parents:
100552
diff
changeset
|
2186 #endif /* HAVE_OTF_GET_VARIATION_GLYPHS */ |
91137
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2187 #endif /* HAVE_LIBOTF */ |
00323e98bffb
Don't include Freetype headers. Include "ftfont.h".
Kenichi Handa <handa@m17n.org>
parents:
91108
diff
changeset
|
2188 |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
2189 Lisp_Object |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2190 ftfont_font_format (FcPattern *pattern, Lisp_Object filename) |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
2191 { |
90680
254cfd053f9c
(ftfont_pattern_entity): Check if FC_FONTFORMAT is
Kenichi Handa <handa@m17n.org>
parents:
90676
diff
changeset
|
2192 FcChar8 *str; |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
2193 |
90680
254cfd053f9c
(ftfont_pattern_entity): Check if FC_FONTFORMAT is
Kenichi Handa <handa@m17n.org>
parents:
90676
diff
changeset
|
2194 #ifdef FC_FONTFORMAT |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2195 if (pattern) |
95433
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
2196 { |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2197 if (FcPatternGetString (pattern, FC_FONTFORMAT, 0, &str) != FcResultMatch) |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2198 return Qnil; |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2199 if (strcmp ((char *) str, "TrueType") == 0) |
95433
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
2200 return intern ("truetype"); |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2201 if (strcmp ((char *) str, "Type 1") == 0) |
95433
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
2202 return intern ("type1"); |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2203 if (strcmp ((char *) str, "PCF") == 0) |
95433
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
2204 return intern ("pcf"); |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2205 if (strcmp ((char *) str, "BDF") == 0) |
95433
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
2206 return intern ("bdf"); |
3ffecc48d809
(ftfont_font_format): Don't use strcasestr.
Kenichi Handa <handa@m17n.org>
parents:
95358
diff
changeset
|
2207 } |
96429
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2208 #endif /* FC_FONTFORMAT */ |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2209 if (STRINGP (filename)) |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2210 { |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2211 int len = SBYTES (filename); |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2212 |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2213 if (len >= 4) |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2214 { |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2215 str = (FcChar8 *) (SDATA (filename) + len - 4); |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2216 if (xstrcasecmp ((char *) str, ".ttf") == 0) |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2217 return intern ("truetype"); |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2218 if (xstrcasecmp ((char *) str, ".pfb") == 0) |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2219 return intern ("type1"); |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2220 if (xstrcasecmp ((char *) str, ".pcf") == 0) |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2221 return intern ("pcf"); |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2222 if (xstrcasecmp ((char *) str, ".bdf") == 0) |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2223 return intern ("bdf"); |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2224 } |
5ee216cdf0e3
(fc_charset_table): New member lang.
Kenichi Handa <handa@m17n.org>
parents:
96076
diff
changeset
|
2225 } |
90676
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
2226 return intern ("unknown"); |
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
2227 } |
c43c3837f597
(ftfont_pattern_entity): Add fontformat in a pattern.
Kenichi Handa <handa@m17n.org>
parents:
90623
diff
changeset
|
2228 |
90400 | 2229 |
2230 void | |
2231 syms_of_ftfont () | |
2232 { | |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2233 DEFSYM (Qfreetype, "freetype"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2234 DEFSYM (Qmonospace, "monospace"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2235 DEFSYM (Qsans_serif, "sans-serif"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2236 DEFSYM (Qserif, "serif"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2237 DEFSYM (Qmono, "mono"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2238 DEFSYM (Qsans, "sans"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2239 DEFSYM (Qsans__serif, "sans serif"); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2240 |
90400 | 2241 staticpro (&freetype_font_cache); |
90441
d63258b13d84
(Qiso8859_1, Qiso10646_1, Qunicode_bmp): Moved to
Kenichi Handa <handa@m17n.org>
parents:
90427
diff
changeset
|
2242 freetype_font_cache = Fcons (Qt, Qnil); |
90400 | 2243 |
90464
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2244 staticpro (&ftfont_generic_family_list); |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2245 ftfont_generic_family_list |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2246 = Fcons (Fcons (Qmonospace, Qt), |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2247 Fcons (Fcons (Qsans_serif, Qt), |
4702b592db4c
(Qmonospace, Qsans_serif, Qserif, Qmono, Qsans)
Kenichi Handa <handa@m17n.org>
parents:
90450
diff
changeset
|
2248 Fcons (Fcons (Qsans, Qt), Qnil))); |
90400 | 2249 |
95103 | 2250 staticpro (&ft_face_cache); |
2251 ft_face_cache = Qnil; | |
2252 | |
90400 | 2253 ftfont_driver.type = Qfreetype; |
2254 register_font_driver (&ftfont_driver, NULL); | |
2255 } | |
90427 | 2256 |
2257 /* arch-tag: 7cfa432c-33a6-4988-83d2-a82ed8604aca | |
2258 (do not change this comment) */ |