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

2023-01-29前端开发问题
116

本文介绍了自定义字体未在 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 上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

layui实现laydate日历控件控制之前日期不可选择
具体实现代码如下: laydate.render({ elem: '#start_time', min:0, //,type: 'date' //默认,可不填}); 只要加一个min参数,就可以控制了。0表示之前的日期不可...
2024-11-29 前端开发问题
133

layui laydate日期时间范围,时间默认设定为23:59:59
在Layui中,如果你想设置日期时间选择器(datetime)的默认结束时间为当天的23:59:59,你可以使用如下代码: laydate.render({ elem: '#test10' ,type: 'datetime' ,range: true ,max: '{:date("Y-m-d 23:59:59")}' ,ready: function(date){ $(".layui-laydat...
2024-10-24 前端开发问题
279

layui要如何改变时间日历布局大小?
问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
2024-10-24 前端开发问题
271

jQuery怎么动态向页面添加代码?
append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href...
2024-10-18 前端开发问题
125

layui自定义内容打印
layui集成有打印功能,当我们需要自定义内容打印,需要怎么操作呢?以下是具体代码: div class="layui-inline" label class="layui-form-label"打印表格/label table id="table_info" tr td7/td td8/td td9/td /tr /table/divdiv class="layui-inline" a id=...
2024-10-15 前端开发问题
287

layui table数据表格reload where参数保留
1、创建表格对象 layui.use('table', function () { var table = layui.table; tableObj = table.render({ id: "tableId", url: 'url', //数据接口 elem: '#tableId', page: { limit: 15, limits: [15, 30, 50, 100] }, //开启分页 cols: [[ //表头 ... ]], w...
2024-07-18 前端开发问题
385