Choose the correct title font smartly
This commit is contained in:
parent
06fb6d4eb2
commit
109d6b91ce
Binary file not shown.
@ -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
|
wqyMicroHei is released under the GPLv3 with font embedding exception and Apache-2.0 licenses
|
||||||
By Qianqian Fang and The WenQuanYi Project Contributors
|
By Qianqian Fang and The WenQuanYi Project Contributors
|
||||||
|
@ -68,6 +68,10 @@ void FTEnvironment::loadFont()
|
|||||||
(FileManager::TTF, "Ubuntu-B.ttf", true)).c_str(),
|
(FileManager::TTF, "Ubuntu-B.ttf", true)).c_str(),
|
||||||
0, &(FTEnvironment::ft_face[F_BOLD]));
|
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
|
FTEnvironment::ft_err += FT_New_Face(FTEnvironment::ft_lib, (file_manager->getAssetChecked
|
||||||
(FileManager::TTF, "Ubuntu-B.ttf",true)).c_str(),
|
(FileManager::TTF, "Ubuntu-B.ttf",true)).c_str(),
|
||||||
0, &(FTEnvironment::ft_face[F_DIGIT]));
|
0, &(FTEnvironment::ft_face[F_DIGIT]));
|
||||||
|
@ -33,8 +33,9 @@ enum FontUse
|
|||||||
F_CJK = 2,
|
F_CJK = 2,
|
||||||
F_AR = 3,
|
F_AR = 3,
|
||||||
F_BOLD = 4,
|
F_BOLD = 4,
|
||||||
F_DIGIT = 5,
|
F_BOLD_FALLBACK = 5,
|
||||||
F_COUNT = 6
|
F_DIGIT = 6,
|
||||||
|
F_COUNT = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TTFLoadingType {T_NORMAL, T_DIGIT, T_BOLD};
|
enum TTFLoadingType {T_NORMAL, T_DIGIT, T_BOLD};
|
||||||
|
@ -381,12 +381,6 @@ bool ScalableFont::loadTTF()
|
|||||||
std::vector <s32> advance;
|
std::vector <s32> advance;
|
||||||
std::vector <s32> height;
|
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;
|
std::set<wchar_t>::iterator it;
|
||||||
s32 current_maxheight = 0;
|
s32 current_maxheight = 0;
|
||||||
s32 t;
|
s32 t;
|
||||||
@ -402,8 +396,33 @@ bool ScalableFont::loadTTF()
|
|||||||
SGUISprite s;
|
SGUISprite s;
|
||||||
core::rect<s32> rectangle;
|
core::rect<s32> rectangle;
|
||||||
|
|
||||||
// Retrieve glyph index from character code, skip useless glyph.
|
int idx;
|
||||||
int idx = FT_Get_Char_Index(cur_face, *it);
|
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)
|
if (idx)
|
||||||
{
|
{
|
||||||
// Load glyph image into the slot (erase previous one)
|
// Load glyph image into the slot (erase previous one)
|
||||||
@ -599,7 +618,7 @@ bool ScalableFont::lazyLoadChar()
|
|||||||
//Lite-Fontconfig for stk
|
//Lite-Fontconfig for stk
|
||||||
int idx;
|
int idx;
|
||||||
int count = 0;
|
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;
|
m_font_use = (FontUse)count;
|
||||||
err = FT_Set_Pixel_Sizes(cur_face, 0, m_dpi);
|
err = FT_Set_Pixel_Sizes(cur_face, 0, m_dpi);
|
||||||
|
Loading…
Reference in New Issue
Block a user