Merge pull request #6952 from Robyt3/TextRender-Font-Index-File

Add font index, support font family variants depending on language
This commit is contained in:
Edgar 2023-08-05 15:49:12 +00:00 committed by GitHub
commit 8c49c2ea4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 1282 additions and 872 deletions

1
.gitignore vendored
View file

@ -119,7 +119,6 @@ tags
*.exe *.exe
*.fifo *.fifo
*.filters *.filters
*.json
*.lnk *.lnk
*.log *.log
*.opensdf *.opensdf

View file

@ -1451,9 +1451,10 @@ set(EXPECTED_DATA
emoticons.png emoticons.png
extras.png extras.png
fonts/DejaVuSans.ttf fonts/DejaVuSans.ttf
fonts/GlowSansJCompressed-Book.otf fonts/Font_Awesome_6_Free-Solid-900.otf
fonts/Icons.otf fonts/GlowSansJ-Compressed-Book.otf
fonts/SourceHanSansSC-Regular.otf fonts/SourceHanSans.ttc
fonts/index.json
game.png game.png
gui_buttons.png gui_buttons.png
gui_cursor.png gui_cursor.png
@ -1731,7 +1732,7 @@ set(EXPECTED_DATA
wordlist.txt wordlist.txt
) )
set_glob(DATA GLOB_RECURSE "cfg;frag;json;map;otf;png;rules;ttf;txt;vert;wv" data ${EXPECTED_DATA}) set_glob(DATA GLOB_RECURSE "cfg;frag;json;map;otf;png;rules;ttc;ttf;txt;vert;wv" data ${EXPECTED_DATA})
######################################################################## ########################################################################
# COPY DATA AND SHARED LIBS # COPY DATA AND SHARED LIBS

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

19
data/fonts/index.json Normal file
View file

@ -0,0 +1,19 @@
{
"font files": [
"DejaVuSans.ttf",
"Font_Awesome_6_Free-Solid-900.otf",
"GlowSansJ-Compressed-Book.otf",
"SourceHanSans.ttc"
],
"default": "DejaVu Sans",
"language variants": {
"japanese": "Glow Sans J Compressed Book",
"korean": "Source Han Sans K",
"simplified_chinese": "Source Han Sans SC",
"traditional_chinese": "Source Han Sans TC"
},
"fallbacks": [
"Source Han Sans"
],
"icon": "Font Awesome 6 Free"
}

View file

