Я работаю над кроссплатформенным приложением.В веб-просмотре я хочу использовать @ font-face.Он отлично работает на Android, но не работает на UWP.Мой файл шрифта находится в папке Assets / Fonts и в таблице стилей. Я использую следующий код:
@font-face {
font-family: 'defont';
src: url('Assets/Fonts/mher.ttf');
}
В Android я использовал это:
src: url('file:///android_asset/mher.ttf');
Но при том же подходе япопробуйте в UWP, это не работает.Пожалуйста, у кого-нибудь есть идеи?
ОБНОВЛЕНИЕ:
Ниже приведен мой код C # использования обычного WebView.Я получаю html-контент из локального html-файла, заменяю некоторые заполнители и отображаю новую html-строку в 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;