Blit part of a graphic to background (for use as font-character)

Started by deetee, November 24, 2010, 11:05:45 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

deetee

Hi all!

Fonts are a big topic in bennugd. Most *.fnt-files are DOS-fonts and not suitable for bennugd. Using ttf-fonts requires an extra lib.
So I decided to give a graphic-font a try.

I found a font-tool (FONY) which is capable to import ttf-fonts and save it as (one) png-graphic-file. Using a monospace font shows me every ie 16 x-pixel a new character.

How can I cut this part of the whole graphic and put it on the screen? The only function in bennugd which seem capable to blit a rectangular block of a graphic to another is "map_block_copy". My first try with this function didn't work. Maybe that's why I wanted to blit to background (not another graphic)?

Is there another (more efficient) function or can you give me please some code example for map_block_copy?

TIA deetee

handsource-dyko

There's a tile spiltter example in bennupack, located in the 2- medium exaples directory.
I've looked at the code, an I think it could a solution for your problem.
The program is written by "Pixel" (found that in the source).

Another thing you could try is to make a small conversion utillity, that loads a ttf font,
and outputs a fnt font.

Maybe this works (I found this example in the source tree of the bennu karaoke game)


IMPORT "mod_video";
IMPORT "mod_map";
IMPORT "mod_ttf";
IMPORT "mod_say";

PROCESS main();
PRIVATE
int fontid=0;

BEGIN
   set_mode(640, 480, 16, MODE_WINDOW);
   fontid=ttf_loadaa("DejaVuSans-Bold.ttf",48,16,RGB(255,0,0),RGB(0,255,0));
   save_fnt(fontid, "font.fnt");
   unload_fnt(fontid);
END



Please note that I haven't tested both examples myself, but they seem usefull.

DCelso

That you sais is very complex and is very similar to a tiles engine, you can search information of it.
The theory is very simple but is better insert the image of the text result in a graph of a process because you can destroy the text only killing the process.
Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/

deetee

Hello all!

Thanks for the hints.

handsource-dyko: I tried your code to use bennu+mod_ttf to convert ttf-fonts to fnt-fonts - and it works (great).
It seems that this solves all my font problems  :) - thank you very much.

Regards
deetee

DCelso

you can use fntedit and fntedit32 to do, too. The adventage of fntedit32 is that you can create fnts with alpha colors and shadows.
Monstruos Diabólicos

"A PAck of classic GAMEs For BennuGD" en desarrollo
http://code.google.com/p/apagame4be/