Example usage for android.graphics Typeface isItalic

List of usage examples for android.graphics Typeface isItalic

Introduction

In this page you can find the example usage for android.graphics Typeface isItalic.

Prototype

public final boolean isItalic() 

Source Link

Document

Returns true if getStyle() has the ITALIC bit set.

Usage

From source file:Main.java

private static String getFontName(String fontType, Typeface typeface) {
    if (fontType == null)
        if (typeface == null)
            return "Roboto-Regular";
        else if (typeface.isBold() && typeface.isItalic())
            return "Roboto-BoldItalic";
        else if (typeface.isBold())
            return "Roboto-Bold";
        else if (typeface.isItalic())
            return "Roboto-Italic";
        else/*from  w ww.  j  a v a 2s .  c o  m*/
            return "Roboto-Regular";
    else if (fontType.equals("roboto-light"))
        if (typeface == null)
            return "Roboto-Light";
        else if (typeface.isItalic())
            return "Roboto-LightItalic";
        else
            return "Roboto-Light";
    else if (fontType.equals("roboto-condensed"))
        if (typeface == null)
            return "RobotoCondensed-Regular";
        else if (typeface.isBold() && typeface.isItalic())
            return "RobotoCondensed-BoldItalic";
        else if (typeface.isBold())
            return "RobotoCondensed-Bold";
        else if (typeface.isItalic())
            return "RobotoCondensed-Italic";
        else
            return "RobotoCondensed-Regular";
    else if (fontType.equals("roboto-slab"))
        if (typeface == null)
            return "RobotoSlab-Regular";
        else if (typeface.isBold())
            return "RobotoSlab-Bold";
        else
            return "RobotoSlab-Regular";
    else if (fontType.equals("roboto-slab-light"))
        return "RobotoSlab-Light";
    else if (fontType.equals("roboto-slab-thin"))
        return "RobotoSlab-Thin";
    else if (fontType.equals("roboto-condensed-light"))
        if (typeface == null)
            return "RobotoCondensed-Light";
        else if (typeface.isItalic())
            return "RobotoCondensed-LightItalic";
        else
            return "RobotoCondensed-Light";
    else if (fontType.equals("roboto-thin"))
        if (typeface == null)
            return "Roboto-Thin";
        else if (typeface.isItalic())
            return "Roboto-ThinItalic";
        else
            return "Roboto-Thin";
    else if (fontType.equals("roboto-medium"))
        if (typeface == null)
            return "Roboto-Medium";
        else if (typeface.isItalic())
            return "Roboto-MediumItalic";
        else
            return "Roboto-Medium";
    else if (typeface == null)
        return "Roboto-Regular";
    else if (typeface.isBold() && typeface.isItalic())
        return "Roboto-BoldItalic";
    else if (typeface.isBold())
        return "Roboto-Bold";
    else if (typeface.isItalic())
        return "Roboto-Italic";
    else
        return "Roboto-Regular";
}

From source file:com.facebook.appevents.codeless.internal.ViewHierarchy.java

public static JSONObject setAppearanceOfView(View view, JSONObject json, float displayDensity) {
    try {//from  w w w.  ja  v a  2 s.  com
        JSONObject textStyle = new JSONObject();
        if (view instanceof TextView) {
            TextView textView = (TextView) view;
            Typeface typeface = textView.getTypeface();
            if (typeface != null) {
                textStyle.put(TEXT_SIZE, textView.getTextSize());
                textStyle.put(TEXT_IS_BOLD, typeface.isBold());
                textStyle.put(TEXT_IS_ITALIC, typeface.isItalic());
                json.put(TEXT_STYLE, textStyle);
            }
        }
        if (view instanceof ImageView) {
            Drawable drawable = ((ImageView) view).getDrawable();
            if (drawable instanceof BitmapDrawable) {
                if (view.getHeight() / displayDensity <= ICON_MAX_EDGE_LENGTH
                        && view.getWidth() / displayDensity <= ICON_MAX_EDGE_LENGTH) {
                    Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
                    byte[] byteArray = byteArrayOutputStream.toByteArray();
                    String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
                    json.put(ICON_BITMAP, encoded);
                }
            }
        }
    } catch (JSONException e) {
        Utility.logd(TAG, e);
    }

    return json;
}

From source file:com.codename1.impl.android.AndroidImplementation.java

@Override
public Object loadTrueTypeFont(String fontName, String fileName) {
    if (fontName.startsWith("native:")) {
        Typeface t = fontToRoboto(fontName);
        int fontStyle = com.codename1.ui.Font.STYLE_PLAIN;
        if (t.isBold()) {
            fontStyle |= com.codename1.ui.Font.STYLE_BOLD;
        }//from  w w w  . ja va 2  s . c  o  m
        if (t.isItalic()) {
            fontStyle |= com.codename1.ui.Font.STYLE_ITALIC;
        }
        CodenameOneTextPaint newPaint = new CodenameOneTextPaint(t);
        newPaint.setAntiAlias(true);
        newPaint.setSubpixelText(true);
        return new NativeFont(com.codename1.ui.Font.FACE_SYSTEM, fontStyle, com.codename1.ui.Font.SIZE_MEDIUM,
                newPaint, fileName, 0, 0);
    }
    Typeface t = Typeface.createFromAsset(getContext().getAssets(), fileName);
    if (t == null) {
        throw new RuntimeException("Font not found: " + fileName);
    }
    CodenameOneTextPaint newPaint = new CodenameOneTextPaint(t);
    newPaint.setAntiAlias(true);
    newPaint.setSubpixelText(true);
    return new NativeFont(com.codename1.ui.Font.FACE_SYSTEM, com.codename1.ui.Font.STYLE_PLAIN,
            com.codename1.ui.Font.SIZE_MEDIUM, newPaint, fileName, 0, 0);
}

From source file:com.codename1.impl.android.AndroidImplementation.java

@Override
public Object deriveTrueTypeFont(Object font, float size, int weight) {
    NativeFont fnt = (NativeFont) font;//from  w  w w .ja v  a  2  s.c  o  m
    CodenameOneTextPaint paint = (CodenameOneTextPaint) fnt.font;
    paint.setAntiAlias(true);
    Typeface type = paint.getTypeface();
    int fontstyle = Typeface.NORMAL;
    if ((weight & Font.STYLE_BOLD) != 0 || type.isBold()) {
        fontstyle |= Typeface.BOLD;
    }
    if ((weight & Font.STYLE_ITALIC) != 0 || type.isItalic()) {
        fontstyle |= Typeface.ITALIC;
    }
    type = Typeface.create(type, fontstyle);
    CodenameOneTextPaint newPaint = new CodenameOneTextPaint(type);
    newPaint.setTextSize(size);
    newPaint.setAntiAlias(true);
    NativeFont n = new NativeFont(com.codename1.ui.Font.FACE_SYSTEM, weight, com.codename1.ui.Font.SIZE_MEDIUM,
            newPaint, fnt.fileName, size, weight);
    return n;
}