Custom fonts in Android the easy way...

Related tags

Font Calligraphy
Overview

This version of Calligraphy has reached its end-of-life and is no longer maintained. Please migrate to Calligraphy 3!

Calligraphy

Android Arsenal

Custom fonts in Android an OK way.

Are you fed up of Custom Views to set fonts? Or traversing the ViewTree to find TextViews? Yeah me too.

alt text

Getting started

Dependency

Include the dependency Download (.aar) :

dependencies {
    compile 'uk.co.chrisjenx:calligraphy:2.3.0'
}

Add Fonts

Add your custom fonts to assets/. All font definitions are relative to this path.

Assuming that you are using Gradle you should create the assets directory under src/main/ in your project directory if it does not already exist. As it's popular to use multi-project build with Gradle the path is usually app/src/main/assets/, where app is the project name.

You might consider creating a fonts/ subdirectory in the assets directory (as in examples).

Usage

<TextView fontPath="fonts/MyFont.ttf"/>

Note: The missing namespace, this IS intentional.

Installation

Define your default font using CalligraphyConfig, in your Application class in the #onCreate() method.

@Override
public void onCreate() {
    super.onCreate();
    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                            .setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf")
                            .setFontAttrId(R.attr.fontPath)
                            .build()
            );
    //....
}

Note: You don't need to define CalligraphyConfig but the library will apply no default font and use the default attribute of R.attr.fontPath.

Inject into Context

Wrap the Activity Context:

@Override
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}

You're good to go!

Usage

Custom font per TextView

<TextView
    android:text="@string/hello_world"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    fontPath="fonts/Roboto-Bold.ttf"/>

Note: Popular IDE's (Android Studio, IntelliJ) will likely mark this as an error despite being correct. You may want to add tools:ignore="MissingPrefix" to either the View itself or its parent ViewGroup to avoid this. You'll need to add the tools namespace to have access to this "ignore" attribute. xmlns:tools=" http://schemas.android.com/tools". See https://code.google.com/p/android/issues/detail?id=65176.

Custom font in TextAppearance

<style name="TextAppearance.FontPath" parent="android:TextAppearance">
    <!-- Custom Attr-->
    <item name="fontPath">fonts/RobotoCondensed-Regular.ttf</item>
</style>
<TextView
    android:text="@string/hello_world"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="@style/TextAppearance.FontPath"/>

Custom font in Styles

<style name="TextViewCustomFont">
    <item name="fontPath">fonts/RobotoCondensed-Regular.ttf</item>
</style>

Custom font defined in Theme

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <item name="android:textViewStyle">@style/AppTheme.Widget.TextView</item>
</style>

<style name="AppTheme.Widget"/>

<style name="AppTheme.Widget.TextView" parent="android:Widget.Holo.Light.TextView">
    <item name="fontPath">fonts/Roboto-ThinItalic.ttf</item>
</style>

FAQ

Font Resolution

The CalligraphyFactory looks for the font in a pretty specific order, for the most part it's very similar to how the Android framework resolves attributes.

  1. View xml - attr defined here will always take priority.
  2. Style xml - attr defined here is checked next.
  3. TextAppearance xml - attr is checked next, the only caveat to this is IF you have a font defined in the Style and a TextAttribute defined in the View the Style attribute is picked first!
  4. Theme - if defined this is used.
  5. Default - if defined in the CalligraphyConfig this is used of none of the above are found OR if one of the above returns an invalid font.

Why not piggyback off of fontFamily attribute?

We originally did, but it conflicted with users wanting to actually use that attribute, you now have to define a custom attribute.

Why no jar?

We needed to ship a custom ID with Calligraphy to improve the Font Injection flow. This unfortunately means that it has to be an aar. But you're using Gradle now anyway right?

Multiple Typeface's per TextView / Spannables

It is possible to use multiple Typefaces inside a TextView, this isn't new concept to Android.

This could be achieved using something like the following code.

SpannableStringBuilder sBuilder = new SpannableStringBuilder();
sBuilder.append("Hello!") // Bold this
        .append("I use Calligraphy"); // Default TextView font.
