cannot use custom font from local file
See original GitHub issueHello ! I am using your library on ios
I have this component
import React,{Component} from 'react';
import {View,ActivityIndicator,Dimensions} from 'react-native';
import AutoHeightWebView from 'react-native-autoheight-webview';
class DynamicWebView extends Component
{
constructor(props)
{
super(props);
this.state =
{
height: 0
}
this.mycontext = this.props.context;
}
onWebViewMessage = (size) =>
{
if(size.height > 0)
{
this.mycontext.setState({height: parseInt(size.height)});
this.setState({height: parseInt(size.height)})
}
}
render()
{
let wrapperStyle = this.props.wrapperStyle || " style='direction:rtl;font-size: 19px;font-family: ae_AlArabiya;color: #666666;padding: 7px;'";
let content = this.props.content || '';
let style = this.props.style || {};
let height = this.state.height && parseInt(this.state.height)>=0?this.state.height:200;
let css = `<style type="text/css"> @font-face {font-family: ae_AlArabiya; src:url(file:///assets/fonts/ae_AlArabiya.ttf);} *{font-family: ae_AlArabiya}</style>`;
return(<AutoHeightWebView
style={[{ width: Dimensions.get('window').width, marginTop: 35,backgroundColor: '#ffffff'},style]}
customStyle={`@font-face {font-family: ae_AlArabiya;src:url(file:///assets/fonts/ae_AlArabiya.ttf);} * {font-family: ae_AlArabiya;}`}
onSizeUpdated={(size) => {this.onWebViewMessage(size);}}
source={{html: css + "<div" + wrapperStyle + ">"+ content + "</div>"}}
zoomable={false}
baseUrl=""
startInLoadingState={true}
renderLoading={() => <ActivityIndicator />}
/>);
}
}
export default DynamicWebView;
i tried all ways to make my webview use font ae_AlArabiya but without any success.
Note : This was succeeded for normal react-native -webview
I attached a zip file that contains the font
Hope that their is any solution
Thank you in advance for any regards !
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
How To Load and Use Custom Fonts with CSS | DigitalOcean
Once you have downloaded the file, extract the fonts directory contained in the zip file and place it in the same directory as...
Read more >Cannot embed custom font from local file · Issue #372 - GitHub
Hi, I'm trying to set a custom font from a local file as it was shown in examples. ... Cannot embed custom font...
Read more >Custom font (fontface) not working when published
If the font works locally but not when on the server then you need to check the path to the font file. Inspect...
Read more >How to use @font-face in CSS
The @font-face rule allows custom fonts to be loaded on a webpage. Once added to a stylesheet, the rule instructs the browser to...
Read more >font-face - CSS: Cascading Style Sheets - MDN Web Docs
Chrome Edge
@font‑face Full support. Chrome1. Toggle history Full support...
OpenType CBDT and CBLC rendering Full support. Chrome66. Toggle history Full support...
OpenType COLRv0 rendering Full...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@tapannathvani @sislovesmedotcom Now the local custom font example is included within the demo.
anybody can share some example code here, i checked the demo, but i cant understand bcz i am not an expert, please help me…