Skip to content

Font not passing to components #2317

@griffreichert

Description

@griffreichert

I have tried following the docs and a bunch of posts, but I cannot get my fonts to format any react-native-paper components. I follow the expo example of how to load fonts using loadFontAsync(), and when I pass these fonts to my own components using the style prop fontFamily: 'Rubik-Regular' the font works so I know it is not an issue of the font not existing.

I am using expo 39.0.3, react-native 0.63.3, react-native-paper 4.2.0, and react-native-vector-icons 7.1.0.

Any ideas on how to go about making this font work would be greatly appreciated.

import React from 'react';
import { Provider as ReduxProvider } from 'react-redux'
import configureStore from './store'
import { configureFonts, DefaultTheme, Provider as PaperProvider } from 'react-native-paper'
import { AppLoading } from 'expo';
import * as Font from 'expo-font';
import AppNavigator from './components/AppNavigator'

const store = configureStore();

const fontConfig = {
    default: {
        regular: {
            fontFamily: 'Rubik-Regular',
            fontWeight: 'normal',
        },
        medium: {
            fontFamily: 'Rubik-Black',
            fontWeight: 'normal',
        },
        light: {
            fontFamily: 'Rubik-Light',
            fontWeight: 'normal',
        },
        thin: {
            fontFamily: 'Rubik-LightItalic',
            fontWeight: 'normal',
        },
    },
};

const myTheme = {
    dark: false,
    roundness: 30,
    fonts: configureFonts(fontConfig),
    colors: {
        ...DefaultTheme.colors,
        primary: '#0d80d6',
        accent: '#E68FAE',
        background: '#C6E1F2',
    },
    animation: {
        scale: 1.0,
    },
}

export default class App extends React.Component {
    render() {
        return (
            <ReduxProvider store={store}>
                <PaperProvider theme={myTheme}>
                    <AppNavigator />
                </PaperProvider>
            </ReduxProvider>
        );
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions