MeshLib
 
Loading...
Searching...
No Matches
MRRibbonFontManager.h
Go to the documentation of this file.
1#pragma once
2#include "imgui.h"
3#include <array>
4#include "exports.h"
5#include <filesystem>
6
7namespace MR
8{
9
10class MRVIEWER_CLASS RibbonFontManager
11{
12public:
13
14 // Font types used in current design
15 enum class FontType
16 {
17 Default,
18 Small,
19 SemiBold,
20 Icons,
21 Big,
22 BigSemiBold,
23 Headline,
24 Monospace,
25 Count
26 };
27
29 MRVIEWER_API void loadAllFonts( ImWchar* charRanges, float scaling );
30
32 MRVIEWER_API ImFont* getFontByType( FontType type ) const;
34 MRVIEWER_API static float getFontSizeByType( FontType type );
35
37 MRVIEWER_API std::filesystem::path getMenuFontPath() const;
38
41 MRVIEWER_API static ImFont* getFontByTypeStatic( FontType type );
42
45 MRVIEWER_API static void initFontManagerInstance( RibbonFontManager* ribbonFontManager );
46
47private:
48 std::array<ImFont*, size_t( FontType::Count )> fonts_{ nullptr,nullptr,nullptr,nullptr };
49
51 std::filesystem::path getMenuLatinSemiBoldFontPath_() const;
52
54 static RibbonFontManager*& getFontManagerInstance_();
55
56 void loadFont_( FontType type, const ImWchar* ranges, float scaling );
57
59 void loadDefaultFont_( float fontSize, float yOffset = 0.0f );
60
61 struct CustomGlyph
62 {
63 std::function<void( unsigned char* texData, int texW )> render;
64 };
65 void addCustomGlyphs_( FontType font, float scaling, std::vector<CustomGlyph>& glyphs );
66 void renderCustomGlyphsToAtlas_( const std::vector<CustomGlyph>& glyphs );
67};
68
69}
Definition MRRibbonFontManager.h:11
static MRVIEWER_API void initFontManagerInstance(RibbonFontManager *ribbonFontManager)
static MRVIEWER_API float getFontSizeByType(FontType type)
get font size by font type
static MRVIEWER_API ImFont * getFontByTypeStatic(FontType type)
FontType
Definition MRRibbonFontManager.h:16
MRVIEWER_API ImFont * getFontByType(FontType type) const
get font by font type
MRVIEWER_API void loadAllFonts(ImWchar *charRanges, float scaling)
load all fonts using in ribbon menu
MRVIEWER_API std::filesystem::path getMenuFontPath() const
get ribbon menu font path
Definition MRCameraOrientationPlugin.h:7