From 3308ee1d2de270dfd406257122a73bf2f7f33e96 Mon Sep 17 00:00:00 2001 From: weisj Date: Sat, 23 May 2020 16:44:39 +0200 Subject: [PATCH] Updated change notes. Use newer nio.files functions in CreateUITable. Improved font loading. --- change_notes.md | 3 ++- .../weisj/darklaf/properties/font.properties | 14 +++++++------- .../weisj/darklaf/properties/font_sizes.properties | 4 +++- .../src/test/java/documentation/CreateUITable.java | 6 ++++-- .../com/github/weisj/darklaf/PropertyLoader.java | 14 +++++++++++--- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/change_notes.md b/change_notes.md index 5f4136f9..df653cdc 100644 --- a/change_notes.md +++ b/change_notes.md @@ -6,13 +6,14 @@ - Balloons tooltips are now enabled by default for buttons. - Improved html style sheet. - On Windows (Vista and later) darklaf will now use the system font. +- Better interoperability with custom cell renderers. - Improved selection painting. - Added property to control whether the selection is extended to the end of the text component. ````java textComp.putClientProperty(DarkTextUI.KEY_EXTEND_LINE_SELECTION, enabled); ```` - Performance improvements. -- New scrollbar appearance on macOS that more closely resembles the system appearance. +- New scrollbar appearance on macOS that resembles the system appearance more closely. - Added rounded button variant. ````java button.putClientProperty(DarkButtonUI.KEY_ROUND, true); diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/font.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/font.properties index 5dc106b8..a0908962 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/font.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/font.properties @@ -47,10 +47,10 @@ ProgressBar.font = withSize(%fontSize.default)withStyle(0) RadioButton.font = withSize(%fontSize.default)withStyle(0) RadioButtonMenuItem.font = withSize(%fontSize.default)withStyle(0) ScrollPane.font = withSize(%fontSize.default)withStyle(0) -Slider.font = withSize(%fontSize.default, -2)withStyle(0) +Slider.font = withSize(%fontSize.default,-2)withStyle(0) Spinner.font = withSize(%fontSize.default)withStyle(0) TabbedPane.font = withSize(%fontSize.default)withStyle(0) -TabFrameTab.font = from(Label.font)withSize(%fontSize.default,-1)withStyle(0) +TabFrameTab.font = from(Label.font)withSize(%fontSize.title)withStyle(0) Table.font = withSize(%fontSize.default)withStyle(0) TableHeader.font = withSize(%fontSize.default)withStyle(0) TextArea.font = withSize(%fontSize.default)withStyle(0) @@ -62,8 +62,8 @@ ToolBar.font = withSize(%fontSize.default)withStyle(0) ToolTip.font = withSize(%fontSize.default)withStyle(0) Tree.font = withSize(%fontSize.default)withStyle(0) Viewport.font = withSize(%fontSize.default)withStyle(0) -MenuItem.acceleratorFont = withSize(%fontSize.default,-2)withStyle(0) -RadioButtonMenuItem.acceleratorFont = withSize(%fontSize.default,-2)withStyle(0) -Menu.acceleratorFont = withSize(%fontSize.default,-2)withStyle(0) -CheckBoxMenuItem.acceleratorFont = withSize(%fontSize.default,-2)withStyle(0) -InternalFrame.titleFont = withSize(%fontSize.default,-1)withStyle(0) +MenuItem.acceleratorFont = withSize(%fontSize.accelerator)withStyle(0) +RadioButtonMenuItem.acceleratorFont = withSize(%fontSize.accelerator)withStyle(0) +Menu.acceleratorFont = withSize(%fontSize.accelerator)withStyle(0) +CheckBoxMenuItem.acceleratorFont = withSize(%fontSize.accelerator)withStyle(0) +InternalFrame.titleFont = withSize(%fontSize.title)withStyle(0) diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/font_sizes.properties b/core/src/main/resources/com/github/weisj/darklaf/properties/font_sizes.properties index 99754004..983c4591 100644 --- a/core/src/main/resources/com/github/weisj/darklaf/properties/font_sizes.properties +++ b/core/src/main/resources/com/github/weisj/darklaf/properties/font_sizes.properties @@ -24,4 +24,6 @@ # # suppress inspection "UnusedProperty" for whole file # -fontSize.default = 12 +fontSize.default = 12 +fontSize.accelerator = 10 +fontSize.title = 11 diff --git a/core/src/test/java/documentation/CreateUITable.java b/core/src/test/java/documentation/CreateUITable.java index 57eff0b5..a29581a6 100644 --- a/core/src/test/java/documentation/CreateUITable.java +++ b/core/src/test/java/documentation/CreateUITable.java @@ -29,6 +29,7 @@ import java.awt.image.BufferedImage; import java.io.*; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.Map; import java.util.Set; import java.util.regex.Matcher; @@ -73,8 +74,8 @@ public class CreateUITable { workingFolder = FOLDER + theme.getPrefix() + "/"; String os = SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux"; String htmlFile = workingFolder + "defaults_" + os + ".html"; - new File(workingFolder).mkdirs(); - new File(htmlFile).createNewFile(); + Files.createDirectories(new File(workingFolder).toPath()); + Files.createFile(new File(htmlFile).toPath()); try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(htmlFile), StandardCharsets.UTF_8)) { @@ -90,6 +91,7 @@ public class CreateUITable { private String createTables(final Theme theme, final int ident) { UIDefaults defaults = setupThemeDefaults(theme); + defaults.entrySet().stream().filter(e -> e.getValue() instanceof Font).forEach(System.out::println); String misc = "__Misc__"; diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java b/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java index e6ccb06c..70d724cf 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java @@ -301,14 +301,22 @@ public final class PropertyLoader { } else { break; } + if (val.isEmpty()) break; } if (base == null) base = parseExplicitFont(value); if (base == null && accumulator.get(key) instanceof Font) base = (Font) accumulator.get(key); if (base == null) base = currentDefaults.getFont(key); if (base == null) base = new Font(null, Font.PLAIN, 12); - if (size > 0) base = base.deriveFont((float) size); - if (style >= 0) base = base.deriveFont(style); - return new DarkFontUIResource(base.deriveFont(attributes)); + if (size <= 0) size = base.getSize(); + if (style < 0) style = base.getStyle(); + Font font = base.deriveFont(style).deriveFont((float) size); + font = new DarkFontUIResource(font.deriveFont(attributes)); + if (size != font.getSize()) { + throw new IllegalStateException("Font Sizes are not equal. Expected " + size + " but got " + + font.getSize()); + } + assert base.getSize() == font.getSize(); + return font; } private static Font parseExplicitFont(final String value) {