runelite-client: revert font change (#1070)

* runelite-client: revert font change

* Checkstyle Fix 

Checkstyle Fix

* overlayrenderer: Save fonts
This commit is contained in:
James
2019-07-31 10:39:24 -07:00
committed by Ganom
parent 36c0d753bd
commit 8d2b4a7310
43 changed files with 107 additions and 307 deletions

View File

@@ -29,7 +29,6 @@ import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableMap;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.File;
@@ -66,7 +65,6 @@ import net.runelite.api.events.ConfigChanged;
import net.runelite.client.RuneLite;
import static net.runelite.client.RuneLite.PROFILES_DIR;
import net.runelite.client.eventbus.EventBus;
import net.runelite.client.ui.FontManager;
import net.runelite.client.util.ColorUtil;
@Singleton
@@ -508,10 +506,6 @@ public class ConfigManager
{
return Enum.valueOf((Class<? extends Enum>) type, str);
}
if (type == Font.class)
{
return FontManager.getFontOrDefault(FontManager.lookupFont(str));
}
if (type == Instant.class)
{
return Instant.parse(str);
@@ -568,10 +562,6 @@ public class ConfigManager
{
return ((Enum) object).name();
}
if (object instanceof Font)
{
return FontManager.getFontName((Font)object);
}
if (object instanceof Dimension)
{
Dimension d = (Dimension) object;

View File

@@ -24,18 +24,21 @@
*/
package net.runelite.client.config;
import java.awt.Font;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.runelite.client.ui.FontManager;
@Getter
@RequiredArgsConstructor
public enum FontType
{
REGULAR("Regular"),
BOLD("Bold"),
SMALL("Small");
REGULAR("Regular", FontManager.getRunescapeFont()),
BOLD("Bold", FontManager.getRunescapeBoldFont()),
SMALL("Small", FontManager.getRunescapeSmallFont());
private final String name;
private final Font font;
@Override
public String toString()

View File

@@ -30,7 +30,6 @@ import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Insets;
import java.awt.Rectangle;
@@ -101,7 +100,6 @@ import net.runelite.client.plugins.PluginManager;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.DynamicGridLayout;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.PluginPanel;
import net.runelite.client.ui.components.ComboBoxListRenderer;
import net.runelite.client.ui.components.IconButton;
@@ -1017,37 +1015,6 @@ public class ConfigPanel extends PluginPanel
item.add(button, BorderLayout.EAST);
}
if (cid.getType() == Font.class)
{
JComboBox box = new JComboBox(FontManager.getAvailableFontNames());
box.setPreferredSize(new Dimension(150, 25));
box.setRenderer(new ComboBoxListRenderer());
box.setForeground(Color.WHITE);
box.setFocusable(false);
String currentlyConfigured = configManager.getConfiguration(cd.getGroup().value(), cid.getItem().keyName());
if (FontManager.lookupFont(currentlyConfigured) != null)
{
box.setSelectedItem(currentlyConfigured);
box.setToolTipText(currentlyConfigured);
}
else
{
log.debug("Selected font wasn't found on this system, resetting font back to runescape regular");
configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), FontManager.getRunescapeFont());
}
box.addItemListener(e ->
{
if (e.getStateChange() == ItemEvent.SELECTED && box.getSelectedItem() != null)
{
final Font selected = FontManager.lookupFont(box.getSelectedItem().toString());
configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), selected);
box.setToolTipText(box.getSelectedItem().toString());
}
});
item.add(box, BorderLayout.EAST);
}
mainPanel.add(item);
}
}

View File

@@ -26,6 +26,7 @@
package net.runelite.client.plugins.devtools;
import java.awt.Color;
import java.awt.Font;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
@@ -62,6 +63,7 @@ import net.runelite.api.coords.LocalPoint;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.api.widgets.WidgetItem;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
@@ -75,6 +77,7 @@ class DevToolsOverlay extends Overlay
private static final int ITEM_EMPTY = 6512;
private static final int ITEM_FILLED = 20594;
private static final Font FONT = FontManager.getRunescapeFont().deriveFont(Font.BOLD, 16);
private static final Color RED = new Color(221, 44, 0);
private static final Color GREEN = new Color(0, 200, 83);
private static final Color TURQOISE = new Color(0, 200, 157);
@@ -112,6 +115,7 @@ class DevToolsOverlay extends Overlay
@Override
public Dimension render(Graphics2D graphics)
{
graphics.setFont(FONT);
if (plugin.getPlayers().isActive())
{
@@ -394,7 +398,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.getHeight() / 2) - fm.getMaxDescent());
int textY = (int) (slotBounds.getY() + (slotBounds.getHeight() / 2) + (textBounds.getHeight() / 2));
graphics.setColor(new Color(255, 255, 255, 65));
graphics.fill(slotBounds);
@@ -536,7 +540,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.getHeight() / 2) - fm.getMaxDescent());
int textY = (int) (bounds.getY() + (bounds.getHeight() / 2) + (textBounds.getHeight() / 2));
graphics.setColor(Color.BLACK);
graphics.drawString(text, textX + 1, textY + 1);

View File

