impr: Make text look super pretty on macOS finally
This commit is contained in:
parent
1605904eb1
commit
bf6f738d2e
@ -26,7 +26,7 @@ namespace hex {
|
|||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_FALSE);
|
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_TRUE);
|
||||||
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, GLFW_TRUE);
|
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, GLFW_TRUE);
|
||||||
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
|
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE);
|
||||||
}
|
}
|
||||||
@ -96,6 +96,9 @@ namespace hex {
|
|||||||
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
||||||
win->fullFrame();
|
win->fullFrame();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Done to get super crisp font rendering together with GLFW_COCOA_RETINA_FRAMEBUFFER
|
||||||
|
ImGui::GetIO().FontGlobalScale = 1.0F / getBackingScaleFactor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::beginNativeWindowFrame() {
|
void Window::beginNativeWindowFrame() {
|
||||||
|
@ -81,6 +81,13 @@ namespace hex::fonts {
|
|||||||
ImFontConfig config = m_config;
|
ImFontConfig config = m_config;
|
||||||
config.FontDataOwnedByAtlas = false;
|
config.FontDataOwnedByAtlas = false;
|
||||||
|
|
||||||
|
// Since macOS reports half the framebuffer size that's actually available,
|
||||||
|
// we'll multiply all font sizes by that and then divide the global font scale
|
||||||
|
// by the same amount to get super crisp font rendering.
|
||||||
|
#if defined(OS_MACOS)
|
||||||
|
fontSize *= getBackingScaleFactor();
|
||||||
|
#endif
|
||||||
|
|
||||||
config.GlyphOffset = { offset.x, offset.y };
|
config.GlyphOffset = { offset.x, offset.y };
|
||||||
auto font = m_fontAtlas->AddFontFromMemoryTTF(storedFontData.data(), int(storedFontData.size()), fontSize, &config, !glyphRange.empty() ? glyphRange.Data : m_glyphRange.Data);
|
auto font = m_fontAtlas->AddFontFromMemoryTTF(storedFontData.data(), int(storedFontData.size()), fontSize, &config, !glyphRange.empty() ? glyphRange.Data : m_glyphRange.Data);
|
||||||
m_fontSizes.emplace_back(scalable, fontSize);
|
m_fontSizes.emplace_back(scalable, fontSize);
|
||||||
@ -322,7 +329,7 @@ namespace hex::fonts {
|
|||||||
if (pixelPerfectFont)
|
if (pixelPerfectFont)
|
||||||
defaultFont = fontAtlas.addDefaultFont();
|
defaultFont = fontAtlas.addDefaultFont();
|
||||||
else
|
else
|
||||||
defaultFont = fontAtlas.addFontFromRomFs("fonts/JetBrainsMono.ttf", 16, true, ImVec2());
|
defaultFont = fontAtlas.addFontFromRomFs("fonts/JetBrainsMono.ttf", 14, true, ImVec2());
|
||||||
|
|
||||||
if (!fontAtlas.build()) {
|
if (!fontAtlas.build()) {
|
||||||
log::fatal("Failed to load default font!");
|
log::fatal("Failed to load default font!");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user