/**
 * Copyright 2014 Mike Penz
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * <p/>
 * It uses FontAwesome font, licensed under OFL 1.1, which is compatible
 * with this library's license.
 * <p/>
 * http://scripts.sil.org/cms/scripts/render_download.php?format=file&media_id=OFL_plaintext&filename=OFL.txt
 */
package com.mikepenz.iconics.typeface;

import android.content.Context;
import android.graphics.Typeface;

import java.util.Collection;
import java.util.HashMap;

/**
 * Created by mikepenz on 01.11.14.
 */
public class GenericFont implements ITypeface {
    private String mFontName = "GenericFont";
    private String mAuthor = "GenericAuthor";
    private String mMappingPrefix;
    private String mFontFile;

    private Typeface typeface = null;
    private HashMap<String, Character> mChars = new HashMap<>();

    protected GenericFont() {
    }

    public GenericFont(String mappingPrefix, String fontFile) {
        this.mMappingPrefix = mappingPrefix;
        this.mFontFile = fontFile;
    }

    public GenericFont(String fontName, String author, String mappingPrefix, String fontFile) {
        this.mFontName = fontName;
        this.mAuthor = author;
        this.mMappingPrefix = mappingPrefix;
        this.mFontFile = fontFile;
    }

    public void registerIcon(String name, char aChar) {
        mChars.put(mMappingPrefix + "_" + name, aChar);
    }

    @Override
    public IIcon getIcon(String key) {
        return new Icon(mChars.get(key)).withTypeface(this);
    }

    @Override
    public HashMap<String, Character> getCharacters() {
        return new HashMap<>();
    }

    @Override
    public String getMappingPrefix() {
        return mMappingPrefix;
    }

    @Override
    public String getFontName() {
        return mFontName;
    }

    @Override
    public String getVersion() {
        return "1.0.0";
    }

    @Override
    public int getIconCount() {
        return mChars.size();
    }

    @Override
    public Collection<String> getIcons() {
        return mChars.keySet();
    }

    @Override
    public String getAuthor() {
        return mAuthor;
    }

    @Override
    public String getUrl() {
        return "";
    }

    @Override
    public String getDescription() {
        return "";
    }

    @Override
    public String getLicense() {
        return "";
    }

    @Override
    public String getLicenseUrl() {
        return "";
    }

    @Override
    public Typeface getTypeface(Context context) {
        if (typeface == null) {
            try {
                typeface = Typeface.createFromAsset(context.getAssets(), mFontFile);
            } catch (Exception e) {
                return null;
            }
        }
        return typeface;
    }

    public class Icon implements IIcon {

        private String mName;
        private char aChar;
        private ITypeface mTypeface;

        public Icon(char c) {
            this.aChar = c;
        }

        public Icon(String name, char c) {
            this.mName = name;
            this.aChar = c;
        }

        public Icon withTypeface(ITypeface typeface) {
            this.mTypeface = typeface;
            return this;
        }

        @Override
        public String getFormattedName() {
            return "{" + getName() + "}";
        }

        @Override
        public String getName() {
            if (mName != null) {
                return mName;
            }
            return String.valueOf(aChar);
        }

        @Override
        public char getCharacter() {
            return aChar;
        }

        @Override
        public ITypeface getTypeface() {
            if (mTypeface != null) {
                return mTypeface;
            } else {
                return GenericFont.this;
            }
        }
    }
}

@@ -1116,24 +1116,8 @@
 Name
- = %22GenericFont%22
 ;%0A  
@@ -1144,26 +1144,8 @@
 thor
- = %22GenericAuthor%22
 ;%0A  
@@ -1429,65 +1429,55 @@
 this
-.mMappingPrefix = mappingPrefix;%0A        this.mFontFile =
+(%22GenericFont%22, %22GenericAuthor%22, mappingPrefix,
  fon
@@ -1473,32 +1473,33 @@
 Prefix, fontFile
+)
 ;%0A    %7D%0A%0A    pub
@@ -1579,32 +1579,164 @@
 ing fontFile) %7B%0A
+        if (mappingPrefix.length() != 3) %7B%0A            new IllegalArgumentException(%22MappingPrefix must be 3 char long%22);%0A        %7D%0A
         this.mFo

Add mappingPrefix validation