From ff97df74c6580e0a37bc8cad9be6b4c749eae7dd Mon Sep 17 00:00:00 2001 From: tomangelo2 Date: Sat, 28 Oct 2017 22:22:22 +0200 Subject: [PATCH] Added support for italic and bold variants of studio and satcom fonts They aren't currently used anywhere --- src/common/font_config.h | 6 ++++++ src/graphics/engine/text.cpp | 14 ++++++-------- src/graphics/engine/text.h | 13 +++++++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/common/font_config.h b/src/common/font_config.h index a91e5fa0..1c786f93 100644 --- a/src/common/font_config.h +++ b/src/common/font_config.h @@ -46,7 +46,10 @@ const std::map defaultFont = { Gfx::FONT_COMMON_ITALIC, "dvu_sans_italic.ttf" }, { Gfx::FONT_STUDIO, "dvu_sans_mono.ttf" }, { Gfx::FONT_STUDIO_BOLD, "dvu_sans_mono_bold.ttf" }, + { Gfx::FONT_STUDIO_ITALIC, "dvu_sans_mono_italic.ttf" }, { Gfx::FONT_SATCOM, "dvu_sans.ttf" }, + { Gfx::FONT_SATCOM_BOLD, "dvu_sans_bold.ttf" }, + { Gfx::FONT_SATCOM_ITALIC, "dvu_sans_italic.ttf" }, }; const std::map fontType = @@ -56,7 +59,10 @@ const std::map fontType = { Gfx::FONT_COMMON_ITALIC, "FontCommonItalic" }, { Gfx::FONT_STUDIO, "FontStudio" }, { Gfx::FONT_STUDIO_BOLD, "FontStudioBold" }, + { Gfx::FONT_STUDIO_ITALIC, "FontStudioItalic" }, { Gfx::FONT_SATCOM, "FontSatCom" }, + { Gfx::FONT_SATCOM_BOLD, "FontSatComBold" }, + { Gfx::FONT_SATCOM_ITALIC, "FontSatComItalic" }, }; class CFontConfig diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp index 8a023d67..5638c61b 100644 --- a/src/graphics/engine/text.cpp +++ b/src/graphics/engine/text.cpp @@ -128,14 +128,12 @@ bool CText::Create() return false; } - m_fonts[FONT_COMMON] = MakeUnique(fontConfig.GetFont(FONT_COMMON)); - m_fonts[FONT_COMMON_BOLD] = MakeUnique(fontConfig.GetFont(FONT_COMMON_BOLD)); - m_fonts[FONT_COMMON_ITALIC] = MakeUnique(fontConfig.GetFont(FONT_COMMON_ITALIC)); - - m_fonts[FONT_SATCOM] = MakeUnique(fontConfig.GetFont(FONT_SATCOM)); - - m_fonts[FONT_STUDIO] = MakeUnique(fontConfig.GetFont(FONT_STUDIO)); - m_fonts[FONT_STUDIO_BOLD] = MakeUnique(fontConfig.GetFont(FONT_STUDIO_BOLD)); + for (auto type : {FONT_COMMON, FONT_STUDIO, FONT_SATCOM}) + { + m_fonts[static_cast(type)] = MakeUnique(fontConfig.GetFont(type)); + m_fonts[static_cast(type|FONT_BOLD)] = MakeUnique(fontConfig.GetFont(static_cast(type|FONT_BOLD))); + m_fonts[static_cast(type|FONT_ITALIC)] = MakeUnique(fontConfig.GetFont(static_cast(type|FONT_ITALIC))); + } for (auto it = m_fonts.begin(); it != m_fonts.end(); ++it) { diff --git a/src/graphics/engine/text.h b/src/graphics/engine/text.h index 32d50d1f..0c5da66c 100644 --- a/src/graphics/engine/text.h +++ b/src/graphics/engine/text.h @@ -83,14 +83,19 @@ enum FontType //! Alias for italic colobot font FONT_COMMON_ITALIC = FONT_COMMON | FONT_ITALIC, - //! Courier (monospace) font used mainly in code editor (only regular & bold) + //! Studio font used mainly in code editor FONT_STUDIO = 0x01, - //! Alias for bold courier font + //! Alias for bold studio font FONT_STUDIO_BOLD = FONT_STUDIO | FONT_BOLD, + //! Alias for italic studio font (at this point not used anywhere) + FONT_STUDIO_ITALIC = FONT_STUDIO | FONT_ITALIC, - //! SatCom font used for interface - + //! SatCom font used for interface (currently bold and italic wariants aren't used anywhere) FONT_SATCOM = 0x02, + //! Alias for bold satcom font + FONT_SATCOM_BOLD = FONT_SATCOM | FONT_BOLD, + //! Alias for italic satcom font + FONT_SATCOM_ITALIC = FONT_SATCOM | FONT_ITALIC, //! Pseudo-font loaded from textures for buttons, icons, etc. FONT_BUTTON = 0x03,