diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e9193a..e39e593 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,9 @@ if(NOT MSDFGEN_CORE_ONLY) else() target_compile_definitions(msdfgen-ext PUBLIC MSDFGEN_DISABLE_PNG) endif() + if(MSDFGEN_DISABLE_VARIABLE_FONTS) + target_compile_definitions(msdfgen-ext PUBLIC MSDFGEN_DISABLE_VARIABLE_FONTS) + endif() target_link_libraries(msdfgen-ext PRIVATE Freetype::Freetype msdfgen::msdfgen-core) target_include_directories(msdfgen-ext PUBLIC diff --git a/CMakePresets.json b/CMakePresets.json index db68956..f6f2424 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -215,7 +215,7 @@ "name": "osx-core-dbg", "configurePreset": "osx-core-dbg" }, - + { "name": "linux-vcpkg-rel", "configurePreset": "linux-vcpkg-rel" diff --git a/README.md b/README.md index 485cd76..03a4fed 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,7 @@ The text shape description has the following syntax. - The last point of each contour must be equal to the first, or the symbol `#` can be used, which represents the first point. - There can be an edge segment specification between any two points, also separated by semicolons. This can include the edge's color (`c`, `m`, `y` or `w`) and/or one or two Bézier curve control points inside parentheses. - + For example, ``` { -1, -1; m; -1, +1; y; +1, +1; m; +1, -1; y; # } diff --git a/core/equation-solver.cpp b/core/equation-solver.cpp index 4144fa3..7c1cbb3 100644 --- a/core/equation-solver.cpp +++ b/core/equation-solver.cpp @@ -49,7 +49,7 @@ static int solveCubicNormed(double x[3], double a, double b, double c) { x[2] = q*cos(1/3.*(t-2*M_PI))-a; return 3; } else { - double u = (r < 0 ? 1 : -1)*pow(fabs(r)+sqrt(r2-q3), 1/3.); + double u = (r < 0 ? 1 : -1)*pow(fabs(r)+sqrt(r2-q3), 1/3.); double v = u == 0 ? 0 : q/u; x[0] = (u+v)-a; if (u == v || fabs(u-v) < 1e-12*fabs(u+v)) { diff --git a/ext/import-font.cpp b/ext/import-font.cpp index e3d0afe..4faa85a 100644 --- a/ext/import-font.cpp +++ b/ext/import-font.cpp @@ -6,7 +6,9 @@ #include #include FT_FREETYPE_H #include FT_OUTLINE_H +#ifndef MSDFGEN_DISABLE_VARIABLE_FONTS #include FT_MULTIPLE_MASTERS_H +#endif namespace msdfgen { @@ -222,6 +224,8 @@ bool getKerning(double &output, FontHandle *font, unicode_t unicode1, unicode_t return getKerning(output, font, GlyphIndex(FT_Get_Char_Index(font->face, unicode1)), GlyphIndex(FT_Get_Char_Index(font->face, unicode2))); } +#ifndef MSDFGEN_DISABLE_VARIABLE_FONTS + bool setFontVariationAxis(FreetypeHandle *library, FontHandle *font, const char *name, double coordinate) { bool success = false; if (font->face->face_flags&FT_FACE_FLAG_MULTIPLE_MASTERS) { @@ -266,4 +270,6 @@ bool listFontVariationAxes(std::vector &axes, FreetypeHandle return false; } +#endif + } diff --git a/ext/import-font.h b/ext/import-font.h index 4a3be68..4db6499 100644 --- a/ext/import-font.h +++ b/ext/import-font.h @@ -77,9 +77,12 @@ bool loadGlyph(Shape &output, FontHandle *font, unicode_t unicode, double *advan /// Outputs the kerning distance adjustment between two specific glyphs. bool getKerning(double &output, FontHandle *font, GlyphIndex glyphIndex1, GlyphIndex glyphIndex2); bool getKerning(double &output, FontHandle *font, unicode_t unicode1, unicode_t unicode2); + +#ifndef MSDFGEN_DISABLE_VARIABLE_FONTS /// Sets a single variation axis of a variable font. bool setFontVariationAxis(FreetypeHandle *library, FontHandle *font, const char *name, double coordinate); /// Lists names and ranges of variation axes of a variable font. bool listFontVariationAxes(std::vector &axes, FreetypeHandle *library, FontHandle *font); +#endif } diff --git a/main.cpp b/main.cpp index 3930a32..9d6c165 100644 --- a/main.cpp +++ b/main.cpp @@ -147,6 +147,7 @@ static bool parseUnicode(unicode_t &unicode, const char *arg) { return false; } +#ifndef MSDFGEN_DISABLE_VARIABLE_FONTS static FontHandle * loadVarFont(FreetypeHandle *library, const char *filename) { std::string buffer; while (*filename && *filename != '?') @@ -170,6 +171,7 @@ static FontHandle * loadVarFont(FreetypeHandle *library, const char *filename) { return font; } #endif +#endif template static void invertColor(const BitmapRef &bitmap) { @@ -304,7 +306,7 @@ static const char * writeOutput(const BitmapConstRef &bitmap, const ch #define VERSION_UNDERLINE "--------" #endif -#if defined(MSDFGEN_EXTENSIONS) && (defined(MSDFGEN_DISABLE_SVG) || defined(MSDFGEN_DISABLE_PNG)) +#if defined(MSDFGEN_EXTENSIONS) && (defined(MSDFGEN_DISABLE_SVG) || defined(MSDFGEN_DISABLE_PNG) || defined(MSDFGEN_DISABLE_VARIABLE_FONTS)) #define TITLE_SUFFIX " - custom config" #define SUFFIX_UNDERLINE "----------------" #elif !defined(MSDFGEN_EXTENSIONS) && defined(MSDFGEN_USE_OPENMP) @@ -364,7 +366,7 @@ static const char * const helpText = " -svg \n" "\tLoads the last vector path found in the specified SVG file.\n" #endif -#ifdef MSDFGEN_EXTENSIONS +#if defined(MSDFGEN_EXTENSIONS) && !defined(MSDFGEN_DISABLE_VARIABLE_FONTS) " -varfont \n" "\tLoads a single glyph from a variable font. Specify variable values as x.ttf?var1=0.5&var2=1\n" #endif @@ -590,7 +592,12 @@ int main(int argc, const char * const *argv) { #endif #ifdef MSDFGEN_EXTENSIONS //ARG_CASE -font, -varfont - if (argPos+2 < argc && ((!strcmp(arg, "-font") && (inputType = FONT)) || (!strcmp(arg, "-varfont") && (inputType = VAR_FONT)))) { + if (argPos+2 < argc && ( + (!strcmp(arg, "-font") && (inputType = FONT, true)) + #ifndef MSDFGEN_DISABLE_VARIABLE_FONTS + || (!strcmp(arg, "-varfont") && (inputType = VAR_FONT, true)) + #endif + )) { input = argv[argPos+1]; const char *charArg = argv[argPos+2]; unsigned gi; @@ -971,7 +978,12 @@ int main(int argc, const char * const *argv) { FreetypeHandle *ft = initializeFreetype(); if (!ft) return -1; - FontHandle *font = inputType == VAR_FONT ? loadVarFont(ft, input) : loadFont(ft, input); + FontHandle *font = ( + #ifndef MSDFGEN_DISABLE_VARIABLE_FONTS + inputType == VAR_FONT ? loadVarFont(ft, input) : + #endif + loadFont(ft, input) + ); if (!font) { deinitializeFreetype(ft); ABORT("Failed to load font file.");