Code example for Typeface

Methods: creategetStyle

0
 
        if (parts.length > 1)
        { 
            if ("*".equals(parts[1]))
            { 
                style = getTypeface().getStyle();
            } 
            else if ("plain".equalsIgnoreCase(parts[1]) ||
                "normal".equalsIgnoreCase(parts[1]))
            { 
                style = Typeface.NORMAL;
            } 
            else if ("bold".equalsIgnoreCase(parts[1]))
            { 
                style = Typeface.BOLD;
            } 
            else if ("italic".equalsIgnoreCase(parts[1]))
            { 
                style = Typeface.ITALIC;
            } 
            else if ("bolditalic".equalsIgnoreCase(parts[1]))
            { 
                style = Typeface.BOLD_ITALIC;
            } 
            else 
            { 
                throw new IllegalArgumentException(
                    "'" + parts[1] + "' is not a valid typeface style.");
            } 
        } 
        else 
        { 
            style = getTypeface().getStyle();
        } 
 
        if (parts.length > 2)
        { 
            if ("*".equals(parts[2]))
            { 
                textSize = getTypeSize();
            } 
            else 
            { 
                try 
                { 
                    textSize = Float.parseFloat(parts[2]);
                } 
                catch (NumberFormatException e)
                { 
                    throw new IllegalArgumentException(
                        "'" + parts[2] + "' is not a valid typeface size.");
                } 
            } 
        } 
        else 
        { 
            textSize = getTypeSize();
        } 
 
        Typeface newTypeface;
 
        if (family == null)
        { 
            newTypeface = Typeface.create(getTypeface(), style);
        } 
        else 
        { 
            newTypeface = Typeface.create(family, style);
        }