Debian Codegraph @

texk/xdvipsk/otflib/tt_aux.c

raw
1 /* This is xdvipsk, an eXtended version of dvips(k) by Tomas Rokicki.
2
3 Copyright (C) 2016 by VTeX Ltd (www.vtex.lt),
4 the xdvipsk project team - Sigitas Tolusis and Arunas Povilaitis.
5
6 Program original code copyright (C) 2007-2014 by Jin-Hwan Cho and
7 Shunsaku Hirata, the dvipdfmx project team.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 */
23
24 #include <config.h>
25
26 #include "system.h"
27 #include "mem.h"
28 #include "error.h"
29 #include "numbers.h"
30
31 #include "tt_aux.h"
32
33 static int always_embed = 0;
34
35 ULONG ttc_read_offset (sfnt *sfont, int ttc_idx)
36 {
37 ULONG offset = 0, num_dirs = 0;
38
39 if (sfont == NULL || sfont->stream == NULL)
40 ERROR("file not opened");
41
42 if (sfont->type != SFNT_TYPE_TTC)
43 ERROR("ttc_read_offset(): invalid font type");
44
45 sfnt_seek_set (sfont, 4); /* skip version tag */
46
47 /* version = */ sfnt_get_ulong(sfont);
48 num_dirs = sfnt_get_ulong(sfont);
49 if (ttc_idx < 0 || ttc_idx > num_dirs - 1)
50 ERROR("Invalid TTC index number");
51
52 sfnt_seek_set (sfont, 12 + ttc_idx * 4);
53 offset = sfnt_get_ulong (sfont);
54
55 return offset;
56 }