// Create the Typeface you want to apply to certain text
CalligraphyTypefaceSpan typefaceSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/Roboto-Bold.ttf"));
// Apply typeface to the Spannable 0 - 6 "Hello!" This can of course by dynamic.
sBuilder.setSpan(typefaceSpan, 0, 6, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
setText(sBuilder, TextView.BufferType.SPANNABLE);

Of course this is just an example. Your mileage may vary.

Exceptions / Pitfalls

To our knowledge (try: grep -r -e "void set[^(]*(Typeface " <android source dir>) there are two standard Android widgets that have multiple methods to set typefaces. They are:

  • android.support.v7.widget.SwitchCompat
  • android.widget.Switch

Both have a method called setSwitchTypeface that sets the typeface within the switch (e.g. on/off, yes/no). SetTypeface sets the typeface of the label. You will need to create your own subclass that overrides setTypeface and calls both super.setTypeface and super.setSwitchTypeface.

Collaborators

Note

This library was created because it is currently not possible to declare a custom font in XML files in Android.

If you feel this should be possible to do, please star this issue on the official Android bug tracker.

Licence

Copyright 2013 Christopher Jenkins

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Badge

Comments
  • Not working in Lollipop and AppCompat library

    Not working in Lollipop and AppCompat library

    On Android 4.4 with AppCompat Library, Calligraphy 1.1.+ doesn't work. However, Calligraphy 0.7.+ works fine.

    On Android 5.0 with AppCompat Libary, both Calligraphy 1.1.+ and 0.7.+ does not seem to work.

    bug finished 
    opened by ruqqq 79
  • Can't change Toolbar's font from default.

    Can't change Toolbar's font from default.

    Hi! I have a problem with changing the Toolbar's title font.

    It successfully gets the default font set in Application, but no way to configure it separately. I tried all solutions, fontPath through textAppearance using Toolbar's setTitleTextAppearance() (and its analog from xml), fontPath in style and use it as toolbar's style, changing the toolbar theme. Nothing helps... The same is with new design support library NavigationView. I have no idea how to change the font from default one for items.

    Do you have any ideas why it is so?

    opened by Jeevuz 71
  • Custom Layout Crash InflateException

    Custom Layout Crash InflateException

    Hello Chris, just wanted to start off by saying thanks for such a great library! With that in mind I'm hoping this crash report helps improve it.

    I'm currently seeing a crash on a couple of Samsung devices where the apps are crashing in what seems to be a failure to inflate a xml file used in a custom layout that extends FrameLayout. Below is the stack trace I've collected:

    android.view.InflateException: Binary XML file line #63: Error inflating class at android.view.LayoutInflater.createView(LayoutInflater.java:626) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:162) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:146) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700) at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) at android.view.LayoutInflater.inflate(LayoutInflater.java:498) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:398) at android.view.LayoutInflater.inflate(LayoutInflater.java:354) at android.view.View.inflate(View.java:18474) at re.snapwi.ui.RetryLayout.init(RetryLayout.java:52) at re.snapwi.ui.RetryLayout.(RetryLayout.java:31) at re.snapwi.ui.photo.PhotoGalleryFragment.onCreateView(PhotoGalleryFragment.java:116) at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:454) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5602) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(NativeStart.java) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Constructor.java) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.createView(LayoutInflater.java:600) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:162) at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:146) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700) at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) at android.view.LayoutInflater.inflate(LayoutInflater.java:498) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:398) at android.view.LayoutInflater.inflate(LayoutInflater.java:354) at android.view.View.inflate(View.java:18474) at re.snapwi.ui.RetryLayout.init(RetryLayout.java:52) at re.snapwi.ui.RetryLayout.(RetryLayout.java:31)

    Line 52 of RetryLayout is calling inflate in the custom framelayout:

    private void init(Context context) {
        setLayoutTransition(new LayoutTransition());
        inflate(context, R.layout.retry_framelayout, this); // This is LINE 52
        progressLayout = findViewById(R.id.retryProgressLayout);
        progressBarDefault = findViewById(R.id.retryProgress);
       topProgressBar = findViewById(R.id.smoothProgressBar);
    
       retryLayout = findViewById(R.id.retryButtonLayout);
       mainLayout = (FrameLayout) findViewById(R.id.mainContent);
       retryTextView = (TextView) findViewById(R.id.retryTextView);
       retryTextView.setTextColor(retryTextColor);
       retryButton = (Button) findViewById(R.id.retryButton);
       mShortAnimationDuration = getResources().getInteger(android.R.integer.config_longAnimTime);
     }
    

    The inflateException then points to Binary XML file line #63 which is the beginning of a ProgressBar tag

     <ProgressBar  
        android:id="@+id/retryProgress"
        style="@style/SnapwireSpinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:visibility="gone" />
    

    The crash is affecting the following Samsung models: SM N910G, GT N7100, SCH S960L

    opened by marcoRS 34
  • Support for TabLayout from Android Design Support library.

    Support for TabLayout from Android Design Support library.

    Thank you for this amazing library.

    I am having an issue with the TabLayout widget introduced in the new Design Support Library launched by the Android team. The textviews in the tabs are not responding to the font change.

    I have followed the steps from http://chrisjenx.com/calligraphy-2-0-0/. I am using v2.1.1 of your library. Am I missing something?

    opened by awanishraj 33
  • Toolbar subtitle is not set when using calligraphy

    Toolbar subtitle is not set when using calligraphy

    Hi, I'm using Calligraphy the default way (initing in Application and overriding attachBaseContext)

    Calling toolbar.setSubtitle doesn't work. If I commented the attachBaseContext override, it works normally.

    Any suggestion for fixes or, unfortunately, hacks, is welcome.

    LATE EDIT:

    Calling toolbar.setSubtitle doesn't work.

    By this I meant that the subtitle isn't displayed, and the title is vertically centered. (it's like subtitle view behavior is View.GONE)

    opened by eriuzo 31
  • NoClassDefFoundError while loading my activity

    NoClassDefFoundError while loading my activity

    Awesome library, makes custom fonts a breathe. Work fine on my testing device (Nexus 5 running M) but crashed with the following stack trace on a Samsung (no surprise there) device (GT S7272 running 4.2.2) Any ideas?

    Fatal Exception: java.lang.NoClassDefFoundError: uk.co.chrisjenx.calligraphy.R$attr
           at uk.co.chrisjenx.calligraphy.CalligraphyConfig$Builder.<init>(CalligraphyConfig.java:150)
           at net.sarmady.contactcarswithtabs.ContactCarsApplication.onCreate(ContactCarsApplication.java:145)
           at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1017)
           at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4552)
           at android.app.ActivityThread.access$1400(ActivityThread.java:150)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
           at android.os.Handler.dispatchMessage(Handler.java:99)
           at android.os.Looper.loop(Looper.java:137)
           at android.app.ActivityThread.main(ActivityThread.java:5279)
           at java.lang.reflect.Method.invokeNative(Method.java)
           at java.lang.reflect.Method.invoke(Method.java:511)
           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
           at dalvik.system.NativeStart.main(NativeStart.java)
    
    opened by mSobhy90 31
  • Not running on devices running lower than lollipop

    Not running on devices running lower than lollipop

    I am able to run calligraphy ver 2.0.1 on lollipop device, if I try to run it on lower version device (kitkat) I am getting following issue

    02-16 16:19:23.541 3053-3053/com.tabtor.student E/dalvikvm﹕ Could not find class 'uk.co.chrisjenx.calligraphy.CalligraphyFactory', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater. 02-16 16:19:23.541 3053-3053/com.tabtor.student E/dalvikvm﹕ Could not find class 'uk.co.chrisjenx.calligraphy.CalligraphyFactory', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater. 02-16 16:19:23.541 3053-3053/com.tabtor.student E/dalvikvm﹕ Could not find class 'uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory2', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.setUpLayoutFactories 02-16 16:19:23.541 3053-3053/com.tabtor.student E/dalvikvm﹕ Could not find class 'uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.setUpLayoutFactories 02-16 16:19:23.541 3053-3053/com.tabtor.student E/dalvikvm﹕ Could not find class 'uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.setFactory 02-16 16:19:23.541 3053-3053/com.tabtor.student E/dalvikvm﹕ Could not find class 'uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory2', referenced from method uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.setFactory2 02-16 16:19:23.541 3053-3053/com.tabtor.student E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.NoClassDefFoundError: uk.co.chrisjenx.calligraphy.CalligraphyFactory at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.(CalligraphyLayoutInflater.java:43) at uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper.getSystemService(CalligraphyContextWrapper.java:111) at android.view.LayoutInflater.from(LayoutInflater.java:210) at android.view.ContextThemeWrapper.getSystemService(ContextThemeWrapper.java:113) at android.app.Activity.getSystemService(Activity.java:4473) at android.view.LayoutInflater.from(LayoutInflater.java:210) at com.android.internal.policy.impl.PhoneWindow.(PhoneWindow.java:218) at com.android.internal.policy.impl.Policy.makeNewWindow(Policy.java:63) at com.android.internal.policy.PolicyManager.makeNewWindow(PolicyManager.java:59) at android.app.Activity.attach(Activity.java:5063) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2129) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) at android.app.ActivityThread.access$600(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5041) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method)

    opened by smanne 30
  • A factory has already been set on this LayoutInflater Exception

    A factory has already been set on this LayoutInflater Exception

    java.lang.RuntimeException: Unable to start activity ComponentInfo{org.titibots.android.ide.remote/org.modebots.android.ide.ui.MainActivity}: java.lang.IllegalStateException: A factory has already been set on this LayoutInflater at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.IllegalStateException: A factory has already been set on this LayoutInflater at android.view.LayoutInflater.setFactory(LayoutInflater.java:286) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.setFactory(CalligraphyLayoutInflater.java:85) at android.support.v4.app.Fragment.getLayoutInflater(Fragment.java:935) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489) at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1236) at android.app.Activity.performStart(Activity.java:6006) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

    opened by bishwash-adhikari 28
  • Fix exception with support library v22.1.0

    Fix exception with support library v22.1.0

    Fix #155

    By my research, there are two points to be fixed.

    First point

    When I updated support library and run sample, I saw java.lang.IllegalStateException: A factory has already been set on this LayoutInflater. This exception was caused by that CalligraphyLayoutInflater#setUpLayoutFactories calls setFactory2 and setFactory.

    Second point

    When I fixed the first point, I saw same exception, which was raised by that 'LayoutInflaterCompat.setFactory' was called in Fragment.java. I think Fragment supposes that mActivity.getLayoutInflater().cloneInContext(mActivity); returns LayoutInflater object which is never called setFactory/setFactory2. Therefore I have fixed so that setUpLayoutFactories is not called in constructor.

    I'm not sure that this PR fixes this problem for all devices / OS versions and I have not tested with many situations. Does anyone have any better idea?

    opened by kobakei 26
  • Problem with custom view styles and Calligraphy?

    Problem with custom view styles and Calligraphy?

    I'm having a hard time getting custom views (classes extending TextView) with styles working correctly with Calligraphy. The problem is that Calligraphy seems to ignore fontPath set in style definitions for these views.

    A brief look at Android (API level 21) and Calligraphy (2.0.0) source code indicates that CalligraphyLayoutInflater may not apply the font if the view class is not in one of the following packages: android.widget, android.webkit and android.view. Is this correct?

    enhancement 
    opened by abergenw 26
  • Font path not passed correctly

    Font path not passed correctly

    For some reason I couldn't get styles to work correctly. The custom font loads fine when I type it directly in XML or set it as the default font in OnCreate(). However, when I use styles, they just refuse to load. This is the 2.0.0 snapshot build.

    Here is my style xml

    <resources>
    
        <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"/>
    
        <style name="Font">
            <item name="android:textColor">@color/brown</item>
            <item name="android:textSize">18sp</item>
        </style>
    
        <style name="Font.Bold">
            <item name="fontPath">fonts/belwe_bt.otf</item>
        </style>
    
        <style name="Font.Hollow">
            <item name="fontPath">fonts/belwe_hollow.ttf</item>
        </style>
    
        <style name="Font.Regular">
            <item name="fontPath">fonts/archivo.ttf</item>
        </style>
    
        <style name="Font.Italics">
            <item name="fontPath">fonts/archivo_i.ttf</item>
        </style>
    
    </resources>
    

    The color and sizing work correctly, but the font fails at createFromAsset(). The paths are correct, because when I set them in XML, they work correctly.

    Below is the error message. Notice that the asset path shown is not your typical text. Try selecting it for example. Multiple runs have gotten me Arabic, Russian and Mongolian strings, so I guess some random unicode text is what's being passed for some reason.

    W/Calligraphy﹕ Can't create asset from ‏‮NEW:‬‏ ‏‮‬‏. Make sure you have passed in the correct path and file name.
    java.lang.RuntimeException: Font asset not found ‏‮NEW:‬‏ ‏‮‬‏
            at android.graphics.Typeface.createFromAsset(Typeface.java:190)
            at uk.co.chrisjenx.calligraphy.TypefaceUtils.load(TypefaceUtils.java:34)
            at uk.co.chrisjenx.calligraphy.CalligraphyUtils.applyFontToTextView(CalligraphyUtils.java:112)
            at uk.co.chrisjenx.calligraphy.CalligraphyUtils.applyFontToTextView(CalligraphyUtils.java:141)
            at uk.co.chrisjenx.calligraphy.CalligraphyFactory.onViewCreatedInternal(CalligraphyFactory.java:173)
            at uk.co.chrisjenx.calligraphy.CalligraphyFactory.onViewCreated(CalligraphyFactory.java:131)
            at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:170)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
            at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.onCreateView(CalligraphyLayoutInflater.java:146)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
            at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
    
    opened by geft 25
  • how to solve this error. please help me as soon as possible.

    how to solve this error. please help me as soon as possible.

    05-11 22:22:35.952 1479-1479/com.example.gettogetherapp E/dalvikvm: Could not find class 'androidx.core.view.ViewCompat$2', referenced from method androidx.core.view.ViewCompat.addOnUnhandledKeyEventListener 05-11 22:22:36.010 1479-1479/com.example.gettogetherapp E/dalvikvm: Could not find class 'android.view.View$OnUnhandledKeyEventListener', referenced from method androidx.core.view.ViewCompat.removeOnUnhandledKeyEventListener 05-11 22:22:36.038 1479-1479/com.example.gettogetherapp E/dalvikvm: Could not find class 'androidx.core.view.ViewCompat$1', referenced from method androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener 05-11 22:22:36.799 1479-1479/com.example.gettogetherapp E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method androidx.appcompat.widget.AppCompatImageHelper.hasOverlappingRendering 05-11 22:22:36.811 1479-1563/com.example.gettogetherapp E/dalvikvm: Could not find class 'dalvik.system.DelegateLastClassLoader', referenced from method nk.a 05-11 22:22:36.888 1479-1479/com.example.gettogetherapp E/dalvikvm: Could not find class 'android.view.textclassifier.TextClassificationManager', referenced from method androidx.appcompat.widget.AppCompatTextClassifierHelper.getTextClassifier 05-11 22:22:36.973 1479-1479/com.example.gettogetherapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.gettogetherapp, PID: 1479 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gettogetherapp/com.example.gettogetherapp.SinginActivity}: android.view.InflateException: Binary XML file line #106: Error inflating class Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:5299) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #106: Error inflating class Button at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161) at com.example.gettogetherapp.SinginActivity.onCreate(SinginActivity.kt:16) at android.app.Activity.performCreate(Activity.java:5264) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)  at android.os.Handler.dispatchMessage(Handler.java:110)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:5299)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)  at dalvik.system.NativeStart.main(Native Method)  Caused by: android.content.res.Resources$NotFoundException: File res/color/common_google_signin_btn_tint.xml from drawable resource ID #0x7f050041 at android.content.res.Resources.loadDrawable(Resources.java:2152) at android.content.res.TypedArray.getDrawable(TypedArray.java:602) at android.view.View.(View.java:3579) at android.widget.TextView.(TextView.java:642) at android.widget.Button.(Button.java:107) at androidx.appcompat.widget.AppCompatButton.(AppCompatButton.java:72) at androidx.appcompat.widget.AppCompatButton.(AppCompatButton.java:68) at androidx.appcompat.app.AppCompatViewInflater.createButton(AppCompatViewInflater.java:192) at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:111) at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1407) at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1457) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)  at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)  at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)  at com.example.gettogetherapp.SinginActivity.onCreate(SinginActivity.kt:16)  at android.app.Activity.performCreate(Activity.java:5264)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)  at android.os.Handler.dispatchMessage(Handler.java:110)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:5299)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)  at dalvik.system.NativeStart.main(Native Method)  Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #3: tag requires a 'drawable' attribute or child tag defining a drawable at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:181) at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937) at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877) at android.content.res.Resources.loadDrawable(Resources.java:2148) at android.content.res.TypedArray.getDrawable(TypedArray.java:602)  at android.view.View.(View.java:3579)  at android.widget.TextView.(TextView.java:642)  at android.widget.Button.(Button.java:107)  at androidx.appcompat.widget.AppCompatButton.(AppCompatButton.java:72)  at androidx.appcompat.widget.AppCompatButton.(AppCompatButton.java:68)  at androidx.appcompat.app.AppCompatViewInflater.createButton(AppCompatViewInflater.java:192)  at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:111)  at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1407)  at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1457)  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)  at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)  at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)  at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)  at com.example.gettogetherapp.SinginActivity.onCreate(SinginActivity.kt:16)  at android.app.Activity.performCreate(Activity.java:5264)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)  at android.os.Handler.dispatchMessage(Handler.java:110)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:5299)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)  at dalvik.system.NativeStart.main(Native Method)  05-11 22:22:37.588 1479-1564/com.example.gettogetherapp E/SQLiteLog: (10) Failed to do file read, got: 0, amt: 100, last Errno: 2 05-11 22:22:38.315 1479-1573/com.example.gettogetherapp E/NativeCrypto: ssl=0x569470d0 cert_verify_callback x509_store_ctx=0x56815940 arg=0x0 05-11 22:22:38.315 1479-1573/com.example.gettogetherapp E/NativeCrypto: ssl=0x569470d0 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_ECDSA

    opened by sanu1525 0
  • nokia android 10

    nokia android 10

    hello in android nokia 10 after add this comment crash override fun attachBaseContext(newBase: Context?) { super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)) } and this issue just happen in nokia android 10

    opened by starritree 1
  • No Git tag for version 2.3.0

    No Git tag for version 2.3.0

    Hello,

    I saw that on the GitHub repo the last released version is 2.2.0 However, in maven repo there is a newer version https://mvnrepository.com/artifact/uk.co.chrisjenx/calligraphy/2.3.0

    Can you explain please the reason why not having a 2.3.0 git tag in this repo please ?

    opened by OussamaHaff 0
  • Text was changed

    Text was changed

    I use the default font. My words "> by default" changed to "->"

    ` <TextView

             android:layout_width="wrap_content"
    
            android:layout_height="wrap_content"
    
            android:gravity="center"
    
            android:text="message>" />`
    

    font

    This is what I use font library: DIN-Regular.zip Thanks!

    opened by githubtangchao 0
