[WASAPI] fix stream types and frequencies enumeration
[xbmc.git] / xbmc / guilib / GUIFontManager.h
blob9dbed4682eed4a03c915d5f4bb661e458fef2ccd
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 /*!
12 \file GUIFontManager.h
13 \brief
16 #include "IMsgTargetCallback.h"
17 #include "threads/CriticalSection.h"
18 #include "threads/SingleLock.h"
19 #include "utils/ColorUtils.h"
20 #include "utils/GlobalsHandling.h"
21 #include "windowing/GraphicContext.h"
23 #include <set>
24 #include <utility>
25 #include <vector>
27 // Forward
28 class CGUIFont;
29 class CGUIFontTTF;
30 class CXBMCTinyXML;
31 class TiXmlNode;
32 class CSetting;
33 struct StringSettingOption;
35 struct OrigFontInfo
37 int size;
38 float aspect;
39 std::string fontFilePath;
40 std::string fileName;
41 RESOLUTION_INFO sourceRes;
42 bool preserveAspect;
43 bool border;
46 struct FontMetadata
48 FontMetadata(const std::string& filename, const std::set<std::string>& familyNames)
49 : m_filename{filename}, m_familyNames{familyNames}
53 std::string m_filename;
54 std::set<std::string> m_familyNames;
57 /*!
58 \ingroup textures
59 \brief
61 class GUIFontManager : public IMsgTargetCallback
63 public:
64 GUIFontManager();
65 ~GUIFontManager() override;
67 /*!
68 * \brief Initialize the font manager.
69 * Checks that fonts cache are up to date, otherwise update it.
71 void Initialize();
73 bool IsUpdating() const { return m_critSection.IsLocked(); }
75 bool OnMessage(CGUIMessage& message) override;
77 void Unload(const std::string& strFontName);
78 void LoadFonts(const std::string& fontSet);
79 CGUIFont* LoadTTF(const std::string& strFontName,
80 const std::string& strFilename,
81 KODI::UTILS::COLOR::Color textColor,
82 KODI::UTILS::COLOR::Color shadowColor,
83 const int iSize,
84 const int iStyle,
85 bool border = false,
86 float lineSpacing = 1.0f,
87 float aspect = 1.0f,
88 const RESOLUTION_INFO* res = nullptr,
89 bool preserveAspect = false);
90 CGUIFont* GetFont(const std::string& strFontName, bool fallback = true);
92 /*! \brief return a default font
93 \param border whether the font should be a font with an outline
94 \return the font. `nullptr` if no default font can be found.
96 CGUIFont* GetDefaultFont(bool border = false);
98 void Clear();
99 void FreeFontFile(CGUIFontTTF* pFont);
101 static void SettingOptionsFontsFiller(const std::shared_ptr<const CSetting>& setting,
102 std::vector<StringSettingOption>& list,
103 std::string& current,
104 void* data);
107 * \brief Get the list of user fonts as family names from cache
108 * \return The list of available fonts family names
110 std::vector<std::string> GetUserFontsFamilyNames();
112 protected:
113 void ReloadTTFFonts();
114 static void RescaleFontSizeAndAspect(CGraphicContext& context,
115 float* size,
116 float* aspect,
117 const RESOLUTION_INFO& sourceRes,
118 bool preserveAspect);
119 void LoadFonts(const TiXmlNode* fontNode);
120 CGUIFontTTF* GetFontFile(const std::string& fontIdent);
121 static void GetStyle(const TiXmlNode* fontNode, int& iStyle);
123 std::vector<std::unique_ptr<CGUIFont>> m_vecFonts;
124 std::vector<std::unique_ptr<CGUIFontTTF>> m_vecFontFiles;
125 std::vector<OrigFontInfo> m_vecFontInfo;
126 RESOLUTION_INFO m_skinResolution;
127 bool m_canReload{true};
129 private:
130 void LoadUserFonts();
131 bool LoadFontsFromFile(const std::string& fontsetFilePath,
132 const std::string& fontSet,
133 std::string& firstFontset);
135 mutable CCriticalSection m_critSection;
136 std::vector<FontMetadata> m_userFontsCache;
140 \ingroup textures
141 \brief
143 XBMC_GLOBAL_REF(GUIFontManager, g_fontManager);
144 #define g_fontManager XBMC_GLOBAL_USE(GUIFontManager)