diff --git a/CMakeLists.txt b/CMakeLists.txt index c9a2f7c..b9b201b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ include(cmake/version.cmake) option(MSDF_ATLAS_BUILD_STANDALONE "Build the msdf-atlas-gen standalone executable" ON) option(MSDF_ATLAS_USE_VCPKG "Use vcpkg package manager to link project dependencies" ON) option(MSDF_ATLAS_USE_SKIA "Build with the Skia library" ON) +option(MSDF_ATLAS_NO_ARTERY_FONT "Disable Artery Font export and do not require its submodule" OFF) option(MSDF_ATLAS_MSDFGEN_EXTERNAL "Do not build the msdfgen submodule but find it as an external package" OFF) option(MSDF_ATLAS_INSTALL "Generate installation target" OFF) option(MSDF_ATLAS_DYNAMIC_RUNTIME "Link dynamic runtime library instead of static" OFF) @@ -100,13 +101,15 @@ target_compile_definitions(msdf-atlas-gen PUBLIC MSDF_ATLAS_VERSION_REVISION=${MSDF_ATLAS_VERSION_REVISION} MSDF_ATLAS_COPYRIGHT_YEAR=${MSDF_ATLAS_COPYRIGHT_YEAR} ) -target_include_directories(msdf-atlas-gen - INTERFACE - $ - $ - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/artery-font-format +target_include_directories(msdf-atlas-gen INTERFACE + $ + $ ) +if(MSDF_ATLAS_NO_ARTERY_FONT) + target_compile_definitions(msdf-atlas-gen PUBLIC MSDF_ATLAS_NO_ARTERY_FONT) +else() + target_include_directories(msdf-atlas-gen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/artery-font-format) +endif() set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT msdf-atlas-gen) target_compile_features(msdf-atlas-gen PUBLIC cxx_std_11) diff --git a/msdf-atlas-gen/artery-font-export.cpp b/msdf-atlas-gen/artery-font-export.cpp index bd1ca82..f617a58 100644 --- a/msdf-atlas-gen/artery-font-export.cpp +++ b/msdf-atlas-gen/artery-font-export.cpp @@ -1,6 +1,8 @@ #include "artery-font-export.h" +#ifndef MSDF_ATLAS_NO_ARTERY_FONT + #include #include #include "GlyphGeometry.h" @@ -188,3 +190,5 @@ template bool exportArteryFont(const FontGeometry *fonts, int fontCount, template bool exportArteryFont(const FontGeometry *fonts, int fontCount, const msdfgen::BitmapConstRef &atlas, const char *filename, const ArteryFontExportProperties &properties); } + +#endif diff --git a/msdf-atlas-gen/artery-font-export.h b/msdf-atlas-gen/artery-font-export.h index 593fe5c..f61d417 100644 --- a/msdf-atlas-gen/artery-font-export.h +++ b/msdf-atlas-gen/artery-font-export.h @@ -1,6 +1,8 @@ #pragma once +#ifndef MSDF_ATLAS_NO_ARTERY_FONT + #include #include #include "types.h" @@ -21,3 +23,5 @@ template bool exportArteryFont(const FontGeometry *fonts, int fontCount, const msdfgen::BitmapConstRef &atlas, const char *filename, const ArteryFontExportProperties &properties); } + +#endif diff --git a/msdf-atlas-gen/main.cpp b/msdf-atlas-gen/main.cpp index cb818dc..623b487 100644 --- a/msdf-atlas-gen/main.cpp +++ b/msdf-atlas-gen/main.cpp @@ -46,6 +46,11 @@ using namespace msdf_atlas; #define EXTRA_UNDERLINE #endif +static const char * const versionText = + "MSDF-Atlas-Gen v" MSDF_ATLAS_VERSION_STRING "\n" + " with MSDFgen v" MSDFGEN_VERSION_STRING TITLE_SUFFIX "\n" + "(c) 2020 - " STRINGIZE(MSDF_ATLAS_COPYRIGHT_YEAR) " Viktor Chlumsky"; + static const char * const helpText = R"( MSDF Atlas Generator by Viktor Chlumsky v)" MSDF_ATLAS_VERSION_STRING R"( (with MSDFgen v)" MSDFGEN_VERSION_STRING TITLE_SUFFIX R"() ----------------------------------------------------------------)" VERSION_UNDERLINE EXTRA_UNDERLINE R"( @@ -85,9 +90,13 @@ OUTPUT SPECIFICATION - one or more can be specified -json Writes the atlas's layout data, as well as other metrics into a structured JSON file. -csv - Writes the layout data of the glyphs into a simple CSV file. + Writes the layout data of the glyphs into a simple CSV file.)" +#ifndef MSDF_ATLAS_NO_ARTERY_FONT +R"( -arfont - Stores the atlas and its layout data as an Artery Font file. Supported formats: png, bin, binfloat. + Stores the atlas and its layout data as an Artery Font file. Supported formats: png, bin, binfloat.)" +#endif +R"( -shadronpreview Generates a Shadron script that uses the generated atlas to draw a sample text as a preview. @@ -273,6 +282,7 @@ static bool makeAtlas(const std::vector &glyphs, const std::vecto } } +#ifndef MSDF_ATLAS_NO_ARTERY_FONT if (config.arteryFontFilename) { ArteryFontExportProperties arfontProps; arfontProps.fontSize = config.emSize; @@ -287,6 +297,7 @@ static bool makeAtlas(const std::vector &glyphs, const std::vecto puts("Failed to generate Artery Font file."); } } +#endif return success; } @@ -337,6 +348,10 @@ int main(int argc, const char * const *argv) { const char *arg = argv[argPos]; #define ARG_CASE(s, p) if (!strcmp(arg, s) && argPos+(p) < argc) + // Accept arguments prefixed with -- instead of - + if (arg[0] == '-' && arg[1] == '-') + ++arg; + ARG_CASE("-type", 1) { arg = argv[++argPos]; if (!strcmp(arg, "hardmask")) @@ -427,11 +442,13 @@ int main(int argc, const char * const *argv) { ++argPos; continue; } + #ifndef MSDF_ATLAS_NO_ARTERY_FONT ARG_CASE("-arfont", 1) { config.arteryFontFilename = argv[++argPos]; ++argPos; continue; } + #endif ARG_CASE("-imageout", 1) { config.imageFilename = argv[++argPos]; ++argPos; @@ -666,11 +683,15 @@ int main(int argc, const char * const *argv) { argPos += 2; continue; } + ARG_CASE("-version", 0) { + puts(versionText); + return 0; + } ARG_CASE("-help", 0) { puts(helpText); return 0; } - printf("Unknown setting or insufficient parameters: %s\n", arg); + printf("Unknown setting or insufficient parameters: %s\n", argv[argPos]); suggestHelp = true; ++argPos; } @@ -765,6 +786,7 @@ int main(int argc, const char * const *argv) { } if (config.imageType == ImageType::MTSDF && config.imageFormat == ImageFormat::BMP) ABORT("Atlas type not compatible with image format. MTSDF requires a format with alpha channel."); +#ifndef MSDF_ATLAS_NO_ARTERY_FONT if (config.arteryFontFilename && !(config.imageFormat == ImageFormat::PNG || config.imageFormat == ImageFormat::BINARY || config.imageFormat == ImageFormat::BINARY_FLOAT)) { config.arteryFontFilename = nullptr; result = 1; @@ -774,6 +796,7 @@ int main(int argc, const char * const *argv) { return result; layoutOnly = !(config.arteryFontFilename || config.imageFilename); } +#endif if (imageExtension != ImageFormat::UNSPECIFIED) { // Warn if image format mismatches -imageout extension bool mismatch = false; diff --git a/msdfgen b/msdfgen index a811ef8..7ff249b 160000 --- a/msdfgen +++ b/msdfgen @@ -1 +1 @@ -Subproject commit a811ef8935354d3f6d767cff6c4eebeb683777f2 +Subproject commit 7ff249bcd4da6678c5779d9664633c039fb50c0a