uk.co.chrisjenx.calligraphy.TypefaceUtils Java Examples
The following examples show how to use
uk.co.chrisjenx.calligraphy.TypefaceUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecordsViewHolder.java From UPMiss with GNU General Public License v3.0 | 6 votes |
private void setTimeDay(TextView textView, String day) { final Resources resources = textView.getResources(); final String suffix = resources.getString(R.string.txt_day); final int dayLen = day.length(); SpannableStringBuilder sBuilder = new SpannableStringBuilder(); sBuilder.append(day) // Bold this .append('\n') // Default TextView font. .append(suffix); // Default TextView font. // Create the Typeface you want to apply to certain text CalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(resources.getAssets(), "fonts/Hero.otf")); sBuilder.setSpan(typefaceSpan, 0, dayLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // Font sBuilder.setSpan(new AbsoluteSizeSpan(resources.getDimensionPixelSize(R.dimen.font_24)), 0, dayLen, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // Color sBuilder.setSpan(new ForegroundColorSpan(resources.getColor(R.color.cyan_700)), 0, dayLen, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(sBuilder, TextView.BufferType.SPANNABLE); }
Example #2
Source File: MultipleRowTextView.java From jianshi with Apache License 2.0 | 6 votes |
private void initWith(Context context, AttributeSet attrs) { paint = new Paint(); paint.setTextAlign(Paint.Align.CENTER); paint.setAntiAlias(true); paint.setColor(Color.BLACK); TypedArray typedArray = context.getTheme() .obtainStyledAttributes(attrs, R.styleable.MultipleRowTextView, 0, 0); try { float textSizePixel = typedArray.getDimension( R.styleable.MultipleRowTextView_multiRowTextSize, getResources().getDimension(R.dimen.normal_text_size)); int textSizeSp = DisplayUtil.px2sp(context, textSizePixel); mFontSize = DisplayUtil.sp2px(context, textSizeSp); } finally { typedArray.recycle(); } setTypeface(TypefaceUtils.load(context.getAssets(), "fonts/jianshi_default.otf")); }
Example #3
Source File: TextPointView.java From jianshi with Apache License 2.0 | 6 votes |
private void init(AttributeSet attrs) { TypedArray typedArray = context.getTheme() .obtainStyledAttributes(attrs, R.styleable.TextPointView, 0, 0); singleText = typedArray.getString(R.styleable.TextPointView_text); circleColorRes = typedArray.getInt(R.styleable.TextPointView_redPointViewBgColor, R.color.bright_red); textSize = typedArray.getDimensionPixelSize(R.styleable.TextPointView_textSize, DEFAULT_TEXT_SIZE); typedArray.recycle(); circleView = new View(context); circleView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); setCircleBackgroundColor(circleColorRes); textView = new TextView(context); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); textView.setTypeface(TypefaceUtils.load(context.getAssets(), "fonts/jianshi_default.otf")); textView.setTextSize(textSize); textView.setTextColor(ContextCompat.getColor(context, R.color.white)); textView.setText(singleText); addView(circleView); addView(textView); }
Example #4
Source File: MainActivity.java From UPMiss with GNU General Public License v3.0 | 5 votes |
private void initTitle() { SpannableStringBuilder sBuilder = new SpannableStringBuilder(); sBuilder.append(getTitle()); // Bold this // Create the Typeface you want to apply to certain text try { CalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/Lobster.otf")); // Apply typeface to the Spannable 0 - 6 "Hello!" This can of course by dynamic. sBuilder.setSpan(typefaceSpan, 0, sBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); mToolbar.setTitle(sBuilder); } catch (IllegalArgumentException e) { e.printStackTrace(); } }
Example #5
Source File: BaseFragmentActivity.java From edx-app-android with Apache License 2.0 | 5 votes |
/** * Sets the font of any TextView found within the ToolBar. * <br/> * TODO: Remove this function when this issue gets resolved: https://github.com/chrisjenx/Calligraphy/issues/295 */ private void setToolBarFont() { final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); for (int i = 0; i < toolbar.getChildCount(); i++) { final View child = toolbar.getChildAt(i); if (child instanceof TextView) { final TextView textView = (TextView) child; CalligraphyUtils.applyFontToTextView(textView, TypefaceUtils.load(getAssets(), "fonts/OpenSans-Semibold.ttf")); } } }
Example #6
Source File: DiscussionPostsAdapter.java From edx-app-android with Apache License 2.0 | 5 votes |
@Inject public DiscussionPostsAdapter(Context context, IEdxEnvironment environment) { super(context, R.layout.row_discussion_thread, environment); edx_brand_primary_base = context.getResources().getColor(R.color.edx_brand_primary_base); edx_grayscale_neutral_dark = context.getResources().getColor(R.color.edx_brand_gray_base); edx_brand_secondary_dark = context.getResources().getColor(R.color.edx_brand_secondary_dark); edx_utility_success_dark = context.getResources().getColor(R.color.edx_success_text); openSansSemiBoldFont = TypefaceUtils.load(context.getAssets(), "fonts/OpenSans-Semibold.ttf"); }
Example #7
Source File: TypesetterActivity.java From Typesetter with MIT License | 4 votes |
@Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Typeface typeface = TypefaceUtils.load(getAssets(), "fonts/" + fonts.get(position).getFileName()); binding.fillerTextView.setTypeface(typeface); }