как добавить пользовательское семейство шрифтов в npm reacr-reader

javascript #reactjs #reader #epub.js

#javascript #reactjs #reader #epub.js

Вопрос:

Я использую react-reader npm, и я не могу поместить свое пользовательское семейство шрифтов в свой проект. Кто-нибудь знает ответ на этот вопрос?

https://www.npmjs.com/package/react-reader

Ответ №1:

 import React, { useState,useRef } from "react"
import { ReactReader } from "react-reader"

const App = () => {
  const [location, setLocation] = useState(null)
  const renditionRef = useRef(null);

  return (
    <div style={{ height: "100vh" }}>
      <ReactReader
        location={location}
        locationChanged={ (epubcifi)=>setLocation(epubcifi)}
        url="https://gerhardsletten.github.io/react-reader/files/alice.epub"
        getRendition={(rendition) => {
                renditionRef.current = rendition;
                renditionRef.current.themes.register('custom', {
                  p: {
                   'font-family': `Helvetica`,

                  },
                });
               renditionRef.current.themes.select('custom');
              }}
      />
    </div>
  )
}

export default App
 

Комментарии:

1. как насчет шрифтов Google?

2. Вы тоже можете их использовать. Сначала вы должны импортировать их.