mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-13 06:21:29 -10:00
More user-friendly assert on missed glyph in font.
This commit is contained in:
1 parent
f0ba0265fd
commit
cac07391ca
3 files changed
+28
-1
No files matched your search
@@ -21,6 +21,22 @@
|
||||
#include "NanoVGRenderer.h"
|
||||
#include "tracing/tracing.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// That is a wrapper function for log prints to be availiable for nanovg components. For now it is stb_truetype.h
|
||||
// Planted by ksotar with blessing from asarium
|
||||
void nvgOldCPrintf(const char *message, ...) {
|
||||
nprintf(("General", message));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
namespace {
|
||||
using namespace graphics::paths;
|
||||
|
||||
|
||||
@@ -6,3 +6,6 @@ Changes to fontstash.h
|
||||
- Increased memory size for newer stb_truetype version
|
||||
- Removed pixel snapping from fons__getQuad
|
||||
- Include <malloc.h> as malloc and free weren't found for some reason
|
||||
|
||||
Changes to stb_truetype.h
|
||||
- Added extern function to print in log. Made Assert on missed glyph a bit more friendly
|
||||
@@ -431,6 +431,9 @@ typedef signed int stbtt_int32;
|
||||
typedef char stbtt__check_size32[sizeof(stbtt_int32) == 4 ? 1 : -1];
|
||||
typedef char stbtt__check_size16[sizeof(stbtt_int16) == 2 ? 1 : -1];
|
||||
|
||||
// Function from NanoVGRenderer.cpp to provide log printing capabilities here.
|
||||
extern void nvgOldCPrintf(const char *string, ...);
|
||||
|
||||
// e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h
|
||||
#ifndef STBTT_ifloor
|
||||
#include <math.h>
|
||||
@@ -1501,7 +1504,12 @@ STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codep
|
||||
stbtt_uint16 offset, start;
|
||||
stbtt_uint16 item = (stbtt_uint16)((search - endCount) >> 1);
|
||||
|
||||
STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2 * item));
|
||||
if (unicode_codepoint > ttUSHORT(data + endCount + 2 * item)) {
|
||||
nvgOldCPrintf("WARNING: Probably font character is missing. Unicode decimal index is %d.\n", unicode_codepoint);
|
||||
}
|
||||
STBTT_assert((unicode_codepoint <= ttUSHORT(data + endCount + 2 * item)) &&
|
||||
" \
|
||||
Looks like the font file you're using misses a character. Look into log for 'WARNING: Probably font' to know its code.");
|
||||
start = ttUSHORT(data + index_map + 14 + segcount * 2 + 2 + 2 * item);
|
||||
if (unicode_codepoint < start)
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user