Skip to content

Commit 9e109ac

Browse files
committed
chore: resolve 5 pre-merge issues from code review
1 parent e313bd6 commit 9e109ac

7 files changed

Lines changed: 48 additions & 12 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ endif()
140140

141141
if(UNIX AND NOT APPLE)
142142
find_package(GLEW REQUIRED)
143+
find_package(OpenSSL REQUIRED)
143144
target_include_directories(${PROJECT_NAME}
144145
SYSTEM PRIVATE ${minizip_ng_SOURCE_DIR}
145146
)
@@ -150,6 +151,7 @@ if(UNIX AND NOT APPLE)
150151
GLEW::GLEW
151152
CURL::libcurl
152153
minizip
154+
OpenSSL::Crypto
153155
)
154156
elseif(APPLE)
155157
find_library(COCOA_LIBRARY Cocoa REQUIRED)

src/components/titlebar.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,3 @@ bool RenderTitleBarComponent(std::shared_ptr<RouterNav> router)
229229

230230
return IsItemHovered() || (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) && IsMouseDown(ImGuiMouseButton_Left));
231231
}
232-
233-
void RenderLanguageSelector(float xPos)
234-
{
235-
}

src/include/components.h

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/routes/home.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,6 @@ const void RenderHome(std::shared_ptr<RouterNav> router, float xPos)
173173
const int ContainerSpacing = ScaleX(30);
174174
const int ContainerWidth = (viewport->Size.x - ScaleX(100)) / 2;
175175

176-
// Language selector is part of the home screen — slides with the panel.
177-
RenderLanguageSelector(xPos);
178-
179176
PushStyleColor(ImGuiCol_Border, ImVec4(0.169f, 0.173f, 0.18f, 1.0f));
180177

181178
SetCursorPos({ xPos + (viewport->Size.x - ((ContainerWidth * 2) + ContainerSpacing)) / 2, ((viewport->Size.y - BottomNavBarHeight) / 2.0f) - ContainerHeight / 2.0f });

src/routes/install_prompt.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ const void RenderInstallPrompt(std::shared_ptr<RouterNav> router, float xPos)
331331
PushStyleColor(ImGuiCol_Text, ImVec4(0.422f, 0.425f, 0.441f, 1.0f));
332332

333333
std::string currentTag = selectedRelease.contains("tag_name") ? selectedRelease["tag_name"].get<std::string>() : std::string("(none)");
334-
Text(Locale::Get("installVersion"), currentTag.c_str());
334+
{ char buf[512]; snprintf(buf, sizeof(buf), Locale::Get("installVersion"), currentTag.c_str()); Text("%s", buf); }
335335
SameLine(0, ScaleX(5));
336336

337337
const char* changeText = Locale::Get("installChangeVersion");
@@ -406,10 +406,10 @@ const void RenderInstallPrompt(std::shared_ptr<RouterNav> router, float xPos)
406406
if (installSizeStr.empty()) {
407407
Text("%s", Locale::Get("installSizeNA"));
408408
} else {
409-
Text(Locale::Get("installSizeMB"), stof(installSizeStr) / (1024.0f * 1024.0f));
409+
{ char buf[256]; snprintf(buf, sizeof(buf), Locale::Get("installSizeMB"), stof(installSizeStr) / (1024.0f * 1024.0f)); Text("%s", buf); }
410410
}
411411

412-
Text(Locale::Get("installDownloadMB"), osReleaseInfo.contains("size") ? osReleaseInfo["size"].get<float>() / (1024.0f * 1024.0f) : 0.0f);
412+
{ char buf[256]; snprintf(buf, sizeof(buf), Locale::Get("installDownloadMB"), osReleaseInfo.contains("size") ? osReleaseInfo["size"].get<float>() / (1024.0f * 1024.0f) : 0.0f); Text("%s", buf); }
413413

414414
PopStyleColor();
415415
}

src/routes/installer.cc

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,41 @@ bool VerifyDownloadSignature(const std::string& file, const std::string& expecte
170170
return success;
171171
}
172172
#else
173-
static bool VerifyDownloadSignature(const std::string&, const std::string&) { return true; }
173+
#include <openssl/evp.h>
174+
#include <cstdio>
175+
176+
static bool VerifyDownloadSignature(const std::string& filePath, const std::string& expectedHex)
177+
{
178+
FILE* f = fopen(filePath.c_str(), "rb");
179+
if (!f) return false;
180+
181+
EVP_MD_CTX* ctx = EVP_MD_CTX_new();
182+
if (!ctx) { fclose(f); return false; }
183+
184+
bool success = false;
185+
if (EVP_DigestInit_ex(ctx, EVP_sha256(), nullptr)) {
186+
unsigned char buf[65536];
187+
size_t n;
188+
bool ok = true;
189+
while ((n = fread(buf, 1, sizeof(buf), f)) > 0) {
190+
if (!EVP_DigestUpdate(ctx, buf, n)) { ok = false; break; }
191+
}
192+
if (ok && !ferror(f)) {
193+
unsigned char hash[EVP_MAX_MD_SIZE];
194+
unsigned int hashLen = 0;
195+
if (EVP_DigestFinal_ex(ctx, hash, &hashLen)) {
196+
char hexStr[65] = {};
197+
for (unsigned int i = 0; i < hashLen; i++)
198+
snprintf(hexStr + i * 2, 3, "%02x", hash[i]);
199+
success = (expectedHex == hexStr);
200+
}
201+
}
202+
}
203+
204+
EVP_MD_CTX_free(ctx);
205+
fclose(f);
206+
return success;
207+
}
174208
#endif
175209

176210
TaskScheduler::TaskResult DownloadReleaseAssets(std::unique_ptr<double>& progress, const nlohmann::json& releaseInfo, const nlohmann::json& osReleaseInfo)

src/window/renderer.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ void SetupImGuiScaling(GLFWwindow* window)
112112
ImFontConfig mem_cfg;
113113
mem_cfg.FontDataOwnedByAtlas = false;
114114

115+
#ifdef _WIN32
116+
constexpr static const auto fontPath = "C:/Windows/Fonts/seguiemj.ttf";
117+
static ImFontConfig cfg;
118+
cfg.MergeMode = true;
119+
cfg.FontLoaderFlags |= ImGuiFreeTypeLoaderFlags_LoadColor;
120+
#endif
121+
115122
// ── CJK embedded name-only fonts ─────────────────────────────────────────
116123
// Always merged: tiny subsets (~21 KB total) covering only the characters
117124
// used in language-selector display names (简体中文 繁體中文 日本語 한국어).
@@ -377,6 +384,7 @@ void SetupImGuiScaling(GLFWwindow* window)
377384

378385
/** Explicitly set FreeType as the font loader to ensure color emoji support */
379386
io.Fonts->SetFontLoader(ImGuiFreeType::GetFontLoader());
387+
io.Fonts->Build();
380388

381389
io.DisplayFramebufferScale = ImVec2(scaleFactor, scaleFactor);
382390

0 commit comments

Comments
 (0)