Change font metrics logic in xpglobes and dev plugin to center y text position for any font

This commit is contained in:
l2-
2018-10-24 19:00:09 +02:00
parent 6dec9b5f62
commit dc6dc64dae
2 changed files with 3 additions and 3 deletions

View File

@@ -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);

View File

@@ -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);
}