Added reasons to assertions

This commit is contained in:
2023-07-23 10:15:37 -07:00
parent 1b0218c9f3
commit a5b36fb24a
79 changed files with 359 additions and 291 deletions

View File

@ -11,14 +11,14 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
FT_Face face,
struct TrueTypeFaceTextureStyle style
) {
assertTrue(style.fontSize < 256);
assertTrue(style.fontSize < 256, "TrueTypeFaceTexture::TrueTypeFaceTexture: Font size cannot be greater than 256");
this->face = face;
this->style = style;
// Set freetype font size prior to baking.
if(FT_Set_Pixel_Sizes(face, 0, style.fontSize)) {
assertUnreachable();
assertUnreachable("TrueTypeFaceTexture::TrueTypeFaceTexture: Failed to set font size");
}
size_t w = 0, h = 0;
@ -29,7 +29,7 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
// Load the character
auto ret = FT_Load_Char(face, c, FT_LOAD_BITMAP_METRICS_ONLY);
if(ret) {
assertUnreachable();
assertUnreachable("TrueTypeFaceTexture::TrueTypeFaceTexture: Failed to load character (0)");
}
if(face->glyph->bitmap.width == 0 || face->glyph->bitmap.rows == 0) continue;
@ -39,8 +39,8 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
h += face->glyph->bitmap.rows;
}
assertTrue(w > 0);
assertTrue(h > 0);
assertTrue(w > 0, "TrueTypeFaceTexture::TrueTypeFaceTexture: Width cannot be less than or equal to 0");
assertTrue(h > 0, "TrueTypeFaceTexture::TrueTypeFaceTexture: Height cannot be less than or equal to 0");
// Now buffer pixels to the texture
float_t y = 0;
@ -54,7 +54,7 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
for(c = TRUE_TYPE_CHAR_BEGIN; c < TRUE_TYPE_CHAR_END; c++) {
// Load the character
if(FT_Load_Char(face, c, FT_LOAD_RENDER)) {
assertUnreachable();
assertUnreachable("TrueTypeFaceTexture::TrueTypeFaceTexture: Failed to load character (1)");
}
// Store the character information
@ -74,7 +74,7 @@ TrueTypeFaceTexture::TrueTypeFaceTexture(
face->glyph->bitmap.width * sizeof(uint8_t)
);
offset += w * sizeof(uint8_t);
assertTrue(offset <= (w * h * sizeof(uint8_t)));
assertTrue(offset <= (w * h * sizeof(uint8_t)), "TrueTypeFaceTexture::TrueTypeFaceTexture: Buffer overflow");
}
y += face->glyph->bitmap.rows;
}