久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何修復(fù)錯(cuò)誤:Fontconfig 錯(cuò)誤:無(wú)法加載默認(rèn)配置文

How to fix error: Fontconfig error: Cannot load default config file(如何修復(fù)錯(cuò)誤:Fontconfig 錯(cuò)誤:無(wú)法加載默認(rèn)配置文件)
本文介紹了如何修復(fù)錯(cuò)誤:Fontconfig 錯(cuò)誤:無(wú)法加載默認(rèn)配置文件的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

client.on('guildMemberAdd', async (member) => {
 const channel = member.guild.channels.cache.find(
  (channel) => channel.name === 'general'
 );

 if (!channel) return;

 const canvas = Canvas.createCanvas(700, 250);

 const ctx = canvas.getContext('2d');

 const background = await Canvas.loadImage('./wallpaper.jpg');
 ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

 ctx.strokeStyle = '#ffffff';
 ctx.strokeRect(0, 0, canvas.width, canvas.height);

 // Select the font size and type from one of the natively available fonts
 ctx.font = '60px ArialCE.ttf';
 // Select the style that will be used to fill the text in
 ctx.fillStyle = '#ffffff';
 // Actually fill the text with a solid color
 ctx.fillText(member.displayName, canvas.width / 2.5, canvas.height / 1.8);

 ctx.beginPath();
 // Start the arc to form a circle
 ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
 // Put the pen down
 ctx.closePath();
 // Clip off the region you drew on
 ctx.clip();

 const avatar = await Canvas.loadImage(
  member.user.displayAvatarURL({ format: 'jpg' })
 );
 // Move the image downwards vertically and constrain its height to 200, so it's a square
 ctx.drawImage(avatar, 25, 25, 200, 200);

 const attachment = new Discord.MessageAttachment(
  canvas.toBuffer(),
  'welcome-image.png'
 );

 channel.send(`Welcome ${member.toString()} to the server!`, attachment);
});

我一直在使用 discord.js 制作一個(gè)不和諧的機(jī)器人.我想制作一個(gè)畫(huà)布?xì)g迎信息,然后當(dāng)它制作完成時(shí),它可以正常工作,除了畫(huà)布上的文字.原來(lái)是這樣的:

I have been making a discord bot using discord.js. I wanted to make a canvas welcome message then when made it, it was working and all, except the words on the canvas. It was all like this:

我在谷歌上搜索了很多,但找不到任何解決方案.我得到的錯(cuò)誤是(Fontconfig 錯(cuò)誤:無(wú)法加載默認(rèn)配置文件).我知道這意味著我的系統(tǒng)中沒(méi)有字體,但是如何添加它們.我正在使用 repl.it.

and I searched a lot on google but couldn't find any solution. The error I get is (Fontconfig error: Cannot load default config file). I know it means that there are no fonts in my system but how to add them. I'm using repl.it.

推薦答案

它應(yīng)該在 node-canvas 2.0+ 中工作.簽出新的 Canvas.registerFont 方法:https://github.com/Automattic/node-canvas/#registerfont

It should work in node-canvas 2.0+. checkout new Canvas.registerFont method: https://github.com/Automattic/node-canvas/#registerfont

要使用未安裝為系統(tǒng)字體的字體文件,請(qǐng)使用 registerFont() 將字體注冊(cè)到 Canvas.這必須在創(chuàng)建畫(huà)布之前完成.

To use a font file that is not installed as a system font, use registerFont() to register the font with Canvas. This must be done before the Canvas is created.

const { registerFont, createCanvas } = require('canvas')
registerFont('./fontFolder/comicsans.ttf', { family: 'Comic Sans' })

const canvas = createCanvas(500, 500)
const ctx = canvas.getContext('2d')

ctx.font = '12px "Comic Sans"'
ctx.fillText('Everyone hates this font :(', 250, 10)

例子:

TTF 文件將具有不同的字體名稱.所以這里只有 'Roboto' .否則它不起作用.

TTF file will have a different font name. so only 'Roboto' here. otherwise it doesn't work.

registerFont('./fonts/Roboto-Medium.ttf', {family: 'Roboto'})

不要將 fontName 定義為 'Medium 28px Roboto'.它不會(huì)工作.

Don't define fontName as 'Medium 28px Roboto'. it won't work.

ctx.font = '12px Roboto Medium';

這篇關(guān)于如何修復(fù)錯(cuò)誤:Fontconfig 錯(cuò)誤:無(wú)法加載默認(rèn)配置文件的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機(jī)器人提及發(fā)出該機(jī)器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復(fù)必須使用導(dǎo)入來(lái)加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來(lái)自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時(shí)的歡迎消息)
主站蜘蛛池模板: 九九久久精品视频 | 亚洲国产精选 | 欧美国产精品一区二区三区 | 成人h视频在线 | av一区二区在线观看 | 成人久久久| 中文字幕综合 | 日韩三级 | 野狼在线社区2017入口 | 欧美一区二区三区免费在线观看 | 久久久妇女国产精品影视 | 日韩在线欧美 | 特级黄一级播放 | 久久久久久999 | 91精品国产91久久久久久最新 | 国产高清免费 | 亚洲入口| 国产精品久久久久久久久久久新郎 | 免费一区二区三区在线视频 | 久久毛片 | 成人在线亚洲 | 成人欧美一区二区三区黑人孕妇 | 日韩一二区在线观看 | 国产免费一区二区三区网站免费 | 国产精品久久久久久久久久免费 | 国产区久久 | 国产精品大全 | 在线观看免费av片 | 亚洲成年影院 | 成人欧美一区二区三区黑人孕妇 | 成人区精品一区二区婷婷 | 九色 在线 | 久久99视频 | 东方伊人免费在线观看 | 91传媒在线观看 | 99久久国产| 午夜婷婷激情 | 精品视频一区二区三区 | 伊人精品在线 | 日日摸天天添天天添破 | 国产亚洲一区二区三区 |