added file_size() function
[swftools.git] / src / ttftool.c
bloba3a8da4fc54f971b5fb23d3b934468bece987e4c
1 /* ttftool.c
3 Truetype utility.
5 Part of the swftools package.
7 Copyright (c) 2010 Matthias Kramm <kramm@quiss.org>
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.
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.
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 */
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <unistd.h>
27 #include <math.h>
28 #include "../lib/args.h"
29 #include "../lib/ttf.h"
31 static char * filename = 0;
32 static int showname = 0;
33 static int verbose = 0;
35 static struct options_t options[] = {
36 {"n", "name"},
37 {0,0}
40 int args_callback_option(char*name,char*val)
42 if(!strcmp(name, "V")) {
43 printf("ttftool - part of %s %s\n", PACKAGE, VERSION);
44 exit(0);
45 } else if(!strcmp(name, "n")) {
46 showname = 1;
47 return 0;
48 } else if(!strcmp(name, "v")) {
49 verbose ++;
50 return 0;
51 } else {
52 printf("Unknown option: -%s\n", name);
53 exit(1);
55 return 0;
57 int args_callback_longoption(char*name,char*val)
59 return args_long2shortoption(options, name, val);
61 void args_callback_usage(char *name)
63 printf("\n");
64 printf("Usage: %s <fontfile>\n", name);
65 printf("\n");
66 printf("-h , --help Print short help message and exit\n");
67 printf("-v , --verbose Be verbose. Use more than one -v for greater effect.\n");
68 printf("-o , --output <filename> Write output to file <filename>.\n");
69 printf("-V , --version Print version info and exit\n");
70 printf("\n");
72 int args_callback_command(char*name,char*val)
74 if(filename) {
75 fprintf(stderr, "Please specify only one font\n");
76 exit(1);
78 filename = name;
79 return 0;
83 int main(int argc, char ** argv)
85 processargs(argc, argv);
86 ttf_t* font = ttf_open(filename);
87 if(showname && font->full_name) {
88 printf("%s\n", font->full_name);
90 return 0;