Use U+FFFD instead of crashing when encountering unknown characters.

Also, use a nicer U+FFFD glyph in the builtin vector font.
pull/4/head
whitequark 2016-02-18 05:03:54 +00:00
parent 923374b305
commit cd6d891100
3 changed files with 12 additions and 5 deletions

View File

@ -103,15 +103,18 @@ add_custom_command(
${CMAKE_CURRENT_BINARY_DIR}/generated/bitmapfont.table.h
${CMAKE_CURRENT_SOURCE_DIR}/fonts/unifont-8.0.01.hex.gz
${chars}
DEPENDS unifont2c ${chars}
DEPENDS unifont2c
${CMAKE_CURRENT_SOURCE_DIR}/fonts/unifont-8.0.01.hex.gz
${chars}
VERBATIM)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/vectorfont.table.h
COMMAND $<TARGET_FILE:lff2c>
"${CMAKE_CURRENT_BINARY_DIR}/generated/vectorfont.table.h"
"${CMAKE_CURRENT_SOURCE_DIR}/fonts/unicode.lff.gz"
DEPENDS lff2c ${chars}
${CMAKE_CURRENT_BINARY_DIR}/generated/vectorfont.table.h
${CMAKE_CURRENT_SOURCE_DIR}/fonts/unicode.lff.gz
DEPENDS lff2c
${CMAKE_CURRENT_SOURCE_DIR}/fonts/unicode.lff.gz
VERBATIM)
set(generated_HEADERS

Binary file not shown.

View File

@ -625,7 +625,8 @@ void ssglInitializeBitmapFont()
int ssglBitmapCharWidth(char32_t chr) {
if(!CodepointProperties[chr].exists)
oops();
chr = 0xfffd; // replacement character
return CodepointProperties[chr].isWide ? 2 : 1;
}
@ -633,6 +634,9 @@ void ssglBitmapCharQuad(char32_t chr, double x, double y)
{
int w, h;
if(!CodepointProperties[chr].exists)
chr = 0xfffd; // replacement character
h = 16;
if(chr >= 0xe000 && chr <= 0xefff) {
// Special character, like a checkbox or a radio button