Skip to content

Custom font for all textFields programmatically #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Sep 19 19:16:06 BDT 2014
#Tue May 31 09:21:50 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
17 changes: 15 additions & 2 deletions library/src/main/java/com/alamkanak/weekview/WeekView.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ private enum Direction {
private boolean mVerticalFlingEnabled = true;
private int mAllDayEventHeight = 100;
private int mScrollDuration = 250;
private Typeface mTypeface = Typeface.DEFAULT_BOLD;

// Listeners.
private EventClickListener mEventClickListener;
Expand Down Expand Up @@ -386,7 +387,8 @@ private void init() {
mHeaderTextPaint.setTextSize(mTextSize);
mHeaderTextPaint.getTextBounds("00 PM", 0, "00 PM".length(), rect);
mHeaderTextHeight = rect.height();
mHeaderTextPaint.setTypeface(Typeface.DEFAULT_BOLD);
mHeaderTextPaint.setTypeface(mTypeface);


// Prepare header background paint.
mHeaderBackgroundPaint = new Paint();
Expand Down Expand Up @@ -423,7 +425,8 @@ private void init() {
mTodayHeaderTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTodayHeaderTextPaint.setTextAlign(Paint.Align.CENTER);
mTodayHeaderTextPaint.setTextSize(mTextSize);
mTodayHeaderTextPaint.setTypeface(Typeface.DEFAULT_BOLD);
mTodayHeaderTextPaint.setTypeface(mTypeface);

mTodayHeaderTextPaint.setColor(mTodayHeaderTextColor);

// Prepare event background color.
Expand Down Expand Up @@ -1439,6 +1442,16 @@ public void setHeaderColumnTextColor(int headerColumnTextColor) {
invalidate();
}

public void setTypeface(Typeface typeface){
if(typeface!=null){
mEventTextPaint.setTypeface(typeface);
mTodayHeaderTextPaint.setTypeface(typeface);
mTimeTextPaint.setTypeface(typeface);
mTypeface = typeface;
init();
}
}

public int getHeaderRowPadding() {
return mHeaderRowPadding;
}
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.alamkanak.weekview.sample;

import android.graphics.RectF;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.TypedValue;
Expand Down Expand Up @@ -55,6 +56,9 @@ protected void onCreate(Bundle savedInstanceState) {
// Set up a date time interpreter to interpret how the date and time will be formatted in
// the week view. This is optional.
setupDateTimeInterpreter(false);

Typeface customTypeface = Typeface.createFromAsset(this.getAssets(), "fonts/Raleway/Raleway-Medium.ttf");
mWeekView.setTypeface(customTypeface);
}


Expand Down