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

如何修復錯誤:Fontconfig 錯誤:無法加載默認配置文

How to fix error: Fontconfig error: Cannot load default config file(如何修復錯誤:Fontconfig 錯誤:無法加載默認配置文件)
本文介紹了如何修復錯誤:Fontconfig 錯誤:無法加載默認配置文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

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 制作一個不和諧的機器人.我想制作一個畫布歡迎信息,然后當它制作完成時,它可以正常工作,除了畫布上的文字.原來是這樣的:

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:

我在谷歌上搜索了很多,但找不到任何解決方案.我得到的錯誤是(Fontconfig 錯誤:無法加載默認配置文件).我知道這意味著我的系統中沒有字體,但是如何添加它們.我正在使用 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.

推薦答案

它應該在 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

要使用未安裝為系統字體的字體文件,請使用 registerFont() 將字體注冊到 Canvas.這必須在創建畫布之前完成.

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'.它不會工作.

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

ctx.font = '12px Roboto Medium';

這篇關于如何修復錯誤:Fontconfig 錯誤:無法加載默認配置文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

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(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 九九综合 | 久久亚洲精品国产精品紫薇 | 中文字幕亚洲在线 | 欧美一区二区激情三区 | 日韩国产在线 | 午夜视频免费在线观看 | 午夜视频在线播放 | 一区二区三区免费 | 国产丝袜人妖cd露出 | 久久久久国产精品 | 久久久久久久久久久91 | 色999视频| 狠狠综合久久av一区二区小说 | 99久9 | 成人亚洲片 | 久久aⅴ乱码一区二区三区 亚洲欧美综合精品另类天天更新 | 精品视频在线播放 | 精品国产乱码久久久久久蜜臀 | 精品成人在线 | 欧美国产日韩成人 | 在线黄av| www.成人久久 | 中国一级特黄毛片大片 | 欧美成人黄色小说 | 久久中文字幕一区 | 国产精品永久免费 | 国产精品久久久久久久久久久免费看 | 99视频久| 欧美激情在线观看一区二区三区 | 国产成人精品综合 | 午夜影院操 | 草久久久 | 午夜精| 99精品国产一区二区青青牛奶 | 国产一区二区三区免费观看在线 | 亚洲美女在线一区 | 久久久久久成人 | 精品久久久久一区二区国产 | 亚洲精品一区二区三区四区高清 | 中文字幕成人 | 免费久 |