I don't think there's a way to directly use a .png file as an actual font file. You're probably going to need to use some font creation software and re-make the font you want to use through that.
Posts: 965
Threads: 20
Joined: Jan 2014
Depending on the game, you might... MIGHT.... be able to find the actual font file. some of the viewers show the names of the fonts. Some games, namely PC, use actual .ttf or .otf font files.
I recently discovered when using the JPEXS Free Flash Decompiler that I can now find the actual names of the fonts and google-search them. One such font I found this way was called "Feast Of Blood" it is the font used in Radioative Teddy Bear Zombies. Assuming you needed the font from a flash game, could try that approach.
As for .png files as fonts. Some games do in fact do this (some that come to mind are MineCraft, and a lot of retro-style games, and probably a Ludum Dare entry or two.). I think some engines/systems do support bitmap fonts. A font sheet is not all that different from a sprite sheet. If you already have the capabilities to process one of those, you're half-way there. All you have to do is make the game load + render that.
Let's say you create a font with this layout, let's assume all cells are 16x16 pixels...for simplicty's sake
1234567890
let's assume this gets parsed as a ten frame sprite.
In the game, you probably would have an array:
var chars = [1,2,3,4,5,6,7,8,9,0];
So one way to handle that is for every string, so let's say
"9001" (yes...i did...)
,you process each character individually, and look it up with the characters array
since the font sheet and your array are in the same order, you effectively just display one of these frames for each character:
8,9,9,0
This is ofc, the simple answer. A lot of the font sheets (or modern sprite sheets in general) are no longer ...ermm...consistent. They're packed in weird ways, and the games that would use them need a lookup table for the position and size of absolutely every sprite. Sprite-rippers also don't always organize sheets very optimally in the first place.
imagine the same ten-character font packed in with thousands of other sprites, scattered everywhere, in a sprite sheet that's let's say, 1000x1000 pixels... now imagine a full ascii one sprea-dout in the same way!
But let's not get into that, let me just say I have seen a few examples of lookup tables recently. They're not fun. Almost always need the program that is intended to read them, or require one to be reverse-engineered.
Good luck with whatever you are doing!
As already suggested, definitely start by looking for some libraries that do bitmap fonts. Should be able to find something. If not, well, look for tutorials/suggestions on how to implement one. Or even, based on what you know, just go for it, and make it on your own.
Hope this is somewhat helpful.
I SERIOUSLY need to get to sleep now.
SO glad I am not on facebook.
I have enough trouble getting to sleep because I feel inclined to reply to or comment about something.