自定义字体未在 Electron + Vue App 上显示

Custom font is not showing on Electron + Vue App(自定义字体未在 Electron + Vue App 上显示)
本文介绍了自定义字体未在 Electron + Vue App 上显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在使用 Vue + Electron 开发一个应用程序,我在使用自定义字体时遇到了问题.在 web 模式下运行应用程序时,与自定义字体一起使用的图标显示正常.但是当我使用 electron-builder 构建应用程序时,图标/自定义字体没有加载.

I am developing an app using Vue + Electron and im facing an issue using custom fonts. When running the app in web mode, the icons used with the custom font show ok. But when i build the app using electron-builder, the icons/custom font are not loaded.

我在 index.html 头标签中导入自定义字体,自定义字体位于 src/renderer/assets/fonts 文件夹中.

I import the custom font in the index.html head tag and the custom fonts are located in src/renderer/assets/fonts folder.

任何帮助谢谢

推荐答案

要确保字体包含在电子中,请尝试以下操作:

To make sure that the font is included in electron, try something like this:

在您的渲染器 main.js 中

In your renderer main.js

import './scss/app.scss'

在你的'./scss/app.scss'中

In your './scss/app.scss'

@font-face {
    font-family: 'Your Custom Font';
    src: url('../assets/fonts/Your Custom Font.ttf');
}

这应该确保你的字体被 webpack 包含在电子中.

This should make sure that your font is included with electron by webpack.

这篇关于自定义字体未在 Electron + Vue App 上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

jQuery plugin for generating multi coloured text which changes colour on hover(用于生成多色文本的 jQuery 插件,在悬停时会改变颜色)
Mouseover or hover vue.js(鼠标悬停或悬停 vue.js)
Gmail not showing correct font(Gmail 没有显示正确的字体)
Is it possible to print a chart with vue-chartjs?(是否可以使用 vue-chartjs 打印图表?)
(Vue, ChartJS) Create gradient background for chart from child component canvas context((Vue, ChartJS) 从子组件画布上下文为图表创建渐变背景)
vue-chartjs reactive data error(vue-chartjs 反应数据错误)