diff --git a/app/build.gradle b/app/build.gradle
index d15c31fe..0a6bebcf 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -80,6 +80,7 @@ android {
'src/main/res/layouts',
'src/main/res'
]
+ assets.srcDirs = ['src/main/assets', 'src/main/assets/']
}
}
diff --git a/app/src/main/assets/fonts/ptsans.ttf b/app/src/main/assets/fonts/ptsans.ttf
new file mode 100644
index 00000000..ed0372db
Binary files /dev/null and b/app/src/main/assets/fonts/ptsans.ttf differ
diff --git a/app/src/main/assets/fonts/ptsans_caption.ttf b/app/src/main/assets/fonts/ptsans_caption.ttf
new file mode 100644
index 00000000..c1249393
Binary files /dev/null and b/app/src/main/assets/fonts/ptsans_caption.ttf differ
diff --git a/app/src/main/java/org/schulcloud/mobile/SchulCloudApplication.java b/app/src/main/java/org/schulcloud/mobile/SchulCloudApplication.java
index 386cfb61..53810399 100644
--- a/app/src/main/java/org/schulcloud/mobile/SchulCloudApplication.java
+++ b/app/src/main/java/org/schulcloud/mobile/SchulCloudApplication.java
@@ -8,6 +8,7 @@
import org.schulcloud.mobile.injection.component.ApplicationComponent;
import org.schulcloud.mobile.injection.component.DaggerApplicationComponent;
import org.schulcloud.mobile.injection.module.ApplicationModule;
+import org.schulcloud.mobile.util.TypefaceUtil;
import io.fabric.sdk.android.Fabric;
import timber.log.Timber;
@@ -28,6 +29,9 @@ public void onCreate() {
Timber.plant(new Timber.DebugTree());
Fabric.with(this, new Crashlytics());
}
+
+ // override font
+ TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/ptsans.ttf");
}
public ApplicationComponent getComponent() {
diff --git a/app/src/main/java/org/schulcloud/mobile/util/TypefaceUtil.java b/app/src/main/java/org/schulcloud/mobile/util/TypefaceUtil.java
new file mode 100644
index 00000000..c16348b5
--- /dev/null
+++ b/app/src/main/java/org/schulcloud/mobile/util/TypefaceUtil.java
@@ -0,0 +1,31 @@
+package org.schulcloud.mobile.util;
+
+import android.content.Context;
+import android.graphics.Typeface;
+import android.util.Log;
+
+import java.lang.reflect.Field;
+
+import timber.log.Timber;
+
+public class TypefaceUtil {
+
+ /**
+ * Using reflection to override default typeface
+ * NOTICE: DO NOT FORGET TO SET TYPEFACE FOR APP THEME AS DEFAULT TYPEFACE WHICH WILL BE OVERRIDDEN
+ * @param context to work with assets
+ * @param defaultFontNameToOverride for example "monospace"
+ * @param customFontFileNameInAssets file name of the font from assets
+ */
+ public static void overrideFont(Context context, String defaultFontNameToOverride, String customFontFileNameInAssets) {
+ try {
+ final Typeface customFontTypeface = Typeface.createFromAsset(context.getAssets(), customFontFileNameInAssets);
+
+ final Field defaultFontTypefaceField = Typeface.class.getDeclaredField(defaultFontNameToOverride);
+ defaultFontTypefaceField.setAccessible(true);
+ defaultFontTypefaceField.set(null, customFontTypeface);
+ } catch (Exception e) {
+ Timber.e("Can not set custom font " + customFontFileNameInAssets + " instead of " + defaultFontNameToOverride);
+ }
+ }
+}
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index d253293c..87993d46 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -4,6 +4,7 @@
- @color/primary
- @color/primary_dark
- @color/primary_dark
+ - serif
- @style/BarStyle