React-native-render-html: Unrecognized font family

Created on 20 May 2020  路  9Comments  路  Source: meliorence/react-native-render-html

Simulator Screen Shot - iPhone X - 2020-05-20 at 13 11 05

1.Unrecognized font family 'serif'

bug css FAQ candidate

Most helpful comment

@aje It was closed by the author! This error is probably caused by inline style. This is a known issue and we should be better at documenting the caveats; you can add font-style to the list of forbidden rules with the prop ignoredStyles={['font-family']}

All 9 comments

I'm with the same problem _Unrecognized font family 'Arial, Helvetica, sans-serif'_ and the case is, should I know every font that the user could use and import it to my app?

There's no way to replace an unrecognized font family for another one, like browsers do?

Thanks

why this issue is closed without any response?

Got the same issue. tried to de delete the node style but style the same.

@aje It was closed by the author! This error is probably caused by inline style. This is a known issue and we should be better at documenting the caveats; you can add font-style to the list of forbidden rules with the prop ignoredStyles={['font-family']}

I have found a fix for my issue, i had to delete the styles of any element who had the fontFamily style in it, i used alterChildren props to do so.

   alterChildren={node => {
                if (node.name === 'time') {
                  if (node?.attribs?.style) {
                    delete node.attribs.style
                  }
                }
                if (node.name === 'a') {
                  if (node?.attribs?.style) {
                    delete node.attribs.style
                  }
                }
                if (node.name === 'p') {
                  if (node?.attribs?.style) {
                    delete node.attribs.style
                  }
                }
                if (node.name === 'div') {
                  delete node.attribs.style
                }
                return node.children
              }}

may be that's not the best solution, let me know if there is a better way.

Hello i was closed the bug because i saw this document. https://github.com/react-native-training/react-native-fonts

if you want to ignore the font-family,
<HTML html={htmlContent} contentWidth={ contentWidth } ignoredStyles = {['font-family']} />

This issue has been fixed in the Foundry release. Try it out now! See #430 for instructions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aiavci picture aiavci  路  3Comments

sayem314 picture sayem314  路  6Comments

fahadhaq picture fahadhaq  路  6Comments

f-roland picture f-roland  路  3Comments

presencewebdesign picture presencewebdesign  路  7Comments