Subversion Repositories AndroidProjects

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.gebauz.Bauzoid.graphics;

import java.util.HashMap;

import com.badlogic.gdx.Gdx;
import com.gebauz.Bauzoid.file.FileUtil;
import com.gebauz.Bauzoid.game.Game;
import com.gebauz.Bauzoid.game.GameObject;

/** Manages the fonts currently loaded into the system.
 * Makes sure fonts don't get loaded multiple times.
 *
 * @author chris
 *
 */

public class FontCollection extends GameObject
{
       
        private HashMap<String, Font> mFonts = new HashMap<String, Font>();

        public FontCollection(Game game)
        {
                super(game);
               
        }
       
        public void init()
        {
               
        }
       
        public void exit()
        {
                //mFonts.
        }
       
        public Font loadFont(String filename)
        {
                String fontName = FileUtil.extractPath(filename);
               
                if (mFonts.containsKey(fontName))
                        return getFont(fontName);
               
                Font font = FontUtil.createFontFromBinaryFile(getGame().getGraphics(), Gdx.files.internal(filename));
                mFonts.put(fontName, font);
                return font;
        }
       
        public Font getFont(String fontName)
        {
                return mFonts.get(fontName);
        }
}