mirror of
https://github.com/rememberber/MooTool.git
synced 2026-08-30 18:02:12 +08:00
Fix font rendering: use composite fonts with CJK fallback for all font selections
Replace new Font() with FontUtils.getCompositeFont() to ensure proper CJK character rendering when non-CJK fonts are selected in Quick Notes and JSON Beauty features. Agent-Logs-Url: https://github.com/rememberber/MooTool/sessions/3e5ca918-e592-42d2-abad-a7c5ae323ec4 Co-authored-by: rememberber <4653893+rememberber@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
3640bb8287
commit
0bc63263dc
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.luoboduner.moo.tool.ui.component.textviewer;
|
||||
|
||||
import com.formdev.flatlaf.util.FontUtils;
|
||||
import com.luoboduner.moo.tool.App;
|
||||
import com.luoboduner.moo.tool.ui.form.MainWindow;
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
@@ -40,7 +41,7 @@ public class JsonRSyntaxTextViewer extends CommonRSyntaxTextViewer {
|
||||
if (fontSize == 0) {
|
||||
fontSize = MainWindow.getInstance().getMainPanel().getFont().getSize() + 2;
|
||||
}
|
||||
Font font = new Font(fontName, Font.PLAIN, fontSize);
|
||||
Font font = FontUtils.getCompositeFont(fontName, Font.PLAIN, fontSize);
|
||||
setFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-10
@@ -153,16 +153,7 @@ public class QuickNoteRSyntaxTextViewer extends RSyntaxTextArea {
|
||||
if (fontSize == 0) {
|
||||
fontSize = getFont().getSize() + 2;
|
||||
}
|
||||
Font font;
|
||||
if (FlatJetBrainsMonoFont.FAMILY.equals(fontName)) {
|
||||
font = FontUtils.getCompositeFont(FlatJetBrainsMonoFont.FAMILY, Font.PLAIN, fontSize);
|
||||
}
|
||||
// else if (FlatInterFont.FAMILY.equals(fontName)) {
|
||||
// font = FontUtils.getCompositeFont(FlatInterFont.FAMILY, Font.PLAIN, fontSize);
|
||||
// }
|
||||
else {
|
||||
font = new Font(fontName, Font.PLAIN, fontSize);
|
||||
}
|
||||
Font font = FontUtils.getCompositeFont(fontName, Font.PLAIN, fontSize);
|
||||
setFont(font);
|
||||
}
|
||||
|
||||
|
||||
+2
-21
@@ -1,7 +1,6 @@
|
||||
package com.luoboduner.moo.tool.ui.component.textviewer;
|
||||
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.fonts.jetbrains_mono.FlatJetBrainsMonoFont;
|
||||
import com.formdev.flatlaf.util.FontUtils;
|
||||
import com.luoboduner.moo.tool.App;
|
||||
import com.luoboduner.moo.tool.dao.TQuickNoteMapper;
|
||||
@@ -43,16 +42,7 @@ public class QuickNoteRSyntaxTextViewerManager {
|
||||
plainTextViewer.setSyntaxEditingStyle(tQuickNote.getSyntax());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(tQuickNote.getFontName()) && StringUtils.isNotEmpty(tQuickNote.getFontSize())) {
|
||||
Font font;
|
||||
if (FlatJetBrainsMonoFont.FAMILY.equals(tQuickNote.getFontName())) {
|
||||
font = FontUtils.getCompositeFont(FlatJetBrainsMonoFont.FAMILY, Font.PLAIN, Integer.parseInt(tQuickNote.getFontSize()));
|
||||
}
|
||||
// else if (FlatInterFont.FAMILY.equals(tQuickNote.getFontName())) {
|
||||
// font = FontUtils.getCompositeFont(FlatInterFont.FAMILY, Font.PLAIN, Integer.parseInt(tQuickNote.getFontSize()));
|
||||
// }
|
||||
else {
|
||||
font = new Font(tQuickNote.getFontName(), Font.PLAIN, Integer.parseInt(tQuickNote.getFontSize()));
|
||||
}
|
||||
Font font = FontUtils.getCompositeFont(tQuickNote.getFontName(), Font.PLAIN, Integer.parseInt(tQuickNote.getFontSize()));
|
||||
plainTextViewer.setFont(font);
|
||||
}
|
||||
|
||||
@@ -76,16 +66,7 @@ public class QuickNoteRSyntaxTextViewerManager {
|
||||
QuickNoteRSyntaxTextViewer plainTextViewer = (QuickNoteRSyntaxTextViewer) rTextScrollPane.getTextArea();
|
||||
TQuickNote tQuickNote = quickNoteMapper.selectByName(name);
|
||||
if (StringUtils.isNotEmpty(tQuickNote.getFontName()) && StringUtils.isNotEmpty(tQuickNote.getFontSize())) {
|
||||
Font font;
|
||||
if (FlatJetBrainsMonoFont.FAMILY.equals(tQuickNote.getFontName())) {
|
||||
font = FontUtils.getCompositeFont(FlatJetBrainsMonoFont.FAMILY, Font.PLAIN, Integer.parseInt(tQuickNote.getFontSize()));
|
||||
}
|
||||
// else if (FlatInterFont.FAMILY.equals(tQuickNote.getFontName())) {
|
||||
// font = FontUtils.getCompositeFont(FlatInterFont.FAMILY, Font.PLAIN, Integer.parseInt(tQuickNote.getFontSize()));
|
||||
// }
|
||||
else {
|
||||
font = new Font(tQuickNote.getFontName(), Font.PLAIN, Integer.parseInt(tQuickNote.getFontSize()));
|
||||
}
|
||||
Font font = FontUtils.getCompositeFont(tQuickNote.getFontName(), Font.PLAIN, Integer.parseInt(tQuickNote.getFontSize()));
|
||||
plainTextViewer.setFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.luoboduner.moo.tool.ui.listener.func;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.json.JSONConfig;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.formdev.flatlaf.fonts.jetbrains_mono.FlatJetBrainsMonoFont;
|
||||
import com.formdev.flatlaf.util.FontUtils;
|
||||
import com.formdev.flatlaf.util.SystemFileChooser;
|
||||
import com.luoboduner.moo.tool.App;
|
||||
@@ -170,12 +169,7 @@ public class JsonBeautyListener {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
String fontName = e.getItem().toString();
|
||||
int fontSize = Integer.parseInt(jsonBeautyForm.getFontSizeComboBox().getSelectedItem().toString());
|
||||
Font font;
|
||||
if (FlatJetBrainsMonoFont.FAMILY.equals(fontName)) {
|
||||
font = FontUtils.getCompositeFont(FlatJetBrainsMonoFont.FAMILY, Font.PLAIN, fontSize);
|
||||
} else {
|
||||
font = new Font(fontName, Font.PLAIN, fontSize);
|
||||
}
|
||||
Font font = FontUtils.getCompositeFont(fontName, Font.PLAIN, fontSize);
|
||||
jsonBeautyForm.getTextArea().setFont(font);
|
||||
|
||||
App.config.setJsonBeautyFontName(fontName);
|
||||
@@ -189,12 +183,7 @@ public class JsonBeautyListener {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
int fontSize = Integer.parseInt(e.getItem().toString());
|
||||
String fontName = jsonBeautyForm.getFontNameComboBox().getSelectedItem().toString();
|
||||
Font font;
|
||||
if (FlatJetBrainsMonoFont.FAMILY.equals(fontName)) {
|
||||
font = FontUtils.getCompositeFont(FlatJetBrainsMonoFont.FAMILY, Font.PLAIN, fontSize);
|
||||
} else {
|
||||
font = new Font(fontName, Font.PLAIN, fontSize);
|
||||
}
|
||||
Font font = FontUtils.getCompositeFont(fontName, Font.PLAIN, fontSize);
|
||||
jsonBeautyForm.getTextArea().setFont(font);
|
||||
|
||||
App.config.setJsonBeautyFontName(fontName);
|
||||
|
||||
Reference in New Issue
Block a user