Suppose I want to use DroidKufi-Regular.ttf font But want to use text size 12 and 15. Mean I want to use the same font with two text size variation. How can I do that dynamically (In java Code)?
I'm using the below code to use custom ttf file if the language is RTL. Its good to show RTL languages with text size 12 But when the language is LTR its too small so now I want to use text size 15.
MyApp extends Application
Configuration config = context.getResources().getConfiguration();
if (isRTL(Locale.getDefault())) {
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/DroidKufi-Regular.ttf")
.setFontAttrId(R.attr.fontPath)
.build());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
config.setLayoutDirection(locale);
}
}
For now I have defined text size in themes (styles.xml). I want to use it dynamically in the above code snippet.
I know I can define a separate theme for LTR and there use needed text size 15 But the problem is I have many variations already so it would be time consuming, But if its possible dynamically the results can be achieved in few line of code.
Suppose I want to use DroidKufi-Regular.ttf font But want to use text size 12 and 15. Mean I want to use the same font with two text size variation. How can I do that dynamically (In java Code)?
I'm using the below code to use custom ttf file if the language is RTL. Its good to show RTL languages with text size 12 But when the language is LTR its too small so now I want to use text size 15.
MyApp extends Application
For now I have defined text size in themes (styles.xml). I want to use it dynamically in the above code snippet. I know I can define a separate theme for LTR and there use needed text size 15 But the problem is I have many variations already so it would be time consuming, But if its possible dynamically the results can be achieved in few line of code.
Thanks Regards, Inzimam Tariq