From b3af91d70f62d0f055ce6f2ee9e7fc11f649d579 Mon Sep 17 00:00:00 2001 From: Valkryst Date: Thu, 28 Sep 2017 09:55:26 -0300 Subject: [PATCH] Rewrites width/height vars ad a Dimension obj. --- src/com/valkryst/VTerminal/font/Font.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/com/valkryst/VTerminal/font/Font.java b/src/com/valkryst/VTerminal/font/Font.java index c163192c5f..89026dde3f 100644 --- a/src/com/valkryst/VTerminal/font/Font.java +++ b/src/com/valkryst/VTerminal/font/Font.java @@ -4,6 +4,7 @@ import lombok.NonNull; import lombok.ToString; +import java.awt.Dimension; import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; @@ -19,10 +20,8 @@ public class Font { */ private final HashMap characterImages; - /** The width of the font. */ - @Getter private final int width; - /** The height of the font. */ - @Getter private final int height; + /** The width/height of the font. */ + @Getter private final Dimension dimensions; /** * Constructs a new Font. @@ -42,8 +41,9 @@ public class Font { public Font(final @NonNull HashMap characterImages, final int scale) throws IOException { this.characterImages = characterImages; - width = characterImages.get('X').getWidth() * scale; - height = characterImages.get('X').getHeight() * scale; + final int width = characterImages.get('X').getWidth() * scale; + final int height = characterImages.get('X').getHeight() * scale; + dimensions = new Dimension(width, height); if (scale > 0) { final AffineTransform tx = AffineTransform.getScaleInstance(scale, scale); @@ -83,4 +83,12 @@ public boolean isCharacterSupported(final char character) { public BufferedImage getCharacterImage(final char character) { return characterImages.get(character); } + + public int getWidth() { + return dimensions.width; + } + + public int getHeight() { + return dimensions.height; + } }