@ -23,19 +23,44 @@ freely, subject to the following restrictions:
All content under 'data' except the assets, font, language & skin files, All content under 'data' except the assets, font, language & skin files,
(which have their own licenses) are released under (which have their own licenses) are released under
CC-BY-SA 3.0 (https://creativecommons.org/licenses/by-sa/3.0/). CC-BY-SA 3.0 (https://creativecommons.org/licenses/by-sa/3.0/).
SIL OFL 1.1 License for the 'Icon.otf' ('Font Awesome 6 Free-Solid-900.otf') file:
Copyright (c) 2022 Fonticons, Inc. (https://fontawesome.com) DejaVuSans.ttf:
---------------
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
Font_Awesome_6_Free-Solid-900.otf:
----------------------------------
Copyright (c) 2023 Fonticons, Inc. (https://fontawesome.com)
with Reserved Font Name: "Font Awesome". with Reserved Font Name: "Font Awesome".
This Font Software is licensed under the SIL Open Font License, Version 1.1. This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL http://scripts.sil.org/OFL
SIL OPEN FONT LICENSE GlowSansJ-Compressed-Book.otf:
Version 1.1 - 26 February 2007 ------------------------------
The other fonts are released under CC-BY-SA 3.0 (https://creativecommons.org/licenses/by-sa/3.0/). © 2020 Project Wêlai
Developer: Celestial Phineas
Glow Sans fonts are released under SIL Open Font License 1.1.
SourceHanSans.ttc:
------------------
Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font
Name 'Source'. Source is a trademark of Adobe in the United States
and/or other countries.
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
------------------------------------------------------------------------ ------------------------------------------------------------------------
@ -47,3 +72,189 @@ check the individual libraries.
With that being said, contact us if there is anything you want to do With that being said, contact us if there is anything you want to do
that the license does not permit. that the license does not permit.
------------------------------------------------------------------------
SIL OPEN FONT LICENSE
---------------------
Version 1.1 - 26 February 2007
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting — in part or in whole — any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Bitstream Vera Fonts Copyright
------------------------------
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
a trademark of Bitstream, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license ("Fonts") and associated
documentation files (the "Font Software"), to reproduce and distribute the
Font Software, including without limitation the rights to use, copy, merge,
publish, distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to the
following conditions:
The above copyright and trademark notices and this permission notice shall
be included in all copies of one or more of the Font Software typefaces.
The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional glyphs or characters may be added to the Fonts, only if the fonts
are renamed to names not containing either the words "Bitstream" or the word
"Vera".
This License becomes null and void to the extent applicable to Fonts or Font
Software that has been modified and is distributed under the "Bitstream
Vera" names.
The Font Software may be sold as part of a larger software package but no
copy of one or more of the Font Software typefaces may be sold by itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
FONT SOFTWARE.
Except as contained in this notice, the names of Gnome, the Gnome
Foundation, and Bitstream Inc., shall not be used in advertising or
otherwise to promote the sale, use or other dealings in this Font Software
without prior written authorization from the Gnome Foundation or Bitstream
Inc., respectively. For further information, contact: fonts at gnome dot
org.
Arev Fonts Copyright
------------------------------
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of the fonts accompanying this license ("Fonts") and
associated documentation files (the "Font Software"), to reproduce
and distribute the modifications to the Bitstream Vera Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to
the following conditions:
The above copyright and trademark notices and this permission notice
shall be included in all copies of one or more of the Font Software
typefaces.
The Font Software may be modified, altered, or added to, and in
particular the designs of glyphs or characters in the Fonts may be
modified and additional glyphs or characters may be added to the
Fonts, only if the fonts are renamed to names not containing either
the words "Tavmjong Bah" or the word "Arev".
This License becomes null and void to the extent applicable to Fonts
or Font Software that has been modified and is distributed under the
"Tavmjong Bah Arev" names.
The Font Software may be sold as part of a larger software package but
no copy of one or more of the Font Software typefaces may be sold by
itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the name of Tavmjong Bah shall not
be used in advertising or otherwise to promote the sale, use or other
dealings in this Font Software without prior written authorization
from Tavmjong Bah. For further information, contact: tavmjong @ free
. fr.

View file

@ -180,7 +180,6 @@ public:
virtual void SwitchWindowScreen(int Index) = 0; virtual void SwitchWindowScreen(int Index) = 0;
virtual void SetWindowParams(int FullscreenMode, bool IsBorderless, bool AllowResizing) = 0; virtual void SetWindowParams(int FullscreenMode, bool IsBorderless, bool AllowResizing) = 0;
virtual void ToggleWindowVSync() = 0; virtual void ToggleWindowVSync() = 0;
virtual void LoadFont() = 0;
virtual void Notify(const char *pTitle, const char *pMessage) = 0; virtual void Notify(const char *pTitle, const char *pMessage) = 0;
virtual void UpdateAndSwap() = 0; virtual void UpdateAndSwap() = 0;

View file

@ -3050,8 +3050,9 @@ void CClient::Run()
} }
#endif #endif
// init font rendering // init text render
Kernel()->RequestInterface<IEngineTextRender>()->Init(); IEngineTextRender *pTextRender = Kernel()->RequestInterface<IEngineTextRender>();
pTextRender->Init();
// init the input // init the input
Input()->Init(); Input()->Init();
@ -3408,6 +3409,9 @@ void CClient::Run()
m_aNetClient[i].Close(); m_aNetClient[i].Close();
delete m_pEditor; delete m_pEditor;
// shutdown text render while graphics are still available
pTextRender->Shutdown();
} }
bool CClient::InitNetworkClient(char *pError, size_t ErrorSize) bool CClient::InitNetworkClient(char *pError, size_t ErrorSize)
@ -4287,61 +4291,6 @@ void CClient::ToggleWindowVSync()
g_Config.m_GfxVsync ^= 1; g_Config.m_GfxVsync ^= 1;
} }
void CClient::LoadFont()
{
static CFont *pDefaultFont = 0;
char aFilename[IO_MAX_PATH_LENGTH];
char aBuff[1024];
const char *pFontFile = "fonts/DejaVuSans.ttf";
const char *apFallbackFontFiles[] =
{
"fonts/GlowSansJCompressed-Book.otf",
"fonts/SourceHanSansSC-Regular.otf",
};
IOHANDLE File = Storage()->OpenFile(pFontFile, IOFLAG_READ, IStorage::TYPE_ALL, aFilename, sizeof(aFilename));
if(File)
{
IEngineTextRender *pTextRender = Kernel()->RequestInterface<IEngineTextRender>();
pDefaultFont = pTextRender->GetFont(aFilename);
if(pDefaultFont == NULL)
{
void *pBuf;
unsigned Size;
io_read_all(File, &pBuf, &Size);
pDefaultFont = pTextRender->LoadFont(aFilename, (unsigned char *)pBuf, Size);
}
io_close(File);
for(auto &pFallbackFontFile : apFallbackFontFiles)
{
bool FontLoaded = false;
File = Storage()->OpenFile(pFallbackFontFile, IOFLAG_READ, IStorage::TYPE_ALL, aFilename, sizeof(aFilename));
if(File)
{
void *pBuf;
unsigned Size;
io_read_all(File, &pBuf, &Size);
io_close(File);
FontLoaded = pTextRender->LoadFallbackFont(pDefaultFont, aFilename, (unsigned char *)pBuf, Size);
}
if(!FontLoaded)
{
str_format(aBuff, std::size(aBuff), "failed to load the fallback font. filename='%s'", pFallbackFontFile);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gameclient", aBuff);
}
}
pTextRender->SetDefaultFont(pDefaultFont);
}
if(!pDefaultFont)
{
str_format(aBuff, std::size(aBuff), "failed to load font. filename='%s'", pFontFile);
m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "gameclient", aBuff);
}
}
void CClient::Notify(const char *pTitle, const char *pMessage) void CClient::Notify(const char *pTitle, const char *pMessage)
{ {
if(m_pGraphics->WindowActive() || !g_Config.m_ClShowNotifications) if(m_pGraphics->WindowActive() || !g_Config.m_ClShowNotifications)

View file

@ -510,7 +510,6 @@ public:
void SwitchWindowScreen(int Index) override; void SwitchWindowScreen(int Index) override;
void SetWindowParams(int FullscreenMode, bool IsBorderless, bool AllowResizing) override; void SetWindowParams(int FullscreenMode, bool IsBorderless, bool AllowResizing) override;
void ToggleWindowVSync() override; void ToggleWindowVSync() override;
void LoadFont() override;
void Notify(const char *pTitle, const char *pMessage) override; void Notify(const char *pTitle, const char *pMessage) override;
void BenchmarkQuit(int Seconds, const char *pFilename); void BenchmarkQuit(int Seconds, const char *pFilename);

File diff suppressed because it is too large Load diff

View file

@ -57,9 +57,10 @@ enum ETextRenderFlags
TEXT_RENDER_FLAG_ONE_TIME_USE = 1 << 9, TEXT_RENDER_FLAG_ONE_TIME_USE = 1 << 9,
}; };
enum enum class EFontPreset
{ {
TEXT_FONT_ICON_FONT = 0, DEFAULT_FONT,
ICON_FONT,
}; };
namespace FontIcons { namespace FontIcons {
@ -133,8 +134,6 @@ MAYBE_UNUSED static const char *FONT_ICON_DICE_FIVE = "\xEF\x94\xA3";
MAYBE_UNUSED static const char *FONT_ICON_DICE_SIX = "\xEF\x94\xA6"; MAYBE_UNUSED static const char *FONT_ICON_DICE_SIX = "\xEF\x94\xA6";
} // end namespace FontIcons } // end namespace FontIcons
class CFont;
enum ETextCursorSelectionMode enum ETextCursorSelectionMode
{ {
// ignore any kind of selection // ignore any kind of selection
@ -186,10 +185,8 @@ public:
float m_LineWidth; float m_LineWidth;
float m_X, m_Y; float m_X, m_Y;
float m_MaxCharacterHeight; float m_MaxCharacterHeight;
float m_LongestLineWidth; float m_LongestLineWidth;
CFont *m_pFont;
float m_FontSize; float m_FontSize;
float m_AlignedFontSize; float m_AlignedFontSize;
@ -255,13 +252,9 @@ public:
virtual void MoveCursor(CTextCursor *pCursor, float x, float y) const = 0; virtual void MoveCursor(CTextCursor *pCursor, float x, float y) const = 0;
virtual void SetCursorPosition(CTextCursor *pCursor, float x, float y) const = 0; virtual void SetCursorPosition(CTextCursor *pCursor, float x, float y) const = 0;
virtual CFont *LoadFont(const char *pFilename, unsigned char *pBuf, size_t Size) = 0; virtual void LoadFonts() = 0;
virtual bool LoadFallbackFont(CFont *pFont, const char *pFilename, unsigned char *pBuf, size_t Size) const = 0; virtual void SetFontPreset(EFontPreset FontPreset) = 0;
virtual CFont *GetFont(size_t FontIndex) = 0; virtual void SetFontLanguageVariant(const char *pLanguageFile) = 0;
virtual CFont *GetFont(const char *pFilename) = 0;
virtual void SetDefaultFont(CFont *pFont) = 0;
virtual void SetCurFont(CFont *pFont) = 0;
virtual void SetRenderFlags(unsigned Flags) = 0; virtual void SetRenderFlags(unsigned Flags) = 0;
virtual unsigned GetRenderFlags() const = 0; virtual unsigned GetRenderFlags() const = 0;
@ -288,10 +281,10 @@ public:
virtual STextBoundingBox GetBoundingBoxTextContainer(STextContainerIndex TextContainerIndex) = 0; virtual STextBoundingBox GetBoundingBoxTextContainer(STextContainerIndex TextContainerIndex) = 0;
virtual void UploadEntityLayerText(void *pTexBuff, size_t ImageColorChannelCount, int TexWidth, int TexHeight, int TexSubWidth, int TexSubHeight, const char *pText, int Length, float x, float y, int FontHeight) = 0; virtual void UploadEntityLayerText(void *pTexBuff, size_t ImageColorChannelCount, int TexWidth, int TexHeight, int TexSubWidth, int TexSubHeight, const char *pText, int Length, float x, float y, int FontSize) = 0;
virtual int AdjustFontSize(const char *pText, int TextLength, int MaxSize, int MaxWidth) const = 0; virtual int AdjustFontSize(const char *pText, int TextLength, int MaxSize, int MaxWidth) const = 0;
virtual float GetGlyphOffsetX(int FontSize, char TextCharacter) const = 0; virtual float GetGlyphOffsetX(int FontSize, char TextCharacter) const = 0;
virtual int CalculateTextWidth(const char *pText, int TextLength, int FontWidth, int FontHeight) const = 0; virtual int CalculateTextWidth(const char *pText, int TextLength, int FontWidth, int FontSize) const = 0;
virtual bool SelectionToUTF8OffSets(const char *pText, int SelStart, int SelEnd, int &OffUTF8Start, int &OffUTF8End) const = 0; virtual bool SelectionToUTF8OffSets(const char *pText, int SelStart, int SelEnd, int &OffUTF8Start, int &OffUTF8End) const = 0;
virtual bool UTF8OffToDecodedOff(const char *pText, int UTF8Off, int &DecodedOff) const = 0; virtual bool UTF8OffToDecodedOff(const char *pText, int UTF8Off, int &DecodedOff) const = 0;
@ -321,6 +314,7 @@ class IEngineTextRender : public ITextRender
MACRO_INTERFACE("enginetextrender", 0) MACRO_INTERFACE("enginetextrender", 0)
public: public:
virtual void Init() = 0; virtual void Init() = 0;
virtual void Shutdown() override = 0;
}; };
extern IEngineTextRender *CreateEngineTextRender(); extern IEngineTextRender *CreateEngineTextRender();

View file

@ -272,9 +272,9 @@ int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const c
if(Checkable) if(Checkable)
{ {
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
UI()->DoLabel(&Box, FONT_ICON_XMARK, Box.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); UI()->DoLabel(&Box, FONT_ICON_XMARK, Box.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
} }
else else
UI()->DoLabel(&Box, pBoxText, Box.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); UI()->DoLabel(&Box, pBoxText, Box.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
@ -538,7 +538,7 @@ int CMenus::RenderMenubar(CUIRect r)
Box.VSplitLeft(33.0f, &Button, &Box); Box.VSplitLeft(33.0f, &Button, &Box);
static CButtonContainer s_StartButton; static CButtonContainer s_StartButton;
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
bool GotNewsOrUpdate = false; bool GotNewsOrUpdate = false;
@ -573,7 +573,7 @@ int CMenus::RenderMenubar(CUIRect r)
} }
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
Box.VSplitLeft(10.0f, 0, &Box); Box.VSplitLeft(10.0f, 0, &Box);
@ -694,7 +694,7 @@ int CMenus::RenderMenubar(CUIRect r)
} }
} }
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
Box.VSplitRight(33.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button);
@ -745,7 +745,7 @@ int CMenus::RenderMenubar(CUIRect r)
} }
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
if(NewPage != -1) if(NewPage != -1)
{ {

View file

@ -199,7 +199,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
float FontSize = 14.0f; float FontSize = 14.0f;
if(SmallFont) if(SmallFont)
FontSize = 6.0f; FontSize = 6.0f;
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
TextRender()->TextColor(TextColor); TextRender()->TextColor(TextColor);
TextRender()->TextOutlineColor(TextOutlineColor); TextRender()->TextOutlineColor(TextOutlineColor);
@ -207,7 +207,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor()); TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
}; };
int NumPlayers = 0; int NumPlayers = 0;
@ -474,7 +474,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
// render quick search // render quick search
{ {
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 16.0f, TEXTALIGN_ML); UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 16.0f, TEXTALIGN_ML);
@ -482,7 +482,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
ExcludeIconWidth = TextRender()->TextWidth(16.0f, FONT_ICON_BAN, -1, -1.0f); ExcludeIconWidth = TextRender()->TextWidth(16.0f, FONT_ICON_BAN, -1, -1.0f);
ExcludeSearchIconMax = maximum(SearchIconWidth, ExcludeIconWidth); ExcludeSearchIconMax = maximum(SearchIconWidth, ExcludeIconWidth);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
QuickSearch.VSplitLeft(ExcludeSearchIconMax, 0, &QuickSearch); QuickSearch.VSplitLeft(ExcludeSearchIconMax, 0, &QuickSearch);
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch); QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
@ -504,12 +504,12 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
// render quick exclude // render quick exclude
{ {
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&QuickExclude, FONT_ICON_BAN, 16.0f, TEXTALIGN_ML); UI()->DoLabel(&QuickExclude, FONT_ICON_BAN, 16.0f, TEXTALIGN_ML);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
QuickExclude.VSplitLeft(ExcludeSearchIconMax, 0, &QuickExclude); QuickExclude.VSplitLeft(ExcludeSearchIconMax, 0, &QuickExclude);
QuickExclude.VSplitLeft(5.0f, 0, &QuickExclude); QuickExclude.VSplitLeft(5.0f, 0, &QuickExclude);
@ -1416,11 +1416,11 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
Header.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, UI()->MouseHovered(&Header) ? 0.4f : 0.25f), IGraphics::CORNER_ALL, 5.0f); Header.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, UI()->MouseHovered(&Header) ? 0.4f : 0.25f), IGraphics::CORNER_ALL, 5.0f);
Header.VSplitLeft(Header.h, &GroupIcon, &GroupLabel); Header.VSplitLeft(Header.h, &GroupIcon, &GroupLabel);
GroupIcon.Margin(2.0f, &GroupIcon); GroupIcon.Margin(2.0f, &GroupIcon);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->TextColor(UI()->MouseHovered(&Header) ? TextRender()->DefaultTextColor() : ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f)); TextRender()->TextColor(UI()->MouseHovered(&Header) ? TextRender()->DefaultTextColor() : ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f));
UI()->DoLabel(&GroupIcon, s_aListExtended[FriendType] ? FONT_ICON_SQUARE_MINUS : FONT_ICON_SQUARE_PLUS, GroupIcon.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); UI()->DoLabel(&GroupIcon, s_aListExtended[FriendType] ? FONT_ICON_SQUARE_MINUS : FONT_ICON_SQUARE_PLUS, GroupIcon.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
switch(FriendType) switch(FriendType)
{ {
case FRIEND_PLAYER_ON: case FRIEND_PLAYER_ON:
@ -1535,7 +1535,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
SLabelProperties Props; SLabelProperties Props;
Props.m_EnableWidthCheck = false; Props.m_EnableWidthCheck = false;
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
TextRender()->TextColor(0.4f, 0.7f, 0.94f, 1.0f); TextRender()->TextColor(0.4f, 0.7f, 0.94f, 1.0f);
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 1.0f); TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 1.0f);
@ -1546,7 +1546,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor()); TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
} }
// server info text // server info text

