diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/jewelrycount/JewelryCount.java b/runelite-client/src/main/java/net/runelite/client/plugins/jewelrycount/JewelryCount.java index 5eee3b28e2..fe9e4f798a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/jewelrycount/JewelryCount.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/jewelrycount/JewelryCount.java @@ -28,11 +28,16 @@ import net.runelite.client.RuneLite; import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.Overlay; +import java.awt.Font; +import java.awt.GraphicsEnvironment; + public class JewelryCount extends Plugin { private final JewelryCountConfig config = RuneLite.getRunelite().getConfigManager().getConfig(JewelryCountConfig.class); private final Overlay overlay = new JewelryCountOverlay(this); + private Font font; + @Override public Overlay getOverlay() { @@ -42,7 +47,10 @@ public class JewelryCount extends Plugin @Override protected void startUp() throws Exception { - + font = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("/runescape_small.ttf")); + font = font.deriveFont(Font.PLAIN, 16); + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + ge.registerFont(font); } @Override @@ -55,4 +63,9 @@ public class JewelryCount extends Plugin { return config; } + + public Font getFont() + { + return font; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/jewelrycount/JewelryCountOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/jewelrycount/JewelryCountOverlay.java index 0d34a715d8..2e5f17b032 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/jewelrycount/JewelryCountOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/jewelrycount/JewelryCountOverlay.java @@ -25,7 +25,6 @@ package net.runelite.client.plugins.jewelrycount; import java.awt.*; -import java.awt.geom.Rectangle2D; import net.runelite.api.Client; import net.runelite.api.GameState; @@ -39,11 +38,13 @@ import net.runelite.client.ui.overlay.OverlayPosition; class JewelryCountOverlay extends Overlay { private final JewelryCountConfig config; + private final JewelryCount plugin; JewelryCountOverlay(JewelryCount plugin) { super(OverlayPosition.DYNAMIC); this.config = plugin.getConfig(); + this.plugin = plugin; } @Override @@ -102,10 +103,6 @@ class JewelryCountOverlay extends Overlay Rectangle widgetBounds = widget.getBounds(); - //to match inventory text - widgetBounds.x -= 5; - widgetBounds.y -= 1; - renderWidgetText(graphics, widgetBounds, charges.getCharges(), Color.white); } @@ -116,19 +113,23 @@ class JewelryCountOverlay extends Overlay private void renderWidgetText(Graphics2D graphics, Rectangle bounds, int charges, Color color) { - String text = charges + ""; - FontMetrics fm = graphics.getFontMetrics(); - Rectangle2D textBounds = fm.getStringBounds(text, graphics); + Font font = plugin.getFont(); + if (font != null) + { + graphics.setFont(font); + } - int textX = (int) (bounds.getX() + bounds.getWidth() - textBounds.getWidth()); - int textY = (int) (bounds.getY() + (textBounds.getHeight())); + FontMetrics fm = graphics.getFontMetrics(); + + int textX = (int) bounds.getX(); + int textY = (int) bounds.getY() + fm.getHeight(); //text shadow graphics.setColor(Color.BLACK); - graphics.drawString(text, textX + 1, textY + 1); + graphics.drawString(String.valueOf(charges), textX + 1, textY + 1); graphics.setColor(color); - graphics.drawString(text, textX, textY); + graphics.drawString(String.valueOf(charges), textX, textY); } } diff --git a/runelite-client/src/main/resources/runescape_small.ttf b/runelite-client/src/main/resources/runescape_small.ttf new file mode 100644 index 0000000000..7998560026 Binary files /dev/null and b/runelite-client/src/main/resources/runescape_small.ttf differ