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