Releases(v2.2.0)
  • v2.2.0(May 3, 2016)

    Added AppCompat Styles (AppCompatTextView will now pickup textViewStyle etc). Thanks @paul-turner Fix for Toolbar not inflating TextViews upfront.

    Source code(tar.gz)
    Source code(zip)
  • v2.1.0(Jul 20, 2015)

    Changes:

    • Fixed #155, We now clone correctly.
    • Added Styles for Custom Views. (builder.addCustomStyle(ToggleButton.class, android.R.attr.buttonStyleToggle))
    Source code(tar.gz)
    Source code(zip)
  • v2.0.2(Mar 17, 2015)

    2.0.2 (05/01/2015) Fixed CalligraphyConfig.Builder missing return statements. Fixed createView() getting the wrong parent context, Fixed: #135, #120 2.0.1 (28/01/2014) Throw exception on passing null into CalligraphySpan Fixed memory bug with Toolbar. @dlew

    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Jan 16, 2015)

Owner
Christopher Jenkins
Christopher Jenkins
A full example of custom fonts in XML using data binding and including font caching.

[Deprecated] Fonts in XML are now supported by the Android support library as of 26.0, including in styles and themes. I recommend using the support l

Lisa Wray 776 Sep 24, 2022
A lightweight Android library for use iconic fonts.

Print A lightweight Android library for use iconic fonts. Download Gradle: compile 'com.github.johnkil.print:print:1.3.1' Maven: <dependency> <gro

Evgeny Shishkin 203 Nov 24, 2022
A lightweight Android library for use iconic fonts.

Print A lightweight Android library for use iconic fonts. Download Gradle: compile 'com.github.johnkil.print:print:1.3.1' Maven: <dependency> <gro

Evgeny Shishkin 204 Nov 13, 2022
Material and Holo iconic fonts.

Android Icon Fonts Material and Holo iconic fonts. Source Material Extracted 433 Material Design icons from Google's Project Polymer website by Shreya

Evgeny Shishkin 225 Sep 23, 2022
Custom font library for android | Library to change/add font of Entire Android Application at once without wasting your time - TextViews, EditText, Buttons, Views etc.,

AppFontChanger In a Single shot change font of Entire Android Application - TextViews, EditText, Buttons, Views etc., Kindly use the following links t

Prabhakar Thota 48 Aug 10, 2022
Typeface helper for Android

Android Typeface Helper Android lacks proper support for custom typefaces. Most obvious method of defining typeface for UI elements via XML attributes

Norbsoft Sp. z o.o. 756 Aug 8, 2022
Helper object for injecting typeface into various text views of android.

