I'm using this function to load a font with opentype.js in a bare react-native app running on Android, but I'm getting the error "Font could not be loaded" :
const fontLoader = (url) =>
new Promise((resolve, reject) => {
opentype.load('fonts/TextMe-Regular.otf', (error, font) => {
if (error) {
console.log('error on fontLoader:', error);
reject(error);
}
console.log('fontLoader:', font);
resolve(font);
});
});
I've checked the folder inside android > app > src > main > assets > fonts and the TextMe-Regular.otf is there. My app structure is index.js, App > assets > fonts
EDIT:
I've found a way to load the font from this absolute path:
10.0.2.2:8081/assets/assets/fonts/TextMe-Regular.otf
but I can't find the relative path.