-
Notifications
You must be signed in to change notification settings - Fork 912
添加了字体缩放功能 #6437
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
添加了字体缩放功能 #6437
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1197,24 +1197,39 @@ protected Node createRightNode() { | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| HBox hBox = new HBox(); | ||||||||||||||||||||||||||||
| hBox.setSpacing(8); | ||||||||||||||||||||||||||||
| hBox.setSpacing(3); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| FontComboBox cboFont = new FontComboBox(); | ||||||||||||||||||||||||||||
| cboFont.setValue(settings().launcherFontFamilyProperty().get()); | ||||||||||||||||||||||||||||
| FXUtils.onChange(cboFont.valueProperty(), FontManager::setFontFamily); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| JFXTextField txtFontSize = new JFXTextField(); | ||||||||||||||||||||||||||||
| FXUtils.setLimitWidth(txtFontSize, 50); | ||||||||||||||||||||||||||||
| FXUtils.bind(txtFontSize, settings().launcherFontSizeProperty(), SafeStringConverter.fromFiniteDouble() | ||||||||||||||||||||||||||||
| .restrict(it -> it > 0) | ||||||||||||||||||||||||||||
| .fallbackTo(FontManager.DEFAULT_FONT_SIZE) | ||||||||||||||||||||||||||||
| .asPredicate(Validator.addTo(txtFontSize))); | ||||||||||||||||||||||||||||
|
Comment on lines
+1208
to
+1211
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 字体大小的输入限制仅为
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| JFXButton clearButton = FXUtils.newToggleButton4(SVG.RESTORE); | ||||||||||||||||||||||||||||
| clearButton.setOnAction(e -> cboFont.setValue(null)); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| FXUtils.installFastTooltip(clearButton, i18n("button.reset")); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| hBox.getChildren().setAll(cboFont, clearButton); | ||||||||||||||||||||||||||||
| hBox.getChildren().setAll(cboFont, txtFontSize, clearButton); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| borderPane.setRight(hBox); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| vbox.getChildren().add(new Label("Hello Minecraft! Launcher")); | ||||||||||||||||||||||||||||
| Label lblFontDisplay = new Label("Hello Minecraft! Launcher"); | ||||||||||||||||||||||||||||
| lblFontDisplay.fontProperty().bind(Bindings.createObjectBinding( | ||||||||||||||||||||||||||||
| () -> Font.font( | ||||||||||||||||||||||||||||
| Lang.requireNonNullElse(settings().launcherFontFamilyProperty().get(), | ||||||||||||||||||||||||||||
| Font.getDefault().getFamily()), | ||||||||||||||||||||||||||||
| settings().launcherFontSizeProperty().get()), | ||||||||||||||||||||||||||||
| settings().launcherFontFamilyProperty(), settings().launcherFontSizeProperty())); | ||||||||||||||||||||||||||||
|
Comment on lines
+1225
to
+1230
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 预览标签
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| vbox.getChildren().add(lblFontDisplay); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| fontPane.getContent().add(vbox); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,6 +138,9 @@ | |
| "launcherFontFamily": { | ||
| "type": "string" | ||
| }, | ||
| "launcherFontSize": { | ||
| "type": "number" | ||
| }, | ||
|
Comment on lines
+141
to
+143
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| "windowTransparent": { | ||
| "type": "boolean" | ||
| }, | ||
|
|
||
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.
防御性编程:如果用户手动编辑
launcher-settings.json并将launcherFontSize设置为无效值(例如<= 0、NaN或无穷大),可能会生成无效的 CSS,从而导致渲染问题或解析器错误。建议在生成样式表之前对字体大小进行有效性校验,若无效则回退到默认值。