-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UI] Changed default Windows font & Allow loading custom font #2135
base: master
Are you sure you want to change the base?
Conversation
Gliniak
commented
Feb 25, 2023
•
edited
Loading
edited
- Changed font on Windows to tahoma
- Allowed loading Greek and Cyrillic glyphs
- Unified font size to 12. This causes default UI to look a bit bigger
- Set oversample to 2 to make font more readable (especially custom fonts)
cd3180b
to
bef4e5d
Compare
Hello! |
Sure (at least on windows), do you know font that looks good and support these glyphs? |
SegoeUI, Arial, Times New Roman. |
Not sure what's a better idea there. |
What if bundle with emulator some free nice looking font as default, for example Koruri, it could be big - size is an issue? |
Brilliant! Thank you very much!!! |
src/xenia/ui/imgui_drawer.cc
Outdated
PWSTR fonts_dir; | ||
HRESULT result = SHGetKnownFolderPath(FOLDERID_Fonts, 0, NULL, &fonts_dir); | ||
if (FAILED(result)) { | ||
CoTaskMemFree(static_cast<void*>(fonts_dir)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fonts_dir
would likely (though I'm not entirely sure about this specific case, of course) only be initialized if the function has succeeded, this freeing may cause a crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath
The calling process is responsible for freeing this resource once it is no longer needed by calling [CoTaskMemFree](https://learn.microsoft.com/en-us/windows/desktop/api/combaseapi/nf-combaseapi-cotaskmemfree), whether SHGetKnownFolderPath succeeds or not
src/xenia/ui/imgui_drawer.cc
Outdated
font_path = std::wstring(fonts_dir); | ||
CoTaskMemFree(static_cast<void*>(fonts_dir)); | ||
#endif | ||
font_path.append(font_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A blank line above this line would make the code visually more structured.
src/xenia/ui/imgui_drawer.cc
Outdated
0, | ||
}; | ||
|
||
const std::filesystem::path ImGuiDrawer::GetWindowsFont(std::string font_name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might have been more platform-independent as other operating systems also have their own font storages, and possibly accepting the name (family, weight, italic, etc. possibly) of the font with the necessary lookups in the OS rather than directly the file name. The fallback behavior is also pretty non-obvious in this function. On Windows, it returns an empty path if it has failed to obtain the system fonts directory. However, on other platforms, it just silently tries to get the path from the working directory instead.
src/xenia/ui/imgui_drawer.cc
Outdated
const std::filesystem::path font_path = GetWindowsFont("tahoma.ttf"); | ||
if (!std::filesystem::exists(font_path)) { | ||
XELOGW( | ||
"Unable to find tahoma font in Windows fonts directory. Switching to " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tahoma → Tahoma
- Unified font size to 12. This causes default UI to look a bit bigger - Set oversample to 2 to make font more readable (especially custom fonts)