1
0
Fork 0

include/Spectre/System/Log.h: implement a static "Log" class instead of just a function.

This commit is contained in:
Henrik Hautakoski 2019-11-10 14:56:56 +01:00
parent e10daeaaa6
commit 3b27db9435
No known key found for this signature in database
GPG key ID: 96765B12FEAC4745
8 changed files with 101 additions and 31 deletions

View file

@ -38,12 +38,11 @@ LibWrapper::LibWrapper()
{
FT_Error error = FT_Init_FreeType(&handle);
if (error) {
log("Could not initialize FreeType\n");
Log::error("Could not initialize FreeType");
return;
} else {
log("FreeType font driver was initialized.\n");
}
Log::info("FreeType font driver was initialized.");
error = FT_Stroker_New(handle, &stroker);
}
@ -55,7 +54,7 @@ LibWrapper::~LibWrapper()
error = FT_Done_FreeType(handle);
if (error) {
log("Could not close FreeType\n");
Log::error("Could not close FreeType");
}
}
@ -75,7 +74,7 @@ bool FreeTypeDriver::setCharacterSize(unsigned int size)
{
FT_Error error = FT_Set_Pixel_Sizes(m_face, 0, size);
if (error) {
log("FreeType: failed to set character size\n");
Log::warn("FreeType: failed to set character size");
return false;
}
return true;
@ -88,14 +87,14 @@ bool FreeTypeDriver::loadFromFile(const std::string& filename)
error = FT_New_Face(LibWrapper::getInstance().handle, filename.c_str(), 0, &face);
if (error) {
log("FreeType: could not load file (%s): %s\n",
Log::warn("FreeType: could not load file (%s): %s",
filename.c_str(), FT_GetErrorString(error));
return false;
}
error = FT_Select_Charmap(face, FT_ENCODING_UNICODE);
if (error) {
log("FreeType: (%s) failed to set unicode charmap\n", filename.c_str());
Log::warn("FreeType: (%s) failed to set unicode charmap", filename.c_str());
return false;
}
@ -121,7 +120,7 @@ Font::Glyph FreeTypeDriver::loadGlyph(unsigned int codepoint, Image& img, unsign
}
if (FT_Load_Char(m_face, codepoint, flags) != 0) {
log("FreeType: failed to load glyph for character code '%c'\n", codepoint);
Log::warn("FreeType: failed to load glyph for character code '%c'", codepoint);
}
FT_Error error = FT_Get_Glyph(m_face->glyph, &glyph_info);
@ -158,7 +157,7 @@ Font::Glyph FreeTypeDriver::loadGlyph(unsigned int codepoint, Image& img, unsign
glyph.advance = static_cast<unsigned char>(metrics.horiAdvance >> 6) + (outlineSize * 2);
} else {
log("FreeType: failed to load glyph for character code '%c'\n", codepoint);
Log::warn("FreeType: failed to load glyph for character code '%c'", codepoint);
}
return glyph;