Skip to content

Commit

Permalink
Added macro config header to installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Chlumsky committed Nov 11, 2023
1 parent f04dc6a commit f12d7ca
Show file tree
Hide file tree
Showing 21 changed files with 91 additions and 21 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
40 changes: 36 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,27 +224,59 @@ 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}
COMPATIBILITY SameMajorVersion
)

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}
Expand Down
12 changes: 12 additions & 0 deletions cmake/msdfgen-config.h.in
Original file line number Diff line number Diff line change
@@ -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}
4 changes: 1 addition & 3 deletions core/BitmapRef.hpp
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions core/EdgeColor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#pragma once

#include "base.h"

namespace msdfgen {

/// Edge color specifies which color channels an edge belongs to.
Expand Down
2 changes: 0 additions & 2 deletions core/EdgeHolder.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

#include "EdgeHolder.h"

#include <cstddef>

namespace msdfgen {

void EdgeHolder::swap(EdgeHolder &a, EdgeHolder &b) {
Expand Down
1 change: 1 addition & 0 deletions core/Scanline.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma once

#include <vector>
#include "base.h"

namespace msdfgen {

Expand Down
2 changes: 0 additions & 2 deletions core/ShapeDistanceFinder.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

#include "ShapeDistanceFinder.h"

#include <cstddef>

namespace msdfgen {

template <class ContourCombiner>
Expand Down
1 change: 1 addition & 0 deletions core/SignedDistance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <cmath>
#include <cfloat>
#include "base.h"

namespace msdfgen {

Expand Down
2 changes: 1 addition & 1 deletion core/Vector2.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

#pragma once

#include <cstddef>
#include <cmath>
#include "base.h"

namespace msdfgen {

Expand Down
1 change: 1 addition & 0 deletions core/arithmetics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma once

#include <cmath>
#include "base.h"

namespace msdfgen {

Expand Down
16 changes: 16 additions & 0 deletions core/base.h
Original file line number Diff line number Diff line change
@@ -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;

}
1 change: 0 additions & 1 deletion core/edge-selectors.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

#include "edge-selectors.h"

#include <cstddef>
#include "arithmetics.hpp"

namespace msdfgen {
Expand Down
2 changes: 2 additions & 0 deletions core/equation-solver.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#pragma once

#include "base.h"

namespace msdfgen {

// ax^2 + bx + c = 0
Expand Down
1 change: 0 additions & 1 deletion core/generator-config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

#pragma once

#include <cstddef>
#include "BitmapRef.hpp"

#ifndef MSDFGEN_PUBLIC
Expand Down
1 change: 0 additions & 1 deletion core/msdfgen.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

#include "../msdfgen.h"

#include <cstddef>
#include <vector>
#include "edge-selectors.h"
#include "contour-combiners.h"
Expand Down
2 changes: 0 additions & 2 deletions core/pixel-conversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

namespace msdfgen {

typedef unsigned char byte;

inline byte pixelFloatToByte(float x) {
return byte(clamp(256.f*x, 255.f));
}
Expand Down
2 changes: 0 additions & 2 deletions ext/import-font.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

#pragma once

#include <cstddef>
#include "../core/Shape.h"

namespace msdfgen {

typedef unsigned char byte;
typedef unsigned unicode_t;

class FreetypeHandle;
Expand Down
1 change: 0 additions & 1 deletion ext/import-svg.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

#pragma once

#include <cstddef>
#include "../core/Shape.h"

#ifndef MSDFGEN_DISABLE_SVG
Expand Down
1 change: 1 addition & 0 deletions msdfgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*
*/

#include "core/base.h"
#include "core/arithmetics.hpp"
#include "core/Vector2.hpp"
#include "core/Projection.h"
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit f12d7ca

Please sign in to comment.