Load all the fonts - Android Graphics

Android examples for Graphics:Font

Description

Load all the fonts

Demo Code


//package com.java2s;
import android.content.Context;
import android.graphics.Typeface;

public class Main {
    public static final String[] fontPath = { "fonts/Blox2.ttf",
            "fonts/FolksInCube.ttf", "fonts/GautsMotelLowerLeft.ttf",
            "fonts/GautsMotelLowerRight.ttf",
            "fonts/GautsMotelUpperLeft.ttf",
            "fonts/GautsMotelUpperRight.ttf", "fonts/HighLevel.ttf",
            "fonts/Intaglio.ttf", "fonts/VintageOne.ttf" };
    public static boolean fontsLoaded = false;
    public static Typeface[] fonts = new Typeface[fontPath.length];

    /**/*  w ww.j a  v  a2  s. c om*/
     * Load all the fonts
     *
     * @param context - the current context
     */
    public static void loadRobotoFonts(Context context) {
        for (int i = 0; i < fontPath.length; i++) {
            fonts[i] = Typeface.createFromAsset(context.getAssets(),
                    fontPath[i]);
        }
        fontsLoaded = true;

    }
}

Related Tutorials