@@ -192,7 +192,7 @@ class VarInspector extends JFrame
{
lastTick = tick;
JLabel header = new JLabel("Tick " + tick);
header.setFont(FontManager.getSmallFont(getFont()));
header.setFont(FontManager.getRunescapeSmallFont());
header.setBorder(new CompoundBorder(
BorderFactory.createMatteBorder(0, 0, 1, 0, ColorScheme.LIGHT_GRAY_COLOR),
BorderFactory.createEmptyBorder(3, 6, 0, 0)

View File

@@ -49,7 +49,7 @@ class ItemPanel extends JPanel
JLabel name = new JLabel(item.getName());
JLabel location = new JLabel(StringUtils.capitalize(kitType.toString().toLowerCase()));
location.setFont(FontManager.getSmallFont(getFont()));
location.setFont(FontManager.getRunescapeSmallFont());
JLabel imageLabel = new JLabel();
icon.addTo(imageLabel);

View File

@@ -223,14 +223,14 @@ class FeedPanel extends PluginPanel
Color darkerForeground = UIManager.getColor("Label.foreground").darker();
JLabel titleLabel = new JLabel(item.getTitle());
titleLabel.setFont(FontManager.getSmallFont(getFont()));
titleLabel.setFont(FontManager.getRunescapeSmallFont());
titleLabel.setBackground(null);
titleLabel.setForeground(darkerForeground);
titleLabel.setPreferredSize(new Dimension(CONTENT_WIDTH - TIME_WIDTH, 0));
Duration duration = Duration.between(Instant.ofEpochMilli(item.getTimestamp()), Instant.now());
JLabel timeLabel = new JLabel(durationToString(duration));
timeLabel.setFont(FontManager.getSmallFont(getFont()));
timeLabel.setFont(FontManager.getRunescapeSmallFont());
timeLabel.setForeground(darkerForeground);
titleAndTime.add(titleLabel, BorderLayout.WEST);
@@ -239,9 +239,9 @@ class FeedPanel extends PluginPanel
JPanel content = new JPanel(new BorderLayout());
content.setBackground(null);
JLabel contentLabel = new JLabel(lineBreakText(item.getContent(), FontManager.getSmallFont(getFont())));
JLabel contentLabel = new JLabel(lineBreakText(item.getContent(), FontManager.getRunescapeSmallFont()));
contentLabel.setBorder(new EmptyBorder(2, 0, 0, 0));
contentLabel.setFont(FontManager.getSmallFont(getFont()));
contentLabel.setFont(FontManager.getRunescapeSmallFont());
contentLabel.setForeground(darkerForeground);
content.add(contentLabel, BorderLayout.CENTER);

View File

@@ -136,11 +136,11 @@ class GrandExchangeOfferSlot extends JPanel
itemName.setForeground(Color.WHITE);
itemName.setVerticalAlignment(JLabel.BOTTOM);
itemName.setFont(FontManager.getSmallFont(getFont()));
itemName.setFont(FontManager.getRunescapeSmallFont());
offerInfo.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
offerInfo.setVerticalAlignment(JLabel.TOP);
offerInfo.setFont(FontManager.getSmallFont(getFont()));
offerInfo.setFont(FontManager.getRunescapeSmallFont());
JLabel switchFaceViewIcon = new JLabel();
switchFaceViewIcon.setIcon(RIGHT_ARROW_ICON);
@@ -172,11 +172,11 @@ class GrandExchangeOfferSlot extends JPanel
itemPrice.setForeground(Color.WHITE);
itemPrice.setVerticalAlignment(JLabel.BOTTOM);
itemPrice.setFont(FontManager.getSmallFont(getFont()));
itemPrice.setFont(FontManager.getRunescapeSmallFont());
offerSpent.setForeground(Color.WHITE);
offerSpent.setVerticalAlignment(JLabel.TOP);
offerSpent.setFont(FontManager.getSmallFont(getFont()));
offerSpent.setFont(FontManager.getRunescapeSmallFont());
JLabel switchDetailsViewIcon = new JLabel();
switchDetailsViewIcon.setIcon(LEFT_ARROW_ICON);

View File

@@ -109,6 +109,8 @@ public class GroundItemsOverlay extends Overlay
{
return null;
}
final FontMetrics fm = graphics.getFontMetrics();
final Player player = client.getLocalPlayer();
if (player == null || client.getViewportWidget() == null)
@@ -116,8 +118,6 @@ public class GroundItemsOverlay extends Overlay
return null;
}
final FontMetrics fm = graphics.getFontMetrics();
offsetMap.clear();
final LocalPoint localLocation = player.getLocalLocation();
final Point mousePos = client.getMouseCanvasPosition();
@@ -319,14 +319,14 @@ public class GroundItemsOverlay extends Overlay
// Item bounds
int x = textX - 2;
int y = textY - stringHeight - 2 + fm.getMaxDescent();
int y = textY - stringHeight - 2;
int width = stringWidth + 4;
int height = stringHeight + 4;
final Rectangle itemBounds = new Rectangle(x, y, width, height);
// Hidden box
x += width + 2;
y = textY - (fm.getMaxAscent() + RECTANGLE_SIZE) / 2;
y = textY - (RECTANGLE_SIZE + stringHeight) / 2;
width = height = RECTANGLE_SIZE;
final Rectangle itemHiddenBox = new Rectangle(x, y, width, height);

View File

@@ -294,7 +294,7 @@ public class HiscorePanel extends PluginPanel
private JPanel makeSkillPanel(HiscoreSkill skill)
{
JLabel label = new JLabel();
label.setFont(FontManager.getSmallFont(getFont()));
label.setFont(FontManager.getRunescapeSmallFont());
label.setText("--");
String skillName = (skill == null ? "combat" : skill.getName().toLowerCase());

View File

@@ -117,7 +117,7 @@ public class InfoPanel extends PluginPanel
versionPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
versionPanel.setLayout(new GridLayout(0, 1));
final Font smallFont = FontManager.getSmallFont(getFont());
final Font smallFont = FontManager.getRunescapeSmallFont();
JLabel version = new JLabel(htmlLabel("RuneLite version: ", runeLiteProperties.getVersion()));
version.setFont(smallFont);
@@ -207,7 +207,7 @@ public class InfoPanel extends PluginPanel
/**
* Builds a link panel with a given icon, text and url to redirect to.
*/
private JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, String url)
private static JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, String url)
{
return buildLinkPanel(icon, topText, bottomText, () -> LinkBrowser.browse(url));
}
@@ -215,7 +215,7 @@ public class InfoPanel extends PluginPanel
/**
* Builds a link panel with a given icon, text and callable to call.
*/
private JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, Runnable callback)
private static JPanel buildLinkPanel(ImageIcon icon, String topText, String bottomText, Runnable callback)
{
JPanel container = new JPanel();
container.setBackground(ColorScheme.DARKER_GRAY_COLOR);
@@ -269,11 +269,11 @@ public class InfoPanel extends PluginPanel
JLabel topLine = new JLabel(topText);
topLine.setForeground(Color.WHITE);
topLine.setFont(FontManager.getSmallFont(getFont()));
topLine.setFont(FontManager.getRunescapeSmallFont());
JLabel bottomLine = new JLabel(bottomText);
bottomLine.setForeground(Color.WHITE);
bottomLine.setFont(FontManager.getSmallFont(getFont()));
bottomLine.setFont(FontManager.getRunescapeSmallFont());
textContainer.add(topLine);
textContainer.add(bottomLine);

View File

@@ -170,7 +170,7 @@ class ItemChargeOverlay extends WidgetItemOverlay
final Rectangle bounds = itemWidget.getCanvasBounds();
final TextComponent textComponent = new TextComponent();
textComponent.setPosition(new Point(bounds.x, bounds.y + 1 + graphics.getFontMetrics().getMaxAscent() - graphics.getFontMetrics().getMaxDescent()));
textComponent.setPosition(new Point(bounds.x - 1, bounds.y + 15));
textComponent.setText(charges < 0 ? "?" : String.valueOf(charges));
textComponent.setColor(plugin.getColor(charges));
textComponent.render(graphics);

View File

@@ -49,7 +49,7 @@ class BookPanel extends JPanel
JLabel image = new JLabel();
b.getIcon().addTo(image);
JLabel name = new JLabel(b.getShortName());
location.setFont(FontManager.getSmallFont(getFont()));
location.setFont(FontManager.getRunescapeSmallFont());
layout.setVerticalGroup(layout.createParallelGroup()
.addComponent(image)

View File

@@ -97,12 +97,12 @@ class LootTrackerBox extends JPanel
logTitle.setBackground(ColorScheme.DARKER_GRAY_COLOR.darker());
final JLabel titleLabel = new JLabel(Text.removeTags(id));
titleLabel.setFont(FontManager.getSmallFont(getFont()));
titleLabel.setFont(FontManager.getRunescapeSmallFont());
titleLabel.setForeground(Color.WHITE);
logTitle.add(titleLabel, BorderLayout.WEST);
subTitleLabel.setFont(FontManager.getSmallFont(getFont()));
subTitleLabel.setFont(FontManager.getRunescapeSmallFont());
subTitleLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
logTitle.add(subTitleLabel, BorderLayout.CENTER);
@@ -121,7 +121,7 @@ class LootTrackerBox extends JPanel
subTitleLabel.setText(subtitle);
}
priceLabel.setFont(FontManager.getSmallFont(getFont()));
priceLabel.setFont(FontManager.getRunescapeSmallFont());
priceLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR);
logTitle.add(priceLabel, BorderLayout.EAST);

