Example usage for android.graphics Typeface NORMAL

List of usage examples for android.graphics Typeface NORMAL

Introduction

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

Prototype

int NORMAL

To view the source code for android.graphics Typeface NORMAL.

Click Source Link

Usage

From source file:com.github.irshulx.Components.InputExtensions.java

private void updateTextStyle(TextView editText, EditorTextStyle editorTextStyle) {
    EditorControl tag;//from  w ww. j a v a2  s .co m
    if (editText == null) {
        editText = (EditText) editorCore.getActiveView();
    }
    EditorControl editorControl = editorCore.getControlTag(editText);
    if (isEditorTextStyleHeaders(editorTextStyle)) {
        if (editorCore.containsStyle(editorControl.editorTextStyles, editorTextStyle)) {
            editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, NORMALTEXTSIZE);
            editText.setTypeface(getTypeface(CONTENT, Typeface.NORMAL));
            tag = reWriteTags(editorControl, EditorTextStyle.NORMAL);
        } else {
            editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, getTextStyleFromStyle(editorTextStyle));
            editText.setTypeface(getTypeface(HEADING, Typeface.BOLD));
            tag = reWriteTags(editorControl, editorTextStyle);
        }
        editText.setTag(tag);
    }
}

From source file:com.github.irshulx.Components.InputExtensions.java

public void boldifyText(EditorControl tag, TextView editText, int textMode) {
    if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLD)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Delete);
        editText.setTypeface(getTypeface(textMode, Typeface.NORMAL));
    } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLDITALIC)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Delete);
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Insert);
        editText.setTypeface(getTypeface(textMode, Typeface.ITALIC));
    } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.ITALIC)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Insert);
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Delete);
        editText.setTypeface(getTypeface(textMode, Typeface.BOLD_ITALIC));
    } else {/*from  www  .ja v  a2s.c o m*/
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Insert);
        editText.setTypeface(getTypeface(textMode, Typeface.BOLD));
    }
    editText.setTag(tag);
}

From source file:org.appspot.apprtc.util.ThumbnailsCacheManager.java

public static void LoadMenuImage(final String url, MenuItem menuItem, String displayname, final boolean rounded,
        Resources resources, boolean fromCache) {
    final Resources mResources = resources;
    final WeakReference<MenuItem> menuItemImage = new WeakReference<MenuItem>(menuItem);
    final Handler uiHandler = new Handler();
    final int FG_COLOR = 0xFFFAFAFA;
    final String name = displayname;

    if (fromCache) {
        Bitmap bitmap = ThumbnailsCacheManager.getBitmapFromDiskCache(url);

        if (bitmap != null) {
            if (rounded) {
                RoundedBitmapDrawable roundedBitmap = RoundedBitmapDrawableFactory.create(mResources, bitmap);
                roundedBitmap.setCircular(true);
                menuItemImage.get().setIcon(roundedBitmap);
            } else {
                menuItemImage.get().setIcon(new BitmapDrawable(bitmap));
            }//from w w  w .j  a v  a 2s . c  o  m
            return;
        }
    }

    AsyncHttpURLConnection httpConnection = new AsyncHttpURLConnection("GET", url, "",
            new AsyncHttpURLConnection.AsyncHttpEvents() {
                @Override
                public void onHttpError(String errorMessage) {
                    Log.d("LoadImage", errorMessage);
                }

                @Override
                public void onHttpComplete(String response) {
                    int size = 96;
                    Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
                    Canvas canvas = new Canvas(bitmap);
                    final String trimmedName = name == null ? "" : name.trim();
                    drawTile(canvas, trimmedName, 0, 0, size, size);
                    ThumbnailsCacheManager.addBitmapToCache(url, bitmap);
                    onHttpComplete(bitmap);
                }

                @Override
                public void onHttpComplete(final Bitmap response) {
                    if (menuItemImage != null && menuItemImage.get() != null) {
                        uiHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                if (rounded) {
                                    RoundedBitmapDrawable roundedBitmap = RoundedBitmapDrawableFactory
                                            .create(mResources, response);
                                    roundedBitmap.setCircular(true);
                                    menuItemImage.get().setIcon(roundedBitmap);
                                } else {
                                    menuItemImage.get().setIcon(new BitmapDrawable(response));
                                }
                            }

                        });

                    }
                }

                private boolean drawTile(Canvas canvas, String letter, int tileColor, int left, int top,
                        int right, int bottom) {
                    letter = letter.toUpperCase(Locale.getDefault());
                    Paint tilePaint = new Paint(), textPaint = new Paint();
                    tilePaint.setColor(tileColor);
                    textPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
                    textPaint.setColor(FG_COLOR);
                    textPaint.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
                    textPaint.setTextSize((float) ((right - left) * 0.8));
                    Rect rect = new Rect();

                    canvas.drawRect(new Rect(left, top, right, bottom), tilePaint);
                    textPaint.getTextBounds(letter, 0, 1, rect);
                    float width = textPaint.measureText(letter);
                    canvas.drawText(letter, (right + left) / 2 - width / 2,
                            (top + bottom) / 2 + rect.height() / 2, textPaint);
                    return true;
                }

                private boolean drawTile(Canvas canvas, String name, int left, int top, int right, int bottom) {
                    if (name != null) {
                        final String letter = getFirstLetter(name);
                        final int color = ThumbnailsCacheManager.getColorForName(name);
                        drawTile(canvas, letter, color, left, top, right, bottom);
                        return true;
                    }
                    return false;
                }

            });
    httpConnection.setBitmap();
    httpConnection.send();
}

