This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uk.co.chrisjenx.calligraphy.CalligraphyConfig; | |
// ... | |
private fun initCustomFonts() { | |
CalligraphyConfig.initDefault(CalligraphyConfig.Builder() | |
.setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf") | |
.setFontAttrId(R.attr.fontPath) | |
.build() | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper | |
// ... | |
override fun attachBaseContext(newBase: Context) { | |
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<font-family xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto"> | |
<!-- Regular --> | |
<font | |
app:font="@font/my_custom_font_regular" | |
app:fontStyle="normal" | |
app:fontWeight="400" /> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myView.setTypeface( | |
TypefaceUtils.load(requireContext().assets, "fonts/my_custom_font_regular.ttf") | |
) | |
// To: | |
myView.setTypeface( | |
ResourcesCompat.getFont(requireContext(), R.font.my_custom_font_family) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val spannable = SpannableString("My spannable string with custom font") | |
spannable.setSpan(CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/my_custom_font_regular.ttf"))) | |
myTextView.text = spannable | |
// To: | |
val spannable = SpannableString("My spannable string with custom font") | |
spannable.setSpan(TypefaceSpan(ResourcesCompat.getFont(context, R.font.maison_neue_medium))) | |
myTextView.text = spannable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<TextView | |
... | |
fontPath="fonts/my_custom_font_regular.ttf" /> | |
<!-- To: --> | |
<TextView | |
... | |
android:fontFamily="@font/my_custom_font_family" /> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style name="MyStyle"> | |
<item name="fontFamily">fonts/my_custom_font_regular.ttf</item> | |
</style> | |
<!-- To: --> | |
<style name="MyStyle"> | |
<item name="android:fontFamily">@font/my_custom_font_family</item> | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
int intNumber = 10; | |
double doubleNumber = 70.0; | |
double exponentialNumber = 1.35e2; | |
int hexadecimalNumber = 0xF1A; | |
double castIntToDouble = intNumber.toDouble(); | |
int castDoubleToInt = doubleNumber.toInt(); | |
var intString = intNumber.toString(); | |
int? parsedNumber = int.tryParse("16"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
String singleQuotes = 'Double quotes in "single" quotes'; | |
String doubleQuotes = "Single quotes in 'double' quotes"; | |
String multiLine = ''' | |
{ | |
"field": "value" | |
} | |
'''; | |
String concat = 'Dart ' + 'is ' + 'fun!'; | |
String concatV2 = 'Dart ' 'is ' 'fun!'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
// Mutable variable | |
String explicitMutableVariable = "Hey!"; | |
var implicitMutableVariable = "Hey!"; | |
// Immutable variable (runtime constant) | |
final String explicitImmutableVariable = "Hey!"; | |
final implicitImmutableVariable = "Hey!"; | |
// Compile time constant | |
const String explicitConstant = "Hey!"; | |
const implicitConstant = "Hey!"; |