View File

@@ -349,8 +349,8 @@ class LootTrackerPanel extends PluginPanel
overallInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
overallInfo.setLayout(new GridLayout(2, 1));
overallInfo.setBorder(new EmptyBorder(2, 10, 2, 0));
overallKillsLabel.setFont(FontManager.getSmallFont(getFont()));
overallGpLabel.setFont(FontManager.getSmallFont(getFont()));
overallKillsLabel.setFont(FontManager.getRunescapeSmallFont());
overallGpLabel.setFont(FontManager.getRunescapeSmallFont());
overallInfo.add(overallKillsLabel);
overallInfo.add(overallGpLabel);
overallPanel.add(overallIcon, BorderLayout.WEST);

View File

@@ -53,7 +53,7 @@ public class MTAInventoryOverlay extends Overlay
{
if (room.inside())
{
graphics.setFont(FontManager.getSmallFont(graphics.getFont()));
graphics.setFont(FontManager.getRunescapeBoldFont());
room.over(graphics);
}
}

View File

@@ -53,7 +53,7 @@ public class MTASceneOverlay extends Overlay
{
if (room.inside())
{
graphics.setFont(FontManager.getSmallFont(graphics.getFont()));
graphics.setFont(FontManager.getRunescapeBoldFont());
room.under(graphics);
}
}

View File

@@ -116,7 +116,7 @@ class ProfilesPanel extends PluginPanel
JPanel helpPanel = new JPanel(new BorderLayout());
helpPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
JLabel helpLabel = new JLabel("<html> <p>" + HELP + "</p></html>");
helpLabel.setFont(FontManager.getSmallFont(getFont()));
helpLabel.setFont(FontManager.getRunescapeSmallFont());
helpPanel.setPreferredSize(HELP_PREFERRED_SIZE);
// helpPanel.setSize(MINIMUM_SIZE);
helpPanel.add(helpLabel, BorderLayout.NORTH);

View File

@@ -90,10 +90,6 @@ public class RunepouchOverlay extends WidgetItemOverlay
Point location = itemWidget.getCanvasLocation();
StringBuilder tooltipBuilder = new StringBuilder();
// location.getY() + graphics.getFontMetrics().getMaxAscent() - graphics.getFontMetrics().getMaxDescent()
// this will draw the character exactly on the border
int yLocation = location.getY() + 1 +
graphics.getFontMetrics().getMaxAscent() - graphics.getFontMetrics().getMaxDescent();
for (int i = 0; i < AMOUNT_VARBITS.length; i++)
{
Varbits amountVarbit = AMOUNT_VARBITS[i];
@@ -129,12 +125,9 @@ public class RunepouchOverlay extends WidgetItemOverlay
int yOffset = (1 + (graphics.getFontMetrics().getMaxAscent()) * i);
graphics.setColor(Color.black);
graphics.drawString("" + formatNumber(amount), location.getX() + (plugin.isShowIcons() ? 13 : 6),
yLocation + yOffset);
graphics.setColor(plugin.getFontColor());
graphics.drawString("" + formatNumber(amount), location.getX() + (plugin.isShowIcons() ? 12 : 5),
yLocation + yOffset);
location.getY() + 13 + (graphics.getFontMetrics().getHeight() - 1) * i);
graphics.setColor(plugin.getFontColor());
graphics.drawString("" + formatNumber(amount), location.getX() + (plugin.isShowIcons() ? 11 : 4),
@@ -149,13 +142,7 @@ public class RunepouchOverlay extends WidgetItemOverlay
if (image != null)
{
OverlayUtil.renderImageLocation(graphics,
//TODO :: SEE WHAT ONE IS RIGHT?
//new Point(location.getX() - 1, location.getY() + graphics.getFontMetrics().getMaxAscent() * i - 1),
//image);
//or
//new Point(location.getX(), location.getY() + (1 + graphics.getFontMetrics().getMaxAscent()) * i),
//image);
new Point(location.getX(), location.getY() + (1 + graphics.getFontMetrics().getMaxAscent()) * i),
new Point(location.getX() - 1, location.getY() + graphics.getFontMetrics().getHeight() * i - 1),
image);
}
}

View File

@@ -71,7 +71,7 @@ public class ScreenMarkerCreationPanel extends JPanel
setBorder(new EmptyBorder(8, 8, 8, 8));
setLayout(new BorderLayout());
instructionsLabel.setFont(FontManager.getSmallFont(getFont()));
instructionsLabel.setFont(FontManager.getRunescapeSmallFont());
instructionsLabel.setForeground(Color.WHITE);
JPanel actionsContainer = new JPanel(new GridLayout(1, 2, 8, 0));

View File

@@ -162,7 +162,7 @@ class ScreenMarkerPanel extends JPanel
nameActions.setBackground(ColorScheme.DARKER_GRAY_COLOR);
save.setVisible(false);
save.setFont(FontManager.getSmallFont(getFont()));
save.setFont(FontManager.getRunescapeSmallFont());
save.setForeground(ColorScheme.PROGRESS_COMPLETE_COLOR);
save.addMouseListener(new MouseAdapter()
{
@@ -191,7 +191,7 @@ class ScreenMarkerPanel extends JPanel
});
cancel.setVisible(false);
cancel.setFont(FontManager.getSmallFont(getFont()));
cancel.setFont(FontManager.getRunescapeSmallFont());
cancel.setForeground(ColorScheme.PROGRESS_ERROR_COLOR);
cancel.addMouseListener(new MouseAdapter()
{
@@ -217,7 +217,7 @@ class ScreenMarkerPanel extends JPanel
}
});
rename.setFont(FontManager.getSmallFont(getFont()));
rename.setFont(FontManager.getRunescapeSmallFont());
rename.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker());
rename.addMouseListener(new MouseAdapter()
{

View File

@@ -117,7 +117,7 @@ class SlayerOverlay extends WidgetItemOverlay
return;
}
graphics.setFont(FontManager.getSmallFont(graphics.getFont()));
graphics.setFont(FontManager.getRunescapeBoldFont());
final Rectangle bounds = itemWidget.getCanvasBounds();
final TextComponent textComponent = new TextComponent();

View File

@@ -195,8 +195,8 @@ public class SlayerTaskPanel extends PluginPanel
overallInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
overallInfo.setLayout(new GridLayout(2, 1));
overallInfo.setBorder(new EmptyBorder(2, 10, 2, 0));
overallKillsLabel.setFont(FontManager.getSmallFont(getFont()));
overallTimeLabel.setFont(FontManager.getSmallFont(getFont()));
overallKillsLabel.setFont(FontManager.getRunescapeSmallFont());
overallTimeLabel.setFont(FontManager.getRunescapeSmallFont());
overallInfo.add(overallKillsLabel);
overallInfo.add(overallTimeLabel);
overallPanel.add(overallIcon, BorderLayout.WEST);

View File

@@ -90,8 +90,8 @@ class SuppliesTrackerPanel extends PluginPanel
overallInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
overallInfo.setLayout(new GridLayout(2, 1));
overallInfo.setBorder(new EmptyBorder(0, 10, 0, 0));
overallSuppliesUsedLabel.setFont(FontManager.getSmallFont(getFont()));
overallCostLabel.setFont(FontManager.getSmallFont(getFont()));
overallSuppliesUsedLabel.setFont(FontManager.getRunescapeSmallFont());
overallCostLabel.setFont(FontManager.getRunescapeSmallFont());
overallInfo.add(overallSuppliesUsedLabel);
overallInfo.add(overallCostLabel);
overallPanel.add(overallIcon, BorderLayout.WEST);

View File

@@ -106,11 +106,11 @@ class OverviewItemPanel extends JPanel
JLabel titleLabel = new JLabel(title);
titleLabel.setForeground(Color.WHITE);
titleLabel.setFont(FontManager.getSmallFont(getFont()));
titleLabel.setFont(FontManager.getRunescapeSmallFont());
statusLabel = new JLabel();
statusLabel.setForeground(Color.GRAY);
statusLabel.setFont(FontManager.getSmallFont(getFont()));
statusLabel.setFont(FontManager.getRunescapeSmallFont());
textContainer.add(titleLabel);
textContainer.add(statusLabel);

View File

@@ -67,10 +67,10 @@ public class TimeablePanel<T> extends JPanel
infoPanel.setBorder(new EmptyBorder(4, 4, 4, 0));
final JLabel location = new JShadowedLabel(title);
location.setFont(FontManager.getSmallFont(getFont()));
location.setFont(FontManager.getRunescapeSmallFont());
location.setForeground(Color.WHITE);
estimate.setFont(FontManager.getSmallFont(getFont()));
estimate.setFont(FontManager.getRunescapeSmallFont());
estimate.setForeground(Color.GRAY);
infoPanel.add(location);

View File

@@ -155,7 +155,7 @@ public class ClockTabPanel extends TabContentPanel
JLabel headerLabel = new JLabel(title);
headerLabel.setForeground(Color.WHITE);
headerLabel.setFont(FontManager.getSmallFont(getFont()));
headerLabel.setFont(FontManager.getRunescapeSmallFont());
panel.add(headerLabel, BorderLayout.CENTER);
IconButton addButton = new IconButton(ADD_ICON, ADD_ICON_HOVER);
@@ -175,7 +175,7 @@ public class ClockTabPanel extends TabContentPanel
JLabel infoLabel = new JShadowedLabel(text);
infoLabel.setForeground(ColorScheme.LIGHT_GRAY_COLOR.darker());
infoLabel.setFont(FontManager.getSmallFont(getFont()));
infoLabel.setFont(FontManager.getRunescapeSmallFont());
panel.add(infoLabel);
return panel;

View File

@@ -129,7 +129,7 @@ class StopwatchPanel extends ClockPanel
private JLabel createSmallLabel(String text)
{
JLabel label = new JLabel(text, SwingConstants.CENTER);
label.setFont(FontManager.getSmallFont(getFont()));
label.setFont(FontManager.getRunescapeSmallFont());
label.setForeground(LAP_DATA_COLOR);
return label;

View File

@@ -92,7 +92,7 @@ public class FarmingTabPanel extends TabContentPanel
groupLabel.setBorder(new EmptyBorder(15, 0, 0, 0));
}
groupLabel.setFont(FontManager.getSmallFont(getFont()));
groupLabel.setFont(FontManager.getRunescapeSmallFont());
add(groupLabel, c);
c.gridy++;

View File

@@ -104,7 +104,7 @@ class WorldTableHeader extends JPanel
});
textLabel.setText(title);
textLabel.setFont(FontManager.getSmallFont(getFont()));
textLabel.setFont(FontManager.getRunescapeSmallFont());
final JMenuItem refresh = new JMenuItem("Refresh worlds");
refresh.addActionListener(e ->

View File

@@ -273,7 +273,7 @@ class WorldTableRow extends JPanel
column.setBorder(new EmptyBorder(0, 5, 0, 5));
playerCountField = new JLabel(world.getPlayers() + "");
playerCountField.setFont(FontManager.getSmallFont(getFont()));
playerCountField.setFont(FontManager.getRunescapeSmallFont());
column.add(playerCountField, BorderLayout.WEST);
@@ -302,7 +302,7 @@ class WorldTableRow extends JPanel
column.setBorder(new EmptyBorder(0, 5, 0, 5));
activityField = new JLabel(world.getActivity());
activityField.setFont(FontManager.getSmallFont(getFont()));
activityField.setFont(FontManager.getRunescapeSmallFont());
column.add(activityField, BorderLayout.WEST);

View File

@@ -180,10 +180,10 @@ class XpInfoBox extends JPanel
statsPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
statsPanel.setBorder(new EmptyBorder(6, 5, 0, 2));
expGained.setFont(FontManager.getSmallFont(getFont()));
expHour.setFont(FontManager.getSmallFont(getFont()));
expLeft.setFont(FontManager.getSmallFont(getFont()));
actionsLeft.setFont(FontManager.getSmallFont(getFont()));
expGained.setFont(FontManager.getRunescapeSmallFont());
expHour.setFont(FontManager.getRunescapeSmallFont());
expLeft.setFont(FontManager.getRunescapeSmallFont());
actionsLeft.setFont(FontManager.getRunescapeSmallFont());
statsPanel.add(expGained);
statsPanel.add(expLeft);

View File

@@ -111,8 +111,8 @@ class XpPanel extends PluginPanel
overallInfo.setLayout(new GridLayout(2, 1));
overallInfo.setBorder(new EmptyBorder(0, 10, 0, 0));
overallExpGained.setFont(FontManager.getSmallFont(getFont()));
overallExpHour.setFont(FontManager.getSmallFont(getFont()));
overallExpGained.setFont(FontManager.getRunescapeSmallFont());
overallExpHour.setFont(FontManager.getRunescapeSmallFont());
overallInfo.add(overallExpGained);
overallInfo.add(overallExpHour);

View File

@@ -24,19 +24,11 @@
*/
package net.runelite.client.ui;
import com.google.common.collect.ImmutableBiMap;
import java.awt.Canvas;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.GraphicsEnvironment;
import java.io.IOException;
import java.util.Map;
import lombok.Getter;
import net.runelite.client.config.FontType;
import javax.swing.text.StyleContext;
public class FontManager
{
@@ -44,59 +36,37 @@ public class FontManager
private static final Font runescapeSmallFont;
private static final Font runescapeBoldFont;
@Getter
private static class CachedFont
{
private final Font reg;
private final Font small;
private final Font bold;
private CachedFont(Font f)
{
reg = f.deriveFont(14.0f);
small = getFontOffCorrectSize(f);
bold = f.deriveFont(Font.BOLD, 14.0f);
}
}
private static final ImmutableBiMap<String, Font> fontMap;
private static final Map<Font, CachedFont> derivedFontMap = new HashMap<>();
static
{
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
try
{
runescapeFont = Font.createFont(Font.TRUETYPE_FONT,
Font font = Font.createFont(Font.TRUETYPE_FONT,
FontManager.class.getResourceAsStream("runescape.ttf"))
.deriveFont(Font.PLAIN, 16);
ge.registerFont(font);
runescapeSmallFont = Font.createFont(Font.TRUETYPE_FONT,
runescapeFont = StyleContext.getDefaultStyleContext()
.getFont(font.getName(), Font.PLAIN, 16);
ge.registerFont(runescapeFont);
Font smallFont = Font.createFont(Font.TRUETYPE_FONT,
FontManager.class.getResourceAsStream("runescape_small.ttf"))
.deriveFont(Font.PLAIN, 16);
ge.registerFont(smallFont);
runescapeBoldFont = Font.createFont(Font.TRUETYPE_FONT,
runescapeSmallFont = StyleContext.getDefaultStyleContext()
.getFont(smallFont.getName(), Font.PLAIN, 16);
ge.registerFont(runescapeSmallFont);
Font boldFont = Font.createFont(Font.TRUETYPE_FONT,
FontManager.class.getResourceAsStream("runescape_bold.ttf"))
.deriveFont(Font.PLAIN, 16);
ge.registerFont(boldFont);
final LinkedHashMap<String, Font> _fontMap = new LinkedHashMap<>();
_fontMap.put("Runescape", runescapeFont);
// Get all available fonts on the system
Font[] availableFonts = ge.getAllFonts();
// build bidirectional map
Arrays.stream(availableFonts).sorted(Comparator.comparing(Font::getFontName)).forEach(f ->
{
if (!_fontMap.containsKey(f.getFontName()))
{
_fontMap.put(f.getFontName(), f);
}
});
fontMap = ImmutableBiMap.copyOf(_fontMap);
ge.registerFont(runescapeFont);
ge.registerFont(runescapeSmallFont);
runescapeBoldFont = StyleContext.getDefaultStyleContext()
.getFont(boldFont.getName(), Font.PLAIN, 16);
ge.registerFont(runescapeBoldFont);
}
catch (FontFormatException ex)
@@ -109,25 +79,6 @@ public class FontManager
}
}
private static Font getFontOffCorrectSize(Font f)
{
// Size of the font is already set
if (f.getSize2D() > 1)
{
return f;
}
// Dummy canvas for font metrics
Canvas c = new Canvas();
f = f.deriveFont(12f);
if (c.getFontMetrics(f).getMaxAscent() > 11)
{
f = f.deriveFont(11f);
}
return f;
}
public static Font getRunescapeFont()
{
return runescapeFont;
@@ -142,93 +93,4 @@ public class FontManager
{
return runescapeBoldFont;
}
private static boolean isRunescapeFont(Font f)
{
return f.equals(runescapeFont) || f.equals(runescapeSmallFont) || f.equals(runescapeBoldFont);
}
public static Font getSmallFont(Font f)
{
if (isRunescapeFont(f))
{
return runescapeSmallFont;
}
if (derivedFontMap.containsKey(f))
{
return derivedFontMap.get(f).getSmall();
}
// cache and return
CachedFont cachedFont = new CachedFont(f);
derivedFontMap.put(f, cachedFont);
return cachedFont.getSmall();
}
public static Font getFontFromType(Font f, FontType type)
{
switch (type)
{
case SMALL:
return getSmallFont(f);
case BOLD:
if (isRunescapeFont(f))
{
return runescapeBoldFont;
}
if (derivedFontMap.containsKey(f))
{
return derivedFontMap.get(f).getBold();
}
// cache and return
CachedFont cachedBoldFont = new CachedFont(f);
derivedFontMap.put(f, cachedBoldFont);
return cachedBoldFont.getBold();
default: //in this case regular
if (isRunescapeFont(f))
{
return runescapeFont;
}
if (derivedFontMap.containsKey(f))
{
return derivedFontMap.get(f).getReg();
}
// cache and return
CachedFont cachedFont = new CachedFont(f);
derivedFontMap.put(f, cachedFont);
return cachedFont.getReg();
}
}
public static Font lookupFont(String fontName)
{
return fontMap.get(fontName);
}
public static String getFontName(Font font)
{
return fontMap.inverse().get(font);
}
public static String[] getAvailableFontNames()
{
return fontMap.keySet().toArray(new String[0]);
}
public static boolean isAvailable(Font font)
{
return fontMap.containsKey(font.getFontName());
}
public static Font getFontOrDefault(Font font)
{
if (font == null || !fontMap.containsKey(font.getFontName()))
{
return getRunescapeFont();
}
return getFontOffCorrectSize(font);
}
}
}

View File

@@ -52,7 +52,7 @@ public class PluginErrorPanel extends JPanel
noResultsTitle.setForeground(Color.WHITE);
noResultsTitle.setHorizontalAlignment(SwingConstants.CENTER);
noResultsDescription.setFont(FontManager.getSmallFont(getFont()));
noResultsDescription.setFont(FontManager.getRunescapeSmallFont());
noResultsDescription.setForeground(Color.GRAY);
noResultsDescription.setHorizontalAlignment(SwingConstants.CENTER);

View File

@@ -77,15 +77,15 @@ public class ProgressBar extends DimmableJPanel
topIndent = 2;
}
leftLabel.setFont(FontManager.getSmallFont(getFont()));
leftLabel.setFont(FontManager.getRunescapeSmallFont());
leftLabel.setForeground(Color.WHITE);
leftLabel.setBorder(new EmptyBorder(topIndent, 5, 0, 0));
rightLabel.setFont(FontManager.getSmallFont(getFont()));
rightLabel.setFont(FontManager.getRunescapeSmallFont());
rightLabel.setForeground(Color.WHITE);
rightLabel.setBorder(new EmptyBorder(topIndent, 0, 0, 5));
centerLabel.setFont(FontManager.getSmallFont(getFont()));
centerLabel.setFont(FontManager.getRunescapeSmallFont());
centerLabel.setForeground(Color.WHITE);
centerLabel.setHorizontalAlignment(SwingConstants.CENTER);
centerLabel.setBorder(new EmptyBorder(topIndent, 0, 0, 0));

View File

@@ -56,7 +56,6 @@ import net.runelite.client.input.KeyListener;
import net.runelite.client.input.KeyManager;
import net.runelite.client.input.MouseAdapter;
import net.runelite.client.input.MouseManager;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.JagexColors;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.MiscUtils;
@@ -122,10 +121,9 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
private void updateConfig()
{
// Overlay Fonts
Font clientFont = runeLiteConfig.clientFont();
this.standardFont = FontManager.getFontFromType(clientFont, runeLiteConfig.fontType());
this.tooltipFont = FontManager.getFontFromType(clientFont, runeLiteConfig.tooltipFontType());
this.interfaceFont = FontManager.getFontFromType(clientFont, runeLiteConfig.interfaceFontType());
this.standardFont = runeLiteConfig.fontType().getFont();
this.tooltipFont = runeLiteConfig.tooltipFontType().getFont();
this.interfaceFont = runeLiteConfig.interfaceFontType().getFont();
}
private void onConfigChanged(ConfigChanged event)
@@ -486,7 +484,7 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
// Set font based on configuration
if (position == OverlayPosition.DYNAMIC || position == OverlayPosition.DETACHED)
{
subGraphics.setFont(this.standardFont);
subGraphics.setFont(this.standardFont); // TODO MAKE USE CONFIG SYSTEM
}
else if (position == OverlayPosition.TOOLTIP)
{

View File

@@ -39,7 +39,7 @@ import net.runelite.client.ui.FontManager;
@Setter
public class InfoBoxComponent implements LayoutableRenderableEntity
{
private static final int SEPARATOR = 2;
private static final int SEPARATOR = 3;
private static final int DEFAULT_SIZE = 32;
@Getter
@@ -63,15 +63,7 @@ public class InfoBoxComponent implements LayoutableRenderableEntity
return new Dimension();
}
if (graphics.getFont().equals(FontManager.getRunescapeFont()) && getSize() > DEFAULT_SIZE)
{
graphics.setFont(FontManager.getRunescapeFont());
}
else
{
graphics.setFont(FontManager.getSmallFont(graphics.getFont()));
}
graphics.setFont(getSize() < DEFAULT_SIZE ? FontManager.getRunescapeSmallFont() : FontManager.getRunescapeFont());
final int baseX = preferredLocation.x;
final int baseY = preferredLocation.y;
@@ -99,7 +91,7 @@ public class InfoBoxComponent implements LayoutableRenderableEntity
final TextComponent textComponent = new TextComponent();
textComponent.setColor(color);
textComponent.setText(text);
textComponent.setPosition(new Point(baseX + ((size - metrics.stringWidth(text)) / 2), baseY + size - metrics.getMaxDescent() - SEPARATOR));
textComponent.setPosition(new Point(baseX + ((size - metrics.stringWidth(text)) / 2), baseY + size - SEPARATOR));
textComponent.render(graphics);
}

View File

@@ -68,7 +68,7 @@ public class LineComponent implements LayoutableRenderableEntity
final FontMetrics metrics = graphics.getFontMetrics();
final int baseX = preferredLocation.x;
final int baseY = preferredLocation.y;
final int baseY = preferredLocation.y + metrics.getHeight();
int x = baseX;
int y = baseY;
final int leftFullWidth = getLineWidth(left, metrics);
@@ -92,7 +92,6 @@ public class LineComponent implements LayoutableRenderableEntity
for (int i = 0; i < lineCount; i++)
{
y += metrics.getMaxAscent();
String leftText = "";
String rightText = "";
@@ -117,7 +116,7 @@ public class LineComponent implements LayoutableRenderableEntity
rightLineComponent.setText(rightText);
rightLineComponent.setColor(rightColor);
rightLineComponent.render(graphics);
y += metrics.getMaxDescent();
y += metrics.getHeight();
}
final Dimension dimension = new Dimension(preferredSize.width, y - baseY);
@@ -125,7 +124,6 @@ public class LineComponent implements LayoutableRenderableEntity
bounds.setSize(dimension);
return dimension;
}
y += metrics.getMaxAscent();
final TextComponent leftLineComponent = new TextComponent();
leftLineComponent.setPosition(new Point(x, y));
@@ -138,7 +136,6 @@ public class LineComponent implements LayoutableRenderableEntity
rightLineComponent.setText(right);
rightLineComponent.setColor(rightColor);
rightLineComponent.render(graphics);
y += metrics.getMaxDescent();
final Dimension dimension = new Dimension(preferredSize.width, y - baseY);
bounds.setLocation(preferredLocation);

View File

@@ -109,7 +109,7 @@ public class ProgressBarComponent implements LayoutableRenderableEntity
final int width = preferredSize.width;
final int height = Math.max(preferredSize.height, 16);
final int progressTextX = barX + (width - metrics.stringWidth(textToWrite)) / 2;
final int progressTextY = barY + ((height - metrics.getHeight()) / 2) + metrics.getMaxAscent();
final int progressTextY = barY + ((height - metrics.getHeight()) / 2) + metrics.getHeight();
final int progressFill = (int) (width * Math.min(1, pc));
// Draw bar

View File

@@ -64,7 +64,7 @@ public class TitleComponent implements LayoutableRenderableEntity
titleComponent.setColor(color);
titleComponent.setPosition(new Point(
baseX + ((preferredSize.width - metrics.stringWidth(text)) / 2),
baseY + metrics.getMaxAscent()));
baseY + metrics.getHeight()));
final Dimension rendered = titleComponent.render(graphics);
final Dimension dimension = new Dimension(preferredSize.width, rendered.height);
bounds.setLocation(preferredLocation);

View File

@@ -106,7 +106,7 @@ public class TooltipComponent implements RenderableEntity
textComponent.setColor(nextColor);
String text = line.substring(begin, j);
textComponent.setText(text);
textComponent.setPosition(new Point(lineX, textY + (i + 1) * metrics.getMaxAscent() + i * metrics.getMaxDescent()));
textComponent.setPosition(new Point(lineX, textY + (i + 1) * textHeight - textDescent));
textComponent.render(graphics);
lineX += metrics.stringWidth(text);
@@ -144,7 +144,7 @@ public class TooltipComponent implements RenderableEntity
textComponent.setColor(nextColor);
String text = line.substring(begin, j + 1);
textComponent.setText(text);
textComponent.setPosition(new Point(lineX, textY + (i + 1) * metrics.getMaxAscent() + i * metrics.getMaxDescent()));
textComponent.setPosition(new Point(lineX, textY + (i + 1) * textHeight - textDescent));
textComponent.render(graphics);
lineX += metrics.stringWidth(text);
@@ -159,7 +159,7 @@ public class TooltipComponent implements RenderableEntity
final TextComponent textComponent = new TextComponent();
textComponent.setColor(nextColor);
textComponent.setText(line.substring(begin));
textComponent.setPosition(new Point(lineX, textY + (i + 1) * metrics.getMaxAscent() + i * metrics.getMaxDescent()));
textComponent.setPosition(new Point(lineX, textY + (i + 1) * textHeight - textDescent));
textComponent.render(graphics);
}

View File

@@ -278,7 +278,7 @@ public class WorldMapOverlay extends Overlay
graphics.setColor(JagexColors.TOOLTIP_BORDER);
graphics.drawRect((int) tooltipRect.getX(), (int) tooltipRect.getY(), (int) tooltipRect.getWidth(), (int) tooltipRect.getHeight());
graphics.setColor(JagexColors.TOOLTIP_TEXT);
graphics.drawString(tooltip, drawPoint.getX(), drawPoint.getY() + fm.getMaxAscent());
graphics.drawString(tooltip, drawPoint.getX(), drawPoint.getY() + height);
}
private Point clipToRectangle(Point drawPoint, Rectangle mapDisplayRectangle)