View file

@ -32,7 +32,7 @@ int CMenus::DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pT
{ {
pRect->Draw(ColorRGBA(1.0f, 1.0f, 1.0f, (Checked ? 0.10f : 0.5f) * UI()->ButtonColorMul(pButtonContainer)), Corners, 5.0f); pRect->Draw(ColorRGBA(1.0f, 1.0f, 1.0f, (Checked ? 0.10f : 0.5f) * UI()->ButtonColorMul(pButtonContainer)), Corners, 5.0f);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor()); TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
CUIRect Temp; CUIRect Temp;
@ -48,7 +48,7 @@ int CMenus::DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pT
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
} }
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
return UI()->DoButtonLogic(pButtonContainer, Checked, pRect); return UI()->DoButtonLogic(pButtonContainer, Checked, pRect);
} }
@ -1162,13 +1162,13 @@ void CMenus::RenderDemoList(CUIRect MainView)
else else
IconColor = ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f); IconColor = ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->TextColor(IconColor); TextRender()->TextColor(IconColor);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING);
UI()->DoLabel(&Button, pIconType, 12.0f, TEXTALIGN_ML); UI()->DoLabel(&Button, pIconType, 12.0f, TEXTALIGN_ML);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
} }
else if(ID == COL_DEMONAME) else if(ID == COL_DEMONAME)
{ {

View file

@ -665,13 +665,13 @@ void CMenus::RenderServerControl(CUIRect MainView)
{ {
Bottom.VSplitLeft(240.0f, &QuickSearch, &Bottom); Bottom.VSplitLeft(240.0f, &QuickSearch, &Bottom);
QuickSearch.HSplitTop(5.0f, 0, &QuickSearch); QuickSearch.HSplitTop(5.0f, 0, &QuickSearch);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML); UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML);
float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f); float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch); QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch); QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);

