private BitmapFont load(AssetManager assetManager, String folder, InputStream in) throws IOException{
MaterialDef spriteMat =
(MaterialDef) assetManager.loadAsset(new AssetKey("Common/MatDefs/Misc/Unshaded.j3md"));
BitmapCharacterSet charSet = new BitmapCharacterSet();
Material[] matPages = null;
BitmapFont font = new BitmapFont();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String regex = "[\\s=]+";
font.setCharSet(charSet);
String line;
while ((line = reader.readLine())!=null){
String[] tokens = line.split(regex);
if (tokens[0].equals("info")){
// Get rendered size
for (int i = 1; i < tokens.length; i++){
if (tokens[i].equals("size")){
charSet.setRenderedSize(Integer.parseInt(tokens[i + 1]));
}
}
}else if (tokens[0].equals("common")){
// Fill out BitmapCharacterSet fields
for (int i = 1; i < tokens.length; i++){
String token = tokens[i];
if (token.equals("lineHeight")){
charSet.setLineHeight(Integer.parseInt(tokens[i + 1]));
}else if (token.equals("base")){
charSet.setBase(Integer.parseInt(tokens[i + 1]));
}else if (token.equals("scaleW")){
charSet.setWidth(Integer.parseInt(tokens[i + 1]));
}else if (token.equals("scaleH")){
charSet.setHeight(Integer.parseInt(tokens[i + 1]));
}else if (token.equals("pages")){
// number of texture pages
matPages = new Material[Integer.parseInt(tokens[i + 1])];
font.setPages(matPages);
}
}
}else if (tokens[0].equals("page")){
int index = -1;
Texture tex = null;