Merge branch 'freetype_lazyloadchar' of github.com:supertuxkart/stk-code into freetype_lazyloadchar

This commit is contained in:
hiker 2015-10-19 13:31:39 +11:00
commit 3a544b69eb
6 changed files with 38 additions and 14 deletions

Binary file not shown.

View File

@ -1,4 +1,4 @@
GNU FreeFont (FreeSans, FreeSansBold, FreeMono) is released under the GPLv3
GNU FreeFont (FreeSans, FreeSansBold) is released under the GPLv3
wqyMicroHei is released under the GPLv3 with font embedding exception and Apache-2.0 licenses
By Qianqian Fang and The WenQuanYi Project Contributors

View File

@ -68,6 +68,10 @@ void FTEnvironment::loadFont()
(FileManager::TTF, "Ubuntu-B.ttf", true)).c_str(),
0, &(FTEnvironment::ft_face[F_BOLD]));
FTEnvironment::ft_err += FT_New_Face(FTEnvironment::ft_lib, (file_manager->getAssetChecked
(FileManager::TTF, "FreeSansBold.ttf", true)).c_str(),
0, &(FTEnvironment::ft_face[F_BOLD_FALLBACK]));
FTEnvironment::ft_err += FT_New_Face(FTEnvironment::ft_lib, (file_manager->getAssetChecked
(FileManager::TTF, "Ubuntu-B.ttf",true)).c_str(),
0, &(FTEnvironment::ft_face[F_DIGIT]));

View File

@ -33,8 +33,9 @@ enum FontUse
F_CJK = 2,
F_AR = 3,
F_BOLD = 4,
F_DIGIT = 5,
F_COUNT = 6
F_BOLD_FALLBACK = 5,
F_DIGIT = 6,
F_COUNT = 7
};
enum TTFLoadingType {T_NORMAL, T_DIGIT, T_BOLD};

View File

@ -107,10 +107,10 @@ bool GlyphPageCreator::insertGlyph(FT_Bitmap bits, core::rect<s32>& rect)
const u32 image_pitch = image->getPitch() / sizeof(u32);
u32* image_data = (u32*)image->lock();
u8* glyph_data = bits.buffer;
for (u32 y = 0; y < bits.rows; ++y)
for (u32 y = 0; y < (unsigned)bits.rows; ++y)
{
u8* row = glyph_data;
for (u32 x = 0; x < bits.width; ++x)
for (u32 x = 0; x < (unsigned)bits.width; ++x)
{
image_data[y * image_pitch + x] |= static_cast<u32>(255.0f * (static_cast<float>(*row++) / gray_count)) << 24;
//data[y * image_pitch + x] |= ((u32)(*bitsdata++) << 24);

View File

@ -381,12 +381,6 @@ bool ScalableFont::loadTTF()
std::vector <s32> advance;
std::vector <s32> height;
err = FT_Set_Pixel_Sizes(cur_face, 0, m_dpi);
if (err)
Log::error("ScalableFont::loadTTF", "Can't set font size.");
slot = cur_face->glyph;
std::set<wchar_t>::iterator it;
s32 current_maxheight = 0;
s32 t;
@ -402,8 +396,33 @@ bool ScalableFont::loadTTF()
SGUISprite s;
core::rect<s32> rectangle;
// Retrieve glyph index from character code, skip useless glyph.
int idx = FT_Get_Char_Index(cur_face, *it);
int idx;
if (m_type == T_BOLD) //Lite-Fontconfig for stk, this one is specifically for bold title
{
int count = F_BOLD;
while (count < irr::gui::F_COUNT)
{
m_font_use = (FontUse)count;
err = FT_Set_Pixel_Sizes(cur_face, 0, m_dpi);
if (err)
Log::error("ScalableFont::loadTTF", "Can't set font size.");
idx = FT_Get_Char_Index(cur_face, *it);
if (idx > 0) break;
count++;
}
}
else
{
err = FT_Set_Pixel_Sizes(cur_face, 0, m_dpi);
if (err)
Log::error("ScalableFont::loadTTF", "Can't set font size.");
idx = FT_Get_Char_Index(cur_face, *it);
}
slot = cur_face->glyph;
if (idx)
{
// Load glyph image into the slot (erase previous one)
@ -599,7 +618,7 @@ bool ScalableFont::lazyLoadChar()
//Lite-Fontconfig for stk
int idx;
int count = 0;
while (count < irr::gui::F_COUNT - 2) //Exclude bold and digit font
while (count < irr::gui::F_COUNT - 3) //Exclude bold with fallback and digit font
{
m_font_use = (FontUse)count;
err = FT_Set_Pixel_Sizes(cur_face, 0, m_dpi);