mirror of https://github.com/Chlumsky/msdfgen.git
Fix crash on invalid varfont, print version, accept --args
This commit is contained in:
parent
a811ef8935
commit
7ff249bcd4
|
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2016 - 2022 Viktor Chlumsky
|
Copyright (c) 2016 - 2023 Viktor Chlumsky
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
||||||
22
main.cpp
22
main.cpp
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR - standalone console program
|
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR - standalone console program
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* A utility by Viktor Chlumsky, (c) 2014 - 2022
|
* A utility by Viktor Chlumsky, (c) 2014 - 2023
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ static FontHandle * loadVarFont(FreetypeHandle *library, const char *filename) {
|
||||||
while (*filename && *filename != '?')
|
while (*filename && *filename != '?')
|
||||||
buffer.push_back(*filename++);
|
buffer.push_back(*filename++);
|
||||||
FontHandle *font = loadFont(library, buffer.c_str());
|
FontHandle *font = loadFont(library, buffer.c_str());
|
||||||
if (*filename++ == '?') {
|
if (font && *filename++ == '?') {
|
||||||
do {
|
do {
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
while (*filename && *filename != '=')
|
while (*filename && *filename != '=')
|
||||||
|
|
@ -299,7 +299,11 @@ static const char * writeOutput(const BitmapConstRef<float, N> &bitmap, const ch
|
||||||
#define SUFFIX_UNDERLINE
|
#define SUFFIX_UNDERLINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char *helpText =
|
static const char * const versionText =
|
||||||
|
"MSDFgen v" MSDFGEN_VERSION_STRING TITLE_SUFFIX "\n"
|
||||||
|
"(c) 2016 - " STRINGIZE(MSDFGEN_COPYRIGHT_YEAR) " Viktor Chlumsky";
|
||||||
|
|
||||||
|
static const char * const helpText =
|
||||||
"\n"
|
"\n"
|
||||||
"Multi-channel signed distance field generator by Viktor Chlumsky v" MSDFGEN_VERSION_STRING TITLE_SUFFIX "\n"
|
"Multi-channel signed distance field generator by Viktor Chlumsky v" MSDFGEN_VERSION_STRING TITLE_SUFFIX "\n"
|
||||||
"------------------------------------------------------------------" VERSION_UNDERLINE SUFFIX_UNDERLINE "\n"
|
"------------------------------------------------------------------" VERSION_UNDERLINE SUFFIX_UNDERLINE "\n"
|
||||||
|
|
@ -406,6 +410,8 @@ static const char *helpText =
|
||||||
"\tRenders an image preview without flattening the color channels.\n"
|
"\tRenders an image preview without flattening the color channels.\n"
|
||||||
" -translate <x> <y>\n"
|
" -translate <x> <y>\n"
|
||||||
"\tSets the translation of the shape in shape units.\n"
|
"\tSets the translation of the shape in shape units.\n"
|
||||||
|
" -version\n"
|
||||||
|
"\tPrints the version of the program.\n"
|
||||||
" -windingpreprocess\n"
|
" -windingpreprocess\n"
|
||||||
"\tAttempts to fix only the contour windings assuming no self-intersections and even-odd fill rule.\n"
|
"\tAttempts to fix only the contour windings assuming no self-intersections and even-odd fill rule.\n"
|
||||||
" -yflip\n"
|
" -yflip\n"
|
||||||
|
|
@ -520,6 +526,10 @@ int main(int argc, const char * const *argv) {
|
||||||
#define ARG_MODE(s, m) if (!strcmp(arg, s)) { mode = m; ++argPos; continue; }
|
#define ARG_MODE(s, m) if (!strcmp(arg, s)) { mode = m; ++argPos; continue; }
|
||||||
#define SET_FORMAT(fmt, ext) do { format = fmt; if (!outputSpecified) output = "output." ext; } while (false)
|
#define SET_FORMAT(fmt, ext) do { format = fmt; if (!outputSpecified) output = "output." ext; } while (false)
|
||||||
|
|
||||||
|
// Accept arguments prefixed with -- instead of -
|
||||||
|
if (arg[0] == '-' && arg[1] == '-')
|
||||||
|
++arg;
|
||||||
|
|
||||||
ARG_MODE("sdf", SINGLE)
|
ARG_MODE("sdf", SINGLE)
|
||||||
ARG_MODE("psdf", PSEUDO)
|
ARG_MODE("psdf", PSEUDO)
|
||||||
ARG_MODE("msdf", MULTI)
|
ARG_MODE("msdf", MULTI)
|
||||||
|
|
@ -851,11 +861,15 @@ int main(int argc, const char * const *argv) {
|
||||||
argPos += 2;
|
argPos += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
ARG_CASE("-version", 0) {
|
||||||
|
puts(versionText);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
ARG_CASE("-help", 0) {
|
ARG_CASE("-help", 0) {
|
||||||
puts(helpText);
|
puts(helpText);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
printf("Unknown setting or insufficient parameters: %s\n", arg);
|
printf("Unknown setting or insufficient parameters: %s\n", argv[argPos]);
|
||||||
suggestHelp = true;
|
suggestHelp = true;
|
||||||
++argPos;
|
++argPos;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
/*
|
/*
|
||||||
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR
|
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR
|
||||||
* ---------------------------------------------
|
* ---------------------------------------------
|
||||||
* A utility by Viktor Chlumsky, (c) 2014 - 2022
|
* A utility by Viktor Chlumsky, (c) 2014 - 2023
|
||||||
*
|
*
|
||||||
* The extension module provides ways to easily load input and save output using popular formats.
|
* The extension module provides ways to easily load input and save output using popular formats.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
/*
|
/*
|
||||||
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR
|
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR
|
||||||
* ---------------------------------------------
|
* ---------------------------------------------
|
||||||
* A utility by Viktor Chlumsky, (c) 2014 - 2022
|
* A utility by Viktor Chlumsky, (c) 2014 - 2023
|
||||||
*
|
*
|
||||||
* The technique used to generate multi-channel distance fields in this code
|
* The technique used to generate multi-channel distance fields in this code
|
||||||
* has been developed by Viktor Chlumsky in 2014 for his master's thesis,
|
* has been developed by Viktor Chlumsky in 2014 for his master's thesis,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue