Skip to content

Commit

Permalink
Change the font family and scale
Browse files Browse the repository at this point in the history
NOTE: This does *not* change spacing between lines, so larger text sizes may look strange
  • Loading branch information
Gaming32 committed Dec 30, 2021
1 parent 1a32c6f commit ced2264
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/main/ArrayVisualizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ final public class ArrayVisualizer {

private Statistics statSnapshot;
private String fontSelection;
private int fontSelectionScale;

private volatile boolean TEXTDRAW;
private volatile boolean COLOR;
Expand Down Expand Up @@ -378,11 +379,25 @@ public void run() {
this.arrays = new ArrayList<>();
this.arrays.add(this.array);

this.fontSelection = "Times New Roman";
this.fontSelectionScale = 25;
List<Integer> statsInfoList = new ArrayList<>();
try (Scanner statsScanner = new Scanner(new File("stats-config.txt"))) {
while (statsScanner.hasNextLine()) {
String line = statsScanner.nextLine().trim();
if (line.length() > 0 && line.charAt(0) == '#') continue;
if (line.startsWith("FONT: ")) {
String font = line.substring(5);
int fontScale = 25;
int starIndex;
if ((starIndex = font.indexOf('*')) != -1) {
fontScale = Integer.parseInt(font.substring(starIndex + 1).trim());
font = font.substring(0, starIndex);
}
fontSelection = font.trim();
fontSelectionScale = fontScale;
continue;
}
Integer type = STAT_CONFIG_KEYS.get(line.toLowerCase());
if (type == null) {
System.err.println("Unknown statistic type: " + type);
Expand Down Expand Up @@ -474,8 +489,7 @@ public void run() {
this.category = "";
this.heading = "";
this.extraHeading = "";
this.fontSelection = "Times New Roman";
this.typeFace = new Font(this.fontSelection, Font.PLAIN, (int) (this.getWindowRatio() * 25));
this.typeFace = new Font(fontSelection, Font.PLAIN, (int) (this.getWindowRatio() * fontSelectionScale));

this.statSnapshot = new Statistics(this);

Expand Down Expand Up @@ -1110,7 +1124,7 @@ public double getWindowRatio() {
return this.cw / 1280d;
}
public void updateFontSize() {
this.typeFace = new Font(this.fontSelection, Font.PLAIN, (int) (this.getWindowRatio() * 25));
this.typeFace = new Font(fontSelection, Font.PLAIN, (int) (this.getWindowRatio() * fontSelectionScale));
this.mainRender.setFont(this.typeFace);
}

Expand Down
1 change: 1 addition & 0 deletions stats-config.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FONT: Times New Roman * 25
# fps
#
sort
Expand Down

0 comments on commit ced2264

Please sign in to comment.