3 % Copyright
2006-2008 Taco Hoekwater
<taco@@luatex.org
>
5 % This file is part of LuaTeX.
7 % LuaTeX is free software
; you can redistribute it and
/or modify it under
8 % the terms of the GNU General Public License as published by the Free
9 % Software Foundation
; either version
2 of the License
, or
(at your
10 % option
) any later version.
12 % LuaTeX is distributed in the hope that it will be useful
, but WITHOUT
13 % ANY WARRANTY
; without even the implied warranty of MERCHANTABILITY or
14 % FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 % License for more details.
17 % You should have received a copy of the GNU General Public License along
18 % with LuaTeX
; if not
, see
<http
://www.gnu.org
/licenses
/>.
24 #include
"font/writettf.h"
25 #include
"font/writecff.h"
28 extern unsigned char
*ttf_buffer
;
29 void writetype0
(PDF pdf
, fd_entry
* fd
)
41 fd_cur
= fd
; /* |fd_cur| is global inside \.
{writettf.w
} */
42 assert
(fd_cur-
>fm
!= NULL);
43 assert
(is_opentype
(fd_cur-
>fm
) || is_truetype
(fd_cur-
>fm
));
44 assert
(is_included
(fd_cur-
>fm
));
49 luatex_find_file
(fd_cur-
>fm-
>ff_name
, find_opentype_file_callback
);
50 if
(cur_file_name
== NULL) {
52 luatex_find_file
(fd_cur-
>fm-
>ff_name
, find_truetype_file_callback
);
53 if
(cur_file_name
== NULL) {
54 formatted_error
("type 0","cannot find file '%s'", fd_cur-
>fm-
>ff_name
);
57 callback_id
= callback_defined
(read_opentype_file_callback
);
58 if
(callback_id
> 0) {
59 if
(run_callback
(callback_id
, "S->bSd", cur_file_name
,
60 &file_opened, &ttf_buffer, &ttf_size) &&
61 file_opened
&& ttf_size > 0) {
63 formatted_error
("type 0","cannot find file '%s'", cur_file_name
);
66 if
(!otf_open
(cur_file_name
)) {
67 formatted_error
("type 0","cannot find file '%s'", cur_file_name
);
73 fd_cur-
>ff_found
= true
;
75 sfont
= sfnt_open
(ttf_buffer
, ttf_size
);
76 if
(sfont-
>type
== SFNT_TYPE_TTC
)
77 i
= ff_get_ttc_index
(fd-
>fm-
>ff_name
, fd-
>fm-
>ps_name
);
80 if
(is_subsetted
(fd_cur-
>fm
)) {
81 report_start_file
(filetype_subset
, cur_file_name
);
83 report_start_file
(filetype_font
, cur_file_name
);
87 if
(sfont-
>type
== SFNT_TYPE_TTC
) otc_read_tabdir
(i
);
88 else ttf_read_tabdir
();
91 /* read font parameters
*/
92 if
(ttf_name_lookup
("head", false
) != NULL)
94 if
(ttf_name_lookup
("hhea", false
) != NULL)
96 if
(ttf_name_lookup
("PCLT", false
) != NULL)
98 if
(ttf_name_lookup
("post", false
) != NULL)
102 tab
= ttf_seek_tab
("CFF ", 0);
104 /* TODO the next
0 is a subfont index
*/
105 cff
= read_cff
(ttf_buffer
+ ttf_curbyte
, (long
) tab-
>length
, 0);
106 if
(!is_subsetted
(fd_cur-
>fm
)) {
107 /* not subsetted
, just do a copy
*/
108 for
(i
= (long
) tab-
>length
; i
> 0; i--
)
109 strbuf_putchar
(pdf-
>fb
, (unsigned char
) ttf_getnum
(1));
112 if
(cff_is_cidfont
(cff
)) {
113 write_cid_cff
(pdf
, cff
, fd_cur
);
115 for
(i
= tab-
>length
; i
> 0; i--
)
116 strbuf_putchar
(pdf-
>fb
, (unsigned char
) ttf_getnum
(1));
119 write_cff
(pdf
, cff
, fd_cur
);
122 /* not understood
, just do a copy
*/
123 for
(i
= (long
) tab-
>length
; i
> 0; i--
)
124 strbuf_putchar
(pdf-
>fb
, (unsigned char
) ttf_getnum
(1));
129 if
(is_subsetted
(fd_cur-
>fm
)) {
130 report_stop_file
(filetype_subset
);
132 report_stop_file
(filetype_font
);
134 cur_file_name
= NULL;