Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Embed fonts into the app for consistent typography across all platforms #118

Merged
merged 1 commit into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/main/java/seedu/address/ui/UiFont.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package seedu.address.ui;

import javafx.scene.text.Font;

//@@author keithsoc
/**
* A singleton class that manages the loading of custom fonts and embedding it into the application
* so that typography will be consistent on different platforms e.g. Windows, macOS, etc.
*/
public class UiFont {

/** Resource folder where font files are stored. */
private static final String FONTS_FILE_FOLDER = "/fonts/";

/** List of all the custom fonts */
private static final String[] fontList = {
"OpenSans-Light.ttf", "SegoeUI.ttf", "SegoeUI-Bold.ttf", "SegoeUI-Light.ttf", "SegoeUI-Semibold.ttf"
};

private static UiFont instance;

private UiFont() {
// Prevents any other class from instantiating
}

/**
* @return instance of UiTheme
*/
public static UiFont getInstance() {
if (instance == null) {
instance = new UiFont();
}
return instance;
}

/**
* Load in all the fonts specified in fontList String array.
*/
public void embedFonts() {
for (String font : fontList) {
Font.loadFont(getClass().getResourceAsStream(FONTS_FILE_FOLDER + font), 10);
}
}

}
//@@author
7 changes: 5 additions & 2 deletions src/main/java/seedu/address/ui/UiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ public void start(Stage primaryStage) {
logger.info("Starting UI...");
primaryStage.setTitle(config.getAppTitle());

//Set the application icon.
// Set the application icon.
primaryStage.getIcons().add(getImage(ICON_APPLICATION));

// Set the application fonts.
UiFont.getInstance().embedFonts();

try {
mainWindow = new MainWindow(primaryStage, config, prefs, logic);
mainWindow.show(); //This should be called before creating other UI parts
mainWindow.show(); // This should be called before creating other UI parts
mainWindow.fillInnerParts();

} catch (Throwable e) {
Expand Down
Binary file added src/main/resources/fonts/OpenSans-Light.ttf
Binary file not shown.
Binary file added src/main/resources/fonts/SegoeUI-Bold.ttf
Binary file not shown.
Binary file added src/main/resources/fonts/SegoeUI-Light.ttf
Binary file not shown.
Binary file added src/main/resources/fonts/SegoeUI-Semibold.ttf
Binary file not shown.
Binary file added src/main/resources/fonts/SegoeUI.ttf
Binary file not shown.
23 changes: 12 additions & 11 deletions src/main/resources/view/ThemeDay.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}

.tab-pane .tab-header-area {
-fx-padding: 0 0 0 0;
-fx-padding: 0;
-fx-min-height: 0;
-fx-max-height: 0;
}
Expand Down Expand Up @@ -108,7 +108,7 @@
/* Profile Photo */

.profile-photo-pane {
-fx-font-family: "Segoe UI Light";
-fx-font-family: "Open Sans Light";
-fx-font-size: 30px;
}

Expand All @@ -121,9 +121,9 @@
}

.list-cell {
-fx-label-padding: 0 0 0 0;
-fx-label-padding: 0;
-fx-graphic-text-gap: 0;
-fx-padding: 0 0 0 0;
-fx-padding: 0;
-fx-border-radius: 5;
-fx-background-radius: 5;
}
Expand All @@ -143,16 +143,18 @@
/* Person List Card Fonts */

.cell_big_label {
-fx-font-family: "Helvetica";
-fx-font-family: "Segoe UI";
-fx-font-size: 25px;
-fx-text-fill: black;
-fx-padding: 3 0 3 0;
-fx-effect: dropshadow(one-pass-box, rgba(0, 0, 0, 0.5), 1, 0, 0, 0); /* Add extra darkness to font albeit subtly */
}

.cell_small_label {
-fx-font-family: "Helvetica";
-fx-font-family: "Segoe UI";
-fx-font-size: 16px;
-fx-text-fill: #1f1f1f;
-fx-padding: 3 0 3 0;
}

/* Command Box & Result Display Box Background */
Expand Down Expand Up @@ -251,7 +253,7 @@
-fx-padding: 12 25 12 35;
-fx-background-radius: 0;
-fx-background-color: #d13438;
-fx-font-family: "Segoe UI", Helvetica, Arial, sans-serif;
-fx-font-family: "Segoe UI";
-fx-font-size: 11pt;
-fx-text-fill: #d8d8d8;
-fx-background-insets: 0 0 0 0, 0, 1, 2;
Expand Down Expand Up @@ -311,7 +313,7 @@

.scroll-bar .increment-button, .scroll-bar .decrement-button {
-fx-background-color: transparent;
-fx-padding: 0 0 0 0;
-fx-padding: 0;
}

.scroll-bar .increment-arrow, .scroll-bar .decrement-arrow {
Expand Down Expand Up @@ -367,11 +369,10 @@
}

#tags .label {
-fx-font-family: "Helvetica";
-fx-font-family: "Segoe UI Bold";
-fx-font-size: 11pt;
-fx-font-weight: bold;
-fx-text-fill: white;
-fx-padding: 1 8 1 8;
-fx-padding: 2 8 3 8;
-fx-background-color: #fc4465;
-fx-border-radius: 5;
-fx-background-radius: 5;
Expand Down
23 changes: 12 additions & 11 deletions src/main/resources/view/ThemeNight.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}

.tab-pane .tab-header-area {
-fx-padding: 0 0 0 0;
-fx-padding: 0;
-fx-min-height: 0;
-fx-max-height: 0;
}
Expand Down Expand Up @@ -108,7 +108,7 @@
/* Profile Photo */

.profile-photo-pane {
-fx-font-family: "Segoe UI Light";
-fx-font-family: "Open Sans Light";
-fx-font-size: 31px;
}

Expand All @@ -121,9 +121,9 @@
}

.list-cell {
-fx-label-padding: 0 0 0 0;
-fx-label-padding: 0;
-fx-graphic-text-gap: 0;
-fx-padding: 0 0 0 0;
-fx-padding: 0;
-fx-border-radius: 5;
-fx-background-radius: 5;
}
Expand All @@ -143,15 +143,17 @@
/* Person List Card Fonts */

.cell_big_label {
-fx-font-family: "Helvetica";
-fx-font-family: "Segoe UI";
-fx-font-size: 25px;
-fx-text-fill: white;
-fx-padding: 3 0 3 0;
}

.cell_small_label {
-fx-font-family: "Helvetica";
-fx-font-family: "Segoe UI";
-fx-font-size: 16px;
-fx-text-fill: white;
-fx-padding: 3 0 3 0;
}

/* Command Box & Result Display Box Background */
Expand Down Expand Up @@ -250,7 +252,7 @@
-fx-padding: 12 25 12 35;
-fx-background-radius: 0;
-fx-background-color: #d13438;
-fx-font-family: "Segoe UI", Helvetica, Arial, sans-serif;
-fx-font-family: "Segoe UI";
-fx-font-size: 11pt;
-fx-text-fill: #d8d8d8;
-fx-background-insets: 0 0 0 0, 0, 1, 2;
Expand Down Expand Up @@ -310,7 +312,7 @@

.scroll-bar .increment-button, .scroll-bar .decrement-button {
-fx-background-color: transparent;
-fx-padding: 0 0 0 0;
-fx-padding: 0;
}

.scroll-bar .increment-arrow, .scroll-bar .decrement-arrow {
Expand Down Expand Up @@ -366,11 +368,10 @@
}

#tags .label {
-fx-font-family: "Helvetica";
-fx-font-family: "Segoe UI Bold";
-fx-font-size: 11pt;
-fx-font-weight: bold;
-fx-text-fill: white;
-fx-padding: 1 8 1 8;
-fx-padding: 2 8 3 8;
-fx-background-color: #fc4465;
-fx-border-radius: 5;
-fx-background-radius: 5;
Expand Down