TypefaceHelper Helper object for injecting typeface into various text views of android. Overview We can use various custom typefaces asset for any tex

Drivemode, Inc. 105 Nov 25, 2022
An android library to display FontAwesome Icons in any View or a MenuItem

DroidAwesome A library to display FontAwesome Icons in any View or a MenuItem Views Supported: TextView AutoComplete TextView EditText Switch CheckBox

Livin 38 Aug 25, 2022
Fontize is an Android library that enables multi-font selection functionality to diversify your app.

Fontize Android Library Built with ❤︎ by Gourav Khunger Fontize is an Android library, written in kotlin, that enables your android app have multiple

Gourav Khunger 8 Jul 5, 2022
Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the brand new Roboto Slab fonts.

Android-RobotoTextView Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the bran

Evgeny Shishkin 782 Nov 12, 2022
Custom fonts in Android the easy way...

This version of Calligraphy has reached its end-of-life and is no longer maintained. Please migrate to Calligraphy 3! Calligraphy Custom fonts in Andr

Christopher Jenkins 8.6k Nov 21, 2022
Custom View classes for TextView, EditText & Buttons - to set custom fonts

CustomFontView Custom font classes for TextView, EditText & Buttons How to integrate the library in your app? Gradle Dependecy dependencies {

Anitaa Murthy 27 Oct 4, 2022
Useful library to use custom fonts in your android app

EasyFonts A simple and useful android library to use custom fonts in android apps without adding fonts into asset/resource folder.Also by using this l

Vijay Vankhede 419 Sep 9, 2022
IconicDroid is a custom Android Drawable which allows to draw icons from several iconic fonts.

IconicDroid IconicDroid is a custom Android Drawable which allows to draw icons from several iconic fonts. Try out the sample application on the Googl

Artur Termenji 387 Nov 20, 2022
Android Library to use custom fonts with ease.

FontometricsLibrary A Simple Android Library to use Custom Fonts with Ease. Use Customs Fonts in your Android project without adding any .ttf/.otf in

Ishmeet Singh 188 Nov 15, 2022
A full example of custom fonts in XML using data binding and including font caching.

[Deprecated] Fonts in XML are now supported by the Android support library as of 26.0, including in styles and themes. I recommend using the support l

Lisa Wray 776 Sep 24, 2022
An easy way to customize your log in Android,including output to console, writing log to file in high performance way and so on

EasyLog An easy way to customize your log in Android,including output to console, writing log to file in high performance way and so on. 1. Initializa

Taylor 34 Nov 22, 2022
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Carbon Material Design implementation for Android 4.0 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implemen

null 3k Nov 23, 2022
A lightweight Android library for use iconic fonts.

Print A lightweight Android library for use iconic fonts. Download Gradle: compile 'com.github.johnkil.print:print:1.3.1' Maven: <dependency> <gro

Evgeny Shishkin 203 Nov 24, 2022
Material Design implementation for Android 4.0+. Shadows, ripples, vectors, fonts, animations, widgets, rounded corners and more.

Carbon Material Design implementation for Android 4.0 and newer. This is not the exact copy of the Lollipop's API and features. It's a custom implemen

null 3k Nov 23, 2022