mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-03-23 03:01:08 +00:00
Make our ImGui code build with older Visual C++ versions again
At least VS2017 doesn't like the big string literal of proggyvector_font_base85.h (its limit is 64KB, Error C1091), so go back to using proggyvector_font.h (which contains an int32 array) for MSVC.. Keep the base85 version around for proper compilers, because (unlike the non-base85 version of the font) it works on Big Endian machines. It seems like VS2022, maybe even some point release of VS2019 removed this limitation (our CI build succeeds), but I couldn't find any details about that change.
This commit is contained in:
parent
e3795a36e0
commit
09b1ede069
2 changed files with 4161 additions and 1 deletions
4146
neo/sys/proggyvector_font.h
Normal file
4146
neo/sys/proggyvector_font.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -72,7 +72,14 @@ extern ImGuiTextBuffer WriteImGuiStyleToCode( const ImGuiStyle& style, const ImG
|
|||
namespace D3 {
|
||||
namespace ImGuiHooks {
|
||||
|
||||
#include "proggyvector_font_base85.h"
|
||||
#ifdef _MSC_VER
|
||||
// Visual C++ (at least up to some 2019 version) doesn't support string literals
|
||||
// with more than 65535 bytes, so the base85-encoded version won't work here..
|
||||
// this alternative doesn't work with Big Endian, but that's not overly relevant for Windows.
|
||||
#include "proggyvector_font.h"
|
||||
#else // proper compilers that support longer string literals
|
||||
#include "proggyvector_font_base85.h"
|
||||
#endif
|
||||
|
||||
static SDL_Window* sdlWindow = NULL;
|
||||
ImGuiContext* imguiCtx = NULL;
|
||||
|
@ -322,7 +329,14 @@ void NewFrame()
|
|||
strcpy( fontCfg.Name, "ProggyVector" );
|
||||
float fontSize = 18.0f * GetScale();
|
||||
float fontSizeInt = roundf( fontSize ); // font sizes are supposed to be rounded to integers
|
||||
#ifdef _MSC_VER
|
||||
// because Visual C++ (at least up to 2019) doesn't support the long string literal
|
||||
// of the base85-encoded font, use the alternative compression instead
|
||||
// (this is incompatible with Big Endian, so keep on using Base85 for other platforms)
|
||||
io.Fonts->AddFontFromMemoryCompressedTTF(ProggyVector_compressed_data, ProggyVector_compressed_size, fontSizeInt, nullptr);
|
||||
#else // better compilers
|
||||
io.Fonts->AddFontFromMemoryCompressedBase85TTF(ProggyVector_compressed_data_base85, fontSizeInt, &fontCfg);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Start the Dear ImGui frame
|
||||
|
|
Loading…
Reference in a new issue