mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:10:04 +00:00
Represent raw font data as char instead of std::uint8_t
This commit is contained in:
parent
fe1acb32cf
commit
104227aa42
3 changed files with 18 additions and 19 deletions
|
|
@ -62,7 +62,7 @@ public:
|
|||
void InitializeFontconfig();
|
||||
void UpdateImGuiFont(types::FontCategory fontCategory);
|
||||
|
||||
const std::vector<std::uint8_t>& GetRawFontData(const std::string& filename);
|
||||
const std::vector<char>& GetRawFontData(const std::string& filename);
|
||||
|
||||
static FontRecord MatchFontFile(const std::string& family,
|
||||
const std::vector<std::string>& styles);
|
||||
|
|
@ -81,8 +81,7 @@ public:
|
|||
imguiFonts_ {};
|
||||
std::shared_mutex imguiFontsMutex_ {};
|
||||
|
||||
boost::unordered_flat_map<std::string, std::vector<std::uint8_t>>
|
||||
rawFontData_ {};
|
||||
boost::unordered_flat_map<std::string, std::vector<char>> rawFontData_ {};
|
||||
std::mutex rawFontDataMutex_ {};
|
||||
|
||||
std::shared_ptr<types::ImGuiFont> defaultFont_ {};
|
||||
|
|
@ -303,7 +302,7 @@ FontManager::LoadImGuiFont(const std::string& family,
|
|||
return imguiFont;
|
||||
}
|
||||
|
||||
const std::vector<std::uint8_t>&
|
||||
const std::vector<char>&
|
||||
FontManager::Impl::GetRawFontData(const std::string& filename)
|
||||
{
|
||||
std::unique_lock rawFontDataLock {rawFontDataMutex_};
|
||||
|
|
@ -316,16 +315,16 @@ FontManager::Impl::GetRawFontData(const std::string& filename)
|
|||
}
|
||||
|
||||
// Raw font data needs to be loaded
|
||||
std::basic_ifstream<std::uint8_t> ifs {filename, std::ios::binary};
|
||||
std::basic_ifstream<char> ifs {filename, std::ios::binary};
|
||||
ifs.seekg(0, std::ios_base::end);
|
||||
std::size_t dataSize = ifs.tellg();
|
||||
ifs.seekg(0, std::ios_base::beg);
|
||||
|
||||
// Store the font data in a buffer
|
||||
std::vector<std::uint8_t> buffer {};
|
||||
std::vector<char> buffer {};
|
||||
buffer.reserve(dataSize);
|
||||
std::copy(std::istreambuf_iterator<std::uint8_t>(ifs),
|
||||
std::istreambuf_iterator<std::uint8_t>(),
|
||||
std::copy(std::istreambuf_iterator<char>(ifs),
|
||||
std::istreambuf_iterator<char>(),
|
||||
std::back_inserter(buffer));
|
||||
|
||||
// Place the buffer in the cache
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ImGuiFont::Impl
|
|||
{
|
||||
public:
|
||||
explicit Impl(const std::string& fontName,
|
||||
const std::vector<std::uint8_t>& fontData,
|
||||
const std::vector<char>& fontData,
|
||||
units::font_size::pixels<int> size) :
|
||||
fontName_ {fontName}, size_ {size}
|
||||
{
|
||||
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
~Impl() {}
|
||||
|
||||
void CreateImGuiFont(const std::vector<std::uint8_t>& fontData);
|
||||
void CreateImGuiFont(const std::vector<char>& fontData);
|
||||
|
||||
const std::string fontName_;
|
||||
const units::font_size::pixels<int> size_;
|
||||
|
|
@ -42,14 +42,14 @@ public:
|
|||
};
|
||||
|
||||
ImGuiFont::ImGuiFont(const std::string& fontName,
|
||||
const std::vector<std::uint8_t>& fontData,
|
||||
const std::vector<char>& fontData,
|
||||
units::font_size::pixels<int> size) :
|
||||
p(std::make_unique<Impl>(fontName, fontData, size))
|
||||
{
|
||||
}
|
||||
ImGuiFont::~ImGuiFont() = default;
|
||||
|
||||
void ImGuiFont::Impl::CreateImGuiFont(const std::vector<std::uint8_t>& fontData)
|
||||
void ImGuiFont::Impl::CreateImGuiFont(const std::vector<char>& fontData)
|
||||
{
|
||||
logger_->debug("Creating Font: {}", fontName_);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class ImGuiFont
|
|||
{
|
||||
public:
|
||||
explicit ImGuiFont(const std::string& fontName,
|
||||
const std::vector<std::uint8_t>& fontData,
|
||||
const std::vector<char>& fontData,
|
||||
units::font_size::pixels<int> size);
|
||||
~ImGuiFont();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue