update Dear ImGui to 1.92.0, part 2

TODO:
- testing
- testing
- testing
- additional testing
- extra testing

and of course:
- testing
This commit is contained in:
tildearrow 2025-08-12 02:22:26 -05:00
parent 11ecbebcdc
commit ee7087b7a5
36 changed files with 245 additions and 741 deletions

View file

@ -701,7 +701,7 @@ void ImGui_ImplDX11_Shutdown()
IM_DELETE(bd);
}
bool ImGui_ImplDX11_NewFrame()
void ImGui_ImplDX11_NewFrame()
{
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX11_Init()?");

View file

@ -28,7 +28,7 @@ struct ID3D11Buffer;
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context);
IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown();
IMGUI_IMPL_API bool ImGui_ImplDX11_NewFrame();
IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame();
IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data);
// Use if you want to reset your rendering device without losing Dear ImGui state.

View file

@ -499,7 +499,7 @@ void ImGui_ImplDX9_InvalidateDeviceObjects()
ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows();
}
bool ImGui_ImplDX9_NewFrame()
void ImGui_ImplDX9_NewFrame()
{
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX9_Init()?");

View file

@ -25,7 +25,7 @@ struct IDirect3DDevice9;
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device);
IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown();
IMGUI_IMPL_API bool ImGui_ImplDX9_NewFrame();
IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame();
IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data);
// Use if you want to reset your rendering device without losing Dear ImGui state.

View file

@ -31,7 +31,7 @@
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id<MTLDevice> device);
IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
IMGUI_IMPL_API bool ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor);
IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor);
IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* drawData,
id<MTLCommandBuffer> commandBuffer,
id<MTLRenderCommandEncoder> commandEncoder);
@ -59,7 +59,7 @@ IMGUI_IMPL_API void ImGui_ImplMetal_UpdateTexture(ImTextureData* tex);
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplMetal_Init(MTL::Device* device);
IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown();
IMGUI_IMPL_API bool ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor);
IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTL::RenderPassDescriptor* renderPassDescriptor);
IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data,
MTL::CommandBuffer* commandBuffer,
MTL::RenderCommandEncoder* commandEncoder);

View file

@ -169,7 +169,7 @@ void ImGui_ImplMetal_Shutdown()
io.BackendFlags &= ~(ImGuiBackendFlags_RendererHasVtxOffset | ImGuiBackendFlags_RendererHasTextures | ImGuiBackendFlags_RendererHasViewports);
}
bool ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
{
ImGui_ImplMetal_Data* bd = ImGui_ImplMetal_GetBackendData();
IM_ASSERT(bd != nil && "Context or backend not initialized! Did you call ImGui_ImplMetal_Init()?");
@ -183,9 +183,7 @@ bool ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor)
bd->SharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor];
#endif
if (bd->SharedMetalContext.depthStencilState == nil)
return ImGui_ImplMetal_CreateDeviceObjects(bd->SharedMetalContext.device);
return true;
ImGui_ImplMetal_CreateDeviceObjects(bd->SharedMetalContext.device);
}
static void ImGui_ImplMetal_SetupRenderState(ImDrawData* draw_data, id<MTLCommandBuffer> commandBuffer,

View file

@ -132,7 +132,7 @@ void ImGui_ImplOpenGL2_Shutdown()
IM_DELETE(bd);
}
bool ImGui_ImplOpenGL2_NewFrame()
void ImGui_ImplOpenGL2_NewFrame()
{
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData();
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplOpenGL2_Init()?");

View file

@ -31,7 +31,7 @@
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init();
IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown();
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_NewFrame();
IMGUI_IMPL_API void ImGui_ImplOpenGL2_NewFrame();
IMGUI_IMPL_API void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data);
// Called by Init/NewFrame/Shutdown

View file

@ -440,12 +440,11 @@ void ImGui_ImplOpenGL3_Shutdown()
IM_DELETE(bd);
}
bool ImGui_ImplOpenGL3_NewFrame()
void ImGui_ImplOpenGL3_NewFrame()
{
ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplOpenGL3_Init()?");
bool ret=true;
ImGui_ImplOpenGL3_InitLoader(); // Lazily init loader if not already done for e.g. DLL boundaries.
if (!bd->ShaderHandle)
@ -1028,7 +1027,7 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
glBindVertexArray(last_vertex_array);
#endif
return whatReturn;
return true;
}
void ImGui_ImplOpenGL3_DestroyDeviceObjects()

View file

@ -34,7 +34,7 @@
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_NewFrame();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
// (Optional) Called by Init/NewFrame/Shutdown

View file

@ -988,7 +988,7 @@ static void ImGui_ImplSDL2_UpdateMonitors()
}
}
static void ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(SDL_Window* window, SDL_Renderer* renderer, ImVec2* out_size, ImVec2* out_framebuffer_scale)
static void ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(SDL_Window* window, SDL_Renderer* renderer, ImVec2* out_size, ImVec2* out_framebuffer_scale, int* out_w, int* out_h, int* out_display_w, int* out_display_h)
{
int w, h;
int display_w, display_h;
@ -1007,10 +1007,11 @@ static void ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(SDL_Window* window,
#endif
else
SDL_GL_GetDrawableSize(window, &display_w, &display_h);
if (out_size != nullptr)
// tildearrow: don't set the size if it is 0
if (out_size != nullptr && w > 0 && h > 0)
*out_size = ImVec2((float)w, (float)h);
// tildearrow: TODO: good idea?
if (out_framebuffer_scale != nullptr)
if (out_framebuffer_scale != nullptr && w > 0 && h > 0)
*out_framebuffer_scale = (w > 0 && h > 0) ? ImVec2((float)display_w / w, (float)display_h / h) : ImVec2(1.0f, 1.0f);
}
@ -1020,13 +1021,13 @@ void ImGui_ImplSDL2_NewFrame()
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDL2_Init()?");
ImGuiIO& io = ImGui::GetIO();
// Setup main viewport size (every frame to accommodate for window resizing)
ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(bd->Window, bd->Renderer, &io.DisplaySize, &io.DisplayFramebufferScale);
// tildearrow
int w=0, h=0;
int display_w=0, display_h=0;
// Setup main viewport size (every frame to accommodate for window resizing)
ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(bd->Window, bd->Renderer, &io.DisplaySize, &io.DisplayFramebufferScale, &w, &h, &display_w, &display_h);
if (w > 0 && h > 0) {
io.DisplaySize = ImVec2((float)w, (float)h);
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
}
// TODO: is this before, or after?
// Update monitors
@ -1228,7 +1229,7 @@ static ImVec2 ImGui_ImplSDL2_GetWindowFramebufferScale(ImGuiViewport* viewport)
// FIXME: SDL_Renderer does not support multi-viewport.
ImGui_ImplSDL2_ViewportData* vd = (ImGui_ImplSDL2_ViewportData*)viewport->PlatformUserData;
ImVec2 framebuffer_scale;
ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(vd->Window, nullptr, nullptr, &framebuffer_scale);
ImGui_ImplSDL2_GetWindowSizeAndFramebufferScale(vd->Window, nullptr, nullptr, &framebuffer_scale, NULL, NULL, NULL, NULL);
return framebuffer_scale;
}

View file

@ -113,7 +113,7 @@ static void ImGui_ImplSDLRenderer2_SetupRenderState(SDL_Renderer* renderer)
SDL_RenderSetClipRect(renderer, nullptr);
}
bool ImGui_ImplSDLRenderer2_NewFrame()
void ImGui_ImplSDLRenderer2_NewFrame()
{
ImGui_ImplSDLRenderer2_Data* bd = ImGui_ImplSDLRenderer2_GetBackendData();
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDLRenderer2_Init()?");

View file

@ -34,7 +34,7 @@ struct SDL_Renderer;
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer);
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_Shutdown();
IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_NewFrame();
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_NewFrame();
IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_RenderDrawData(ImDrawData* draw_data, SDL_Renderer* renderer);
// Called by Init/NewFrame/Shutdown

View file

