Customize the font styling in my React Native Expo app to use the satoshi font

I am looking to use the Satoshi font for my react native expo app. However, I am having trouble figuring out how to set the custom font. I have tried following methods from YouTube channels but none of them seem to work. Every time I try to install the font, I end up encountering an error.

https://i.sstatic.net/WYlxe.png

Answer №1

  1. Get the Expo Font package:

    npm i expo-font

  2. Acquire the Satoshi font:

Obtain the genuine Satoshi font from a trusted source like Google Fonts or Santoshi Fonts. Save the font file in the assets/fonts directory of your project.

  1. Establish a useFonts hook:

    import { useFonts } from 'expo-font';
    
     const useSatoshiFont = () => {
     const [fontsLoaded] = useFonts({
      'Satoshi': require('../assets/fonts/Satoshi.ttf'),
     });
     return fontsLoaded;
    };
    
  2. Implement the hook in your component:

    import { useSatoshiFont } from './useSatoshiFont';
    
     const MyComponent = () => {
     const fontsLoaded = useSatoshiFont();
    
     if (!fontsLoaded) {
     // Display a loading indicator during font loading
      return <Text>Loading...</Text>;
        }
    
       return <Text style={{ fontFamily: 'Satoshi' }}>This displays in Satoshi 
        font</Text>;
       };
    
  3. Add the font family to the app.json file of your app:

    {
      "expo": {
       "fonts": [
        {
        "name": "Satoshi",
         "style": "normal"
        }
       ]
      }
     }
    
  • Ensure that the font filename and the font family name in the app.json file match correctly.

  • The app.json file should be stored in the primary directory of your project.

  • Rebuild your app after implementing these alterations.

    expo clean
    expo start
    

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What are some effective strategies for resolving the persistent issue of Visual Studio Code warnings, MDN Reference difficulties, and other challenges?

Is there a way to turn off TypeScript warnings and completely disable TS in Visual Studio Code for standard JavaScript files while using SvelteKit? I typically opt out of using TS when starting a new project. Furthermore, is it possible to get rid of the ...

Combine multiple key values from an array of objects into a single array

I have a set of key and value pairs that I need to filter based on whether the values are in an array or not, and then combine them into a single array. const holiday_expenses = { food: [{name: "abc", place: "xyz"}], travel: [{name: ...

Save the SSLSocketFactory as a static field in the store

Within my Android project, I have been using the code snippet below to establish a connection with a Tomcat server across multiple activities. Now, I am looking to refactor this code and encapsulate it within another class. This way, I can avoid reloading ...

Guide to incorporating a ScrollView with numerous ListViews into a drawer layout (Navigation Drawer)

I am currently working on integrating a navigation drawer into my project, specifically in K9-mail. I am attempting to create a navigation drawer with three listviews, and my goal is for each listview to share the same scrollbar. This means that they shoul ...

The deployment of a React application to AWS Amplify encounters an error in the Amplify Console

When I try to deploy my application using the AWS Amplify console, the Build step for the backend fails. The error message indicates that there is a missing configuration file or directory. { Error: ENOENT: no such file or directory, scandir '/code ...

Rearrange an irregular matrix using JavaScript

I have a matrix that can vary in width depending on the results received from the server. Here is an example: [undefined, undefined] [1, 2, 3, 4] [1, 2] [undefined, undefined, undefined] [1, 2, 3, 4, 5, 6] My goal is to transform it into this format: [u ...

Stop Caching with Jquery Infinite Scroll (IAS)

I am using jQuery + IAS to implement infinite scroll functionality on my website. However, I have encountered an issue where the cache is being disabled when making requests for new content. Specifically, the URL that is accessed to retrieve the next page ...

Challenges encountered when trying to incorporate vanilla JavaScript within a Ruby environment

While working on my controller, I attempted to render vanilla JavaScript but encountered an unexpected outcome. Below is the code snippet: class UploadController < ApplicationController def index render :file => 'app\views&bs ...

Unlock the full potential of NextAuth by incorporating wildcard and custom domains for enhanced user

I am currently developing a NextJS application that functions as a multi-tenant SaaS platform. Within the app, each customer has the ability to either utilize a subdomain on our site or map their own custom domain via CNAME. My goal is to enable our cust ...

Seeking the location of the `onconnect` event within the Express framework

With the use of "express," I have implemented a middleware function like so: app.use(function(request, response, next) { console.log(request.headers["user-agent"]); // etc. }); This currently displays the user-agent header in the console for ever ...

Is it possible to manually provide jwplayer with the segments of a video feed?

In brief, my current project involves developing a plugin to retrieve segments from an HLS playlist hosted on my personal server (using WebSocket) instead of relying on a content delivery network. While I've successfully replaced the XHR component, I ...

Approach to Using Bootstrap 4 with Intl-Tel-Input

I've been attempting to integrate intl-tel-input with bootstrap 4, but I'm facing an issue where the placeholder for the input is not showing up. I've tried various solutions found online, but none of them seem to work. Here's my HTML ...

Error Found: The function .setFromEuler() in THREE.Quaternion now requires an Euler rotation as input instead of a Vector3, along with its corresponding order

In my ThreeJS/WebGL project, I have created a rotating planet displayed inside an iframe. While the functionality is working as intended, I am encountering a warning and an error: Warning: THREE.WebGLRenderer: Texture is not power of two. Texture.minFilte ...

Querying through a database containing 1 million <string Name, int score> pairs efficiently within sub-linear time

My JSON object holds 1 million pairs. var student = {[ { name: "govi", score: "65" }, { name: "dharti", score: "80" }, { name: "Akash", score: "75" },............. up to a million ...

Generate a dynamic add to cart section for every last configurable choice, assisting with this task

Currently, I am involved in a project that involves displaying configurable options on a product page, along with querying the database to check which vendors carry the product. The list of vendors is then displayed using JavaScript. In order to make the ...

DOM doesn't reflect changes to nested object when component prop is updated

I have a complex object structured in a multidimensional way that appears as follows: obj: { 1: { 'a' => [ [] ], 'b' => [ [] ] }, 2: { 'x' => [ [], [] ] } } This object is located in the r ...

Accessing decodable object parameters from JSON within an iOS app using URLSession dataTask

I received a response from URLSession dataTask, how can I effectively transform the data I received: response: {"message":"login successful","data":{"id":15,"username":"Dummy2","password":"1234","email":"<a href="/cdn-cgi/l/email-protection" class="__ ...

Do not repeat the outer loop

Currently, I am faced with a situation where I need to iterate through two lists or arrays in order to extract the necessary values. Here is how I am approaching it: var html = ""; $.each(list, function (i, set1) { //set1 represents a list or array $. ...

Having trouble with Next.js and Next-auth? When I make an HTTP request in getServerSideProps, getSession is returning null in my secured API Route

I am currently working on securing an API Route that is being called from both the Client and Server-side on different pages. When accessing the test page, it returns a 401 error. However, when accessing the test2 page, the content is retrieved successfu ...

Comparison between modules and standalone components

It has come to my attention that there is a growing trend in Angular 17 to move away from using modules, opting instead for standalone components. This approach makes Angular more similar to Vuejs or React, where the concept of modules is not as prominent. ...