1 /******************************************************************************* 2 * Copyright 2011 See AUTHORS file. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17 package com.badlogic.gdx.graphics.g2d.freetype; 18 19 import com.badlogic.gdx.assets.AssetDescriptor; 20 import com.badlogic.gdx.assets.AssetLoaderParameters; 21 import com.badlogic.gdx.assets.AssetManager; 22 import com.badlogic.gdx.assets.loaders.FileHandleResolver; 23 import com.badlogic.gdx.assets.loaders.SynchronousAssetLoader; 24 import com.badlogic.gdx.files.FileHandle; 25 import com.badlogic.gdx.utils.Array; 26 27 /** Makes {@link FreeTypeFontGenerator} managable via {@link AssetManager}. 28 * <p> 29 * Do 30 * {@code assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(new InternalFileHandleResolver()))} 31 * to register it. 32 * </p> 33 * @author Daniel Holderbaum */ 34 public class FreeTypeFontGeneratorLoader extends 35 SynchronousAssetLoader<FreeTypeFontGenerator, FreeTypeFontGeneratorLoader.FreeTypeFontGeneratorParameters> { 36 37 public FreeTypeFontGeneratorLoader (FileHandleResolver resolver) { 38 super(resolver); 39 } 40 41 @Override 42 public FreeTypeFontGenerator load (AssetManager assetManager, String fileName, FileHandle file, 43 FreeTypeFontGeneratorParameters parameter) { 44 FreeTypeFontGenerator generator = null; 45 if (file.extension().equals("gen")) { 46 generator = new FreeTypeFontGenerator(file.sibling(file.nameWithoutExtension())); 47 } else { 48 generator = new FreeTypeFontGenerator(file); 49 } 50 return generator; 51 } 52 53 @Override 54 public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, FreeTypeFontGeneratorParameters parameter) { 55 return null; 56 } 57 58 static public class FreeTypeFontGeneratorParameters extends AssetLoaderParameters<FreeTypeFontGenerator> { 59 } 60 } 61