Discussions
Categories
- 196.7K All Categories
- 2.2K Data
- 235 Big Data Appliance
- 1.9K Data Science
- 449.9K Databases
- 221.6K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 549 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 532 SQLcl
- 4K SQL Developer Data Modeler
- 186.9K SQL & PL/SQL
- 21.3K SQL Developer
- 295.4K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.1K Development Tools
- 104 DevOps
- 3.1K QA/Testing
- 645.9K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 153 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 17 Java Essentials
- 158 Java 8 Questions
- 85.9K Java Programming
- 79 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.2K Java SE
- 13.8K Java Security
- 203 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 398 LiveLabs
- 37 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.6K Other Languages
- 2.3K Chinese
- 170 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 230 Portuguese
Font not being created - default used.

I have a Java application made up of several JTextPane instances, all arranged using a combination of BoxLayout and OverlayLayout. All of the panes are created in a single class, I call 'ttPane' in a single class called 'Screens'. All JTextPane instances and all layout is performed in the EDT.
In the Screens class I create a font by reading a .ttf file and then deriving the final 'default'.
public static void establishFont() {
try {
Font foo = Font.createFont(Font.TRUETYPE_FONT, new File(Screens.fontFileName));
defaultFont = foo.deriveFont(Font.BOLD, (float) Screens.fontSize);
defaultFontFamily = defaultFont.getFamily();
charWidth = FontWidth.getAvgWidth(defaultFont);
charHeight = FontWidth.getHeight(defaultFont);
} catch (FontFormatException | IOException e) {
System.out.println("FontFormatException encountered while trying to create the font.");
}
}
All variables mentioned (other than 'foo') are Screens class variables defined elsewhere as static. The class variable "defaultFont" is referenced in all of the rest of the system as the panes are created and arranged later in the Screens initialization. The font named in 'Screens.fontFileName' is a fixed-width font (Cousine Bold), and the .ttf file is read.
With this code, the program does NOT honor the createFont/deriveFont but reverts to the Java default of DIALOG, which is not acceptable for this application.
If I replace the above code with
public static void establishFont() {
defaultFont = new Font( Font.MONOSPACED, Font.BOLD, Screens.fontSize);
defaultFontFamily = defaultFont.getFamily();
charWidth = FontWidth.getAvgWidth(defaultFont);
charHeight = FontWidth.getHeight(defaultFont);
}
The program works properly using the monospaced font provided by Java, but that is also not acceptable since that font is really crappy, particularly when I run the application in a Windows system.
My code is being developed on a Linux system, no IDE involved, just text edit/compile/test. I'll attach some small images that illustrate the difference. The application is fairly substantial, over 10k LOC, and consists of 15+/- JTextPane instances.
Any help greatly appreciated.
Bill Lee