Skip to content

feat: allow custom fonts #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: allow custom fonts #2

wants to merge 1 commit into from

Conversation

TTsdzb
Copy link

@TTsdzb TTsdzb commented Apr 29, 2025

Allow the user to load custom fonts like loading images.

绘制文本时使用默认字体比较难看,但同时并没有一个方便的加载字体的方式。添加了个接口用来解决这个问题。目前只传回 id 字符串,不确定这样用好不好。

用法:

const font = await ctx.canvas.loadFont("file:///example/url/font.otf")
canvasCtx.font = `50px ${font}`
canvasCtx.fillText("Test", 300, 600)

Allow the user to load custom fonts like loading images.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant