Skip to content

Commit 0eb6187

Browse files
authored
Merge pull request #53 from ronaaron/ttf
Update stb_truetype (ttf font support) and stb_rect_pack while paving the way for easy updates in the future.
2 parents 7fe20af + 8513b63 commit 0eb6187

10 files changed

Lines changed: 11204 additions & 3907 deletions

File tree

nuklear.h

Lines changed: 5482 additions & 1843 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuklear",
3-
"version": "4.01.5",
3+
"version": "4.01.6",
44
"repo": "Immediate-Mode-UI/Nuklear",
55
"description": "A small ANSI C gui toolkit",
66
"keywords": ["gl", "ui", "toolkit"],

src/CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/// - [yy]: Minor version with non-breaking API and library changes
99
/// - [zz]: Bug fix version with no direct changes to API
1010
///
11+
/// - 2020/02/06 (4.01.6) - Update stb_truetype.h and stb_rect_pack.h and separate them
1112
/// - 2019/12/10 (4.01.5) - Fix off-by-one error in NK_INTERSECT
1213
/// - 2019/10/09 (4.01.4) - Fix bug for autoscrolling in nk_do_edit
1314
/// - 2019/09/20 (4.01.3) - Fixed a bug wherein combobox cannot be closed by clicking the header

src/build.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
import fnmatch
33
import os.path
44
import sys
5+
import re
56

67
def print_help():
78
print(
8-
"""usage: python single_header_packer.py --macro <macro> [--intro <files>] --pub <files> --priv <files> [--outro <files>]
9+
"""usage: python single_header_packer.py --macro <macro> [--intro <files>] --extern <files> --pub <files> --priv1 <files> --priv2 <files> [--outro <files>]
910
1011
where <files> can be a comma-separated list of files. e.g. --priv *.c,inc/*.h
12+
13+
The 'extern' files are placed between 'priv1' and 'priv2'.
1114
1215
The resulting code is packed as follows:
1316
@@ -70,6 +73,9 @@ def omit_includes(str, files):
7073
str = str.replace("#include <" + fname + ">", "");
7174
return str
7275

76+
def fix_comments(str):
77+
return re.sub(r"//(.*)(\n|$)", "/* \\1 */\\2", str)
78+
7379
# Main start
7480
# ==========
7581

@@ -79,8 +85,9 @@ def omit_includes(str, files):
7985

8086
intro_files = []
8187
pub_files = []
82-
priv_files = []
83-
outro_files = []
88+
priv_files1 = []
89+
outro_files2 = []
90+
extern_files = []
8491
cur_arg = 1
8592
macro = ""
8693

@@ -99,9 +106,15 @@ def omit_includes(str, files):
99106
elif sys.argv[cur_arg] == "--pub":
100107
cur_arg += 1
101108
pub_files = parse_files(sys.argv[cur_arg])
102-
elif sys.argv[cur_arg] == "--priv":
109+
elif sys.argv[cur_arg] == "--priv1":
110+
cur_arg += 1
111+
priv_files1 = parse_files(sys.argv[cur_arg])
112+
elif sys.argv[cur_arg] == "--priv2":
103113
cur_arg += 1
104-
priv_files = parse_files(sys.argv[cur_arg])
114+
priv_files2 = parse_files(sys.argv[cur_arg])
115+
elif sys.argv[cur_arg] == "--extern":
116+
cur_arg += 1
117+
extern_files = parse_files(sys.argv[cur_arg])
105118
elif sys.argv[cur_arg] == "--outro":
106119
cur_arg += 1
107120
outro_files = parse_files(sys.argv[cur_arg])
@@ -134,9 +147,17 @@ def omit_includes(str, files):
134147

135148
print(os.linesep + "#ifdef " + macro + "_IMPLEMENTATION");
136149
print("");
137-
for f in priv_files:
150+
151+
for f in priv_files1:
138152
print(omit_includes(open(f, 'r').read(),
139-
pub_files + priv_files))
153+
pub_files + priv_files1 + priv_files2 + extern_files))
154+
for f in extern_files:
155+
print(fix_comments(open(f, 'r').read()))
156+
157+
for f in priv_files2:
158+
print(omit_includes(open(f, 'r').read(),
159+
pub_files + priv_files1 + priv_files2 + extern_files))
160+
140161
print("#endif /* " + macro + "_IMPLEMENTATION */");
141162

142163
print(os.linesep + "/*")

src/nuklear.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5461,4 +5461,16 @@ template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
54615461
#define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0)
54625462
#endif
54635463

5464+
#ifdef NK_IMPLEMENTATION
5465+
#define STB_RECT_PACK_IMPLEMENTATION
5466+
#define STB_TRUETYPE_IMPLEMENTATION
5467+
#endif
5468+
5469+
#ifndef STBTT_malloc
5470+
static nk_handle fictional_handle = {0};
5471+
5472+
#define STBTT_malloc(x,u) nk_malloc( fictional_handle, 0, x )
5473+
#define STBTT_free(x,u) nk_mfree( fictional_handle , x)
5474+
#endif
5475+
54645476
#endif /* NK_NUKLEAR_H_ */

0 commit comments

Comments
 (0)