FlatLaf in WinPE
See original GitHub issueMy testing app, which uses FlatLaf, is also run within WinPE.
I have noticed some quirks in WinPE which affect FlatLaf. Since this has been such a minor issue with an easy fix on my side (as well as a pretty rare use-case), I haven’t bothered filing a report about this stuff up until now.
If dealing with WinPE, is outside of your scope, I totally understand that.
The following comments about the frame and font issues are also within the code block (which I use in my app) that I have included below. There may be more efficient ways of checking for WinPE that I am not aware of as well.
Decorated Frame Issue: In WinPE, FlatLaf Decorated window looks funky (the default left, right, and bottom frames are still shown) and is unnecessary since the default style fits in better with WinPE than the Win 10 Decorated style. NOTE: Prior to FlatLaf 1.1, the whole Decorated frame was drawn correctly, but if the windows was minimized, it could not be restored back from the bottom of the screen when clicking the restore button in the titlebar. I double checked that behavior with FlatLaf 1.1 and that is no longer an issue. I suspect your recent work with a more with the native Decorated titlebar is what fixed that. Still, the default Windows style fits in better in WinPE.
Default Font Issue: The regular “Segoe” system font is not included by default (only bold and italic “Segoe” is included in WinPE), so font Font.PLAIN (when using “Segoe” system font) is rendered as bold, making all text bold. My solution has been to use “Tahoma” in WinPE instead since it is included by default, and looks good. It is possible to install “segoeui.ttf” into "\Windows\Fonts" in WinPE, but when I tried this it didn’t really render very well in WinPE, regular text still looked slightly bold and a little off and “Tahoma” looks better than “Segoe” did. “Microsoft Sans Serif” is also available in WinPE, and doesn’t look too bad, but I liked the look of “Tahoma” better (notaably the kerning and letter spacing of bold text).
I will try to grab some screenshots of these issues later today to show you if you don’t have easy access to WinPE.
if (isWindows) {
Boolean isWindowsPE = ((new File("\\Windows\\System32\\startnet.cmd").exists() || new File("\\Windows\\System32\\winpeshl.ini").exists()) && !new CommandReader("reg query HKLM\\SYSTEM\\Setup /v FactoryPreInstallInProgress").getFirstOutputLineContaining("0x1").isEmpty());
if (isWindowsPE) {
// In WinPE, FlatLaf Decorated window looks funky (the default left, right, and bottom frames are still shown) and is unnecessary since the default style fits in better with WinPE than the Win 10 Decorated style.
UIManager.put("TitlePane.useWindowDecorations", false);
if ((defaultFont == null) || !defaultFont.getFamily().equals("Tahoma")) {
if (new File("\\Windows\\Fonts\\tahoma.ttf").exists()) {
// Use "Tahoma" in WinPE because the regular "Segoe" system font is not included by default (only bold and italic "Segoe" is included in WinPE), so font Font.PLAIN (when using "Segoe" system font) is rendered as bold, making all text bold.
// It is possible to install "segoeui.ttf" into "\Windows\Fonts\" in WinPE, but when I tried this it didn't really render very well in WinPE, regular text still looked slightly bold and a little off and "Tahoma" looks better than "Segoe" did.
// "Microsoft Sans Serif" is also available in WinPE, and doesn't look too bad, but I liked the look of "Tahoma" better (notaably the kerning and letter spacing of bold text).
defaultFont = StyleContext.getDefaultStyleContext().getFont("Tahoma", ((defaultFont == null) ? Font.PLAIN : defaultFont.getStyle()), ((defaultFont == null) ? 12 : defaultFont.getSize()));
} else if (defaultFont != null) {
// If somehow "Tahoma" isn't available in WinPE (which should never actually happen), set default font to Font.ITALIC so there it at least some differentiation between intentionally bolded and "regular" text (which will now be italic).
defaultFont = StyleContext.getDefaultStyleContext().getFont(defaultFont.getFamily(), Font.ITALIC, defaultFont.getSize());
}
}
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:11
Thanks for the feedback. I’ve changed it in main branch.
Thx for the info.
FlatLaf now uses
win.defaultGUI.font
on WinPE, which is BTW the same desktop property that the Java Windows L&F uses.Implemented in main branch and available in latest snapshot: https://github.com/JFormDesigner/FlatLaf#snapshots
FlatLaf 1.1.1 release follows the next days… Thanks.