added node alignment and text color

This commit is contained in:
2017-02-07 13:39:17 +00:00
parent 3cc25e7592
commit 83e59573e0
7 changed files with 84 additions and 38 deletions

View File

@@ -5,7 +5,7 @@
std::map<kFont, Font> FontManager::m_fonts;
Sampler FontManager::m_sampler;
bool Font::load(const char* ttf)
bool Font::load(const char* ttf, int font_size)
{
FILE* font_file = fopen(ttf, "rb");
if (font_file)
@@ -18,7 +18,7 @@ bool Font::load(const char* ttf)
assert(bytes==sz);
auto bitmap = std::make_unique<uint8_t[]>(w*h);
chars.resize(num_chars);
int ret = stbtt_BakeFontBitmap(data.get(), 0, 50, bitmap.get(), w, h, start_char, num_chars, chars.data());
int ret = stbtt_BakeFontBitmap(data.get(), 0, (float)font_size, bitmap.get(), w, h, start_char, num_chars, chars.data());
font_tex.create(w, h, GL_RED, bitmap.get());
fclose(font_file);
return true;
@@ -31,9 +31,9 @@ void FontManager::init()
m_sampler.create();
}
bool FontManager::load(kFont id, const char *ttf)
bool FontManager::load(kFont id, const char* ttf, int sz)
{
return m_fonts[id].load(ttf);
return m_fonts[id].load(ttf, sz);
}
const Font& FontManager::get(kFont id)