From: James Procter Date: Thu, 23 Feb 2023 11:58:09 +0000 (+0000) Subject: JAL-4133 update validChar width when font is changed so characters are suppressed... X-Git-Tag: Release_2_11_3_0~18^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=cfea32f10dfe5cde2b5223d8a6c1c26280ac0185;p=jalview.git JAL-4133 update validChar width when font is changed so characters are suppressed for small widths --- diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index e545776..2d057bb 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -229,6 +229,9 @@ public class AlignmentPanel extends GAlignmentPanel implements // set idCanvas bufferedImage to null // to prevent drawing old image FontMetrics fm = getFontMetrics(av.getFont()); + + // update the flag controlling whether the grid is too small to render the font + av.validCharWidth = fm.charWidth('M') <= av.getCharWidth(); scalePanelHolder.setPreferredSize( new Dimension(10, av.getCharHeight() + fm.getDescent())); diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index 8142435..14803df 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -26,6 +26,7 @@ import static jalview.math.RotatableMatrix.Axis.Z; import java.awt.Color; import java.awt.Font; +import java.awt.FontMetrics; import java.awt.Rectangle; import java.io.BufferedReader; import java.io.ByteArrayInputStream; @@ -4882,14 +4883,14 @@ public class Jalview2XML viewport.setIncrement(safeInt(view.getConsThreshold())); viewport.setShowJVSuffix(safeBoolean(view.isShowFullId())); viewport.setRightAlignIds(safeBoolean(view.isRightAlignIds())); + viewport.setFont(new Font(view.getFontName(), + safeInt(view.getFontStyle()), safeInt(view.getFontSize())), + (view.getCharWidth()!=null) ? false : true); if (view.getCharWidth()!=null) { viewport.setCharWidth(view.getCharWidth()); viewport.setCharHeight(view.getCharHeight()); } - viewport.setFont(new Font(view.getFontName(), - safeInt(view.getFontStyle()), safeInt(view.getFontSize())), - true); ViewStyleI vs = viewport.getViewStyle(); vs.setScaleProteinAsCdna(view.isScaleProteinAsCdna()); viewport.setViewStyle(vs);