View file

@ -660,7 +660,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
static CButtonContainer s_RandomSkinButtonID; static CButtonContainer s_RandomSkinButtonID;
static const char *s_apDice[] = {FONT_ICON_DICE_ONE, FONT_ICON_DICE_TWO, FONT_ICON_DICE_THREE, FONT_ICON_DICE_FOUR, FONT_ICON_DICE_FIVE, FONT_ICON_DICE_SIX}; static const char *s_apDice[] = {FONT_ICON_DICE_ONE, FONT_ICON_DICE_TWO, FONT_ICON_DICE_THREE, FONT_ICON_DICE_FOUR, FONT_ICON_DICE_FIVE, FONT_ICON_DICE_SIX};
static int s_CurrentDie = rand() % std::size(s_apDice); static int s_CurrentDie = rand() % std::size(s_apDice);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
if(DoButton_Menu(&s_RandomSkinButtonID, s_apDice[s_CurrentDie], 1, &Button, nullptr, IGraphics::CORNER_ALL, 5.0f, -0.2f)) if(DoButton_Menu(&s_RandomSkinButtonID, s_apDice[s_CurrentDie], 1, &Button, nullptr, IGraphics::CORNER_ALL, 5.0f, -0.2f))
{ {
@ -668,7 +668,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
s_CurrentDie = rand() % std::size(s_apDice); s_CurrentDie = rand() % std::size(s_apDice);
} }
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
GameClient()->m_Tooltips.DoToolTip(&s_RandomSkinButtonID, &Button, Localize("Create a random skin")); GameClient()->m_Tooltips.DoToolTip(&s_RandomSkinButtonID, &Button, Localize("Create a random skin"));
// custom color selector // custom color selector
@ -770,7 +770,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
} }
auto &&RenderFavIcon = [&](const CUIRect &FavIcon, bool AsFav) { auto &&RenderFavIcon = [&](const CUIRect &FavIcon, bool AsFav) {
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
if(AsFav) if(AsFav)
TextRender()->TextColor({1, 1, 0, 1}); TextRender()->TextColor({1, 1, 0, 1});
@ -782,7 +782,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
UI()->DoLabel(&FavIcon, FONT_ICON_STAR, 12.0f, TEXTALIGN_MR, Props); UI()->DoLabel(&FavIcon, FONT_ICON_STAR, 12.0f, TEXTALIGN_MR, Props);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
}; };
int OldSelected = -1; int OldSelected = -1;
@ -873,13 +873,13 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
MainView.HSplitBottom(ms_ButtonHeight, &MainView, &QuickSearch); MainView.HSplitBottom(ms_ButtonHeight, &MainView, &QuickSearch);
QuickSearch.VSplitLeft(240.0f, &QuickSearch, &SkinDB); QuickSearch.VSplitLeft(240.0f, &QuickSearch, &SkinDB);
QuickSearch.HSplitTop(5.0f, 0, &QuickSearch); QuickSearch.HSplitTop(5.0f, 0, &QuickSearch);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML); UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML);
float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f); float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch); QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch); QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
QuickSearch.VSplitLeft(QuickSearch.w - 15.0f, &QuickSearch, &QuickSearchClearButton); QuickSearch.VSplitLeft(QuickSearch.w - 15.0f, &QuickSearch, &QuickSearchClearButton);
@ -922,19 +922,19 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
} }
GameClient()->m_Tooltips.DoToolTip(&s_DirectoryButtonID, &DirectoryButton, Localize("Open the directory to add custom skins")); GameClient()->m_Tooltips.DoToolTip(&s_DirectoryButtonID, &DirectoryButton, Localize("Open the directory to add custom skins"));
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
static CButtonContainer s_SkinRefreshButtonID; static CButtonContainer s_SkinRefreshButtonID;
if(DoButton_Menu(&s_SkinRefreshButtonID, FONT_ICON_ARROW_ROTATE_RIGHT, 0, &RefreshButton, nullptr, IGraphics::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f))) if(DoButton_Menu(&s_SkinRefreshButtonID, FONT_ICON_ARROW_ROTATE_RIGHT, 0, &RefreshButton, nullptr, IGraphics::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f)))
{ {
// reset render flags for possible loading screen // reset render flags for possible loading screen
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
RefreshSkins(); RefreshSkins();
s_InitSkinlist = true; s_InitSkinlist = true;
} }
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
} }
typedef struct typedef struct
@ -1993,7 +1993,6 @@ bool CMenus::RenderLanguageSelection(CUIRect MainView)
if(OldSelected != s_SelectedLanguage) if(OldSelected != s_SelectedLanguage)
{ {
str_copy(g_Config.m_ClLanguagefile, g_Localization.Languages()[s_SelectedLanguage].m_FileName.c_str()); str_copy(g_Config.m_ClLanguagefile, g_Localization.Languages()[s_SelectedLanguage].m_FileName.c_str());
g_Localization.Load(g_Localization.Languages()[s_SelectedLanguage].m_FileName.c_str(), Storage(), Console());
GameClient()->OnLanguageChange(); GameClient()->OnLanguageChange();
} }

