mirror of https://github.com/Chlumsky/msdfgen.git
Added hidden option to disable variable fonts
This commit is contained in:
parent
5eef2e5985
commit
d576034d22
|
|
@ -147,6 +147,9 @@ if(NOT MSDFGEN_CORE_ONLY)
|
||||||
else()
|
else()
|
||||||
target_compile_definitions(msdfgen-ext PUBLIC MSDFGEN_DISABLE_PNG)
|
target_compile_definitions(msdfgen-ext PUBLIC MSDFGEN_DISABLE_PNG)
|
||||||
endif()
|
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_link_libraries(msdfgen-ext PRIVATE Freetype::Freetype msdfgen::msdfgen-core)
|
||||||
target_include_directories(msdfgen-ext
|
target_include_directories(msdfgen-ext
|
||||||
PUBLIC
|
PUBLIC
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,9 @@
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
#include FT_OUTLINE_H
|
#include FT_OUTLINE_H
|
||||||
|
#ifndef MSDFGEN_DISABLE_VARIABLE_FONTS
|
||||||
#include FT_MULTIPLE_MASTERS_H
|
#include FT_MULTIPLE_MASTERS_H
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace msdfgen {
|
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)));
|
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 setFontVariationAxis(FreetypeHandle *library, FontHandle *font, const char *name, double coordinate) {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
if (font->face->face_flags&FT_FACE_FLAG_MULTIPLE_MASTERS) {
|
if (font->face->face_flags&FT_FACE_FLAG_MULTIPLE_MASTERS) {
|
||||||
|
|
@ -266,4 +270,6 @@ bool listFontVariationAxes(std::vector<FontVariationAxis> &axes, FreetypeHandle
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,9 +77,12 @@ bool loadGlyph(Shape &output, FontHandle *font, unicode_t unicode, double *advan
|
||||||
/// Outputs the kerning distance adjustment between two specific glyphs.
|
/// 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, GlyphIndex glyphIndex1, GlyphIndex glyphIndex2);
|
||||||
bool getKerning(double &output, FontHandle *font, unicode_t unicode1, unicode_t unicode2);
|
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.
|
/// Sets a single variation axis of a variable font.
|
||||||
bool setFontVariationAxis(FreetypeHandle *library, FontHandle *font, const char *name, double coordinate);
|
bool setFontVariationAxis(FreetypeHandle *library, FontHandle *font, const char *name, double coordinate);
|
||||||
/// Lists names and ranges of variation axes of a variable font.
|
/// Lists names and ranges of variation axes of a variable font.
|
||||||
bool listFontVariationAxes(std::vector<FontVariationAxis> &axes, FreetypeHandle *library, FontHandle *font);
|
bool listFontVariationAxes(std::vector<FontVariationAxis> &axes, FreetypeHandle *library, FontHandle *font);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
main.cpp
20
main.cpp
|
|
@ -147,6 +147,7 @@ static bool parseUnicode(unicode_t &unicode, const char *arg) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef MSDFGEN_DISABLE_VARIABLE_FONTS
|
||||||
static FontHandle * loadVarFont(FreetypeHandle *library, const char *filename) {
|
static FontHandle * loadVarFont(FreetypeHandle *library, const char *filename) {
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
while (*filename && *filename != '?')
|
while (*filename && *filename != '?')
|
||||||
|
|
@ -170,6 +171,7 @@ static FontHandle * loadVarFont(FreetypeHandle *library, const char *filename) {
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
template <int N>
|
template <int N>
|
||||||
static void invertColor(const BitmapRef<float, N> &bitmap) {
|
static void invertColor(const BitmapRef<float, N> &bitmap) {
|
||||||
|
|
@ -304,7 +306,7 @@ static const char * writeOutput(const BitmapConstRef<float, N> &bitmap, const ch
|
||||||
#define VERSION_UNDERLINE "--------"
|
#define VERSION_UNDERLINE "--------"
|
||||||
#endif
|
#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 TITLE_SUFFIX " - custom config"
|
||||||
#define SUFFIX_UNDERLINE "----------------"
|
#define SUFFIX_UNDERLINE "----------------"
|
||||||
#elif !defined(MSDFGEN_EXTENSIONS) && defined(MSDFGEN_USE_OPENMP)
|
#elif !defined(MSDFGEN_EXTENSIONS) && defined(MSDFGEN_USE_OPENMP)
|
||||||
|
|
@ -364,7 +366,7 @@ static const char * const helpText =
|
||||||
" -svg <filename.svg>\n"
|
" -svg <filename.svg>\n"
|
||||||
"\tLoads the last vector path found in the specified SVG file.\n"
|
"\tLoads the last vector path found in the specified SVG file.\n"
|
||||||
#endif
|
#endif
|
||||||
#ifdef MSDFGEN_EXTENSIONS
|
#if defined(MSDFGEN_EXTENSIONS) && !defined(MSDFGEN_DISABLE_VARIABLE_FONTS)
|
||||||
" -varfont <filename and variables> <character code>\n"
|
" -varfont <filename and variables> <character code>\n"
|
||||||
"\tLoads a single glyph from a variable font. Specify variable values as x.ttf?var1=0.5&var2=1\n"
|
"\tLoads a single glyph from a variable font. Specify variable values as x.ttf?var1=0.5&var2=1\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -590,7 +592,12 @@ int main(int argc, const char * const *argv) {
|
||||||
#endif
|
#endif
|
||||||
#ifdef MSDFGEN_EXTENSIONS
|
#ifdef MSDFGEN_EXTENSIONS
|
||||||
//ARG_CASE -font, -varfont
|
//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];
|
input = argv[argPos+1];
|
||||||
const char *charArg = argv[argPos+2];
|
const char *charArg = argv[argPos+2];
|
||||||
unsigned gi;
|
unsigned gi;
|
||||||
|
|
@ -971,7 +978,12 @@ int main(int argc, const char * const *argv) {
|
||||||
FreetypeHandle *ft = initializeFreetype();
|
FreetypeHandle *ft = initializeFreetype();
|
||||||
if (!ft)
|
if (!ft)
|
||||||
return -1;
|
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) {
|
if (!font) {
|
||||||
deinitializeFreetype(ft);
|
deinitializeFreetype(ft);
|
||||||
ABORT("Failed to load font file.");
|
ABORT("Failed to load font file.");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue