Browse Source

Added macro config header to installation

Chlumsky 1 year ago
parent
commit
f12d7ca000

+ 16 - 0
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

+ 36 - 4
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}

+ 12 - 0
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}

+ 1 - 3
core/BitmapRef.hpp

@@ -1,12 +1,10 @@
 
 #pragma once
 
-#include <cstddef>
+#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 <typename T, int N = 1>
 struct BitmapRef {

+ 2 - 0
core/EdgeColor.h

@@ -1,6 +1,8 @@
 
 #pragma once
 
+#include "base.h"
+
 namespace msdfgen {
 
 /// Edge color specifies which color channels an edge belongs to.

+ 0 - 2
core/EdgeHolder.cpp

@@ -1,8 +1,6 @@
 
 #include "EdgeHolder.h"
 
-#include <cstddef>
-
 namespace msdfgen {
 
 void EdgeHolder::swap(EdgeHolder &a, EdgeHolder &b) {

+ 1 - 0
core/Scanline.h

@@ -2,6 +2,7 @@
 #pragma once
 
 #include <vector>
+#include "base.h"
 
 namespace msdfgen {
 

+ 0 - 2
core/ShapeDistanceFinder.hpp

@@ -1,8 +1,6 @@
 
 #include "ShapeDistanceFinder.h"
 
-#include <cstddef>
-
 namespace msdfgen {
 
 template <class ContourCombiner>

+ 1 - 0
core/SignedDistance.hpp

@@ -3,6 +3,7 @@
 
 #include <cmath>
 #include <cfloat>
+#include "base.h"
 
 namespace msdfgen {
 

+ 1 - 1
core/Vector2.hpp

@@ -1,8 +1,8 @@
 
 #pragma once
 
-#include <cstddef>
 #include <cmath>
+#include "base.h"
 
 namespace msdfgen {
 

+ 1 - 0
core/arithmetics.hpp

@@ -2,6 +2,7 @@
 #pragma once
 
 #include <cmath>
+#include "base.h"
 
 namespace msdfgen {
 

+ 16 - 0
core/base.h

@@ -0,0 +1,16 @@
+
+#pragma once
+
+// This file needs to be included first for all MSDFgen sources
+
+#ifndef MSDFGEN_PUBLIC
+#include <msdfgen/msdfgen-config.h>
+#endif
+
+#include <cstddef>
+
+namespace msdfgen {
+
+typedef unsigned char byte;
+
+}

+ 0 - 1
core/edge-selectors.cpp

@@ -1,7 +1,6 @@
 
 #include "edge-selectors.h"
 
-#include <cstddef>
 #include "arithmetics.hpp"
 
 namespace msdfgen {

+ 2 - 0
core/equation-solver.h

@@ -1,6 +1,8 @@
 
 #pragma once
 
+#include "base.h"
+
 namespace msdfgen {
 
 // ax^2 + bx + c = 0

+ 0 - 1
core/generator-config.h

@@ -1,7 +1,6 @@
 
 #pragma once
 
-#include <cstddef>
 #include "BitmapRef.hpp"
 
 #ifndef MSDFGEN_PUBLIC

+ 0 - 1
core/msdfgen.cpp

@@ -1,7 +1,6 @@
 
 #include "../msdfgen.h"
 
-#include <cstddef>
 #include <vector>
 #include "edge-selectors.h"
 #include "contour-combiners.h"

+ 0 - 2
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));
 }

+ 0 - 2
ext/import-font.h

@@ -1,12 +1,10 @@
 
 #pragma once
 
-#include <cstddef>
 #include "../core/Shape.h"
 
 namespace msdfgen {
 
-typedef unsigned char byte;
 typedef unsigned unicode_t;
 
 class FreetypeHandle;

+ 0 - 1
ext/import-svg.h

@@ -1,7 +1,6 @@
 
 #pragma once
 
-#include <cstddef>
 #include "../core/Shape.h"
 
 #ifndef MSDFGEN_DISABLE_SVG

+ 1 - 0
msdfgen.h

@@ -15,6 +15,7 @@
  *
  */
 
+#include "core/base.h"
 #include "core/arithmetics.hpp"
 #include "core/Vector2.hpp"
 #include "core/Projection.h"

+ 1 - 1
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",