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

  • SEARCH
  • Home
  • 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 6348643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:27:37+00:00 2026-05-24T21:27:37+00:00

Usually, when I initialize the fonts I want to use in my SWING applications,

  • 0

Usually, when I initialize the fonts I want to use in my SWING applications, I do it this way:

public static final Font TITLEFONT = new Font("Calibri", Font.BOLD, 40);

Now, I have to do it a bit differently since I’m using some custom fonts from a .ttf file. I initialize the font this way:

try
{
    InputStream is = OptionsValues.class.getResourceAsStream("fonts//KOMIKAX_.ttf");
    TITLEFONT = Font.createFont(Font.TRUETYPE_FONT, is);
}
catch (Exception ex)
{
    ex.printStackTrace();
    System.err.println("Font not loaded.  Using Calibri font.");
    TITLEFONT = new Font("Calibri", Font.BOLD, 40);
}

I’m pretty sure it initializes it correctly (I can’t tell for sure since it is too small for me to see), but I’d like to know how I can manually set the font’s size (and if it’s bold / other attributes) when loading a font this way.

Thanks a lot in advance!

  • 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-24T21:27:38+00:00Added an answer on May 24, 2026 at 9:27 pm

    createFont returns a Font and you can call deriveFont(...) on this, passing in a float for the point size, or an int and float for Font style and point size. I cannot say whether it will work for your particular situation, but it’s worth a try.

    e.g.,

    InputStream is = OptionsValues.class.getResourceAsStream("fonts//KOMIKAX_.ttf");
    TITLEFONT = Font.createFont(Font.TRUETYPE_FONT, is).deriveFont(Font.BOLD, 40f);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Usually, when I try to initialize a static variable class Test2 { public: static
I know that this is usually not the way to use AngularJS but I
This code generates a pair of public/private keys: KeyPairGenerator keyGen = KeyPairGenerator.getInstance(RSA); keyGen.initialize(1024); KeyPair
Usually Flash and Flex applications are embedded on in HTML using either a combination
Usually when I need to fork in C, I do something like this: pid_t
Usually, before setting up a UILabel, we have to initialize CGRect like below CGRect
Usually like this: #include <boost/assign/std/vector.hpp> vector<int> v; v += 1,2,3,4,5; Except for a: #include
I'm trying to initialize a static class, with an argument, and then run some
T x(value) is usually the better choice because it will directly initialize x with
I need a 'good' way to initialize the pseudo-random number generator in C++. I've

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.