From 26955702ee050dc73321f29bd2ececef97983e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Tue, 24 Sep 2024 20:23:38 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-130379=20fix:NewUI=E5=AF=8C=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E7=BC=96=E8=BE=91=E5=99=A8=E5=AD=97=E4=BD=93=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/report/RichTextEditingPane.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java b/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java index 39061a4b6d..12efcceab6 100644 --- a/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java @@ -14,12 +14,14 @@ import com.fr.log.FineLoggerFactory; import com.fr.report.cell.cellattr.core.RichText; import com.fr.report.cell.cellattr.core.RichTextConverter; +import java.awt.Font; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultHighlighter; +import javax.swing.text.DefaultStyledDocument; import javax.swing.text.Element; import javax.swing.text.Highlighter; import javax.swing.text.StyledDocument; @@ -27,6 +29,8 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import static com.formdev.flatlaf.util.UIScale.scale; + /** * 富文本的编辑区域 * @@ -50,6 +54,22 @@ public class RichTextEditingPane extends UITextPane{ public RichTextEditingPane() { this.addMouseListener(doubleClickFormulaListener); this.addFocusListener(focusListener); + setDocument(new ScaledStyledDocument()); + } + + /** + * 支持字体缩放的Document对象 + */ + public static class ScaledStyledDocument extends DefaultStyledDocument { + + @Override + public Font getFont(AttributeSet a) { + Font font = super.getFont(a); + if (font != null) { + return font.deriveFont(font.getStyle(), scale(font.getSize())); + } + return null; + } } /**