View file

@ -640,13 +640,13 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
MainView.HSplitBottom(ms_ButtonHeight, &MainView, &QuickSearch); MainView.HSplitBottom(ms_ButtonHeight, &MainView, &QuickSearch);
QuickSearch.VSplitLeft(240.0f, &QuickSearch, &DirectoryButton); QuickSearch.VSplitLeft(240.0f, &QuickSearch, &DirectoryButton);
QuickSearch.HSplitTop(5.0f, 0, &QuickSearch); QuickSearch.HSplitTop(5.0f, 0, &QuickSearch);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML); UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML);
float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f); float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch); QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch); QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
QuickSearch.VSplitLeft(QuickSearch.w - 15.0f, &QuickSearch, &QuickSearchClearButton); QuickSearch.VSplitLeft(QuickSearch.w - 15.0f, &QuickSearch, &QuickSearchClearButton);
@ -691,7 +691,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
} }
GameClient()->m_Tooltips.DoToolTip(&s_AssetsDirID, &DirectoryButton, Localize("Open the directory to add custom assets")); GameClient()->m_Tooltips.DoToolTip(&s_AssetsDirID, &DirectoryButton, Localize("Open the directory to add custom assets"));
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
static CButtonContainer s_AssetsReloadBtnID; static CButtonContainer s_AssetsReloadBtnID;
if(DoButton_Menu(&s_AssetsReloadBtnID, FONT_ICON_ARROW_ROTATE_RIGHT, 0, &ReloadButton, nullptr, IGraphics::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f))) if(DoButton_Menu(&s_AssetsReloadBtnID, FONT_ICON_ARROW_ROTATE_RIGHT, 0, &ReloadButton, nullptr, IGraphics::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f)))
@ -699,7 +699,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
ClearCustomItems(s_CurCustomTab); ClearCustomItems(s_CurCustomTab);
} }
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
} }
void CMenus::ConchainAssetsEntities(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) void CMenus::ConchainAssetsEntities(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)

