我有同样的问题,其中有与事实,因为你已经知道了,Android将会从文件名中读取,而iOS版将全名属性读做。而且,的确,我混淆了我的字体参考。
我解决这个问题的第一件事是仔细检查我的字体是否正确地位于android/app/src/main/assets/fonts/
。
然后我最终将我的字体重命名为与iOS使用的字体完全相同的名称,并将该名称用作参考。这里是我的意思是:
export const sansSerifLight = 'Aileron-Light'; // Filename is 'Aileron-Light.otf'
export const sansSerifRegular = 'Aileron-Regular'; // Filename is 'Aileron-Regular.otf'
export const sansSerifBold = 'Aileron-Bold'; // Filename is 'Aileron-Bold.otf'
export const serifRegular = 'LibreBaskerville-Regular'; // Filename is 'LibreBaskerville-Regular.ttf'
export const serifBold = 'LibreBaskerville-Bold'; // Filename is 'LibreBaskerville-Bold.ttf'
export const serifItalic = 'LibreBaskerville-Italic'; // Filename is 'LibreBaskerville-Italic.ttf'
export const sansSerifTitle = 'ADAM.CG PRO'; // Filename is 'ADAM.CG PRO.otf'
export const serifTitle = 'Oranienbaum'; // Filename is 'Oranienbaum.ttf
然后:
<MyComponent style={{ fontFamily: serifTitle }} />
这着实让事物的方式不容易出错,更容易维护我。
嘿。抱歉回复晚了。我花了一些时间来回到这个。我已经创建了一个文件,我在这个平台上放置了正确的字符串。它正在工作。谢谢你的灵感:) – parohy