diff --git a/dgl/Makefile b/dgl/Makefile index e570a949..72840583 100644 --- a/dgl/Makefile +++ b/dgl/Makefile @@ -13,6 +13,9 @@ BUILD_CXX_FLAGS += $(DGL_FLAGS) -I. -Isrc -DDONT_SET_USING_DGL_NAMESPACE -Wno-un BUILD_CXX_FLAGS += -Isrc/pugl-upstream/include LINK_FLAGS += $(DGL_LIBS) +ifeq ($(NVG_DISABLE_SKIPPING_WHITESPACE),true) +BUILD_CXX_FLAGS += -DNVG_DISABLE_SKIPPING_WHITESPACE +endif ifeq ($(USE_OPENGL3),true) BUILD_CXX_FLAGS += -DDGL_USE_OPENGL3 endif diff --git a/dgl/src/nanovg/nanovg.c b/dgl/src/nanovg/nanovg.c index 3f9c0b4b..14765dd3 100644 --- a/dgl/src/nanovg/nanovg.c +++ b/dgl/src/nanovg/nanovg.c @@ -30,6 +30,12 @@ #include "stb_image.h" #endif +#ifdef NVG_DISABLE_SKIPPING_WHITESPACE +#define NVG_SKIPPED_CHAR NVG_SPACE +#else +#define NVG_SKIPPED_CHAR NVG_CHAR +#endif + #ifdef _MSC_VER #pragma warning(disable: 4100) // unreferenced formal parameter #pragma warning(disable: 4127) // conditional expression is constant @@ -2775,7 +2781,7 @@ int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, floa } else { if (rowStart == NULL) { // Skip white space until the beginning of the line - if (type == NVG_CHAR || type == NVG_CJK_CHAR) { + if (type == NVG_CHAR || type == NVG_CJK_CHAR || type == NVG_SKIPPED_CHAR) { // The current char is the row so far rowStartX = iter.x; rowStart = iter.str; @@ -2795,7 +2801,7 @@ int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, floa float nextWidth = iter.nextx - rowStartX; // track last non-white space character - if (type == NVG_CHAR || type == NVG_CJK_CHAR) { + if (type == NVG_CHAR || type == NVG_CJK_CHAR || type == NVG_SKIPPED_CHAR) { rowEnd = iter.next; rowWidth = iter.nextx - rowStartX; rowMaxX = q.x1 - rowStartX;