View file

@ -192,7 +192,8 @@ void CGameClient::OnConsoleInit()
for(auto &pComponent : m_vpAll) for(auto &pComponent : m_vpAll)
pComponent->OnConsoleInit(); pComponent->OnConsoleInit();
// Console()->Chain("cl_languagefile", ConchainLanguageUpdate, this);
Console()->Chain("player_name", ConchainSpecialInfoupdate, this); Console()->Chain("player_name", ConchainSpecialInfoupdate, this);
Console()->Chain("player_clan", ConchainSpecialInfoupdate, this); Console()->Chain("player_clan", ConchainSpecialInfoupdate, this);
Console()->Chain("player_country", ConchainSpecialInfoupdate, this); Console()->Chain("player_country", ConchainSpecialInfoupdate, this);
@ -254,7 +255,8 @@ void CGameClient::OnInit()
for(int i = 0; i < NUM_NETOBJTYPES; i++) for(int i = 0; i < NUM_NETOBJTYPES; i++)
Client()->SnapSetStaticsize(i, m_NetObjHandler.GetObjSize(i)); Client()->SnapSetStaticsize(i, m_NetObjHandler.GetObjSize(i));
Client()->LoadFont(); TextRender()->LoadFonts();
TextRender()->SetFontLanguageVariant(g_Config.m_ClLanguagefile);
// update and swap after font loading, they are quite huge // update and swap after font loading, they are quite huge
Client()->UpdateAndSwap(); Client()->UpdateAndSwap();
@ -380,6 +382,8 @@ void CGameClient::OnInit()
void CGameClient::OnUpdate() void CGameClient::OnUpdate()
{ {
HandleLanguageChanged();
CUIElementBase::Init(UI()); // update static pointer because game and editor use separate UI CUIElementBase::Init(UI()); // update static pointer because game and editor use separate UI
// handle mouse movement // handle mouse movement
@ -971,6 +975,21 @@ void CGameClient::OnWindowResize()
void CGameClient::OnLanguageChange() void CGameClient::OnLanguageChange()
{ {
// The actual language change is delayed because it
// might require clearing the text render font atlas,
// which would invalidate text that is currently drawn.
m_LanguageChanged = true;
}
void CGameClient::HandleLanguageChanged()
{
if(!m_LanguageChanged)
return;
m_LanguageChanged = false;
g_Localization.Load(g_Config.m_ClLanguagefile, Storage(), Console());
TextRender()->SetFontLanguageVariant(g_Config.m_ClLanguagefile);
UI()->OnLanguageChange(); UI()->OnLanguageChange();
} }
@ -2285,6 +2304,13 @@ void CGameClient::ConKill(IConsole::IResult *pResult, void *pUserData)
((CGameClient *)pUserData)->SendKill(-1); ((CGameClient *)pUserData)->SendKill(-1);
} }
void CGameClient::ConchainLanguageUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{
pfnCallback(pResult, pCallbackUserData);
if(pResult->NumArguments())
((CGameClient *)pUserData)->OnLanguageChange();
}
void CGameClient::ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) void CGameClient::ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{ {
pfnCallback(pResult, pCallbackUserData); pfnCallback(pResult, pCallbackUserData);

View file

@ -201,6 +201,7 @@ private:
static void ConTeam(IConsole::IResult *pResult, void *pUserData); static void ConTeam(IConsole::IResult *pResult, void *pUserData);
static void ConKill(IConsole::IResult *pResult, void *pUserData); static void ConKill(IConsole::IResult *pResult, void *pUserData);
static void ConchainLanguageUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainSpecialDummyInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainSpecialDummyInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainSpecialDummy(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainSpecialDummy(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
@ -487,7 +488,9 @@ public:
void OnWindowResize(); void OnWindowResize();
bool m_LanguageChanged = false;
void OnLanguageChange(); void OnLanguageChange();
void HandleLanguageChanged();
void RenderShutdownMessage(); void RenderShutdownMessage();

View file

@ -934,10 +934,10 @@ int CUI::DoButton_Menu(CUIElement &UIElement, const CButtonContainer *pID, const
pText = GetTextLambda(); pText = GetTextLambda();
NewRect.m_Text = pText; NewRect.m_Text = pText;
if(Props.m_UseIconFont) if(Props.m_UseIconFont)
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
DoLabel(NewRect, &Text, pText, Text.h * CUI::ms_FontmodHeight, TEXTALIGN_MC); DoLabel(NewRect, &Text, pText, Text.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
if(Props.m_UseIconFont) if(Props.m_UseIconFont)
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
} }
} }
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
@ -1615,11 +1615,11 @@ int CUI::DoDropDown(CUIRect *pRect, int CurSelection, const char **pStrs, int Nu
CUIRect DropDownIcon; CUIRect DropDownIcon;
pRect->HMargin(2.0f, &DropDownIcon); pRect->HMargin(2.0f, &DropDownIcon);
DropDownIcon.VSplitRight(5.0f, &DropDownIcon, nullptr); DropDownIcon.VSplitRight(5.0f, &DropDownIcon, nullptr);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
DoLabel(&DropDownIcon, FONT_ICON_CIRCLE_CHEVRON_DOWN, DropDownIcon.h * CUI::ms_FontmodHeight, TEXTALIGN_MR); DoLabel(&DropDownIcon, FONT_ICON_CIRCLE_CHEVRON_DOWN, DropDownIcon.h * CUI::ms_FontmodHeight, TEXTALIGN_MR);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
if(State.m_SelectionPopupContext.m_SelectionIndex >= 0) if(State.m_SelectionPopupContext.m_SelectionIndex >= 0)
{ {

View file

@ -466,11 +466,11 @@ int CEditor::DoButton_FontIcon(const void *pID, const char *pText, int Checked,
{ {
pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f); pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING);
UI()->DoLabel(pRect, pText, FontSize, TEXTALIGN_MC); UI()->DoLabel(pRect, pText, FontSize, TEXTALIGN_MC);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
} }
@ -5203,11 +5203,11 @@ void CEditor::RenderFileDialog()
pIconType = FONT_ICON_FOLDER; pIconType = FONT_ICON_FOLDER;
} }
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING);
UI()->DoLabel(&FileIcon, pIconType, 12.0f, TEXTALIGN_ML); UI()->DoLabel(&FileIcon, pIconType, 12.0f, TEXTALIGN_ML);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
SLabelProperties Props; SLabelProperties Props;
Props.m_MaxWidth = Button.w; Props.m_MaxWidth = Button.w;
@ -7347,11 +7347,11 @@ void CEditor::RenderMenubar(CUIRect MenuBar)
if(m_Map.m_Modified) if(m_Map.m_Modified)
{ {
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&ChangedIndicator, FONT_ICON_CIRCLE, 8.0f, TEXTALIGN_MC); UI()->DoLabel(&ChangedIndicator, FONT_ICON_CIRCLE, 8.0f, TEXTALIGN_MC);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(nullptr); TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
static int s_ChangedIndicator; static int s_ChangedIndicator;
DoButton_Editor_Common(&s_ChangedIndicator, "", 0, &ChangedIndicator, 0, "This map has unsaved changes"); // just for the tooltip, result unused DoButton_Editor_Common(&s_ChangedIndicator, "", 0, &ChangedIndicator, 0, "This map has unsaved changes"); // just for the tooltip, result unused
} }