diff --git a/CHANGELOG.md b/CHANGELOG.md index 1274a087..79cbd4fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,20 @@ +## Version 1.11 (2023-11-11) + +- Reworked SVG parser, which now supports multiple paths and other shapes - requires Skia +- Major performance improvements due to inlining certain low-level classes +- A limited version of the standalone executable can now be built without any dependencies +- Fixed `listFontVariationAxes` which previously reported incorrectly scaled values +- Fixed potential crash when generating SDF from an empty `Shape` +- Fixed a small bug in the error correction routine +- Errors now reported to `stderr` rather than `stdout` +- All command line arguments can now also be passed with two dashes instead of one +- Added `-version` argument to print the program's version +- `Shape` can now be loaded from a pointer to FreeType's `FT_Outline` +- Added hidden CMake options to selectively disable PNG, SVG, or variable font support +- Added CMake presets +- Other minor bug fixes + ## Version 1.10 (2023-01-15) - Switched to vcpkg as the primary dependency management system diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ddf9da6..f00f7f76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,7 +224,38 @@ if(MSDFGEN_INSTALL) include(CMakePackageConfigHelpers) set(MSDFGEN_CONFIG_PATH "lib/cmake/msdfgen") - # install tree package config + # Generate msdfgen-config.h + if(BUILD_SHARED_LIBS AND WIN32) + set(MSDFGEN_PUBLIC_MACRO_VALUE " __declspec(dllimport)") + else() + set(MSDFGEN_PUBLIC_MACRO_VALUE "") + endif() + set(MSDFGEN_ADDITIONAL_DEFINES "") + if(MSDFGEN_USE_CPP11) + set(MSDFGEN_ADDITIONAL_DEFINES "${MSDFGEN_ADDITIONAL_DEFINES}\n#define MSDFGEN_USE_CPP11") + endif() + if(MSDFGEN_USE_OPENMP) + set(MSDFGEN_ADDITIONAL_DEFINES "${MSDFGEN_ADDITIONAL_DEFINES}\n#define MSDFGEN_USE_OPENMP") + endif() + if(NOT MSDFGEN_CORE_ONLY) + set(MSDFGEN_ADDITIONAL_DEFINES "${MSDFGEN_ADDITIONAL_DEFINES}\n#define MSDFGEN_EXTENSIONS") + if(MSDFGEN_USE_SKIA) + set(MSDFGEN_ADDITIONAL_DEFINES "${MSDFGEN_ADDITIONAL_DEFINES}\n#define MSDFGEN_USE_SKIA") + endif() + if(MSDFGEN_DISABLE_SVG) + set(MSDFGEN_ADDITIONAL_DEFINES "${MSDFGEN_ADDITIONAL_DEFINES}\n#define MSDFGEN_DISABLE_SVG") + endif() + if(NOT MSDFGEN_DISABLE_PNG) + set(MSDFGEN_ADDITIONAL_DEFINES "${MSDFGEN_ADDITIONAL_DEFINES}\n#define MSDFGEN_USE_LIBPNG") + else() + set(MSDFGEN_ADDITIONAL_DEFINES "${MSDFGEN_ADDITIONAL_DEFINES}\n#define MSDFGEN_DISABLE_PNG") + endif() + if(MSDFGEN_DISABLE_VARIABLE_FONTS) + set(MSDFGEN_ADDITIONAL_DEFINES "${MSDFGEN_ADDITIONAL_DEFINES}\n#define MSDFGEN_DISABLE_VARIABLE_FONTS") + endif() + endif() + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/msdfgen-config.h.in" msdfgen-config.h) + write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/msdfgenConfigVersion.cmake" VERSION ${PROJECT_VERSION} @@ -232,19 +263,20 @@ if(MSDFGEN_INSTALL) ) configure_package_config_file( - cmake/msdfgenConfig.cmake.in + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/msdfgenConfig.cmake.in" ${MSDFGEN_CONFIG_PATH}/msdfgenConfig.cmake INSTALL_DESTINATION ${MSDFGEN_CONFIG_PATH} NO_CHECK_REQUIRED_COMPONENTS_MACRO ) - # build tree package config configure_file( - cmake/msdfgenConfig.cmake.in + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/msdfgenConfig.cmake.in" msdfgenConfig.cmake @ONLY ) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/msdfgen-config.h" DESTINATION include/msdfgen) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/msdfgen-config.h" DESTINATION include/msdfgen/msdfgen) install(TARGETS msdfgen-core EXPORT msdfgenTargets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/cmake/msdfgen-config.h.in b/cmake/msdfgen-config.h.in new file mode 100644 index 00000000..4959f6b2 --- /dev/null +++ b/cmake/msdfgen-config.h.in @@ -0,0 +1,12 @@ + +#pragma once + +#define MSDFGEN_PUBLIC${MSDFGEN_PUBLIC_MACRO_VALUE} +#define MSDFGEN_EXT_PUBLIC${MSDFGEN_PUBLIC_MACRO_VALUE} + +#define MSDFGEN_VERSION ${MSDFGEN_VERSION} +#define MSDFGEN_VERSION_MAJOR ${MSDFGEN_VERSION_MAJOR} +#define MSDFGEN_VERSION_MINOR ${MSDFGEN_VERSION_MINOR} +#define MSDFGEN_VERSION_REVISION ${MSDFGEN_VERSION_REVISION} +#define MSDFGEN_COPYRIGHT_YEAR ${MSDFGEN_COPYRIGHT_YEAR} +${MSDFGEN_ADDITIONAL_DEFINES} diff --git a/core/BitmapRef.hpp b/core/BitmapRef.hpp index ec8a0e48..cb17f95d 100644 --- a/core/BitmapRef.hpp +++ b/core/BitmapRef.hpp @@ -1,12 +1,10 @@ #pragma once -#include +#include "base.h" namespace msdfgen { -typedef unsigned char byte; - /// Reference to a 2D image bitmap or a buffer acting as one. Pixel storage not owned or managed by the object. template struct BitmapRef { diff --git a/core/EdgeColor.h b/core/EdgeColor.h index 9d49a5a8..5d3730c9 100644 --- a/core/EdgeColor.h +++ b/core/EdgeColor.h @@ -1,6 +1,8 @@ #pragma once +#include "base.h" + namespace msdfgen { /// Edge color specifies which color channels an edge belongs to. diff --git a/core/EdgeHolder.cpp b/core/EdgeHolder.cpp index 0605f969..cffcff46 100644 --- a/core/EdgeHolder.cpp +++ b/core/EdgeHolder.cpp @@ -1,8 +1,6 @@ #include "EdgeHolder.h" -#include - namespace msdfgen { void EdgeHolder::swap(EdgeHolder &a, EdgeHolder &b) { diff --git a/core/Scanline.h b/core/Scanline.h index 9c8f3404..c0abc686 100644 --- a/core/Scanline.h +++ b/core/Scanline.h @@ -2,6 +2,7 @@ #pragma once #include +#include "base.h" namespace msdfgen { diff --git a/core/ShapeDistanceFinder.hpp b/core/ShapeDistanceFinder.hpp index c19b8f72..07fb5cdc 100644 --- a/core/ShapeDistanceFinder.hpp +++ b/core/ShapeDistanceFinder.hpp @@ -1,8 +1,6 @@ #include "ShapeDistanceFinder.h" -#include - namespace msdfgen { template diff --git a/core/SignedDistance.hpp b/core/SignedDistance.hpp index cc1014b1..62e73c03 100644 --- a/core/SignedDistance.hpp +++ b/core/SignedDistance.hpp @@ -3,6 +3,7 @@ #include #include +#include "base.h" namespace msdfgen { diff --git a/core/Vector2.hpp b/core/Vector2.hpp index d76c5e1e..0208c614 100644 --- a/core/Vector2.hpp +++ b/core/Vector2.hpp @@ -1,8 +1,8 @@ #pragma once -#include #include +#include "base.h" namespace msdfgen { diff --git a/core/arithmetics.hpp b/core/arithmetics.hpp index 6da0132e..d5158ad0 100644 --- a/core/arithmetics.hpp +++ b/core/arithmetics.hpp @@ -2,6 +2,7 @@ #pragma once #include +#include "base.h" namespace msdfgen { diff --git a/core/base.h b/core/base.h new file mode 100644 index 00000000..ab85c136 --- /dev/null +++ b/core/base.h @@ -0,0 +1,16 @@ + +#pragma once + +// This file needs to be included first for all MSDFgen sources + +#ifndef MSDFGEN_PUBLIC +#include +#endif + +#include + +namespace msdfgen { + +typedef unsigned char byte; + +} diff --git a/core/edge-selectors.cpp b/core/edge-selectors.cpp index 9bc49b1f..aee78847 100644 --- a/core/edge-selectors.cpp +++ b/core/edge-selectors.cpp @@ -1,7 +1,6 @@ #include "edge-selectors.h" -#include #include "arithmetics.hpp" namespace msdfgen { diff --git a/core/equation-solver.h b/core/equation-solver.h index bae097b2..bfeeb158 100644 --- a/core/equation-solver.h +++ b/core/equation-solver.h @@ -1,6 +1,8 @@ #pragma once +#include "base.h" + namespace msdfgen { // ax^2 + bx + c = 0 diff --git a/core/generator-config.h b/core/generator-config.h index f12206d6..b7b15347 100644 --- a/core/generator-config.h +++ b/core/generator-config.h @@ -1,7 +1,6 @@ #pragma once -#include #include "BitmapRef.hpp" #ifndef MSDFGEN_PUBLIC diff --git a/core/msdfgen.cpp b/core/msdfgen.cpp index e2ba1431..0289295f 100644 --- a/core/msdfgen.cpp +++ b/core/msdfgen.cpp @@ -1,7 +1,6 @@ #include "../msdfgen.h" -#include #include #include "edge-selectors.h" #include "contour-combiners.h" diff --git a/core/pixel-conversion.hpp b/core/pixel-conversion.hpp index 7e9b6d08..3ef8a2d1 100644 --- a/core/pixel-conversion.hpp +++ b/core/pixel-conversion.hpp @@ -5,8 +5,6 @@ namespace msdfgen { -typedef unsigned char byte; - inline byte pixelFloatToByte(float x) { return byte(clamp(256.f*x, 255.f)); } diff --git a/ext/import-font.h b/ext/import-font.h index b5ca3130..292a7b87 100644 --- a/ext/import-font.h +++ b/ext/import-font.h @@ -1,12 +1,10 @@ #pragma once -#include #include "../core/Shape.h" namespace msdfgen { -typedef unsigned char byte; typedef unsigned unicode_t; class FreetypeHandle; diff --git a/ext/import-svg.h b/ext/import-svg.h index 6be61ad7..ec409a9e 100644 --- a/ext/import-svg.h +++ b/ext/import-svg.h @@ -1,7 +1,6 @@ #pragma once -#include #include "../core/Shape.h" #ifndef MSDFGEN_DISABLE_SVG diff --git a/msdfgen.h b/msdfgen.h index 8121671c..dff8beb6 100644 --- a/msdfgen.h +++ b/msdfgen.h @@ -15,6 +15,7 @@ * */ +#include "core/base.h" #include "core/arithmetics.hpp" #include "core/Vector2.hpp" #include "core/Projection.h" diff --git a/vcpkg.json b/vcpkg.json index 458bf5e9..ebcbaa7a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,7 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/master/docs/vcpkg.schema.json", "name": "msdfgen", - "version": "1.10.0", + "version": "1.11.0", "default-features": [ "extensions", "geometry-preprocessing",