From dc6dc64dae107cfc9ed894426844816c3b746838 Mon Sep 17 00:00:00 2001 From: l2- Date: Wed, 24 Oct 2018 19:00:09 +0200 Subject: [PATCH] Change font metrics logic in xpglobes and dev plugin to center y text position for any font --- .../net/runelite/client/plugins/devtools/DevToolsOverlay.java | 4 ++-- .../net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java index b986112645..907c2ce4e2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/devtools/DevToolsOverlay.java @@ -370,7 +370,7 @@ class DevToolsOverlay extends Overlay Rectangle2D textBounds = fm.getStringBounds(idText, graphics); int textX = (int) (slotBounds.getX() + (slotBounds.getWidth() / 2) - (textBounds.getWidth() / 2)); - int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (fm.getAscent() / 2)); + int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (fm.getHeight() / 2) - fm.getMaxDescent()); graphics.setColor(new Color(255, 255, 255, 65)); graphics.fill(slotBounds); @@ -480,7 +480,7 @@ class DevToolsOverlay extends Overlay Rectangle2D textBounds = fm.getStringBounds(text, graphics); int textX = (int) (bounds.getX() + (bounds.getWidth() / 2) - (textBounds.getWidth() / 2)); - int textY = (int) (bounds.getY() + (bounds.getHeight() / 2) + (fm.getMaxAscent() / 2)); + int textY = (int) (bounds.getY() + (bounds.getHeight() / 2) + (fm.getHeight() / 2) - fm.getMaxDescent()); graphics.setColor(Color.BLACK); graphics.drawString(text, textX + 1, textY + 1); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java index 1b487ebe5c..232fb2588e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java @@ -185,7 +185,7 @@ public class XpGlobesOverlay extends Overlay final FontMetrics metrics = graphics.getFontMetrics(); int drawX = x + (config.xpOrbSize() / 2) - (metrics.stringWidth(progress) / 2); - int drawY = y + (config.xpOrbSize() / 2) + (metrics.getHeight() / 2); + int drawY = y + (config.xpOrbSize() / 2) + (metrics.getHeight() / 2) - metrics.getMaxDescent(); OverlayUtil.renderTextLocation(graphics, new Point(drawX, drawY), progress, Color.WHITE); }