How to make a Font and use it
I recently saw that when sfml loads a font from memory by receiving a const char*
.
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 li开发者_如何学Goke 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)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:
Load the font from a file in memory.
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.
精彩评论