From source file:nkarasch.repeatingreminder.gui.AlertView.java

private static Typeface getFrequencyFont() {
    if (frequencyFont == null) {
        frequencyFont = Typeface.create("sans-serif-light", Typeface.NORMAL);
    }//from  ww  w .j a  v a2  s .co m
    return frequencyFont;
}

From source file:com.github.irshulx.Components.InputExtensions.java

public void italicizeText(EditorControl tag, TextView editText, int textMode) {

    if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.ITALIC)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Delete);
        editText.setTypeface(getTypeface(textMode, Typeface.NORMAL));
    } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLDITALIC)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Delete);
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Insert);
        editText.setTypeface(getTypeface(textMode, Typeface.BOLD));
    } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLD)) {
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Insert);
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Delete);
        editText.setTypeface(getTypeface(textMode, Typeface.BOLD_ITALIC));
    } else {//from   ww w. ja  va2  s.co  m
        tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Insert);
        editText.setTypeface(getTypeface(textMode, Typeface.ITALIC));
    }
    editText.setTag(tag);
}

From source file:devlight.io.library.ArcProgressStackView.java

public void setTypeface(final String typeface) {
    Typeface tempTypeface;/* www  . j  a v a2 s.c  om*/
    try {
        if (isInEditMode())
            return;
        tempTypeface = Typeface.createFromAsset(getContext().getAssets(), typeface);
    } catch (Exception e) {
        tempTypeface = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL);
    }

    setTypeface(tempTypeface);
}

From source file:org.appcelerator.titanium.util.TiUIHelper.java

public static FontDesc getFontStyle(final Context context, final HashMap<String, Object> d) {
    FontDesc desc = new FontDesc();
    if (d == null) {
        desc.setDefaults(context);/*from  ww w.j  av a 2 s .com*/
        return desc;
    }
    String fontSize = null;
    if (d.containsKey("size")) {
        fontSize = TiConvert.toString(d, "size");
    }
    float[] result = new float[2];
    getSizeAndUnits(fontSize, result);
    desc.sizeUnit = (int) result[0];
    desc.size = result[1];

    String fontWeight = null;
    String fontStyle = null;
    if (d.containsKey("weight")) {
        fontWeight = TiConvert.toString(d, "weight");
    }
    if (d.containsKey("style")) {
        fontStyle = TiConvert.toString(d, "style");
    }
    desc.style = toTypefaceStyle(fontWeight, fontStyle);

    String fontFamily = null;
    if (d.containsKey("family")) {
        fontFamily = TiConvert.toString(d, "family");
    }
    if (fontWeight != null && desc.style == Typeface.NORMAL && fontWeight != "normal") {
        desc.typeface = toTypeface(context, fontFamily, fontWeight);
    } else {
        desc.typeface = toTypeface(context, fontFamily, null);
    }
    return desc;
}

From source file:com.android.deskclock.Utils.java

/**
 * @param context - context used to get time format string resource
 * @param showAmPm - include the am/pm string if true
 * @return format string for 12 hours mode time
 *//* w  ww .  j  a va2s  . c o  m*/
public static CharSequence get12ModeFormat(Context context, boolean showAmPm) {
    String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), "hma");
    if (!showAmPm) {
        pattern = pattern.replaceAll("a", "").trim();
    }

    // Replace spaces with "Hair Space"
    pattern = pattern.replaceAll(" ", "\u200A");
    // Build a spannable so that the am/pm will be formatted
    int amPmPos = pattern.indexOf('a');
    if (amPmPos == -1) {
        return pattern;
    }

    final Resources resources = context.getResources();
    final float amPmProportion = resources.getFraction(R.fraction.ampm_font_size_scale, 1, 1);
    final Spannable sp = new SpannableString(pattern);
    sp.setSpan(new RelativeSizeSpan(amPmProportion), amPmPos, amPmPos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    sp.setSpan(new StyleSpan(Typeface.NORMAL), amPmPos, amPmPos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    sp.setSpan(new TypefaceSpan("sans-serif"), amPmPos, amPmPos + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    // Make the font smaller for locales with long am/pm strings.
    if (Utils.isAmPmStringLong()) {
        final float proportion = resources.getFraction(R.fraction.reduced_clock_font_size_scale, 1, 1);
        sp.setSpan(new RelativeSizeSpan(proportion), 0, pattern.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    return sp;
}

From source file:cn.oddcloud.www.navigationtabbar.ntb.NavigationTabBar.java

public void setTypeface(final String typeface) {
    if (TextUtils.isEmpty(typeface))
        return;//from   w  w  w .j  av  a  2  s. c om

    Typeface tempTypeface;
    try {
        tempTypeface = Typeface.createFromAsset(getContext().getAssets(), typeface);
    } catch (Exception e) {
        tempTypeface = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL);
        e.printStackTrace();
    }

    setTypeface(tempTypeface);
}

From source file:cn.oddcloud.www.navigationtabbar.ntb.NavigationTabBar.java

private void setBadgeTypeface() {
    mBadgePaint
            .setTypeface(mIsBadgeUseTypeface ? mTypeface : Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
}