| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- // Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- #pragma once
- #include <AnKi/Ui/UiObject.h>
- #include <AnKi/Gr/Texture.h>
- #include <AnKi/Util/ClassWrapper.h>
- #include <AnKi/Util/WeakArray.h>
- namespace anki {
- /// @addtogroup ui
- /// @{
- /// Font class.
- class Font : public UiObject
- {
- public:
- Font(UiManager* manager)
- : UiObject(manager)
- {
- }
- ~Font();
- /// Initialize the font.
- Error init(const CString& filename, ConstWeakArray<U32> fontHeights);
- /// Get font image atlas.
- ANKI_INTERNAL const TextureViewPtr& getTextureView() const
- {
- return m_texView;
- }
- ANKI_INTERNAL const ImFont& getImFont(U32 fontHeight) const
- {
- for(const FontEntry& f : m_fonts)
- {
- if(f.m_height == fontHeight)
- {
- return *f.m_imFont;
- }
- }
- ANKI_ASSERT(0);
- return *m_fonts[0].m_imFont;
- }
- ANKI_INTERNAL const ImFont& getFirstImFont() const
- {
- return *m_fonts[0].m_imFont;
- }
- ANKI_INTERNAL ImFontAtlas* getImFontAtlas()
- {
- return m_imFontAtlas.get();
- }
- private:
- ClassWrapper<ImFontAtlas> m_imFontAtlas;
- DynamicArray<U8> m_fontData;
- class FontEntry
- {
- public:
- ImFont* m_imFont;
- U32 m_height;
- };
- DynamicArray<FontEntry> m_fonts;
- TexturePtr m_tex;
- TextureViewPtr m_texView; ///< Whole texture view
- void createTexture(const void* data, U32 width, U32 height);
- };
- /// @}
- } // end namespace anki
|