| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 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> |
| 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 |
|
| 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()); |
| 132 |
CheckIsScript(argc,argv); |
| 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 |
} |