List of usage examples for android.graphics Typeface create
public static Typeface create(Typeface family, @Style int style)
From source file:com.near.chimerarevo.fragments.PostFragment.java
private void addTitle(String text, int type) { TextView txt = new TextView(getActivity()); txt.setText(text);//from w w w .ja v a 2s . co m txt.setTypeface(Typeface.create("sans-serif-condensed", Typeface.BOLD)); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params.setMargins(10, 10, 10, 0); txt.setLayoutParams(params); txt.setTextIsSelectable(true); switch (type) { case 1: txt.setTextSize(26); break; case 2: txt.setTextSize(24); break; case 3: txt.setTextSize(22); break; case 4: txt.setTextSize(20); break; case 5: txt.setTextSize(18); break; default: break; } lay.addView(txt); }
From source file:nkarasch.repeatingreminder.gui.AlertView.java
private static Typeface getFrequencyFont() { if (frequencyFont == null) { frequencyFont = Typeface.create("sans-serif-light", Typeface.NORMAL); }/*ww w . j a va2 s.c om*/ return frequencyFont; }
From source file:devlight.io.library.ArcProgressStackView.java
public void setTypeface(final String typeface) { Typeface tempTypeface;//from w ww.j a va 2 s . c o m 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:cn.oddcloud.www.navigationtabbar.ntb.NavigationTabBar.java
public void setTypeface(final String typeface) { if (TextUtils.isEmpty(typeface)) return;// w ww . j a v 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)); }
From source file:devlight.io.library.ntb.NavigationTabBar.java
protected void setBadgeTypeface() { mBadgePaint .setTypeface(mIsBadgeUseTypeface ? mTypeface : Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); }
From source file:com.andexert.calendarlistview.library.SimpleMonthView.java
protected void initView() { mMonthTitlePaint = new Paint(); // mMonthTitlePaint.setFakeBoldText(true); mMonthTitlePaint.setAntiAlias(true); mMonthTitlePaint.setTextSize(MONTH_LABEL_TEXT_SIZE); // mMonthTitlePaint.setTypeface(Typeface.create(mMonthTitleTypeface, Typeface.BOLD)); mMonthTitlePaint.setColor(mMonthTextColor); mMonthTitlePaint.setTextAlign(Align.CENTER); mMonthTitlePaint.setStyle(Style.FILL); mMonthTitleBGPaint = new Paint(); mMonthTitleBGPaint.setFakeBoldText(true); mMonthTitleBGPaint.setAntiAlias(true); mMonthTitleBGPaint.setColor(mMonthTitleBGColor); mMonthTitleBGPaint.setTextAlign(Align.CENTER); mMonthTitleBGPaint.setStyle(Style.FILL); mSelectedCirclePaint = new Paint(); mSelectedCirclePaint.setFakeBoldText(true); mSelectedCirclePaint.setAntiAlias(true); mSelectedCirclePaint.setColor(mSelectedDaysColor); mSelectedCirclePaint.setTextAlign(Align.CENTER); mSelectedCirclePaint.setStyle(Style.FILL); // mSelectedCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA); mMonthDayLabelPaint = new Paint(); mMonthDayLabelPaint.setAntiAlias(true); mMonthDayLabelPaint.setTextSize(MONTH_DAY_LABEL_TEXT_SIZE); mMonthDayLabelPaint.setColor(mDayTextColor); mMonthDayLabelPaint.setTypeface(Typeface.create(mDayOfWeekTypeface, Typeface.NORMAL)); mMonthDayLabelPaint.setStyle(Style.FILL); mMonthDayLabelPaint.setTextAlign(Align.CENTER); mMonthDayLabelPaint.setFakeBoldText(true); mMonthNumPaint = new Paint(); mMonthNumPaint.setAntiAlias(true);//from w w w. j a va 2s. com mMonthNumPaint.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE); mMonthNumPaint.setStyle(Style.FILL); mMonthNumPaint.setTextAlign(Align.CENTER); // mMonthNumPaint.setFakeBoldText(false); mMonthNumLinePaint = new Paint(); mMonthNumLinePaint.setAntiAlias(true); mMonthNumLinePaint.setStrokeWidth(getResources().getDimensionPixelSize(R.dimen.month_day_line_width)); mMonthNumLinePaint.setColor(ContextCompat.getColor(getContext(), R.color.month_num_line)); }
From source file:com.android.argb.edhlc.Utils.java
public static void createRecordListElement(View parent, Record currentRecord, String highlightedPlayerName) { RelativeLayout selectedRecord = (RelativeLayout) parent.findViewById(R.id.selectedRecord); selectedRecord.setVisibility(currentRecord.isSelected() ? View.VISIBLE : View.GONE); TextView textDateRecordCard = (TextView) parent.findViewById(R.id.textDateRecordCard); LinearLayout linearFirstLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearFirstLineRecordCard); TextView textFirstIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFirstIndicatorRecordCard); TextView textFirstPlayerRecordCard = (TextView) parent.findViewById(R.id.textFirstPlayerRecordCard); TextView textFirstDeckRecordCard = (TextView) parent.findViewById(R.id.textFirstDeckRecordCard); View divider1RecordCard = parent.findViewById(R.id.divider1RecordCard); LinearLayout linearSecondLineRecordCard = (LinearLayout) parent .findViewById(R.id.linearSecondLineRecordCard); TextView textSecondIndicatorRecordCard = (TextView) parent.findViewById(R.id.textSecondIndicatorRecordCard); TextView textSecondPlayerRecordCard = (TextView) parent.findViewById(R.id.textSecondPlayerRecordCard); TextView textSecondDeckRecordCard = (TextView) parent.findViewById(R.id.textSecondDeckRecordCard); View divider2RecordCard = parent.findViewById(R.id.divider2RecordCard); LinearLayout linearThirdLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearThirdLineRecordCard); TextView textThirdIndicatorRecordCard = (TextView) parent.findViewById(R.id.textThirdIndicatorRecordCard); TextView textThirdPlayerRecordCard = (TextView) parent.findViewById(R.id.textThirdPlayerRecordCard); TextView textThirdDeckRecordCard = (TextView) parent.findViewById(R.id.textThirdDeckRecordCard); View divider3RecordCard = parent.findViewById(R.id.divider3RecordCard); LinearLayout linearFourthLineRecordCard = (LinearLayout) parent .findViewById(R.id.linearFourthLineRecordCard); TextView textFourthIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFourthIndicatorRecordCard); TextView textFourthPlayerRecordCard = (TextView) parent.findViewById(R.id.textFourthPlayerRecordCard); TextView textFourthDeckRecordCard = (TextView) parent.findViewById(R.id.textFourthDeckRecordCard); Typeface typefaceMedium = Typeface.create("sans-serif-medium", Typeface.NORMAL); Typeface typefaceNormal = Typeface.create("sans-serif", Typeface.NORMAL); int colorAccent = ContextCompat.getColor(parent.getContext(), R.color.accent_color); int colorSecondary = ContextCompat.getColor(parent.getContext(), R.color.secondary_text); textDateRecordCard.setText(String.format("Played on %s", currentRecord.getDate())); switch (currentRecord.getTotalPlayers()) { case 2:/*from w ww . ja va 2 s .c o m*/ linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.GONE); linearFourthLineRecordCard.setVisibility(View.GONE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.GONE); divider3RecordCard.setVisibility(View.GONE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; case 3: linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.VISIBLE); linearFourthLineRecordCard.setVisibility(View.GONE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.VISIBLE); divider3RecordCard.setVisibility(View.GONE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName()); textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textThirdIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; case 4: linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.VISIBLE); linearFourthLineRecordCard.setVisibility(View.VISIBLE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.VISIBLE); divider3RecordCard.setVisibility(View.VISIBLE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName()); textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName()); textFourthDeckRecordCard.setText(currentRecord.getFourthPlace().getDeckName()); textFourthPlayerRecordCard.setText(currentRecord.getFourthPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textThirdIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFourthIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; } }
From source file:org.appcelerator.titanium.util.TiUIHelper.java
@SuppressLint("DefaultLocale") private static Typeface loadTypeface(final Context context, final String fontFamily) { if (context == null) { return null; }/*ww w . ja va 2s . com*/ if (mCustomTypeFaces.containsKey(fontFamily)) { return mCustomTypeFaces.get(fontFamily); } if (mCustomTypeFacesList == null) { AssetManager mgr = context.getAssets(); try { ArrayList<String> fileList = new ArrayList<String>(Arrays.asList(mgr.list(customFontPath))); Iterator it = fileList.iterator(); while (it.hasNext()) { String text = (String) it.next(); if (!text.endsWith(".ttf") && !text.endsWith(".otf")) { it.remove(); } } mCustomTypeFacesList = fileList.toArray(new String[] {}); } catch (Exception e) { Log.e(TAG, "Unable to load 'fonts' assets. Perhaps doesn't exist? " + e.getMessage()); } } if (mCustomTypeFacesList != null) { Typeface tf = null; AssetManager mgr = context.getAssets(); for (String f : mCustomTypeFacesList) { if (f.equals(fontFamily) || f.startsWith(fontFamily + ".") || f.startsWith(fontFamily + "-")) { tf = Typeface.createFromAsset(mgr, customFontPath + "/" + f); synchronized (mCustomTypeFaces) { mCustomTypeFaces.put(fontFamily, tf); } return tf; } } tf = Typeface.create(fontFamily, Typeface.NORMAL); if (tf != null) { synchronized (mCustomTypeFaces) { mCustomTypeFaces.put(fontFamily, tf); } return tf; } } mCustomTypeFaces.put(fontFamily, null); return null; }
From source file:com.github.irshulx.Components.InputExtensions.java
/** * returns the appropriate typeface/* w w w.j a va 2 s . c om*/ * * @param mode => whether heading (0) or content(1) * @param style => NORMAL, BOLD, BOLDITALIC, ITALIC * @return typeface */ public Typeface getTypeface(int mode, int style) { if (mode == HEADING && headingTypeface == null) { return Typeface.create(getFontFace(), style); } else if (mode == CONTENT && contentTypeface == null) { return Typeface.create(getFontFace(), style); } if (mode == HEADING && !headingTypeface.containsKey(style)) { throw new IllegalArgumentException( "the provided fonts for heading is missing the varient for this style. Please checkout the documentation on adding custom fonts."); } else if (mode == CONTENT && !headingTypeface.containsKey(style)) { throw new IllegalArgumentException( "the provided fonts for content is missing the varient for this style. Please checkout the documentation on adding custom fonts."); } if (mode == HEADING) { return FontCache.get(headingTypeface.get(style), editorCore.getContext()); } else { return FontCache.get(contentTypeface.get(style), editorCore.getContext()); } }