@ -17,7 +17,6 @@
struct ImGui_ImplSW_Data
{
SDL_Window* Window;
SWTexture* FontTexture;
ImGui_ImplSW_Data() { memset((void*)this, 0, sizeof(*this)); }
};
@ -537,7 +536,7 @@ static void paint_draw_cmd(const PaintTarget &target,
const ImDrawCmd &pcmd,
const ImVec2& white_uv)
{
const SWTexture* texture = (const SWTexture*)(pcmd.TextureId);
const SWTexture* texture = (const SWTexture*)(pcmd.GetTexID());
IM_ASSERT(texture);
for (unsigned int i = 0; i + 3 <= pcmd.ElemCount;) {
@ -647,7 +646,7 @@ static void paint_imgui(uint32_t *pixels, ImDrawData *drawData, int fb_width, in
bool ImGui_ImplSW_Init(SDL_Window* win) {
ImGuiIO& io = ImGui::GetIO();
ImGuiIO& platform_io = ImGui::GetPlatformIO();
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
IM_ASSERT(io.BackendRendererUserData == nullptr);
if (SDL_HasWindowSurface(win)==SDL_FALSE) {
@ -677,17 +676,22 @@ void ImGui_ImplSW_Shutdown() {
IM_DELETE(bd);
}
bool ImGui_ImplSW_NewFrame() {
void ImGui_ImplSW_NewFrame() {
ImGui_ImplSW_Data* bd = ImGui_ImplSW_GetBackendData();
IM_ASSERT(bd != nullptr);
return true;
}
void ImGui_ImplSW_RenderDrawData(ImDrawData* draw_data) {
ImGui_ImplSW_Data* bd = ImGui_ImplSW_GetBackendData();
IM_ASSERT(bd != nullptr);
// update textures if needed
if (draw_data->Textures!=NULL) {
for (ImTextureData* i: *draw_data->Textures) {
if (i->Status!=ImTextureStatus_OK) ImGui_ImplSW_UpdateTexture(i);
}
}
SDL_Surface* surf = SDL_GetWindowSurface(bd->Window);
if (!surf) return;
@ -704,38 +708,84 @@ void ImGui_ImplSW_RenderDrawData(ImDrawData* draw_data) {
/// CREATE OBJECTS
bool ImGui_ImplSW_CreateFontsTexture() {
ImGuiIO &io = ImGui::GetIO();
ImGui_ImplSW_Data* bd = ImGui_ImplSW_GetBackendData();
// Load default font (embedded in code):
uint8_t *tex_data;
int font_width, font_height;
io.Fonts->GetTexDataAsAlpha8(&tex_data, &font_width, &font_height);
SWTexture* texture = new SWTexture((uint32_t*)tex_data,font_width,font_height,true);
io.Fonts->SetTexID((ImTextureID)texture);
bd->FontTexture = texture;
return true;
}
void ImGui_ImplSW_DestroyFontsTexture() {
ImGuiIO& io = ImGui::GetIO();
ImGui_ImplSW_Data* bd = ImGui_ImplSW_GetBackendData();
if (bd->FontTexture)
{
delete bd->FontTexture;
io.Fonts->SetTexID(0);
bd->FontTexture = 0;
}
}
bool ImGui_ImplSW_CreateDeviceObjects() {
return true;
}
void ImGui_ImplSW_DestroyDeviceObjects() {
ImGui_ImplSW_DestroyFontsTexture();
}
void ImGui_ImplSW_UpdateTexture(ImTextureData* tex) {
if (tex->Status==ImTextureStatus_WantCreate) {
SWTexture* t=new SWTexture(tex->Width,tex->Height,tex->Format==ImTextureFormat_Alpha8);
memcpy(t->pixels,tex->GetPixels(),tex->GetSizeInBytes());
tex->SetTexID((ImTextureID)t);
tex->SetStatus(ImTextureStatus_OK);
} else if (tex->Status==ImTextureStatus_WantUpdates) {
SWTexture* t=(SWTexture*)tex->GetTexID();
// we don't support format changes (this should not happen)
assert(t->isAlpha==(tex->Format==ImTextureFormat_Alpha8));
if (t->width!=tex->Width || t->height!=tex->Height) {
// width/height changed; recreate texture
SWTexture* newTex=new SWTexture(tex->Width,tex->Height,tex->Format==ImTextureFormat_Alpha8);
// copy previous texture to new one
int i_y=0;
int i_y1=0;
if (t->isAlpha) {
for (int i=0; i<t->height; i++) {
unsigned char* dataOld=(unsigned char*)t->pixels;
unsigned char* dataNew=(unsigned char*)newTex->pixels;
memcpy(&dataNew[i_y1],&dataOld[i_y],t->width);
i_y1+=newTex->width;
i_y+=t->width;
}
} else {
for (int i=0; i<t->height; i++) {
uint32_t* dataOld=t->pixels;
uint32_t* dataNew=newTex->pixels;
memcpy(&dataNew[i_y1],&dataOld[i_y],t->width*sizeof(uint32_t));
i_y1+=newTex->width;
i_y+=t->width;
}
}
// delete previous texture and change texture ID
tex->SetTexID((ImTextureID)newTex);
delete t;
t=newTex;
}
// update region
if (t->isAlpha) {
unsigned char* data=(unsigned char*)t->pixels;
int i_y=t->width*tex->UpdateRect.y;
for (int i=tex->UpdateRect.y; i<tex->UpdateRect.y+tex->UpdateRect.w; i++) {
memcpy(&data[i_y],tex->GetPixelsAt(tex->UpdateRect.x,i),tex->UpdateRect.w);
i_y+=t->width;
}
} else {
uint32_t* data=t->pixels;
int i_y=t->width*tex->UpdateRect.y;
for (int i=tex->UpdateRect.y; i<tex->UpdateRect.y+tex->UpdateRect.w; i++) {
memcpy(&data[i_y],tex->GetPixelsAt(tex->UpdateRect.x,i),tex->UpdateRect.w*sizeof(uint32_t));
i_y+=t->width;
}
}
tex->SetStatus(ImTextureStatus_OK);
} else if (tex->Status==ImTextureStatus_WantDestroy && tex->UnusedFrames>0) {
SWTexture* t=(SWTexture*)tex->GetTexID();
delete t;
tex->SetTexID(ImTextureID_Invalid);
tex->SetStatus(ImTextureStatus_Destroyed);
} else {
// ????????
}
}
#endif // #ifndef IMGUI_DISABLE

View file

@ -38,6 +38,7 @@ struct SWTexture
managed(true),
isAlpha(a) {
pixels=new uint32_t[width*height];
memset(pixels,0,width*height*sizeof(uint32_t));
}
~SWTexture() {
if (managed) delete[] pixels;
@ -46,13 +47,14 @@ struct SWTexture
IMGUI_IMPL_API bool ImGui_ImplSW_Init(SDL_Window* win);
IMGUI_IMPL_API void ImGui_ImplSW_Shutdown();
IMGUI_IMPL_API bool ImGui_ImplSW_NewFrame();
IMGUI_IMPL_API void ImGui_ImplSW_NewFrame();
IMGUI_IMPL_API void ImGui_ImplSW_RenderDrawData(ImDrawData* draw_data);
// Called by Init/NewFrame/Shutdown
IMGUI_IMPL_API bool ImGui_ImplSW_CreateFontsTexture();
IMGUI_IMPL_API void ImGui_ImplSW_DestroyFontsTexture();
IMGUI_IMPL_API bool ImGui_ImplSW_CreateDeviceObjects();
IMGUI_IMPL_API void ImGui_ImplSW_DestroyDeviceObjects();
// for Dear ImGui 1.92+
IMGUI_IMPL_API void ImGui_ImplSW_UpdateTexture(ImTextureData* tex);
#endif // #ifndef IMGUI_DISABLE

View file

@ -264,19 +264,19 @@ void FurnaceGUI::drawAbout() {
double posX=(canvasW/2.0)+(sin(double(i)*0.5+double(aboutScroll)/(90.0*dpiScale))*120*dpiScale)-(ImGui::CalcTextSize(nextLine).x*0.5);
double posY=(canvasH-aboutScroll+42*i*dpiScale);
if (posY<-80*dpiScale || posY>canvasH) continue;
dl->AddText(bigFont,bigFont->FontSize,
dl->AddText(bigFont,BIG_FONT_SIZE,
ImVec2(posX+dpiScale,posY+dpiScale),
0xff000000,nextLine);
dl->AddText(bigFont,bigFont->FontSize,
dl->AddText(bigFont,BIG_FONT_SIZE,
ImVec2(posX+dpiScale,posY-dpiScale),
0xff000000,nextLine);
dl->AddText(bigFont,bigFont->FontSize,
dl->AddText(bigFont,BIG_FONT_SIZE,
ImVec2(posX-dpiScale,posY+dpiScale),
0xff000000,nextLine);
dl->AddText(bigFont,bigFont->FontSize,
dl->AddText(bigFont,BIG_FONT_SIZE,
ImVec2(posX-dpiScale,posY-dpiScale),
0xff000000,nextLine);
dl->AddText(bigFont,bigFont->FontSize,
dl->AddText(bigFont,BIG_FONT_SIZE,
ImVec2(posX,posY),
0xffffffff,nextLine);
}

View file

@ -558,7 +558,7 @@ const char* FurnaceGUI::getSystemName(DivSystem which) {
}
void FurnaceGUI::updateScroll(int amount) {
float lineHeight=(patFont->FontSize+2*dpiScale);
float lineHeight=(PAT_FONT_SIZE+2*dpiScale);
nextScroll=lineHeight*amount;
haveHitBounds=false;
}
@ -569,13 +569,13 @@ void FurnaceGUI::updateScrollRaw(float amount) {
}
void FurnaceGUI::addScroll(int amount) {
float lineHeight=(patFont->FontSize+2*dpiScale);
float lineHeight=(PAT_FONT_SIZE+2*dpiScale);
nextAddScroll=lineHeight*amount;
haveHitBounds=false;
}
void FurnaceGUI::addScrollX(int amount) {
float lineHeight=(patFont->FontSize+2*dpiScale);
float lineHeight=(PAT_FONT_SIZE+2*dpiScale);
nextAddScrollX=lineHeight*amount;
haveHitBounds=false;
}
@ -4304,24 +4304,6 @@ bool FurnaceGUI::loop() {
if (rend->areTexturesSquare()) {
ImGui::GetIO().Fonts->Flags|=ImFontAtlasFlags_Square;
}
if (!ImGui::GetIO().Fonts->Build()) {
logE("error while building font atlas!");
showError(_("error while loading fonts! please check your settings."));
ImGui::GetIO().Fonts->Clear();
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
patFont=mainFont;
bigFont=mainFont;
headFont=mainFont;
if (rend) {
rend->destroyFontsTexture();
if (rend->areTexturesSquare()) {
ImGui::GetIO().Fonts->Flags|=ImFontAtlasFlags_Square;
}
}
if (!ImGui::GetIO().Fonts->Build()) {
logE("error again while building font atlas!");
}
}
firstFrame=true;
mustClear=2;
@ -4393,9 +4375,7 @@ bool FurnaceGUI::loop() {
if (pendingLayoutImport==NULL) pendingLayoutImportStep=0;
}
if (!rend->newFrame()) {
fontsFailed=true;
}
rend->newFrame();
ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame();
@ -7433,35 +7413,6 @@ bool FurnaceGUI::loop() {
ImGui::GetIO().Fonts->Clear();
applyUISettings();
if (rend) {
rend->destroyFontsTexture();
if (rend->areTexturesSquare()) {
ImGui::GetIO().Fonts->Flags|=ImFontAtlasFlags_Square;
}
}
if (!ImGui::GetIO().Fonts->Build()) {
logE("error while building font atlas!");
showError(_("error while loading fonts! please check your settings."));
ImGui::GetIO().Fonts->Clear();
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
patFont=mainFont;
bigFont=mainFont;
headFont=mainFont;
if (rend) {
rend->destroyFontsTexture();
if (rend->areTexturesSquare()) {
ImGui::GetIO().Fonts->Flags|=ImFontAtlasFlags_Square;
}
}
if (!ImGui::GetIO().Fonts->Build()) {
logE("error again while building font atlas!");
} else {
rend->createFontsTexture();
}
} else {
rend->createFontsTexture();
}
}
}
}
@ -7475,17 +7426,6 @@ bool FurnaceGUI::loop() {
patFont=mainFont;
bigFont=mainFont;
headFont=mainFont;
if (rend) {
rend->destroyFontsTexture();
if (rend->areTexturesSquare()) {
ImGui::GetIO().Fonts->Flags|=ImFontAtlasFlags_Square;
}
}
if (!ImGui::GetIO().Fonts->Build()) {
logE("error again while building font atlas!");
} else {
rend->createFontsTexture();
}
}
if (!editOptsVisible) {
@ -7898,21 +7838,6 @@ bool FurnaceGUI::init() {
if (rend->areTexturesSquare()) {
ImGui::GetIO().Fonts->Flags|=ImFontAtlasFlags_Square;
}
if (!ImGui::GetIO().Fonts->Build()) {
logE("error while building font atlas!");
showError(_("error while loading fonts! please check your settings."));
ImGui::GetIO().Fonts->Clear();
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
patFont=mainFont;
bigFont=mainFont;
headFont=mainFont;
if (rend) {
rend->destroyFontsTexture();
}
if (!ImGui::GetIO().Fonts->Build()) {
logE("error again while building font atlas!");
}
}
logD("preparing layout...");
strncpy(finalLayoutPath,(e->getConfigPath()+String(LAYOUT_INI)).c_str(),4095);
@ -8600,7 +8525,6 @@ FurnaceGUI::FurnaceGUI():
patFont(NULL),
bigFont(NULL),
headFont(NULL),
fontRange(NULL),
songLength(0),
songLoopedSectionLength(0),
songFadeoutSectionLength(0),

View file

@ -71,6 +71,11 @@
#define BIND_FOR(x) getMultiKeysName(actionKeys[x].data(),actionKeys[x].size(),true).c_str()
#define MAIN_FONT_SIZE (settings.mainFontSize*dpiScale)
#define PAT_FONT_SIZE (settings.patFontSize*dpiScale)
#define ICON_FONT_SIZE (settings.iconSize*dpiScale)
#define BIG_FONT_SIZE (MAX(1,40*dpiScale))
#define FM_PREVIEW_SIZE 512
#define CHECK_HIDDEN_SYSTEM(x) \
@ -1568,10 +1573,8 @@ class FurnaceGUIRender {
virtual void setBlendMode(FurnaceGUIBlendMode mode);
virtual void resized(const SDL_Event& ev);
virtual void clear(ImVec4 color);
virtual bool newFrame();
virtual void newFrame();
virtual bool canVSync();
virtual void createFontsTexture();
virtual void destroyFontsTexture();
virtual void renderGUI();
virtual void wipe(float alpha);
virtual void drawOsc(float* data, size_t len, ImVec2 pos0, ImVec2 pos1, ImVec4 color, ImVec2 canvasSize, float lineWidth);
@ -1773,8 +1776,6 @@ class FurnaceGUI {
ImFont* patFont;
ImFont* bigFont;
ImFont* headFont;
ImWchar* fontRange;
ImWchar* fontRangeB;
ImVec4 uiColors[GUI_COLOR_MAX];
ImVec4 volColors[128];
ImU32 pitchGrad[256];
@ -1895,10 +1896,6 @@ class FurnaceGUI {
int roundedMenus;
int roundedTabs;
int roundedScrollbars;
int loadJapanese;
int loadChinese;
int loadChineseTraditional;
int loadKorean;
int loadFallback;
int loadFallbackPat;
int fmLayout;
@ -2152,10 +2149,6 @@ class FurnaceGUI {
roundedMenus(0),
roundedTabs(1),
roundedScrollbars(1),
loadJapanese(0),
loadChinese(0),
loadChineseTraditional(0),
loadKorean(0),
loadFallback(1),
loadFallbackPat(1),
fmLayout(4),

View file

@ -751,7 +751,8 @@ void FurnaceGUI::drawPattern() {
signed char l;
int ch=decodeUTF8((const unsigned char*)j,l);
totalAdvanced+=ImGui::GetFont()->GetCharAdvance(ch);
// TODO: eliminate use of GetFontBaked()?
totalAdvanced+=ImGui::GetFontBaked()->GetCharAdvance(ch);
if (totalAdvanced>(chNameLimit-ellipsisSize)) break;
for (int k=0; k<l; k++) {
@ -1070,7 +1071,7 @@ void FurnaceGUI::drawPattern() {
onOffColor=uiColors[GUI_COLOR_PATTERN_STATUS_OFF];
}
}
iconPos[0].x-=mainFont->CalcTextSizeA(mainFont->FontSize,FLT_MAX,0.0f,ICON_FA_SQUARE).x*0.5f;
iconPos[0].x-=mainFont->CalcTextSizeA(MAIN_FONT_SIZE,FLT_MAX,0.0f,ICON_FA_SQUARE).x*0.5f;
dl->AddText(mainFont,settings.mainFontSize*dpiScale,iconPos[0],ImGui::GetColorU32(onOffColor),ICON_FA_SQUARE);
// 2. PITCH SLIDE/VIBRATO
@ -1095,7 +1096,7 @@ void FurnaceGUI::drawPattern() {
} else {
pitchColor=uiColors[GUI_COLOR_PATTERN_STATUS_OFF];
}
iconPos[1].x-=mainFont->CalcTextSizeA(mainFont->FontSize,FLT_MAX,0.0f,pitchIcon).x*0.5f;
iconPos[1].x-=mainFont->CalcTextSizeA(MAIN_FONT_SIZE,FLT_MAX,0.0f,pitchIcon).x*0.5f;
dl->AddText(mainFont,settings.mainFontSize*dpiScale,iconPos[1],ImGui::GetColorU32(pitchColor),pitchIcon);
@ -1115,7 +1116,7 @@ void FurnaceGUI::drawPattern() {
} else {
volColor=uiColors[GUI_COLOR_PATTERN_STATUS_OFF];
}
iconPos[2].x-=mainFont->CalcTextSizeA(mainFont->FontSize,FLT_MAX,0.0f,volIcon).x*0.5f;
iconPos[2].x-=mainFont->CalcTextSizeA(MAIN_FONT_SIZE,FLT_MAX,0.0f,volIcon).x*0.5f;
dl->AddText(mainFont,settings.mainFontSize*dpiScale,iconPos[2],ImGui::GetColorU32(volColor),volIcon);
// 4. OTHER
@ -1196,7 +1197,7 @@ void FurnaceGUI::drawPattern() {
hintColor=uiColors[GUI_COLOR_TEXT];
break;
}
iconPos[i+3].x-=mainFont->CalcTextSizeA(mainFont->FontSize,FLT_MAX,0.0f,hints.hint[i]).x*0.5f;
iconPos[i+3].x-=mainFont->CalcTextSizeA(MAIN_FONT_SIZE,FLT_MAX,0.0f,hints.hint[i]).x*0.5f;
dl->AddText(mainFont,settings.mainFontSize*dpiScale,iconPos[i+3],ImGui::GetColorU32(hintColor),hints.hint[i]);
}
}
@ -1757,7 +1758,7 @@ void FurnaceGUI::drawPattern() {
for (int j=0; j<num; j++) {
ImVec2 partPos=ImVec2(
off.x+patChanX[i.chan]+fmod(rand(),width),
off.y+(playheadY)+randRange(0,patFont->FontSize)
off.y+(playheadY)+randRange(0,PAT_FONT_SIZE)
);
if (partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y) continue;
@ -1848,7 +1849,7 @@ void FurnaceGUI::drawPattern() {
ImVec2 partPos=ImVec2(
off.x+patChanX[i]+(width*0.5+0.5*sin(M_PI*(float)ch->vibratoPosGiant/64.0f)*width),
off.y+(ImGui::GetWindowHeight()*0.5f)+randRange(0,patFont->FontSize)
off.y+(ImGui::GetWindowHeight()*0.5f)+randRange(0,PAT_FONT_SIZE)
);
if (!(partPos.x<winMin.x || partPos.y<winMin.y || partPos.x>winMax.x || partPos.y>winMax.y)) {
@ -1878,8 +1879,8 @@ void FurnaceGUI::drawPattern() {
if (part.life>255) part.life=255;
fdl->AddText(
iconFont,
iconFont->FontSize,
ImVec2(part.pos.x-iconFont->FontSize*0.5,part.pos.y-iconFont->FontSize*0.5),
ICON_FONT_SIZE,
ImVec2(part.pos.x-ICON_FONT_SIZE*0.5,part.pos.y-ICON_FONT_SIZE*0.5),
part.colors[(int)part.life],
part.type
);

View file

@ -482,7 +482,8 @@ int PlotCustomEx(ImGuiPlotType plot_type, const char* label, float (*values_gett
std::string guide1=guideFunc(scale_min);
ImVec2 maxPos=frame_bb.Min;
maxPos.y=frame_bb.Max.y-ImGui::GetFont()->FontSize;
// TODO: get rid of LegacySize somehow
maxPos.y=frame_bb.Max.y-ImGui::GetFont()->LegacySize;
window->DrawList->AddText(maxPos+ImVec2(1.0f,1.0f),0xff000000,guide1.c_str());
window->DrawList->AddText(maxPos+ImVec2(1.0f,-1.0f),0xff000000,guide1.c_str());
window->DrawList->AddText(maxPos+ImVec2(-1.0f,1.0f),0xff000000,guide1.c_str());

View file

@ -71,20 +71,13 @@ void FurnaceGUIRender::resized(const SDL_Event& ev) {
void FurnaceGUIRender::clear(ImVec4 color) {
}
bool FurnaceGUIRender::newFrame() {
return true;
void FurnaceGUIRender::newFrame() {
}
bool FurnaceGUIRender::canVSync() {
return true;
}
void FurnaceGUIRender::createFontsTexture() {
}
void FurnaceGUIRender::destroyFontsTexture() {
}
void FurnaceGUIRender::renderGUI() {
}

View file

@ -308,8 +308,8 @@ void FurnaceGUIRenderDX11::clear(ImVec4 color) {
context->ClearRenderTargetView(renderTarget,floatColor);
}
bool FurnaceGUIRenderDX11::newFrame() {
return ImGui_ImplDX11_NewFrame();
void FurnaceGUIRenderDX11::newFrame() {
ImGui_ImplDX11_NewFrame();
}
bool FurnaceGUIRenderDX11::canVSync() {
@ -317,14 +317,6 @@ bool FurnaceGUIRenderDX11::canVSync() {
return true;
}
void FurnaceGUIRenderDX11::createFontsTexture() {
ImGui_ImplDX11_CreateDeviceObjects();
}
void FurnaceGUIRenderDX11::destroyFontsTexture() {
ImGui_ImplDX11_InvalidateDeviceObjects();
}
void FurnaceGUIRenderDX11::renderGUI() {
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
}

View file

@ -74,10 +74,8 @@ class FurnaceGUIRenderDX11: public FurnaceGUIRender {
void setBlendMode(FurnaceGUIBlendMode mode);
void resized(const SDL_Event& ev);
void clear(ImVec4 color);
bool newFrame();
void newFrame();
bool canVSync();
void createFontsTexture();
void destroyFontsTexture();
void renderGUI();
void wipe(float alpha);
void present();

View file

@ -344,22 +344,14 @@ void FurnaceGUIRenderDX9::present() {
}
}
bool FurnaceGUIRenderDX9::newFrame() {
return ImGui_ImplDX9_NewFrame();
void FurnaceGUIRenderDX9::newFrame() {
ImGui_ImplDX9_NewFrame();
}
bool FurnaceGUIRenderDX9::canVSync() {
return supportsVSync;
}
void FurnaceGUIRenderDX9::createFontsTexture() {
ImGui_ImplDX9_CreateDeviceObjects();
}
void FurnaceGUIRenderDX9::destroyFontsTexture() {
ImGui_ImplDX9_InvalidateDeviceObjects();
}
void FurnaceGUIRenderDX9::renderGUI() {
if (!inScene) {
HRESULT result=device->BeginScene();

View file

@ -57,11 +57,9 @@ class FurnaceGUIRenderDX9: public FurnaceGUIRender {
void setBlendMode(FurnaceGUIBlendMode mode);
void resized(const SDL_Event& ev);
void clear(ImVec4 color);
bool newFrame();
void newFrame();
bool canVSync();
bool areTexturesSquare();
void createFontsTexture();
void destroyFontsTexture();
void renderGUI();
void wipe(float alpha);
void present();

View file

@ -382,22 +382,14 @@ void FurnaceGUIRenderGL::clear(ImVec4 color) {
C(glClear(GL_COLOR_BUFFER_BIT));
}
bool FurnaceGUIRenderGL::newFrame() {
return ImGui_ImplOpenGL3_NewFrame();
void FurnaceGUIRenderGL::newFrame() {
ImGui_ImplOpenGL3_NewFrame();
}
bool FurnaceGUIRenderGL::canVSync() {
return swapIntervalSet;
}
void FurnaceGUIRenderGL::createFontsTexture() {
ImGui_ImplOpenGL3_CreateFontsTexture();
}
void FurnaceGUIRenderGL::destroyFontsTexture() {
ImGui_ImplOpenGL3_DestroyFontsTexture();
}
void FurnaceGUIRenderGL::renderGUI() {
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}

View file

@ -65,10 +65,8 @@ class FurnaceGUIRenderGL: public FurnaceGUIRender {
void setTextureBlendMode(FurnaceGUITexture* which, FurnaceGUIBlendMode mode);
void setBlendMode(FurnaceGUIBlendMode mode);
void clear(ImVec4 color);
bool newFrame();
void newFrame();
bool canVSync();
void createFontsTexture();
void destroyFontsTexture();
void renderGUI();
void wipe(float alpha);
void drawOsc(float* data, size_t len, ImVec2 pos0, ImVec2 pos1, ImVec4 color, ImVec2 canvasSize, float lineWidth);

View file

@ -173,22 +173,14 @@ void FurnaceGUIRenderGL1::clear(ImVec4 color) {
C(glClear(GL_COLOR_BUFFER_BIT));
}
bool FurnaceGUIRenderGL1::newFrame() {
return ImGui_ImplOpenGL2_NewFrame();
void FurnaceGUIRenderGL1::newFrame() {
ImGui_ImplOpenGL2_NewFrame();
}
bool FurnaceGUIRenderGL1::canVSync() {
return swapIntervalSet;
}
void FurnaceGUIRenderGL1::createFontsTexture() {
ImGui_ImplOpenGL2_CreateFontsTexture();
}
void FurnaceGUIRenderGL1::destroyFontsTexture() {
ImGui_ImplOpenGL2_DestroyFontsTexture();
}
void FurnaceGUIRenderGL1::renderGUI() {
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
}

View file

@ -41,11 +41,9 @@ class FurnaceGUIRenderGL1: public FurnaceGUIRender {
void setTextureBlendMode(FurnaceGUITexture* which, FurnaceGUIBlendMode mode);
void setBlendMode(FurnaceGUIBlendMode mode);
void clear(ImVec4 color);
bool newFrame();
void newFrame();
bool canVSync();
bool areTexturesSquare();
void createFontsTexture();
void destroyFontsTexture();
void renderGUI();
void wipe(float alpha);
void present();

View file

@ -37,10 +37,8 @@ class FurnaceGUIRenderMetal: public FurnaceGUIRender {
void setTextureBlendMode(FurnaceGUITexture* which, FurnaceGUIBlendMode mode);
void setBlendMode(FurnaceGUIBlendMode mode);
void clear(ImVec4 color);
bool newFrame();
void newFrame();
bool canVSync();
void createFontsTexture();
void destroyFontsTexture();
void renderGUI();
void wipe(float alpha);
void present();

View file

@ -150,22 +150,14 @@ void FurnaceGUIRenderMetal::clear(ImVec4 color) {
priv->renderEncoder=[priv->cmdBuf renderCommandEncoderWithDescriptor:priv->renderPass];
}
bool FurnaceGUIRenderMetal::newFrame() {
return ImGui_ImplMetal_NewFrame(priv->renderPass);
void FurnaceGUIRenderMetal::newFrame() {
ImGui_ImplMetal_NewFrame(priv->renderPass);
}
bool FurnaceGUIRenderMetal::canVSync() {
return swapIntervalSet;
}
void FurnaceGUIRenderMetal::createFontsTexture() {
ImGui_ImplMetal_CreateFontsTexture(priv->context.device);
}
void FurnaceGUIRenderMetal::destroyFontsTexture() {
ImGui_ImplMetal_DestroyFontsTexture();
}
void FurnaceGUIRenderMetal::renderGUI() {
ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(),priv->cmdBuf,priv->renderEncoder);
}

View file

@ -120,22 +120,14 @@ void FurnaceGUIRenderSDL::clear(ImVec4 color) {
SDL_RenderClear(sdlRend);
}
bool FurnaceGUIRenderSDL::newFrame() {
return ImGui_ImplSDLRenderer2_NewFrame();
void FurnaceGUIRenderSDL::newFrame() {
ImGui_ImplSDLRenderer2_NewFrame();
}
bool FurnaceGUIRenderSDL::canVSync() {
return swapIntervalSet;
}
void FurnaceGUIRenderSDL::createFontsTexture() {
ImGui_ImplSDLRenderer2_CreateFontsTexture();
}
void FurnaceGUIRenderSDL::destroyFontsTexture() {
ImGui_ImplSDLRenderer2_DestroyFontsTexture();
}
void FurnaceGUIRenderSDL::renderGUI() {
ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData(),sdlRend);
}

View file

@ -35,10 +35,8 @@ class FurnaceGUIRenderSDL: public FurnaceGUIRender {
void setTextureBlendMode(FurnaceGUITexture* which, FurnaceGUIBlendMode mode);
void setBlendMode(FurnaceGUIBlendMode mode);
void clear(ImVec4 color);
bool newFrame();
void newFrame();
bool canVSync();
void createFontsTexture();
void destroyFontsTexture();
void renderGUI();
void wipe(float alpha);
void present();

View file

@ -105,22 +105,14 @@ void FurnaceGUIRenderSoftware::clear(ImVec4 color) {
}
}
bool FurnaceGUIRenderSoftware::newFrame() {
return ImGui_ImplSW_NewFrame();
void FurnaceGUIRenderSoftware::newFrame() {
ImGui_ImplSW_NewFrame();
}
bool FurnaceGUIRenderSoftware::canVSync() {
return false;
}
void FurnaceGUIRenderSoftware::createFontsTexture() {
ImGui_ImplSW_CreateFontsTexture();
}
void FurnaceGUIRenderSoftware::destroyFontsTexture() {
ImGui_ImplSW_DestroyFontsTexture();
}
void FurnaceGUIRenderSoftware::renderGUI() {
ImGui_ImplSW_RenderDrawData(ImGui::GetDrawData());
}

View file

@ -32,10 +32,8 @@ class FurnaceGUIRenderSoftware: public FurnaceGUIRender {
void setTextureBlendMode(FurnaceGUITexture* which, FurnaceGUIBlendMode mode);
void setBlendMode(FurnaceGUIBlendMode mode);
void clear(ImVec4 color);
bool newFrame();
void newFrame();
bool canVSync();
void createFontsTexture();
void destroyFontsTexture();
void renderGUI();
void wipe(float alpha);
void present();

View file

@ -3183,62 +3183,6 @@ void FurnaceGUI::drawSettings() {
ImGui::SetTooltip(_("disable to save video memory."));
}
bool loadJapaneseB=settings.loadJapanese;
if (ImGui::Checkbox(_("Display Japanese characters"),&loadJapaneseB)) {
settings.loadJapanese=loadJapaneseB;
settingsChanged=true;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_(
"Only toggle this option if you have enough graphics memory.\n"
"This is a temporary solution until dynamic font atlas is implemented in Dear ImGui.\n\n"
"このオプションは、十分なグラフィックメモリがある場合にのみ切り替えてください。\n"
"これは、Dear ImGuiにダイナミックフォントアトラスが実装されるまでの一時的な解決策です。"
));
}
bool loadChineseB=settings.loadChinese;
if (ImGui::Checkbox(_("Display Chinese (Simplified) characters"),&loadChineseB)) {
settings.loadChinese=loadChineseB;
settingsChanged=true;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_(
"Only toggle this option if you have enough graphics memory.\n"
"This is a temporary solution until dynamic font atlas is implemented in Dear ImGui.\n\n"
"请在确保你有足够的显存后再启动此设定\n"
"这是一个在ImGui实现动态字体加载之前的临时解决方案"
));
}
bool loadChineseTraditionalB=settings.loadChineseTraditional;
if (ImGui::Checkbox(_("Display Chinese (Traditional) characters"),&loadChineseTraditionalB)) {
settings.loadChineseTraditional=loadChineseTraditionalB;
settingsChanged=true;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_(
"Only toggle this option if you have enough graphics memory.\n"
"This is a temporary solution until dynamic font atlas is implemented in Dear ImGui.\n\n"
"請在確保你有足夠的顯存后再啟動此設定\n"
"這是一個在ImGui實現動態字體加載之前的臨時解決方案"
));
}
bool loadKoreanB=settings.loadKorean;
if (ImGui::Checkbox(_("Display Korean characters"),&loadKoreanB)) {
settings.loadKorean=loadKoreanB;
settingsChanged=true;
}
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip(_(
"Only toggle this option if you have enough graphics memory.\n"
"This is a temporary solution until dynamic font atlas is implemented in Dear ImGui.\n\n"
"그래픽 메모리가 충분한 경우에만 이 옵션을 선택하십시오.\n"
"이 옵션은 Dear ImGui에 동적 글꼴 아틀라스가 구현될 때까지 임시 솔루션입니다."
));
}
// SUBSECTION PROGRAM
CONFIG_SUBSECTION(_("Program"));
ImGui::Text(_("Title bar:"));
@ -5058,10 +5002,6 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
settings.headFontPath=conf.getString("headFontPath","");
settings.patFontPath=conf.getString("patFontPath","");
settings.loadJapanese=conf.getInt("loadJapanese",0);
settings.loadChinese=conf.getInt("loadChinese",0);
settings.loadChineseTraditional=conf.getInt("loadChineseTraditional",0);
settings.loadKorean=conf.getInt("loadKorean",0);
settings.loadFallback=conf.getInt("loadFallback",1);
settings.loadFallbackPat=conf.getInt("loadFallbackPat",1);
@ -5315,10 +5255,6 @@ void FurnaceGUI::readConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
clampSetting(settings.roundedMenus,0,1);
clampSetting(settings.roundedTabs,0,1);
clampSetting(settings.roundedScrollbars,0,1);
clampSetting(settings.loadJapanese,0,1);
clampSetting(settings.loadChinese,0,1);
clampSetting(settings.loadChineseTraditional,0,1);
clampSetting(settings.loadKorean,0,1);
clampSetting(settings.loadFallback,0,1);
clampSetting(settings.loadFallbackPat,0,1);
clampSetting(settings.fmLayout,0,7);
@ -5647,10 +5583,6 @@ void FurnaceGUI::writeConfig(DivConfig& conf, FurnaceGUISettingGroups groups) {
conf.set("headFontPath",settings.headFontPath);
conf.set("patFontPath",settings.patFontPath);
conf.set("loadJapanese",settings.loadJapanese);
conf.set("loadChinese",settings.loadChinese);
conf.set("loadChineseTraditional",settings.loadChineseTraditional);
conf.set("loadKorean",settings.loadKorean);
conf.set("loadFallback",settings.loadFallback);
conf.set("loadFallbackPat",settings.loadFallbackPat);
@ -5897,35 +5829,6 @@ void FurnaceGUI::commitSettings() {
applyUISettings();
if (rend) {
rend->destroyFontsTexture();
if (rend->areTexturesSquare()) {
ImGui::GetIO().Fonts->Flags|=ImFontAtlasFlags_Square;
}
}
if (!ImGui::GetIO().Fonts->Build()) {
logE("error while building font atlas!");
showError(_("error while loading fonts! please check your settings."));
ImGui::GetIO().Fonts->Clear();
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
patFont=mainFont;
bigFont=mainFont;
headFont=mainFont;
if (rend) {
rend->destroyFontsTexture();
if (rend->areTexturesSquare()) {
ImGui::GetIO().Fonts->Flags|=ImFontAtlasFlags_Square;
}
}
if (!ImGui::GetIO().Fonts->Build()) {
logE("error again while building font atlas!");
} else {
rend->createFontsTexture();
}
} else {
rend->createFontsTexture();
}
audioEngineChanged=false;
}
@ -6613,275 +6516,52 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
// prepare
#ifdef HAVE_FREETYPE
if (settings.fontBackend==1) {
ImGui::GetIO().Fonts->FontBuilderIO=ImGuiFreeType::GetBuilderForFreeType();
ImGui::GetIO().Fonts->FontBuilderFlags&=~(
ImGuiFreeTypeBuilderFlags_NoHinting|
ImGuiFreeTypeBuilderFlags_NoAutoHint|
ImGuiFreeTypeBuilderFlags_ForceAutoHint|
ImGuiFreeTypeBuilderFlags_LightHinting|
ImGuiFreeTypeBuilderFlags_MonoHinting|
ImGuiFreeTypeBuilderFlags_Bold|
ImGuiFreeTypeBuilderFlags_Oblique|
ImGuiFreeTypeBuilderFlags_Monochrome|
ImGuiFreeTypeBuilderFlags_LoadColor|
ImGuiFreeTypeBuilderFlags_Bitmap
ImGui::GetIO().Fonts->FontLoader=ImGuiFreeType::GetFontLoader();
ImGui::GetIO().Fonts->FontLoaderFlags&=~(
ImGuiFreeTypeLoaderFlags_NoHinting|
ImGuiFreeTypeLoaderFlags_NoAutoHint|
ImGuiFreeTypeLoaderFlags_ForceAutoHint|
ImGuiFreeTypeLoaderFlags_LightHinting|
ImGuiFreeTypeLoaderFlags_MonoHinting|
ImGuiFreeTypeLoaderFlags_Bold|
ImGuiFreeTypeLoaderFlags_Oblique|
ImGuiFreeTypeLoaderFlags_Monochrome|
ImGuiFreeTypeLoaderFlags_LoadColor|
ImGuiFreeTypeLoaderFlags_Bitmap
);
if (!settings.fontAntiAlias) ImGui::GetIO().Fonts->FontBuilderFlags|=ImGuiFreeTypeBuilderFlags_Monochrome;
if (settings.fontBitmap) ImGui::GetIO().Fonts->FontBuilderFlags|=ImGuiFreeTypeBuilderFlags_Bitmap;
if (!settings.fontAntiAlias) ImGui::GetIO().Fonts->FontLoaderFlags|=ImGuiFreeTypeLoaderFlags_Monochrome;
if (settings.fontBitmap) ImGui::GetIO().Fonts->FontLoaderFlags|=ImGuiFreeTypeLoaderFlags_Bitmap;
switch (settings.fontHinting) {
case 0: // off
ImGui::GetIO().Fonts->FontBuilderFlags|=ImGuiFreeTypeBuilderFlags_NoHinting;
ImGui::GetIO().Fonts->FontLoaderFlags|=ImGuiFreeTypeLoaderFlags_NoHinting;
break;
case 1: // slight
ImGui::GetIO().Fonts->FontBuilderFlags|=ImGuiFreeTypeBuilderFlags_LightHinting;
ImGui::GetIO().Fonts->FontLoaderFlags|=ImGuiFreeTypeLoaderFlags_LightHinting;
break;
case 2: // normal
break;
case 3: // full
ImGui::GetIO().Fonts->FontBuilderFlags|=ImGuiFreeTypeBuilderFlags_MonoHinting;
ImGui::GetIO().Fonts->FontLoaderFlags|=ImGuiFreeTypeLoaderFlags_MonoHinting;
break;
}
switch (settings.fontAutoHint) {
case 0: // off
ImGui::GetIO().Fonts->FontBuilderFlags|=ImGuiFreeTypeBuilderFlags_NoAutoHint;
ImGui::GetIO().Fonts->FontLoaderFlags|=ImGuiFreeTypeLoaderFlags_NoAutoHint;
break;
case 1: // on
break;
case 2: // force
ImGui::GetIO().Fonts->FontBuilderFlags|=ImGuiFreeTypeBuilderFlags_ForceAutoHint;
ImGui::GetIO().Fonts->FontLoaderFlags|=ImGuiFreeTypeLoaderFlags_ForceAutoHint;
break;
}
} else {
ImGui::GetIO().Fonts->FontBuilderIO=ImFontAtlasGetBuilderForStbTruetype();
ImGui::GetIO().Fonts->FontLoader=ImFontAtlasGetFontLoaderForStbTruetype();
}
#endif
// set to 800 for now due to problems with unifont
static const ImWchar upTo800[]={
// base
0x20,0x7e,0xa0,0x800,
// for "Display characters" and language choices
0x107, 0x107,
0x10d, 0x10d,
0x131, 0x131,
0x142, 0x142,
0x15f, 0x15f,
0x17c, 0x17c,
0x420, 0x420,
0x423, 0x423,
0x430, 0x430,
0x431, 0x431,
0x432, 0x432,
0x433, 0x433,
0x435, 0x435,
0x437, 0x437,
0x438, 0x438,
0x439, 0x439,
0x43a, 0x43a,
0x43b, 0x43b,
0x43c, 0x43c,
0x43d, 0x43d,
0x43e, 0x43e,
0x43f, 0x43f,
0x440, 0x440,
0x441, 0x441,
0x442, 0x442,
0x443, 0x443,
0x446, 0x446,
0x447, 0x447,
0x448, 0x448,
0x449, 0x449,
0x44b, 0x44b,
0x44c, 0x44c,
0x44d, 0x44d,
0x44f, 0x44f,
0x456, 0x456,
0x457, 0x457,
0x540, 0x540,
0x561, 0x561,
0x565, 0x565,
0x575, 0x575,
0x576, 0x576,
0x580, 0x580,
0xe17, 0xe17,
0xe22, 0xe22,
0xe44, 0xe44,
0x3001, 0x3001,
0x3002, 0x3002,
0x3042, 0x3042,
0x3044, 0x3044,
0x3048, 0x3048,
0x304c, 0x304c,
0x304f, 0x304f,
0x3053, 0x3053,
0x3055, 0x3055,
0x3059, 0x3059,
0x3060, 0x3060,
0x3066, 0x3066,
0x3067, 0x3067,
0x306a, 0x306a,
0x306b, 0x306b,
0x306e, 0x306e,
0x306f, 0x306f,
0x307e, 0x307e,
0x307f, 0x307f,
0x308a, 0x308a,
0x308b, 0x308b,
0x308c, 0x308c,
0x30a2, 0x30a2,
0x30a3, 0x30a3,
0x30a4, 0x30a4,
0x30a9, 0x30a9,
0x30aa, 0x30aa,
0x30af, 0x30af,
0x30b0, 0x30b0,
0x30b7, 0x30b7,
0x30b9, 0x30b9,
0x30c0, 0x30c0,
0x30c3, 0x30c3,
0x30c8, 0x30c8,
0x30ca, 0x30ca,
0x30d5, 0x30d5,
0x30d7, 0x30d7,
0x30df, 0x30df,
0x30e1, 0x30e1,
0x30e2, 0x30e2,
0x30e7, 0x30e7,
0x30e9, 0x30e9,
0x30ea, 0x30ea,
0x30f3, 0x30f3,
0x4e00, 0x4e00,
0x4e2a, 0x4e2a,
0x4e34, 0x4e34,
0x4e4b, 0x4e4b,
0x4f53, 0x4f53,
0x4f60, 0x4f60,
0x4fdd, 0x4fdd,
0x500b, 0x500b,
0x518d, 0x518d,
0x51b3, 0x51b3,
0x5206, 0x5206,
0x5207, 0x5207,
0x524d, 0x524d,
0x52a0, 0x52a0,
0x52a8, 0x52a8,
0x52d5, 0x52d5,
0x5341, 0x5341,
0x5408, 0x5408,
0x540e, 0x540e,
0x542f, 0x542f,
0x555f, 0x555f,
0x5728, 0x5728,
0x5834, 0x5834,
0x591f, 0x591f,
0x5920, 0x5920,
0x5b57, 0x5b57,
0x5b58, 0x5b58,
0x5b9a, 0x5b9a,
0x5b9e, 0x5b9e,
0x5b9f, 0x5b9f,
0x5be6, 0x5be6,
0x6001, 0x6001,
0x614b, 0x614b,
0x65b9, 0x65b9,
0x65e5, 0x65e5,
0x65f6, 0x65f6,
0x662f, 0x662f,
0x663e, 0x663e,
0x6642, 0x6642,
0x66ff, 0x66ff,
0x6709, 0x6709,
0x672c, 0x672c,
0x6848, 0x6848,
0x6b64, 0x6b64,
0x6c7a, 0x6c7a,
0x73b0, 0x73b0,
0x73fe, 0x73fe,
0x7684, 0x7684,
0x786e, 0x786e,
0x78ba, 0x78ba,
0x7b56, 0x7b56,
0x81e8, 0x81e8,
0x88c5, 0x88c5,
0x89e3, 0x89e3,
0x8a2d, 0x8a2d,
0x8a9e, 0x8a9e,
0x8acb, 0x8acb,
0x8bbe, 0x8bbe,
0x8bf7, 0x8bf7,
0x8db3, 0x8db3,
0x8f09, 0x8f09,
0x8f7d, 0x8f7d,
0x8fd9, 0x8fd9,
0x9019, 0x9019,
0x986f, 0x986f,
0x9ad4, 0x9ad4,
0xac00, 0xac00,
0xacbd, 0xacbd,
0xad6c, 0xad6c,
0xad6d, 0xad6d,
0xadf8, 0xadf8,
0xae00, 0xae00,
0xae4c, 0xae4c,
0xaf34, 0xaf34,
0xb2c8, 0xb2c8,
0xb2e4, 0xb2e4,
0xb3d9, 0xb3d9,
0xb420, 0xb420,
0xb54c, 0xb54c,
0xb77c, 0xb77c,
0xb798, 0xb798,
0xb824, 0xb824,
0xb8e8, 0xb8e8,
0xb97c, 0xb97c,
0xb9ac, 0xb9ac,
0xb9cc, 0xb9cc,
0xba54, 0xba54,
0xba74, 0xba74,
0xbaa8, 0xbaa8,
0xbd84, 0xbd84,
0xc120, 0xc120,
0xc124, 0xc124,
0xc158, 0xc158,
0xc194, 0xc194,
0xc2a4, 0xc2a4,
0xc2dc, 0xc2dc,
0xc2ed, 0xc2ed,
0xc544, 0xc544,
0xc57c, 0xc57c,
0xc5b4, 0xc5b4,
0xc5d0, 0xc5d0,
0xc624, 0xc624,
0xc635, 0xc635,
0xc6a9, 0xc6a9,
0xc6b0, 0xc6b0,
0xc740, 0xc740,
0xc744, 0xc744,
0xc774, 0xc774,
0xc784, 0xc784,
0xc785, 0xc785,
0xc791, 0xc791,
0xc801, 0xc801,
0xc815, 0xc815,
0xc9c0, 0xc9c0,
0xcda9, 0xcda9,
0xd0dd, 0xd0dd,
0xd2c0, 0xd2c0,
0xd53d, 0xd53d,
0xd558, 0xd558,
0xd55c, 0xd55c,
0xd569, 0xd569,
0xd574, 0xd574,
0xd604, 0xd604,
0
};
ImFontGlyphRangesBuilder range;
ImVector<ImWchar> outRange;
ImFontConfig fontConf;
ImFontConfig fontConfP;
ImFontConfig fontConfB;
@ -6910,33 +6590,6 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
//fontConf.RasterizerMultiply=1.5;
//fontConfP.RasterizerMultiply=1.5;
range.AddRanges(upTo800);
if (settings.loadJapanese || localeRequiresJapanese) {
range.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesJapanese());
}
if (settings.loadChinese || localeRequiresChinese) {
range.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesChineseSimplifiedCommon());
}
if (settings.loadChineseTraditional || localeRequiresChineseTrad) {
range.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesChineseFull());
}
if (settings.loadKorean || localeRequiresKorean) {
range.AddRanges(ImGui::GetIO().Fonts->GetGlyphRangesKorean());
}
if (!localeExtraRanges.empty()) {
range.AddRanges(localeExtraRanges.data());
}
// I'm terribly sorry
range.UsedChars[0x80>>5]=0;
range.BuildRanges(&outRange);
if (fontRange!=NULL) delete[] fontRange;
fontRange=new ImWchar[outRange.size()];
int index=0;
for (ImWchar& i: outRange) {
fontRange[index++]=i;
}
if (settings.mainFont<0 || settings.mainFont>6) settings.mainFont=0;
if (settings.headFont<0 || settings.headFont>6) settings.headFont=0;
if (settings.patFont<0 || settings.patFont>6) settings.patFont=0;
@ -6961,21 +6614,21 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
fc1.OversampleV=1;
if (settings.mainFont==6) { // custom font
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.mainFontPath.c_str(),MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf,fontRange))==NULL) {
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.mainFontPath.c_str(),MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf))==NULL) {
logW("could not load UI font! reverting to default font");
settings.mainFont=GUI_MAIN_FONT_DEFAULT;
if ((mainFont=addFontZlib(builtinFont[settings.mainFont],builtinFontLen[settings.mainFont],MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf,fontRange))==NULL) {
if ((mainFont=addFontZlib(builtinFont[settings.mainFont],builtinFontLen[settings.mainFont],MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf))==NULL) {
logE("could not load UI font! falling back to Proggy Clean.");
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
}
}
} else if (settings.mainFont==5) { // system font
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_FONT_PATH_1,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf,fontRange))==NULL) {
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_FONT_PATH_2,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf,fontRange))==NULL) {
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_FONT_PATH_3,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf,fontRange))==NULL) {
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_FONT_PATH_1,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf))==NULL) {
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_FONT_PATH_2,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf))==NULL) {
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_FONT_PATH_3,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf))==NULL) {
logW("could not load UI font! reverting to default font");
settings.mainFont=GUI_MAIN_FONT_DEFAULT;
if ((mainFont=addFontZlib(builtinFont[settings.mainFont],builtinFontLen[settings.mainFont],MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf,fontRange))==NULL) {
if ((mainFont=addFontZlib(builtinFont[settings.mainFont],builtinFontLen[settings.mainFont],MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf))==NULL) {
logE("could not load UI font! falling back to Proggy Clean.");
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
}
@ -6983,26 +6636,18 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
}
}
} else {
if ((mainFont=addFontZlib(builtinFont[settings.mainFont],builtinFontLen[settings.mainFont],MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf,fontRange))==NULL) {
if ((mainFont=addFontZlib(builtinFont[settings.mainFont],builtinFontLen[settings.mainFont],MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf))==NULL) {
logE("could not load UI font! falling back to Proggy Clean.");
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
}
}
// four fallback fonts
if (settings.loadJapanese ||
settings.loadChinese ||
settings.loadChineseTraditional ||
settings.loadKorean ||
localeRequiresJapanese ||
localeRequiresChinese ||
localeRequiresChineseTrad ||
localeRequiresKorean ||
settings.loadFallback) {
mainFont=addFontZlib(font_plexSans_compressed_data,font_plexSans_compressed_size,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fc1,fontRange);
mainFont=addFontZlib(font_plexSansJP_compressed_data,font_plexSansJP_compressed_size,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fc1,fontRange);
mainFont=addFontZlib(font_plexSansKR_compressed_data,font_plexSansKR_compressed_size,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fc1,fontRange);
mainFont=addFontZlib(font_unifont_compressed_data,font_unifont_compressed_size,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fc1,fontRange);
if (settings.loadFallback) {
mainFont=addFontZlib(font_plexSans_compressed_data,font_plexSans_compressed_size,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fc1);
mainFont=addFontZlib(font_plexSansJP_compressed_data,font_plexSansJP_compressed_size,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fc1);
mainFont=addFontZlib(font_plexSansKR_compressed_data,font_plexSansKR_compressed_size,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fc1);
mainFont=addFontZlib(font_unifont_compressed_data,font_unifont_compressed_size,MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fc1);
}
ImFontConfig fc;
@ -7011,13 +6656,11 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
fc.OversampleV=1;
fc.PixelSnapH=true;
fc.GlyphMinAdvanceX=e->getConfInt("iconSize",16)*dpiScale;
static const ImWchar fontRangeIcon[]={ICON_MIN_FA,ICON_MAX_FA,0};
if ((iconFont=addFontZlib(iconFont_compressed_data,iconFont_compressed_size,MAX(1,e->getConfInt("iconSize",16)*dpiScale),&fc,fontRangeIcon))==NULL) {
if ((iconFont=addFontZlib(iconFont_compressed_data,iconFont_compressed_size,MAX(1,e->getConfInt("iconSize",16)*dpiScale),&fc))==NULL) {
logE("could not load icon font!");
}
static const ImWchar fontRangeFurIcon[]={ICON_MIN_FUR,ICON_MAX_FUR,0};
if ((furIconFont=addFontZlib(furIcons_compressed_data,furIcons_compressed_size,MAX(1,e->getConfInt("iconSize",16)*dpiScale),&fc,fontRangeFurIcon))==NULL) {
if ((furIconFont=addFontZlib(furIcons_compressed_data,furIcons_compressed_size,MAX(1,e->getConfInt("iconSize",16)*dpiScale),&fc))==NULL) {
logE("could not load Furnace icons font!");
}
@ -7026,21 +6669,21 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
patFont=mainFont;
} else {
if (settings.patFont==6) { // custom font
if ((patFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.patFontPath.c_str(),MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP,upTo800))==NULL) {
if ((patFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.patFontPath.c_str(),MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP))==NULL) {
logW("could not load pattern font! reverting to default font");
settings.patFont=GUI_PAT_FONT_DEFAULT;
if ((patFont=addFontZlib(builtinFontM[settings.patFont],builtinFontMLen[settings.patFont],MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP,upTo800))==NULL) {
if ((patFont=addFontZlib(builtinFontM[settings.patFont],builtinFontMLen[settings.patFont],MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP))==NULL) {
logE("could not load pattern font! falling back to Proggy Clean.");
patFont=ImGui::GetIO().Fonts->AddFontDefault();
}
}
} else if (settings.patFont==5) { // system font
if ((patFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_PAT_FONT_PATH_1,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP,upTo800))==NULL) {
if ((patFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_PAT_FONT_PATH_2,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP,upTo800))==NULL) {
if ((patFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_PAT_FONT_PATH_3,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP,upTo800))==NULL) {
if ((patFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_PAT_FONT_PATH_1,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP))==NULL) {
if ((patFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_PAT_FONT_PATH_2,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP))==NULL) {
if ((patFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_PAT_FONT_PATH_3,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP))==NULL) {
logW("could not load pattern font! reverting to default font");
settings.patFont=GUI_PAT_FONT_DEFAULT;
if ((patFont=addFontZlib(builtinFontM[settings.patFont],builtinFontMLen[settings.patFont],MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP,upTo800))==NULL) {
if ((patFont=addFontZlib(builtinFontM[settings.patFont],builtinFontMLen[settings.patFont],MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP))==NULL) {
logE("could not load pattern font! falling back to Proggy Clean.");
patFont=ImGui::GetIO().Fonts->AddFontDefault();
}
@ -7048,7 +6691,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
}
}
} else {
if ((patFont=addFontZlib(builtinFontM[settings.patFont],builtinFontMLen[settings.patFont],MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP,upTo800))==NULL) {
if ((patFont=addFontZlib(builtinFontM[settings.patFont],builtinFontMLen[settings.patFont],MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fontConfP))==NULL) {
logE("could not load pattern font!");
patFont=ImGui::GetIO().Fonts->AddFontDefault();
}
@ -7056,58 +6699,28 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
}
// four fallback fonts
if (settings.loadFallbackPat && (settings.loadJapanese ||
settings.loadChinese ||
settings.loadChineseTraditional ||
settings.loadKorean ||
if (settings.loadFallbackPat && (
localeRequiresJapanese ||
localeRequiresChinese ||
localeRequiresChineseTrad ||
localeRequiresKorean)) {
patFont=addFontZlib(font_plexMono_compressed_data,font_plexMono_compressed_size,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fc1,fontRange);
patFont=addFontZlib(font_plexSansJP_compressed_data,font_plexSansJP_compressed_size,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fc1,fontRange);
patFont=addFontZlib(font_plexSansKR_compressed_data,font_plexSansKR_compressed_size,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fc1,fontRange);
patFont=addFontZlib(font_unifont_compressed_data,font_unifont_compressed_size,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fc1,fontRange);
patFont=addFontZlib(font_plexMono_compressed_data,font_plexMono_compressed_size,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fc1);
patFont=addFontZlib(font_plexSansJP_compressed_data,font_plexSansJP_compressed_size,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fc1);
patFont=addFontZlib(font_plexSansKR_compressed_data,font_plexSansKR_compressed_size,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fc1);
patFont=addFontZlib(font_unifont_compressed_data,font_unifont_compressed_size,MAX(1,e->getConfInt("patFontSize",18)*dpiScale),&fc1);
}
// 0x39B = Λ
// Հայերեն
// 한국어
// Русский
// č
// ń
// ไทย
static const ImWchar bigFontRange[]={0x20,0xFF,0x39b,0x39b,0x10d,0x10d,0x144,0x144,0x420,0x420,0x423,0x423,0x430,0x430,0x438,0x438,0x439,0x439,0x43a,0x43a,0x43d,0x43d,0x440,0x440,0x441,0x441,0x443,0x443,0x44c,0x44c,0x457,0x457,0x540,0x540,0x561,0x561,0x565,0x565,0x575,0x575,0x576,0x576,0x580,0x580,0xe17,0xe17,0xe22,0xe22,0xe44,0xe44,0x65e5,0x65e5,0x672c,0x672c,0x8a9e,0x8a9e,0xad6d,0xad6d,0xc5b4,0xc5b4,0xd55c,0xd55c,0};
ImFontGlyphRangesBuilder bigFontRangeB;
ImVector<ImWchar> outRangeB;
bigFontRangeB.AddRanges(bigFontRange);
if (!localeExtraRanges.empty()) {
bigFontRangeB.AddRanges(localeExtraRanges.data());
}
// I'm terribly sorry
bigFontRangeB.UsedChars[0x80>>5]=0;
bigFontRangeB.BuildRanges(&outRangeB);
if (fontRangeB!=NULL) delete[] fontRangeB;
fontRangeB=new ImWchar[outRangeB.size()];
index=0;
for (ImWchar& i: outRangeB) {
fontRangeB[index++]=i;
}
if ((bigFont=addFontZlib(font_plexSans_compressed_data,font_plexSans_compressed_size,MAX(1,40*dpiScale),&fontConfB,fontRangeB))==NULL) {
if ((bigFont=addFontZlib(font_plexSans_compressed_data,font_plexSans_compressed_size,MAX(1,40*dpiScale),&fontConfB))==NULL) {
logE("could not load big UI font!");
}
fontConfB.MergeMode=true;
if ((bigFont=addFontZlib(font_plexSansJP_compressed_data,font_plexSansJP_compressed_size,MAX(1,40*dpiScale),&fontConfB,fontRangeB))==NULL) {
if ((bigFont=addFontZlib(font_plexSansJP_compressed_data,font_plexSansJP_compressed_size,MAX(1,40*dpiScale),&fontConfB))==NULL) {
logE("could not load big UI font (japanese)!");
}
if ((bigFont=addFontZlib(font_plexSansKR_compressed_data,font_plexSansKR_compressed_size,MAX(1,40*dpiScale),&fontConfB,fontRangeB))==NULL) {
if ((bigFont=addFontZlib(font_plexSansKR_compressed_data,font_plexSansKR_compressed_size,MAX(1,40*dpiScale),&fontConfB))==NULL) {
logE("could not load big UI font (korean)!");
}
if ((bigFont=addFontZlib(font_unifont_compressed_data,font_unifont_compressed_size,MAX(1,40*dpiScale),&fontConfB,fontRangeB))==NULL) {
if ((bigFont=addFontZlib(font_unifont_compressed_data,font_unifont_compressed_size,MAX(1,40*dpiScale),&fontConfB))==NULL) {
logE("could not load big UI font (fallback)!");
}
@ -7116,21 +6729,21 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
headFont=mainFont;
} else {
if (settings.headFont==6) { // custom font
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.headFontPath.c_str(),MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.headFontPath.c_str(),MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH))==NULL) {
logW("could not load header font! reverting to default font");
settings.headFont=0;
if ((headFont=addFontZlib(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
if ((headFont=addFontZlib(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH))==NULL) {
logE("could not load header font! falling back to IBM Plex Sans.");
headFont=ImGui::GetIO().Fonts->AddFontDefault();
}
}
} else if (settings.headFont==5) { // system font
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_1,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_2,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_3,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_1,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_2,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_3,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH))==NULL) {
logW("could not load header font! reverting to default font");
settings.headFont=0;
if ((headFont=addFontZlib(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
if ((headFont=addFontZlib(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH))==NULL) {
logE("could not load header font! falling back to IBM Plex Sans.");
headFont=ImGui::GetIO().Fonts->AddFontDefault();
}
@ -7138,7 +6751,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
}
}
} else {
if ((headFont=addFontZlib(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
if ((headFont=addFontZlib(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH))==NULL) {
logE("could not load header font!");
headFont=ImGui::GetIO().Fonts->AddFontDefault();
}
@ -7147,7 +6760,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
mainFont->FallbackChar='?';
mainFont->EllipsisChar='.';
mainFont->EllipsisCharCount=3;
//mainFont->EllipsisCharCount=3;
} else if (updateFonts) {
// safe mode
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
@ -7157,33 +6770,32 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
mainFont->FallbackChar='?';
mainFont->EllipsisChar='.';
mainFont->EllipsisCharCount=3;
//mainFont->EllipsisCharCount=3;
}
ImGuiFileDialog::Instance()->okButtonString=_("OK");
ImGuiFileDialog::Instance()->cancelButtonString=_("Cancel");
ImGuiFileDialog::Instance()->searchString=_("Search");
ImGuiFileDialog::Instance()->dirEntryString=_("[Dir]");
ImGuiFileDialog::Instance()->linkEntryString=_("[Link]");
ImGuiFileDialog::Instance()->fileEntryString=_("[File]");
ImGuiFileDialog::Instance()->fileNameString=_("Name:");
ImGuiFileDialog::Instance()->dirNameString=_("Path:");
ImGuiFileDialog::Instance()->buttonResetSearchString=_("Reset search");
ImGuiFileDialog::Instance()->buttonDriveString=_("Drives");
ImGuiFileDialog::Instance()->buttonEditPathString=_("Edit path\nYou can also right click on path buttons");
ImGuiFileDialog::Instance()->buttonResetPathString=_("Go to home directory");
ImGuiFileDialog::Instance()->buttonParentDirString=_("Go to parent directory");
ImGuiFileDialog::Instance()->buttonCreateDirString=_("Create Directory");
ImGuiFileDialog::Instance()->tableHeaderFileNameString=_("File name");
ImGuiFileDialog::Instance()->tableHeaderFileTypeString=_("Type");
ImGuiFileDialog::Instance()->tableHeaderFileSizeString=_("Size");
ImGuiFileDialog::Instance()->tableHeaderFileDateString=_("Date");
ImGuiFileDialog::Instance()->OverWriteDialogTitleString=_("Warning");
ImGuiFileDialog::Instance()->OverWriteDialogMessageString=_("The file you selected already exists! Would you like to overwrite it?");
ImGuiFileDialog::Instance()->OverWriteDialogConfirmButtonString=_("Yes");
ImGuiFileDialog::Instance()->OverWriteDialogCancelButtonString=_("No");
ImGuiFileDialog::Instance()->DateTimeFormat=_("%Y/%m/%d %H:%M");
ImGuiFileDialog::Instance()->okButtonString=_("OK");
ImGuiFileDialog::Instance()->cancelButtonString=_("Cancel");
ImGuiFileDialog::Instance()->searchString=_("Search");
ImGuiFileDialog::Instance()->dirEntryString=_("[Dir]");
ImGuiFileDialog::Instance()->linkEntryString=_("[Link]");
ImGuiFileDialog::Instance()->fileEntryString=_("[File]");
ImGuiFileDialog::Instance()->fileNameString=_("Name:");
ImGuiFileDialog::Instance()->dirNameString=_("Path:");
ImGuiFileDialog::Instance()->buttonResetSearchString=_("Reset search");
ImGuiFileDialog::Instance()->buttonDriveString=_("Drives");
ImGuiFileDialog::Instance()->buttonEditPathString=_("Edit path\nYou can also right click on path buttons");
ImGuiFileDialog::Instance()->buttonResetPathString=_("Go to home directory");
ImGuiFileDialog::Instance()->buttonParentDirString=_("Go to parent directory");
ImGuiFileDialog::Instance()->buttonCreateDirString=_("Create Directory");
ImGuiFileDialog::Instance()->tableHeaderFileNameString=_("File name");
ImGuiFileDialog::Instance()->tableHeaderFileTypeString=_("Type");
ImGuiFileDialog::Instance()->tableHeaderFileSizeString=_("Size");
ImGuiFileDialog::Instance()->tableHeaderFileDateString=_("Date");
ImGuiFileDialog::Instance()->OverWriteDialogTitleString=_("Warning");
ImGuiFileDialog::Instance()->OverWriteDialogMessageString=_("The file you selected already exists! Would you like to overwrite it?");
ImGuiFileDialog::Instance()->OverWriteDialogConfirmButtonString=_("Yes");
ImGuiFileDialog::Instance()->OverWriteDialogCancelButtonString=_("No");
ImGuiFileDialog::Instance()->DateTimeFormat=_("%Y/%m/%d %H:%M");
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeDir,"",uiColors[GUI_COLOR_FILE_DIR],ICON_FA_FOLDER_O);
ImGuiFileDialog::Instance()->SetFileStyle(IGFD_FileStyleByTypeFile,"",uiColors[GUI_COLOR_FILE_OTHER],ICON_FA_FILE_O);