Android Open Source - LimeLight Font Utils






From Project

Back to project page LimeLight.

License

The source code is released under:

GNU General Public License

If you think the Android project LimeLight listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0, as well as to the Additional Term regarding proper
 attribution. The latter is located in Term 11 of the License.
 If a copy of the MPL with the Additional Term was not distributed
 with this file, You can obtain one at http://static.fuzzhq.com/licenses/MPL
 *//*from  w  ww .  ja  v a2s  . c o  m*/

package com.fuzz.android.limelight.util;

import com.fuzz.android.limelight.LimeLight;

import java.io.IOException;
import java.util.ArrayList;

/**
 * Holds methods needed to access and use fonts in LimeLight
 *
 * @author William Xu (Fuzz)
 */
public class FontUtils {

    static private ArrayList<String> fontList;

    /**
     * @return the list of fonts from the assets folder
     */
    public static ArrayList<String> getFonts() {
        if (fontList == null) {
            String[] fontNames = null;
            try {
                fontNames = LimeLight.getActivity().getAssets().list("");
            } catch (IOException e) {
                e.printStackTrace();
            }

            if (fontNames != null) {
                fontList = new ArrayList<String>(fontNames.length);
                String font;
                String fontEnding;
                for (int i = 0; i < fontNames.length; i++) {
                    font = fontNames[i];
                    fontEnding = font.toLowerCase();
                    if (fontEnding.endsWith(".ttf") || fontEnding.endsWith(".otf")) {
                        fontList.add(font);
                    }
                }

            }
        }
        return fontList;
    }

    /**
     * @param fontName name to be formatted and cleaned up
     * @return the cleaned up font name
     */
    public static String sanitizeFontName(String fontName) {

        String sanitized = "";

        String[] capitals = fontName.split("(?=\\p{Upper})");

        for (String s : capitals) {
            sanitized += s + (s.length() > 1 ? " " : "");
        }

        if (sanitized.lastIndexOf(".") > 0) {
            sanitized = sanitized.substring(0, sanitized.lastIndexOf(".")).trim();
        }

        if (sanitized.contains("-")) {
            sanitized = sanitized.replace("-", " - ");
        }

        sanitized = sanitized.replaceAll(" +", " ");

        return sanitized;
    }
}




Java Source Code List

com.fuzz.android.limelight.LimeLight.java
com.fuzz.android.limelight.animation.AnimationHolder.java
com.fuzz.android.limelight.animation.LeftRightAnimation.java
com.fuzz.android.limelight.animation.UpDownAnimation.java
com.fuzz.android.limelight.automate.DrawerAutomator.java
com.fuzz.android.limelight.automate.ViewAutomator.java
com.fuzz.android.limelight.model.ActToViewHelper.java
com.fuzz.android.limelight.model.Act.java
com.fuzz.android.limelight.model.BaseChapter.java
com.fuzz.android.limelight.model.Book.java
com.fuzz.android.limelight.model.ChapterTransition.java
com.fuzz.android.limelight.model.Chapter.java
com.fuzz.android.limelight.model.ModelHelper.java
com.fuzz.android.limelight.model.Text.java
com.fuzz.android.limelight.model.Transition.java
com.fuzz.android.limelight.recorder.FontListAdapter.java
com.fuzz.android.limelight.recorder.RecorderClickListener.java
com.fuzz.android.limelight.recorder.RecorderWindow.java
com.fuzz.android.limelight.recorder.Recorder.java
com.fuzz.android.limelight.recorder.widget.color.ColorHueSlider.java
com.fuzz.android.limelight.recorder.widget.color.ColorPickDialog.java
com.fuzz.android.limelight.recorder.widget.color.ColorSquareView.java
com.fuzz.android.limelight.recorder.widget.color.OnColorChangedListener.java
com.fuzz.android.limelight.recorder.widget.drag.DragAndEditView.java
com.fuzz.android.limelight.recorder.widget.drag.EditorFrameLayout.java
com.fuzz.android.limelight.recorder.widget.drag.OffSetChangeListener.java
com.fuzz.android.limelight.recorder.widget.editor.ActEditor.java
com.fuzz.android.limelight.recorder.widget.editor.ActIconAdapter.java
com.fuzz.android.limelight.recorder.widget.editor.operations.BaseOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeAnimationOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeBackgroundColorOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeIconOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.SetTextColorOperation.java
com.fuzz.android.limelight.recorder.widget.filedialog.FileDirectoryDialog.java
com.fuzz.android.limelight.recorder.widget.filedialog.OnDirectorySelectListener.java
com.fuzz.android.limelight.recorder.widget.snap.SnapHelper.java
com.fuzz.android.limelight.recorder.widget.snap.SnapInfo.java
com.fuzz.android.limelight.text.PrimeTextWatcher.java
com.fuzz.android.limelight.util.FontUtils.java
com.fuzz.android.limelight.util.IOUtils.java
com.fuzz.android.limelight.util.JSONTool.java
com.fuzz.android.limelight.util.LimeLightLog.java
com.fuzz.android.limelight.util.ViewUtils.java
com.fuzz.android.limelight.view.PrimeClickListener.java
com.fuzz.android.limelight.widget.ManualPositionFrameLayout.java