Questions about fonts in Java - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Questions about fonts in Java

galvlogalvlo Posts: 17Member
Is it possible to use a font in a program that people don't have installed on their system? For example, I am a beginning Java programmer and starting out by picking about dinky little games (in this case, a simple open source game of Tetris) and seeing how they work, try to tweak them, etc.

Can I use a font that isn't installed on someone's computer?

Comments

  • VilanyeVilanye Posts: 684Member
    : Is it possible to use a font in a program that people don't have installed on their system? For example, I am a beginning Java programmer and starting out by picking about dinky little games (in this case, a simple open source game of Tetris) and seeing how they work, try to tweak them, etc.
    :
    : Can I use a font that isn't installed on someone's computer?
    :
    No, which is why most text content uses standard fonts. You might be able to add the font file to the distributable.
    [italic][blue]Just my 2 bits[/blue][/italic]

  • galvlogalvlo Posts: 17Member
    [b][red]This message was edited by galvlo at 2007-4-15 21:0:12[/red][/b][hr]
    : : Is it possible to use a font in a program that people don't have installed on their system? For example, I am a beginning Java programmer and starting out by picking about dinky little games (in this case, a simple open source game of Tetris) and seeing how they work, try to tweak them, etc.
    : :
    : : Can I use a font that isn't installed on someone's computer?
    : :
    : No, which is why most text content uses standard fonts. You might be able to add the font file to the distributable.
    : [italic][blue]Just my 2 bits[/blue][/italic]
    :
    :


    Ugh, was hoping I would get that bad news hehe. Ok, is it possible for a game, upon starting, to check and see if you have a particular font installed and if not, prompt the player with the option to install it (include the font in with the game)?


  • VilanyeVilanye Posts: 684Member
    : [b][red]This message was edited by galvlo at 2007-4-15 21:0:12[/red][/b][hr]
    : : : Is it possible to use a font in a program that people don't have installed on their system? For example, I am a beginning Java programmer and starting out by picking about dinky little games (in this case, a simple open source game of Tetris) and seeing how they work, try to tweak them, etc.
    : : :
    : : : Can I use a font that isn't installed on someone's computer?
    : : :
    : : No, which is why most text content uses standard fonts. You might be able to add the font file to the distributable.
    : : [italic][blue]Just my 2 bits[/blue][/italic]
    : :
    : :
    :
    :
    : Ugh, was hoping I would get that bad news hehe. Ok, is it possible for a game, upon starting, to check and see if you have a particular font installed and if not, prompt the player with the option to install it (include the font in with the game)?
    :
    :
    :

    Yes, you can get a list for installed fonts, you can also put them in a String to list in a combo box or whatever:

    [code]
    GraphicsEnvironment get= GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] font = ge.getAllFonts();
    String[] fn = new String[font.length];

    for(int i=0;i<font.length;i++)
    fn[i] = font[i].getFontName();

    [italic][blue]Just my 2 bits[/blue][/italic]

  • VilanyeVilanye Posts: 684Member
    : [b][red]This message was edited by galvlo at 2007-4-15 21:0:12[/red][/b][hr]
    : : : Is it possible to use a font in a program that people don't have installed on their system? For example, I am a beginning Java programmer and starting out by picking about dinky little games (in this case, a simple open source game of Tetris) and seeing how they work, try to tweak them, etc.
    : : :
    : : : Can I use a font that isn't installed on someone's computer?
    : : :
    : : No, which is why most text content uses standard fonts. You might be able to add the font file to the distributable.
    : : [italic][blue]Just my 2 bits[/blue][/italic]
    : :
    : :
    :
    :
    : Ugh, was hoping I would get that bad news hehe. Ok, is it possible for a game, upon starting, to check and see if you have a particular font installed and if not, prompt the player with the option to install it (include the font in with the game)?
    :

    Yes, you can get a list a installed fonts as a Font[] or String[]:

    [code]GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] font = ge.getAllFonts();
    String[] fn = new String[font.length];

    for(int i=0;i<font.length;i++)
    {
    fn[i] = font[i].getFontName();
    // System.out.println(fn[i]);
    }
    [/code]

    I am not sure exactly how to install them in code.

    [italic][blue]Just my 2 bits[/blue][/italic]

Sign In or Register to comment.