made xpdf use SWFTOOLS_TMP, too
[swftools.git] / src / ttftool.c
blob914a80b529a4a0c014034faa86e4fc6ab8e7ca0a
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 char * output = 0;
33 static int showname = 0;
34 static int verbose = 0;
36 static struct options_t options[] = {
37 {"n", "name"},
38 {"o", "output"},
39 {0,0}
42 int args_callback_option(char*name,char*val)
44 if(!strcmp(name, "V")) {
45 printf("ttftool - part of %s %s\n", PACKAGE, VERSION);
46 exit(0);
47 } else if(!strcmp(name, "n")) {
48 showname = 1;
49 return 0;
50 } else if(!strcmp(name, "v")) {
51 verbose ++;
52 return 0;
53 } else if(!strcmp(name, "o")) {
54 output = strdup(val);
55 return 1;
56 } else {
57 printf("Unknown option: -%s\n", name);
58 exit(1);
60 return 0;
62 int args_callback_longoption(char*name,char*val)
64 return args_long2shortoption(options, name, val);
66 void args_callback_usage(char *name)
68 printf("\n");
69 printf("Usage: %s <fontfile>\n", name);
70 printf("\n");
71 printf("-h , --help Print short help message and exit\n");
72 printf("-v , --verbose Be verbose. Use more than one -v for greater effect.\n");
73 printf("-o , --output <filename> Write output to file <filename>.\n");
74 printf("-V , --version Print version info and exit\n");
75 printf("\n");
77 int args_callback_command(char*name,char*val)
79 if(filename) {
80 fprintf(stderr, "Please specify only one font\n");
81 exit(1);
83 filename = name;
84 return 0;
88 int main(int argc, char ** argv)
90 processargs(argc, argv);
91 ttf_t* font = ttf_open(filename);
92 if(showname && font->full_name) {
93 printf("%s\n", font->full_name);
95 if(output) {
96 ttf_save(font, output);
98 return 0;