I want to know if anyone has any idea about how to create an app that can change the interface font style in Samsung phones. I have my favorite font style with me in TrueType format.
There are a lot of font style on Galaxy Apps store but they are paid and not what I want. You can see this app as an example what is does after installing the user can just go to Setting >Device >Font Style > Choose Font from List and change font style.
I have tried decompiling it but didn't get much of it. Or in other words, Flip Font app.
Decompiled source
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="2" android:versionName="1.1" package="com.monotype.android.font.presentltroman" platformBuildVersionCode="23" platformBuildVersionName="6.0-2438415">
<uses-sdk android:minSdkVersion="7" />
<application android:label="@string/app_name" android:icon="@drawable/icon">
<provider android:name=".FontContentProvider" android:authorities="com.example.myfont" />
<support-screens android:largeScreens="true" android:xlargeScreens="true" />
</application>
</manifest>
There is only one activity
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import java.io.FileNotFoundException;
public class FontContentProvider extends ContentProvider {
private static final UriMatcher uriMatcher = new UriMatcher(-1);
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
return null;
}
public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException {
String file_name = uri.getPath();
if (file_name == null) {
throw new FileNotFoundException();
}
if (file_name.startsWith("/")) {
file_name = file_name.substring(1);
}
AssetFileDescriptor ad = null;
try {
ad = getContext().getAssets().openFd(file_name);
} catch (Exception e) {
Log.v("CPFontTest", "cp - openAssetFile EXCEPTION");
}
return ad;
}
public int delete(Uri uri, String selection, String[] selectionArgs) {
return 0;
}
public String getType(Uri uri) {
AssetManager am = getContext().getAssets();
StringBuilder xmlfileStringBuilder = new StringBuilder();
try {
for (String s : am.list("xml")) {
xmlfileStringBuilder.append(s + "\n");
}
return xmlfileStringBuilder.toString();
} catch (Exception e) {
return null;
}
}
public Uri insert(Uri uri, ContentValues values) {
return null;
}
public boolean onCreate() {
return true;
}
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
return null;
}
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
return 0;
}
static {
uriMatcher.addURI(".fontcontentprovider", "fonts", 1);
}
}
I tried putting it in my app but it doesn't work.
While stock Android lacks the ability to customize your system font, plenty of manufacturers have adapted their software to support this highly requested feature, allowing you to easily change fonts for Android
This means that there is no System API that you can plugin to make fonts work on all Android devices. However, individual manufactures do provide a custom font implementation.
I did a quick search for you, but it appears that these manufactures don't provide official/generalised APIs (or vague ones like Samsung) for changing their fonts, instead, you'd have to look at each manufactures theme/font implementation individually (reverse engineering?), and find out how system wide fonts are set and how you can plug into this system.
If you are looking for an example of how root apps do this, there are many open source apps that manipulate fonts, like this.