question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Font path not passed correctly

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:25 (12 by maintainers)

github_iconTop GitHub Comments

4reactions
bendaniel10commented, Jun 17, 2016

I had this issue too. I found out that I put my assets folder in res. The correct way is to put the assets folder in the main folder instead.

Correct: …/main/assets/fonts Wrong: …/main/res/assets/fonts

0reactions
chrisjenxcommented, Dec 16, 2016

If there is another issue please raise a new one. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

relative file path to fonts in css file - Stack Overflow
I finally found out that this was likely due to the file path not being correct. Here is the file structure: enter image...
Read more >
404 on font path in compositions · Issue #4805 · teambit/bit
I get correct path to fonts when I install component in a project. Error locally: Failed to decode downloaded font: http://localhost:3000/ ...
Read more >
Font configuration - ArchWiki
Fontconfig is a library designed to provide a list of available fonts to applications, as well as configuration for how fonts get rendered....
Read more >
Web fonts - Learn web development - MDN Web Docs - Mozilla
We need to make sure the paths to the files are correct, so add fonts/ to the start of each path (adjust as...
Read more >
Fonts display incorrectly in AutoCAD Products
Verify font mapping settings · Find the path to the acad.fmp file in Options > Files > Text Editor, Dictionary, and Font File...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found