annotate src/ftfont.c @ 96136:73e422173a87

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