Debian Codegraph @

fontforgeexe/startnoui.c

raw symbols SCIP
1 /* Copyright (C) 2007-2012 by George Williams */
2 /*
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
8
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12
13 * The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #include <fontforge-config.h>
29 #include <fontforge-version-extras.h>
30
31 #include "encoding.h"
32 #include "fontforgevw.h"
33 #include "gfile.h"
34 #include "scripting.h"
35 #include "start.h"
36 #include "ustring.h"
37
38 #include <locale.h>
39 #include <time.h>
40
41 #ifdef __Mac
42 # include <stdlib.h> /* getenv,setenv */
43 #endif
44
45 static void _doscriptusage(void) {
46 printf( "fontforge [options]\n" );
47 printf( "\t-usage\t\t\t (displays this message, and exits)\n" );
48 printf( "\t-help\t\t\t (displays this message, invokes a browser\n\t\t\t\t using the BROWSER environment variable)\n" );
49 printf( "\t-version\t\t (prints the version of fontforge and exits)\n" );
50 printf( "\t-lang=py\t\t (use python to execute scripts\n" );
51 printf( "\t-lang=ff\t\t (use fontforge's native language to\n\t\t\t\t execute scripts)\n" );
52 printf( "\t-script scriptfile\t (executes scriptfile)\n" );
53 printf( "\t-c script-string\t (executes the argument as scripting cmds)\n" );
54 printf( "\t-skippyfile\t\t (do not execute python init scripts)\n" );
55 printf( "\t-skippyplug\t\t (do not load python plugins)\n" );
56 printf( "\n" );
57 printf( "If no scriptfile/string is given (or if it's \"-\") FontForge will read stdin\n" );
58 printf( "FontForge will read postscript (pfa, pfb, ps, cid), opentype (otf),\n" );
59 printf( "\ttruetype (ttf,ttc), macintosh resource fonts (dfont,bin,hqx),\n" );
60 printf( "\tand bdf and pcf fonts. It will also read its own format --\n" );
61 printf( "\tsfd files.\n" );
62 printf( "Any arguments after the script file will be passed to it.\n");
63 printf( "If the first argument is an executable filename, and that file's first\n" );
64 printf( "\tline contains \"fontforge\" then it will be treated as a scriptfile.\n\n" );
65 printf( "For more information see:\n\thttp://fontforge.sourceforge.net/\n" );
66 printf( "Send bug reports to:\[email protected]\n" );
67 }
68
69 static void doscriptusage(void) {
70 _doscriptusage();
71 exit(0);
72 }
73
74 static void doscripthelp(void) {
75 _doscriptusage();
76 exit(0);
77 }
78
79 int fontforge_main( int argc, char **argv ) {
80 int run_python_init_files = true;
81 int import_python_plugins = true;
82 bool quiet = false;
83 char *pt;
84
85 FindProgRoot(argv[0]);
86 InitSimpleStuff();
87
88 bind_textdomain_codeset("FontForge","UTF-8");
89 bindtextdomain("FontForge", getLocaleDir());
90 textdomain("FontForge");
91 for ( int i=1; i<argc; ++i ) {
92 pt = argv[i];
93
94 if ( strcmp(pt,"-SkipPythonInitFiles")==0 || strcmp(pt,"-skippyfile")==0 ) {
95 run_python_init_files = false;
96 } else if ( strcmp(pt,"-skippyplug")==0 ) {
97 import_python_plugins = false;
98 } else if ( strcmp(pt,"-quiet")==0 ) {
99 quiet = true;
100 }
101 }
102
103 if (!quiet) {
104 time_t tm = FONTFORGE_MODTIME_RAW;
105 struct tm* modtime = gmtime(&tm);
106 fprintf( stderr, "Copyright (c) 2000-%d. See AUTHORS for Contributors.\n", modtime->tm_year+1900 );
107 fprintf( stderr, " License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n" );
108 fprintf( stderr, " with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.\n" );
109 fprintf( stderr, " Version: %s\n", FONTFORGE_VERSION );
110 fprintf( stderr, " Based on sources from %s"
111 #ifdef FREETYPE_HAS_DEBUGGER
112 "-TtfDb"
113 #endif
114 #ifdef _NO_PYTHON
115 "-NoPython"
116 #endif
117 #ifdef FONTFORGE_CONFIG_USE_DOUBLE
118 "-D"
119 #endif
120 ".\n",
121 FONTFORGE_MODTIME_STR );
122 // Can be empty if e.g. building from a tarball
123 if (FONTFORGE_GIT_VERSION[0] != '\0') {
124 fprintf( stderr, " Based on source from git with hash: %s\n", FONTFORGE_GIT_VERSION );
125 }
126 }
127
128 if ( GetDefaultEncoding()==NULL )
129 SetDefaultEncoding(FindOrMakeEncoding("ISO8859-1"));
130 if ( GetDefaultEncoding()==NULL )
131 SetDefaultEncoding(GetCustomEncoding()); /* In case iconv is broken */
132 CheckIsScript(argc,argv); /* Will run the script and exit if it is a script */
133 if ( argc==2 ) {
134 pt = argv[1];
135 if ( *pt=='-' && pt[1]=='-' && pt[2]!='\0') ++pt;
136 if ( strcmp(pt,"-usage")==0 )
137 doscriptusage();
138 else if ( strcmp(pt,"-help")==0 )
139 doscripthelp();
140 else if ( strcmp(pt,"-version")==0 || strcmp(pt,"-v")==0 || strcmp(pt,"-V")==0 )
141 doversion(FONTFORGE_VERSION);
142 }
143 # if defined(_NO_PYTHON)
144 ProcessNativeScript(argc, argv,stdin);
145 # else
146 PyFF_Stdin(run_python_init_files, import_python_plugins);
147 # endif
148
149 return( 0 );
150 }