我使用WebView
来显示一些正确理由的文字(Android
不支持理由)。我在WebView
文字style
中尝试应用自定义字体时已经筋疲力尽了。我已尝试过以下代码,但没有结果:
var html = `<h1 style="font-family: MyFont"> some text here </h1>`
<WebView
source={{html}}
style={{width: 200, height: 200}}
/>
这是我的react native
文件结构:
Project
-android
-node_modules
-...
-assets
--fonts
---MyFont.ttf
MyFont.ttf
位于Project/assets/fonts/
内。我也试过了this,但无法让它发挥作用。它说我应该设置baseUrl
,但我不知道要设置url
。请帮助我,我真的需要一个全面而有效的例子。