Fonts within an executable


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Fonts within an executable

  1. #1
    Join Date
    Aug 2003
    Posts
    5

    Fonts within an executable

    I'm new both here and to Java, so please bear with me.

    My limited research into Java's capabilities indicates that an application can only use those fonts already on the user's machine. Please correct me if I am mistaken.

    My question is: how can I get a Java application to use fonts not supported by the user's machine?

    Here is the scenario: The user downloads a Java executable (possibly in a zip file) and runs it. The user does not have a particular font used by the Java application already on his machine. I want that download to bring the font with it in some fashion that the application can use.

  2. #2
    Join Date
    Aug 2003
    Posts
    5
    Is there no way to do this? I suppose I could make a graphical file that contains all the font's character glyphs and get them that way, but of course I'd prefer not to do that unless necessary.

    Could I perhaps load a font into an object and then save the object to a file? How does that sound as a solution?

    What is the easiest way to do this?

  3. #3
    Join Date
    Mar 2003
    Posts
    834
    You could check to see if the font is installed:
    Code:
    import java.awt.*;
    
    
    public class Test {
            public static void main(String[] args) {
                    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    
                    Font[] fonts = ge.getAllFonts();
                    for (int i=0; i<fonts.length; i++) {
                            String faceName = fonts[i].getName();
                            System.out.println(faceName);
                    }
            }
    }
    ...and if it's not, copy the font file to a specified fonts directory, re-run the above test to check that the font is registered and then continue.
    ArchAngel.
    O:-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center