From 44cd98db96df5ec0b34daaacca003cf9e27e1439 Mon Sep 17 00:00:00 2001 From: jbinda Date: Wed, 10 Jul 2019 08:57:47 +0200 Subject: [PATCH] docs: add docs about custom Fonts (#1151) --- docs/pages/4.fonts.md | 60 +++++++++++++++++++ ...ct-native-web.md => 5.react-native-web.md} | 0 docs/pages/{5.showcase.js => 6.showcase.js} | 0 3 files changed, 60 insertions(+) create mode 100644 docs/pages/4.fonts.md rename docs/pages/{4.react-native-web.md => 5.react-native-web.md} (100%) rename docs/pages/{5.showcase.js => 6.showcase.js} (100%) diff --git a/docs/pages/4.fonts.md b/docs/pages/4.fonts.md new file mode 100644 index 0000000..4c881f6 --- /dev/null +++ b/docs/pages/4.fonts.md @@ -0,0 +1,60 @@ +--- +title: Fonts +--- + +# Fonts + +## Installing custom fonts + +The easiest way to install custom fonts to your RN project is do as follow: + + 1. Define path to asssets directory with fonts in project '`package.json`' + + Example: + + ```js + ... + "rnpm": { + "assets": [ + "fonts" + ] + }, + ... + ``` + + Note: fonts is a folder with .ttf files + + 2. Place your fonts files in your assets folder + 3. Link fonts files using '`react-native link`' command + 4. Restart your project to refresh changes + 5. You are able to use fontFamily based on fonts files + +## Configuring fonts in ThemeProvider + +After you configure the fonts you need to pass them as font object in a custom theme with the `Provider` component. Check the [default theme](https://github.com/callstack/react-native-paper/blob/master/src/styles/DefaultTheme.js) to see what customization options are supported. + +Example: + +```js +import * as React from 'react'; +import { DefaultTheme, Provider as PaperProvider } from 'react-native-paper'; +import App from './src/App'; + +const theme = { + ...DefaultTheme, + fonts: { + regular: 'Roboto', + medium: 'Roboto', + light: 'Roboto Light', + thin: 'Roboto Thin', + }, +}; + +export default function Main() { + return ( + + + + ); +} +``` diff --git a/docs/pages/4.react-native-web.md b/docs/pages/5.react-native-web.md similarity index 100% rename from docs/pages/4.react-native-web.md rename to docs/pages/5.react-native-web.md diff --git a/docs/pages/5.showcase.js b/docs/pages/6.showcase.js similarity index 100% rename from docs/pages/5.showcase.js rename to docs/pages/6.showcase.js