渲染具有大字体大小的字形向量

发布于 2024-10-07 10:23:23 字数 566 浏览 0 评论 0原文

对于我正在从事的项目,我需要在画布上渲染不同字体大小的文本,有时需要多次。为此,我创建一个字形向量,并使用 Graphics2D 绘制它。

font = new Font(fontName, Font.PLAIN, fontSize);
glyphs = font.createGlyphVector(frc, text);

...

g2.setColor(word.getColor());
g2.drawGlyphVector(word.getGlyphs(), (float)word.getPosition().getX(), (float)word.getPosition().getY());

直到最近,当我注意到无法呈现大字体(任何超过 100 的字体)时,此功能一直运行良好。字形向量的创建似乎没有问题,并且对于我期望渲染的文本来说看起来是准确的。 Graphics2D 似乎在渲染字形时遇到问题。

我已经用大量的字体进行了检查,所有的字体似乎都有一个严格的限制,即 100。经过大量的谷歌搜索后,我找不到任何关于上限的提及。

使用 Graphics2D 渲染大字体的字形向量是否存在任何已知问题?

For a project I'm working on, I need to render text of varying font-size on a canvas, sometimes several times. To do this I'm creating a glyph vector, and drawing that using Graphics2D.

font = new Font(fontName, Font.PLAIN, fontSize);
glyphs = font.createGlyphVector(frc, text);

...

g2.setColor(word.getColor());
g2.drawGlyphVector(word.getGlyphs(), (float)word.getPosition().getX(), (float)word.getPosition().getY());

This has been working fine up until recently, when I noticed that large font sizes (anything above 100) can't be rendered. The glyph vector appears to be created without issue, and looks to be accurate for the text I'm expecting to render. It seems that Graphics2D takes issue with rendering the glyphs.

I've checked this with a multitude of font faces, and everything seems to have a hard limit of exactly 100. I've been unable to find any mention of a cap after a fair amount of googling.

Are there any known issues with rendering glyph vectors with large font sizes using Graphics2D?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗喜 2024-10-14 10:23:23

您可以尝试使用 glyphs.getOutline() 并渲染获得的形状吗?

实际上,我尝试过字形矢量渲染,但不记得大字体有任何问题。你能发布一个可编译的代码来显示问题吗?

Can you try to use glyphs.getOutline() and render the obtained shape?

Actually I tried glyph vectors rendering and dont' remember any problems with big fonts. Could you post a compilable code to show the problem?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文