【问题标题】:how to add custom fontFamily to reacr-reader npm如何将自定义字体系列添加到 react-reader npm
【发布时间】:2021-11-30 05:00:21
【问题描述】:

我正在使用 react-reader npm,但我无法将自定义字体系列放入我的项目中。 有人知道这个答案吗?

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

【问题讨论】:

    标签: javascript reactjs reader epub.js


    【解决方案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
    

    【讨论】:

    • 谷歌字体怎么样?
    • 你也可以使用这些。您必须先导入它们。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-09
    • 1970-01-01
    • 1970-01-01
    • 2016-08-11
    相关资源
    最近更新 更多