Home / IOS Development / android – How to change font-family (font-family.ttf from assets) of reactive native web view

android – How to change font-family (font-family.ttf from assets) of reactive native web view



you can achieve this by injecting java scripts into the web view

ie

inject the following code in web view that will change body tag fontFamily

const INJECTED_JAVASCRIPT = `(function() {
   let body = document.getElementsByTagName("BODY")[0];
  body.style.fontFamily = "Courier New";
})();`;

Web View Componenet

console.log('Successfuly Loaded')}
        injectedJavaScript={INJECTED_JAVASCRIPT}
        onError={syntheticEvent => {
          const { nativeEvent } = syntheticEvent;
          console.warn('WebView error: ', nativeEvent);
        }}
      />

Working example link


Source link