Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5844561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:18:37+00:00 2026-05-22T12:18:37+00:00

Followup question from this one: Swing font names do not match? (Making a font

  • 0

Followup question from this one:
Swing font names do not match? (Making a font chooser, and am trying to display the default system font in a JComboBox)

It appears there are logical and physical fonts. The logical fonts are:
Serif, SansSerif, Monospaced, Dialog, and DialogInput.

These fonts are dynamic, and their respective physical font (the font that they will represent during program execution) are decided when the program loads.

I need to access the physical font of these logical fonts.

My first idea was to try and load these files:
http://download.oracle.com/javase/6/docs/technotes/guides/intl/fontconfig.html#loading

by using something like this:
http://www.rgagnon.com/javadetails/java-0434.html

public static Properties load(String propsName) throws Exception {
    Properties props = new Properties();
    URL url = ClassLoader.getSystemResource(propsName);
    props.load(url.openStream());
    return props;
}

and then getting the physical fonts from these properties files.

However, I am just getting NullPointerExceptions when trying to load the properties using the names in the first file (they are not found, but I have checked and actually found them on my system). I don’t know why I am getting this, but regardless of that, I can’t help to think there must be an easier way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:18:38+00:00Added an answer on May 22, 2026 at 12:18 pm
    public static Font getPhysicalFont(Font logicalFont) {
        for (int i=0; i<FontManager.getRegisteredFonts().length; i++) {
            Font2D font = FontManager.getRegisteredFonts()[i];
            if (font instanceof CompositeFont && font.getFontName(Locale.getDefault()).equals(logicalFont.getFontName())) {
                PhysicalFont physicalFont = ((CompositeFont) font).getSlotFont(0);
                return new Font(physicalFont.getFamilyName(Locale.getDefault()), physicalFont.getStyle(), logicalFont.getSize());
            }
        }
        return logicalFont;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a followup question to one I previously asked: start-program-if-not-already-running-in-java I didn't get
This is a followup question of How to encode characters from Oracle to Xml?
THis is a followup to my previous question Font-dependent control positioning. It's an attempt
this is a follow up question from this one , I don't want to
This is a follow-up from this question . Functions are not allowed to write
this is actually a followup from a previous question but it contains different information
OK, this question is actually a follow-up question from my previous one: What would
I am creating a swing font chooser. (See also: How to prevent JComboBox from
My question is basically is a followup question to this one , I need
This is in part a followup to this question . I'm not sure the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.