简体   繁体   中英

How to make a Font and use it

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)

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM