Browse Source

Add NVG_DISABLE_SKIPPING_WHITESPACE build option

pull/351/head
falkTX 3 years ago
parent
commit
86b8a102bb
2 changed files with 11 additions and 2 deletions
  1. +3
    -0
      dgl/Makefile
  2. +8
    -2
      dgl/src/nanovg/nanovg.c

+ 3
- 0
dgl/Makefile View File

@@ -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


+ 8
- 2
dgl/src/nanovg/nanovg.c View File

@@ -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;


Loading…
Cancel
Save