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.

How to use custom fonts for text

See original GitHub issue

<Text key={i} x=‘0’ y=‘0’ fontSize=‘24’ fontFamily='somefont'>&#xE050;</Text>

Seems it uses the default font

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:15

github_iconTop GitHub Comments

1reaction
anhtuank7ccommented, Mar 6, 2017

I have one custom font: Kingsman

I do place font in project_folder/src/fonts/Kingsman.tff then edit packages.json like this:

    "rnpm": {
        "assets": ["./src/fonts/"]
    }

Next, i do link fonts to Android/iOS:

react-native link

Fonts copied to 2 android and ios project

Then i try to display Text to make sure i do correctly:

import { Text} from 'react-native'

...component code

render() {
    return <Text style={{ fontFamily: 'Kingsman', fontSize: 20}} >Demo</Text>;
}

=> Display correct font as expected.

Problem on Android ONLY

import Svg, {Text} from 'react-native-svg';

...component code

render() {
    return (
        <View style={{flex: 1}}>
            <Svg height={100} width={100}>
                <Text fontFamily="Kingsman" fontSize="22" x="10" y="10">Demo</Text>
            </Svg>
        </View>
    );
}

==> Doesn’t make scene on Android device, iOS working good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Load and Use Custom Fonts with CSS | DigitalOcean
Then, you will use a font-hosting service, Google Fonts, to find, select, and load custom fonts onto your page. Lastly, you will load...
Read more >
How to Install Custom Fonts on Your Computer [Quick Tip]
1) Shut down any program you want to use the font in. · close_ppt · 2) Download the font to your computer and...
Read more >
Use a custom font - Flutter documentation
Use a custom font · 1. Import the font files. Supported font formats · 2. Declare the font in the pubspec. pubspec.yaml option...
Read more >
Applying custom fonts to text | Apple Developer Documentation
To use a custom font, add the font file that contains your licensed font to your app, and then apply the font to...
Read more >
The Easy Way to Add Fonts to Your Website (Including ...
In most cases, when looking to add a custom font that does not exist within Google Fonts, you will need to edit the...
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