I am working on cross platform app. In webview I want to use @font-face. It is working fine on Android but not working on UWP. My font file is in Assets/Fonts folder and in style sheet I am using the below code:
@font-face {
font-family: 'defont';
src: url('Assets/Fonts/mher.ttf');
}
In Android I was using this:
src: url('file:///android_asset/mher.ttf');
But when same approach I try in UWP, it is not working. Please anyone has any idea?
UPDATE:
Below is my C# code of using normal WebView. I am getting html content from local html file, replace some placeholders and display new html string to WebView.
var browser = new WebView();
var htmlSource = new HtmlWebViewSource();
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(WebViewPage)).Assembly;
Stream stream = assembly.GetManifestResourceStream("MyApp.Assets.MyTemplate.html");
string templateHtml = "";
using (var reader = new StreamReader(stream))
{
templateHtml = reader.ReadToEnd();
}
templateHtml = templateHtml.Replace("{pageHeading}", _post.Title);
templateHtml = templateHtml.Replace("{body}", _post.Content);
if (_post.IsFeaturedImageAvailable)
{
templateHtml = templateHtml.Replace("{imgSrc}", _post.FeaturedImageUrl);
}else
{
templateHtml = templateHtml.Replace("{imgSrc}", "");
}
templateHtml = templateHtml.Replace("pdfprnt-buttons", "pdfprnt-buttons hide");
htmlSource.Html = templateHtml;
htmlSource.BaseUrl = DependencyService.Get<IBaseUrl>().Get();
browser.Source = htmlSource;
Content = browser;