如何制作字体并使用它
我最近看到,当 sfml 通过接收 const char*
从内存加载字体时。
这如何表示字体?
我还看到arial.hpp文件只包含一个巨大的数字(字符)数组,您可以将其输入到LoadFont中函数
。
SFML 中的字体类也包含一个 image
,但我不知道它是如何设置的,因为它没有加载/设置函数,并且图像是由无符号字符组成的,而不是像这样的字符数组arial 字体是由什么构成的。
所有这些东西如何组合在一起,以及如何创建和加载字体?
(sfml具体步骤也很好)
I recently saw that when sfml loads a font from memory by receiving a const char*
.
How does this represent a font?
I also saw the arial.hpp file only contains a huge array of numbers(chars), which you can feed into the LoadFont function
.
the font class in SFML also holds an image
, but I don't know how it gets set since there's no load/set function for it, and images are made out of unsigned chars, not char arrays like what the arial font is made of.
How does all this stuff fit together, and how do I create and load a font?
(sfml specific steps would be nice also)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,SFML 中没有 LoadFont 函数。有 Font::LoadFromFile 和 Font::LoadFromMemory。我假设你正在谈论这些。
来自 Font::LoadFromMemory 的文档:
它适用于将某些内容加载到内存中的情况。也就是说,如果您不使用普通的文件系统。也许您的所有数据都在 .zip 文件中,因此使用标准文件 IO 没有用。您将其加载到内存块(前面提到的字节数组)中,并将其传递给此函数。
2.0 文档更加完整,因为它列出了接受的字体格式< /a>.
As far as I can tell, there is no
LoadFont
function in SFML. There are Font::LoadFromFile and Font::LoadFromMemory. I'll assume you're talking about those.From the documentaiton for Font::LoadFromMemory:
It is for cases when you have loaded something into memory. That is, if you're not using the normal filesystem. Maybe you have all of your data in .zip files, so using standard file IO won't be useful. You load it into a block of memory (the aforementioned array of bytes), and pass it to this function.
The 2.0 documentation is more complete, as it lists the font formats that are accepted.