Browse Source

REPORT-61207 引导相关字体显示不对且被截断

new-design
kuangshuai 3 years ago
parent
commit
6d1ffd15fa
  1. 21
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideLoadingGlassPane.java
  3. 25
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java
  4. 28
      designer-base/src/main/java/com/fr/design/mainframe/guide/utils/GuideUIUtils.java

21
designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java

@ -7,6 +7,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.guide.utils.GuideUIUtils;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.general.IOUtils;
@ -14,9 +15,7 @@ import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.SwingConstants;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
@ -37,9 +36,9 @@ public class GuideCompleteDialog extends JDialog {
private static final int ICON_HEIGHT = 182;
private static final Color FONT_COLOR = new Color(51, 51, 52);
private static final Color BUTTON_BG_COLOR = new Color(65, 155,249);
private static final Font TITLE_FONT = new Font(Font.SANS_SERIF, Font.BOLD, 22);
private static final Font CONTENT_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 18);
private static final Font BUTTON_FONT = new Font(Font.SANS_SERIF, Font.BOLD, 14);
private static final Font TITLE_FONT = new Font("Default", Font.BOLD, 22);
private static final Font CONTENT_FONT = new Font("Default", Font.PLAIN, 18);
private static final Font BUTTON_FONT = new Font("Default", Font.BOLD, 14);
private static GuideCompleteDialog dialog;
public static GuideCompleteDialog getInstance() {
@ -78,12 +77,11 @@ public class GuideCompleteDialog extends JDialog {
title.setForeground(FONT_COLOR);
textArea = new UITextPane();
changeLineSpacing(textArea, 0.15f,false);
textArea.setFont(CONTENT_FONT);
GuideUIUtils.setTextPaneLineHeight(textArea, 26);
textArea.setEnabled(false);
textArea.setOpaque(false);
textArea.setFont(CONTENT_FONT);
textArea.setPreferredSize(new Dimension(236, 52));
textArea.setBorder(null);
textArea.setDisabledTextColor(FONT_COLOR);
StyledDocument doc = textArea.getStyledDocument();
SimpleAttributeSet center = new SimpleAttributeSet();
@ -141,11 +139,4 @@ public class GuideCompleteDialog extends JDialog {
}
}
};
private void changeLineSpacing(JTextPane pane, float factor, boolean replace) {
pane.selectAll();
MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes());
StyleConstants.setLineSpacing(set, factor);
pane.setParagraphAttributes(set, replace);
}
}

2
designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideLoadingGlassPane.java

@ -40,7 +40,7 @@ public class GuideLoadingGlassPane extends JPanel {
imageContainer.add(GuideLoadingPane.getInstance());
UILabel hintLabel = new UILabel(Toolkit.i18nText("Fine-Design_Guide_Loading_Wait"));
hintLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14));
hintLabel.setFont(new Font("Default", Font.PLAIN, 14));
hintLabel.setHorizontalAlignment(SwingConstants.CENTER);
hintLabel.setForeground(Color.WHITE);

25
designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java

@ -4,12 +4,12 @@ package com.fr.design.mainframe.guide.ui.bubble;
import com.fr.base.GraphHelper;
import com.fr.design.gui.frpane.UITextPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.guide.utils.GuideUIUtils;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import javax.swing.Icon;
import javax.swing.JTextPane;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
@ -32,8 +32,8 @@ import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
public class BubbleWithClose extends Bubble {
private static final Font TITLE_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 14);
private static final Font CONTENT_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
private static final Font TITLE_FONT = new Font("Default", Font.PLAIN, 14);
private static final Font CONTENT_FONT = new Font("Default", Font.PLAIN, 12);
private static final int TITLE_LINE_HEIGHT = 22;
private static final int CONTENT_LINE_HEIGHT = 18;
@ -157,33 +157,18 @@ public class BubbleWithClose extends Bubble {
}
private UITextPane createTextArea(String str, Font font, int lineHeight, Color foreground) {
int lineSpace = lineHeight - font.getSize();
UITextPane textArea= new UITextPane(){
@Override
public Insets getInsets() {
return new Insets(lineSpace / 2 - 1, 0, lineSpace / 2, 0);
}
};
UITextPane textArea= new UITextPane();
textArea.setFont(font);
changeLineSpacing(textArea, lineHeight, true);
GuideUIUtils.setTextPaneLineHeight(textArea, lineHeight);
textArea.setEditable(false);
textArea.setForeground(foreground);
textArea.setDisabledTextColor(foreground);
textArea.setBorder(null);
textArea.setOpaque(false);
textArea.setText(str);
highlightText(textArea);
return textArea;
}
private void changeLineSpacing(JTextPane pane, int lineHeight, boolean replace) {
pane.selectAll();
MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes());
FontMetrics fontMetrics = GraphHelper.getFontMetrics(pane.getFont());
StyleConstants.setLineSpacing(set, (float)(lineHeight - fontMetrics.getHeight()) / fontMetrics.getHeight());
pane.setParagraphAttributes(set, replace);
}
private void highlightText(JTextPane textArea) {
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setForeground(sas, HIGHLIGHT_COLOR);

28
designer-base/src/main/java/com/fr/design/mainframe/guide/utils/GuideUIUtils.java

@ -0,0 +1,28 @@
package com.fr.design.mainframe.guide.utils;
import com.fr.base.GraphHelper;
import javax.swing.BorderFactory;
import javax.swing.JTextPane;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import java.awt.FontMetrics;
import java.awt.Insets;
public class GuideUIUtils {
public static void setTextPaneLineHeight(JTextPane pane, int lineHeight) {
pane.selectAll();
pane.setMargin(new Insets(0,0,0,0));
MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes());
FontMetrics fontMetrics = GraphHelper.getFontMetrics(pane.getFont());
int delta = (lineHeight - fontMetrics.getHeight()) / 2 * 2 ;
if (delta > 0) {
StyleConstants.setLineSpacing(set, delta/ 2.0f / fontMetrics.getHeight());
pane.setParagraphAttributes(set, false);
int dis = fontMetrics.getDescent() - fontMetrics.getLeading();
int marginTop = dis > 0 ? ((delta - dis) / 2 + dis) : ((delta - dis) / 2);
pane.setBorder(BorderFactory.createEmptyBorder(marginTop, 0,0,0));
}
}
}
Loading…
Cancel
Save