Android react-native app not picking up font











up vote
3
down vote

favorite
2












I am trying to use a font "Verveine Corp Regular' inside my react-native app.



The font works in the iOS build, but not in the Android build.



The font is in .tff format and is placed in the root of my work (linked in the package.json and I have run react-native link) and inside "android/gradle/src/main/assets/fonts" but it's still not picking the font up. I have also cleaned and rebuilt the app multiple times.



When inspecting an element which uses the font in the android debugger, it says it's using the font. But the font is still the default font.



Could anyone offer some help or guidance on this issue?



Thanks!










share|improve this question
























  • Show us the package.json
    – vinayr
    Mar 2 '17 at 12:23










  • "rnpm": { "assets": [ "fonts" ] }
    – Jake K
    Mar 2 '17 at 12:24












  • When I inspect the elements that are meant to use the font in the android debugger it says the element is using the font I want it to use. It's just not displaying in that font, just the default.
    – Jake K
    Mar 2 '17 at 12:37










  • add some code where you use the custom font
    – arjun
    Mar 2 '17 at 12:52










  • @arjun like what?
    – Jake K
    Mar 2 '17 at 12:54















up vote
3
down vote

favorite
2












I am trying to use a font "Verveine Corp Regular' inside my react-native app.



The font works in the iOS build, but not in the Android build.



The font is in .tff format and is placed in the root of my work (linked in the package.json and I have run react-native link) and inside "android/gradle/src/main/assets/fonts" but it's still not picking the font up. I have also cleaned and rebuilt the app multiple times.



When inspecting an element which uses the font in the android debugger, it says it's using the font. But the font is still the default font.



Could anyone offer some help or guidance on this issue?



Thanks!










share|improve this question
























  • Show us the package.json
    – vinayr
    Mar 2 '17 at 12:23










  • "rnpm": { "assets": [ "fonts" ] }
    – Jake K
    Mar 2 '17 at 12:24












  • When I inspect the elements that are meant to use the font in the android debugger it says the element is using the font I want it to use. It's just not displaying in that font, just the default.
    – Jake K
    Mar 2 '17 at 12:37










  • add some code where you use the custom font
    – arjun
    Mar 2 '17 at 12:52










  • @arjun like what?
    – Jake K
    Mar 2 '17 at 12:54













up vote
3
down vote

favorite
2









up vote
3
down vote

favorite
2






2





I am trying to use a font "Verveine Corp Regular' inside my react-native app.



The font works in the iOS build, but not in the Android build.



The font is in .tff format and is placed in the root of my work (linked in the package.json and I have run react-native link) and inside "android/gradle/src/main/assets/fonts" but it's still not picking the font up. I have also cleaned and rebuilt the app multiple times.



When inspecting an element which uses the font in the android debugger, it says it's using the font. But the font is still the default font.



Could anyone offer some help or guidance on this issue?



Thanks!










share|improve this question















I am trying to use a font "Verveine Corp Regular' inside my react-native app.



The font works in the iOS build, but not in the Android build.



The font is in .tff format and is placed in the root of my work (linked in the package.json and I have run react-native link) and inside "android/gradle/src/main/assets/fonts" but it's still not picking the font up. I have also cleaned and rebuilt the app multiple times.



When inspecting an element which uses the font in the android debugger, it says it's using the font. But the font is still the default font.



Could anyone offer some help or guidance on this issue?



Thanks!







android ios reactjs fonts react-native






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 2 '17 at 12:49

























asked Mar 2 '17 at 12:17









Jake K

256




256












  • Show us the package.json
    – vinayr
    Mar 2 '17 at 12:23










  • "rnpm": { "assets": [ "fonts" ] }
    – Jake K
    Mar 2 '17 at 12:24












  • When I inspect the elements that are meant to use the font in the android debugger it says the element is using the font I want it to use. It's just not displaying in that font, just the default.
    – Jake K
    Mar 2 '17 at 12:37










  • add some code where you use the custom font
    – arjun
    Mar 2 '17 at 12:52










  • @arjun like what?
    – Jake K
    Mar 2 '17 at 12:54


















  • Show us the package.json
    – vinayr
    Mar 2 '17 at 12:23










  • "rnpm": { "assets": [ "fonts" ] }
    – Jake K
    Mar 2 '17 at 12:24












  • When I inspect the elements that are meant to use the font in the android debugger it says the element is using the font I want it to use. It's just not displaying in that font, just the default.
    – Jake K
    Mar 2 '17 at 12:37










  • add some code where you use the custom font
    – arjun
    Mar 2 '17 at 12:52










  • @arjun like what?
    – Jake K
    Mar 2 '17 at 12:54
















Show us the package.json
– vinayr
Mar 2 '17 at 12:23




Show us the package.json
– vinayr
Mar 2 '17 at 12:23












"rnpm": { "assets": [ "fonts" ] }
– Jake K
Mar 2 '17 at 12:24






"rnpm": { "assets": [ "fonts" ] }
– Jake K
Mar 2 '17 at 12:24














When I inspect the elements that are meant to use the font in the android debugger it says the element is using the font I want it to use. It's just not displaying in that font, just the default.
– Jake K
Mar 2 '17 at 12:37




When I inspect the elements that are meant to use the font in the android debugger it says the element is using the font I want it to use. It's just not displaying in that font, just the default.
– Jake K
Mar 2 '17 at 12:37












add some code where you use the custom font
– arjun
Mar 2 '17 at 12:52




add some code where you use the custom font
– arjun
Mar 2 '17 at 12:52












@arjun like what?
– Jake K
Mar 2 '17 at 12:54




@arjun like what?
– Jake K
Mar 2 '17 at 12:54












5 Answers
5






active

oldest

votes

















up vote
2
down vote



accepted










This is how I used custom font in my project



//sampleStyle.js
import overrideStyles from '/sampleoverridestyles';
iconTextStyle: {
color: '#FFFFFF',
fontSize: 16
}

//sampleoverridestyles.ios.js
export default {
iconTextStyle: {
fontFamily: 'FaktSoftPro-Medium'
}
}

//sampleoverridestyles.android.js
export default {
iconTextStyle: {
fontFamily: 'faktsoftpro_medium'
}
}


since I cannot set the font name same for iOS and android I have overridden it as above and it worked.






share|improve this answer





















  • Are these files in the root of your project?
    – Jake K
    Mar 2 '17 at 13:34










  • my directory structure is like src/modules/mymodule/sytles/..
    – arjun
    Mar 2 '17 at 13:50


















up vote
1
down vote













First, make sure you are up to version 0.16+ with react-native.
Your fonts should be *.ttf or *.otf files and must be located in: /projectname/android/app/src/main/assets/fonts
Make sure the fonts are lowercase only and follow this pattern: fontname.ttf, fontname_bold.ttf, fontname_light.ttf, fontname_bold_italic.ttf





share|improve this answer





















  • Tried all of these :( The fonts were in uppercase, but I have changed them to lowercase.. still no luck.
    – Jake K
    Mar 2 '17 at 12:37


















up vote
1
down vote













Have you defined another font in your AppTheme (styles.xml), that overrides your preferred font?



Have you tested your font with a "Hello World"-App as a minimal test?



Have you implemented your ttf as shown here for example?: How to use custom font in Android Studio






share|improve this answer























  • Yep, I have just tried all these but nothing. When I inspect the element in the android debugger, it says the element is using the font I want it to. But the element is still displaying as the default font.
    – Jake K
    Mar 2 '17 at 12:38


















up vote
1
down vote













I added font in react-native android from here:



https://medium.com/@gattermeier/custom-fonts-in-react-native-for-android-b8a331a7d2a7#.40vw3ooar



Follow all the steps it will work fine.



After adding run react-native run-android






share|improve this answer





















  • I followed the same tutorial but to no aveil
    – Jake K
    Mar 2 '17 at 12:37


















up vote
0
down vote













The other answers helped me get this working for me, thank you. This manuever is probably only necessary when the font has capital letters in the filename. A more complete answer:



Add the font as normal in react native, for example:



{react-native-project}/fonts/GovtAgentBB.ttf



Run react-native link and this will put the font in



{react-native-project}/android/app/src/main/assets/fonts/GovtAgentBB.ttf



{react-native-project}/android/app/src/main/assets/fonts/GovtAgentBB_ital.ttf



But android, bring robotic and not human, doesn't like this. So rename the file with all lower case letters and an underscore before the variant, like:



{react-native-project}/android/app/src/main/assets/fonts/govtagentbb.ttf



{react-native-project}/android/app/src/main/assets/fonts/govtagentbb_ital.ttf



Then, you have to change the font name in the style depending on the platform. For iOS, use the human name that is the name of the font that would be displaying in the title of the window of the Mac Font menu (or just the name you see on the web). For android, you have to, robotically, use the name of the file you just renamed.



      {Platform.OS === 'ios' ? (
<Text style={styles.welcome}>
Hello World!
</Text>
) : (
<Text style={styles.welcomeAndroid}>
Hello World
</Text>
)}
const styles = StyleSheet.create({
...
welcome: {
fontFamily: 'Government Agent BB',
},
welcomeAndroid: {
fontFamily: 'govtagentbb',
},





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42555315%2fandroid-react-native-app-not-picking-up-font%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    5 Answers
    5






    active

    oldest

    votes








    5 Answers
    5






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    This is how I used custom font in my project



    //sampleStyle.js
    import overrideStyles from '/sampleoverridestyles';
    iconTextStyle: {
    color: '#FFFFFF',
    fontSize: 16
    }

    //sampleoverridestyles.ios.js
    export default {
    iconTextStyle: {
    fontFamily: 'FaktSoftPro-Medium'
    }
    }

    //sampleoverridestyles.android.js
    export default {
    iconTextStyle: {
    fontFamily: 'faktsoftpro_medium'
    }
    }


    since I cannot set the font name same for iOS and android I have overridden it as above and it worked.






    share|improve this answer





















    • Are these files in the root of your project?
      – Jake K
      Mar 2 '17 at 13:34










    • my directory structure is like src/modules/mymodule/sytles/..
      – arjun
      Mar 2 '17 at 13:50















    up vote
    2
    down vote



    accepted










    This is how I used custom font in my project



    //sampleStyle.js
    import overrideStyles from '/sampleoverridestyles';
    iconTextStyle: {
    color: '#FFFFFF',
    fontSize: 16
    }

    //sampleoverridestyles.ios.js
    export default {
    iconTextStyle: {
    fontFamily: 'FaktSoftPro-Medium'
    }
    }

    //sampleoverridestyles.android.js
    export default {
    iconTextStyle: {
    fontFamily: 'faktsoftpro_medium'
    }
    }


    since I cannot set the font name same for iOS and android I have overridden it as above and it worked.






    share|improve this answer





















    • Are these files in the root of your project?
      – Jake K
      Mar 2 '17 at 13:34










    • my directory structure is like src/modules/mymodule/sytles/..
      – arjun
      Mar 2 '17 at 13:50













    up vote
    2
    down vote



    accepted







    up vote
    2
    down vote



    accepted






    This is how I used custom font in my project



    //sampleStyle.js
    import overrideStyles from '/sampleoverridestyles';
    iconTextStyle: {
    color: '#FFFFFF',
    fontSize: 16
    }

    //sampleoverridestyles.ios.js
    export default {
    iconTextStyle: {
    fontFamily: 'FaktSoftPro-Medium'
    }
    }

    //sampleoverridestyles.android.js
    export default {
    iconTextStyle: {
    fontFamily: 'faktsoftpro_medium'
    }
    }


    since I cannot set the font name same for iOS and android I have overridden it as above and it worked.






    share|improve this answer












    This is how I used custom font in my project



    //sampleStyle.js
    import overrideStyles from '/sampleoverridestyles';
    iconTextStyle: {
    color: '#FFFFFF',
    fontSize: 16
    }

    //sampleoverridestyles.ios.js
    export default {
    iconTextStyle: {
    fontFamily: 'FaktSoftPro-Medium'
    }
    }

    //sampleoverridestyles.android.js
    export default {
    iconTextStyle: {
    fontFamily: 'faktsoftpro_medium'
    }
    }


    since I cannot set the font name same for iOS and android I have overridden it as above and it worked.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 2 '17 at 13:08









    arjun

    1,99611428




    1,99611428












    • Are these files in the root of your project?
      – Jake K
      Mar 2 '17 at 13:34










    • my directory structure is like src/modules/mymodule/sytles/..
      – arjun
      Mar 2 '17 at 13:50


















    • Are these files in the root of your project?
      – Jake K
      Mar 2 '17 at 13:34










    • my directory structure is like src/modules/mymodule/sytles/..
      – arjun
      Mar 2 '17 at 13:50
















    Are these files in the root of your project?
    – Jake K
    Mar 2 '17 at 13:34




    Are these files in the root of your project?
    – Jake K
    Mar 2 '17 at 13:34












    my directory structure is like src/modules/mymodule/sytles/..
    – arjun
    Mar 2 '17 at 13:50




    my directory structure is like src/modules/mymodule/sytles/..
    – arjun
    Mar 2 '17 at 13:50












    up vote
    1
    down vote













    First, make sure you are up to version 0.16+ with react-native.
    Your fonts should be *.ttf or *.otf files and must be located in: /projectname/android/app/src/main/assets/fonts
    Make sure the fonts are lowercase only and follow this pattern: fontname.ttf, fontname_bold.ttf, fontname_light.ttf, fontname_bold_italic.ttf





    share|improve this answer





















    • Tried all of these :( The fonts were in uppercase, but I have changed them to lowercase.. still no luck.
      – Jake K
      Mar 2 '17 at 12:37















    up vote
    1
    down vote













    First, make sure you are up to version 0.16+ with react-native.
    Your fonts should be *.ttf or *.otf files and must be located in: /projectname/android/app/src/main/assets/fonts
    Make sure the fonts are lowercase only and follow this pattern: fontname.ttf, fontname_bold.ttf, fontname_light.ttf, fontname_bold_italic.ttf





    share|improve this answer





















    • Tried all of these :( The fonts were in uppercase, but I have changed them to lowercase.. still no luck.
      – Jake K
      Mar 2 '17 at 12:37













    up vote
    1
    down vote










    up vote
    1
    down vote









    First, make sure you are up to version 0.16+ with react-native.
    Your fonts should be *.ttf or *.otf files and must be located in: /projectname/android/app/src/main/assets/fonts
    Make sure the fonts are lowercase only and follow this pattern: fontname.ttf, fontname_bold.ttf, fontname_light.ttf, fontname_bold_italic.ttf





    share|improve this answer












    First, make sure you are up to version 0.16+ with react-native.
    Your fonts should be *.ttf or *.otf files and must be located in: /projectname/android/app/src/main/assets/fonts
    Make sure the fonts are lowercase only and follow this pattern: fontname.ttf, fontname_bold.ttf, fontname_light.ttf, fontname_bold_italic.ttf






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 2 '17 at 12:23









    Nitesh Mishra

    459112




    459112












    • Tried all of these :( The fonts were in uppercase, but I have changed them to lowercase.. still no luck.
      – Jake K
      Mar 2 '17 at 12:37


















    • Tried all of these :( The fonts were in uppercase, but I have changed them to lowercase.. still no luck.
      – Jake K
      Mar 2 '17 at 12:37
















    Tried all of these :( The fonts were in uppercase, but I have changed them to lowercase.. still no luck.
    – Jake K
    Mar 2 '17 at 12:37




    Tried all of these :( The fonts were in uppercase, but I have changed them to lowercase.. still no luck.
    – Jake K
    Mar 2 '17 at 12:37










    up vote
    1
    down vote













    Have you defined another font in your AppTheme (styles.xml), that overrides your preferred font?



    Have you tested your font with a "Hello World"-App as a minimal test?



    Have you implemented your ttf as shown here for example?: How to use custom font in Android Studio






    share|improve this answer























    • Yep, I have just tried all these but nothing. When I inspect the element in the android debugger, it says the element is using the font I want it to. But the element is still displaying as the default font.
      – Jake K
      Mar 2 '17 at 12:38















    up vote
    1
    down vote













    Have you defined another font in your AppTheme (styles.xml), that overrides your preferred font?



    Have you tested your font with a "Hello World"-App as a minimal test?



    Have you implemented your ttf as shown here for example?: How to use custom font in Android Studio






    share|improve this answer























    • Yep, I have just tried all these but nothing. When I inspect the element in the android debugger, it says the element is using the font I want it to. But the element is still displaying as the default font.
      – Jake K
      Mar 2 '17 at 12:38













    up vote
    1
    down vote










    up vote
    1
    down vote









    Have you defined another font in your AppTheme (styles.xml), that overrides your preferred font?



    Have you tested your font with a "Hello World"-App as a minimal test?



    Have you implemented your ttf as shown here for example?: How to use custom font in Android Studio






    share|improve this answer














    Have you defined another font in your AppTheme (styles.xml), that overrides your preferred font?



    Have you tested your font with a "Hello World"-App as a minimal test?



    Have you implemented your ttf as shown here for example?: How to use custom font in Android Studio







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited May 23 '17 at 10:29









    Community

    11




    11










    answered Mar 2 '17 at 12:27









    tigercode

    476




    476












    • Yep, I have just tried all these but nothing. When I inspect the element in the android debugger, it says the element is using the font I want it to. But the element is still displaying as the default font.
      – Jake K
      Mar 2 '17 at 12:38


















    • Yep, I have just tried all these but nothing. When I inspect the element in the android debugger, it says the element is using the font I want it to. But the element is still displaying as the default font.
      – Jake K
      Mar 2 '17 at 12:38
















    Yep, I have just tried all these but nothing. When I inspect the element in the android debugger, it says the element is using the font I want it to. But the element is still displaying as the default font.
    – Jake K
    Mar 2 '17 at 12:38




    Yep, I have just tried all these but nothing. When I inspect the element in the android debugger, it says the element is using the font I want it to. But the element is still displaying as the default font.
    – Jake K
    Mar 2 '17 at 12:38










    up vote
    1
    down vote













    I added font in react-native android from here:



    https://medium.com/@gattermeier/custom-fonts-in-react-native-for-android-b8a331a7d2a7#.40vw3ooar



    Follow all the steps it will work fine.



    After adding run react-native run-android






    share|improve this answer





















    • I followed the same tutorial but to no aveil
      – Jake K
      Mar 2 '17 at 12:37















    up vote
    1
    down vote













    I added font in react-native android from here:



    https://medium.com/@gattermeier/custom-fonts-in-react-native-for-android-b8a331a7d2a7#.40vw3ooar



    Follow all the steps it will work fine.



    After adding run react-native run-android






    share|improve this answer





















    • I followed the same tutorial but to no aveil
      – Jake K
      Mar 2 '17 at 12:37













    up vote
    1
    down vote










    up vote
    1
    down vote









    I added font in react-native android from here:



    https://medium.com/@gattermeier/custom-fonts-in-react-native-for-android-b8a331a7d2a7#.40vw3ooar



    Follow all the steps it will work fine.



    After adding run react-native run-android






    share|improve this answer












    I added font in react-native android from here:



    https://medium.com/@gattermeier/custom-fonts-in-react-native-for-android-b8a331a7d2a7#.40vw3ooar



    Follow all the steps it will work fine.



    After adding run react-native run-android







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 2 '17 at 12:32









    Ankush Rishi

    62421135




    62421135












    • I followed the same tutorial but to no aveil
      – Jake K
      Mar 2 '17 at 12:37


















    • I followed the same tutorial but to no aveil
      – Jake K
      Mar 2 '17 at 12:37
















    I followed the same tutorial but to no aveil
    – Jake K
    Mar 2 '17 at 12:37




    I followed the same tutorial but to no aveil
    – Jake K
    Mar 2 '17 at 12:37










    up vote
    0
    down vote













    The other answers helped me get this working for me, thank you. This manuever is probably only necessary when the font has capital letters in the filename. A more complete answer:



    Add the font as normal in react native, for example:



    {react-native-project}/fonts/GovtAgentBB.ttf



    Run react-native link and this will put the font in



    {react-native-project}/android/app/src/main/assets/fonts/GovtAgentBB.ttf



    {react-native-project}/android/app/src/main/assets/fonts/GovtAgentBB_ital.ttf



    But android, bring robotic and not human, doesn't like this. So rename the file with all lower case letters and an underscore before the variant, like:



    {react-native-project}/android/app/src/main/assets/fonts/govtagentbb.ttf



    {react-native-project}/android/app/src/main/assets/fonts/govtagentbb_ital.ttf



    Then, you have to change the font name in the style depending on the platform. For iOS, use the human name that is the name of the font that would be displaying in the title of the window of the Mac Font menu (or just the name you see on the web). For android, you have to, robotically, use the name of the file you just renamed.



          {Platform.OS === 'ios' ? (
    <Text style={styles.welcome}>
    Hello World!
    </Text>
    ) : (
    <Text style={styles.welcomeAndroid}>
    Hello World
    </Text>
    )}
    const styles = StyleSheet.create({
    ...
    welcome: {
    fontFamily: 'Government Agent BB',
    },
    welcomeAndroid: {
    fontFamily: 'govtagentbb',
    },





    share|improve this answer

























      up vote
      0
      down vote













      The other answers helped me get this working for me, thank you. This manuever is probably only necessary when the font has capital letters in the filename. A more complete answer:



      Add the font as normal in react native, for example:



      {react-native-project}/fonts/GovtAgentBB.ttf



      Run react-native link and this will put the font in



      {react-native-project}/android/app/src/main/assets/fonts/GovtAgentBB.ttf



      {react-native-project}/android/app/src/main/assets/fonts/GovtAgentBB_ital.ttf



      But android, bring robotic and not human, doesn't like this. So rename the file with all lower case letters and an underscore before the variant, like:



      {react-native-project}/android/app/src/main/assets/fonts/govtagentbb.ttf



      {react-native-project}/android/app/src/main/assets/fonts/govtagentbb_ital.ttf



      Then, you have to change the font name in the style depending on the platform. For iOS, use the human name that is the name of the font that would be displaying in the title of the window of the Mac Font menu (or just the name you see on the web). For android, you have to, robotically, use the name of the file you just renamed.



            {Platform.OS === 'ios' ? (
      <Text style={styles.welcome}>
      Hello World!
      </Text>
      ) : (
      <Text style={styles.welcomeAndroid}>
      Hello World
      </Text>
      )}
      const styles = StyleSheet.create({
      ...
      welcome: {
      fontFamily: 'Government Agent BB',
      },
      welcomeAndroid: {
      fontFamily: 'govtagentbb',
      },





      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        The other answers helped me get this working for me, thank you. This manuever is probably only necessary when the font has capital letters in the filename. A more complete answer:



        Add the font as normal in react native, for example:



        {react-native-project}/fonts/GovtAgentBB.ttf



        Run react-native link and this will put the font in



        {react-native-project}/android/app/src/main/assets/fonts/GovtAgentBB.ttf



        {react-native-project}/android/app/src/main/assets/fonts/GovtAgentBB_ital.ttf



        But android, bring robotic and not human, doesn't like this. So rename the file with all lower case letters and an underscore before the variant, like:



        {react-native-project}/android/app/src/main/assets/fonts/govtagentbb.ttf



        {react-native-project}/android/app/src/main/assets/fonts/govtagentbb_ital.ttf



        Then, you have to change the font name in the style depending on the platform. For iOS, use the human name that is the name of the font that would be displaying in the title of the window of the Mac Font menu (or just the name you see on the web). For android, you have to, robotically, use the name of the file you just renamed.



              {Platform.OS === 'ios' ? (
        <Text style={styles.welcome}>
        Hello World!
        </Text>
        ) : (
        <Text style={styles.welcomeAndroid}>
        Hello World
        </Text>
        )}
        const styles = StyleSheet.create({
        ...
        welcome: {
        fontFamily: 'Government Agent BB',
        },
        welcomeAndroid: {
        fontFamily: 'govtagentbb',
        },





        share|improve this answer












        The other answers helped me get this working for me, thank you. This manuever is probably only necessary when the font has capital letters in the filename. A more complete answer:



        Add the font as normal in react native, for example:



        {react-native-project}/fonts/GovtAgentBB.ttf



        Run react-native link and this will put the font in



        {react-native-project}/android/app/src/main/assets/fonts/GovtAgentBB.ttf



        {react-native-project}/android/app/src/main/assets/fonts/GovtAgentBB_ital.ttf



        But android, bring robotic and not human, doesn't like this. So rename the file with all lower case letters and an underscore before the variant, like:



        {react-native-project}/android/app/src/main/assets/fonts/govtagentbb.ttf



        {react-native-project}/android/app/src/main/assets/fonts/govtagentbb_ital.ttf



        Then, you have to change the font name in the style depending on the platform. For iOS, use the human name that is the name of the font that would be displaying in the title of the window of the Mac Font menu (or just the name you see on the web). For android, you have to, robotically, use the name of the file you just renamed.



              {Platform.OS === 'ios' ? (
        <Text style={styles.welcome}>
        Hello World!
        </Text>
        ) : (
        <Text style={styles.welcomeAndroid}>
        Hello World
        </Text>
        )}
        const styles = StyleSheet.create({
        ...
        welcome: {
        fontFamily: 'Government Agent BB',
        },
        welcomeAndroid: {
        fontFamily: 'govtagentbb',
        },






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 11 at 0:45









        Michael Bushe

        655713




        655713






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42555315%2fandroid-react-native-app-not-picking-up-font%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Full-time equivalent

            さくらももこ

            13 indicted, 8 arrested in Calif. drug cartel investigation