The Game Creators
The Game Creators Home Online Shop Click to Login
  Hot: Christmas CompetitionNovember NewsletterModel Pack 36DB Pro Pack 2009DGS BonanzaCharacter PackFPS Creator Bonanza;
The Game Creators
2D / Bitmap Font Pack 2 ... FREE to a good home!

Go to the first page of this board Return to the Forum Menu Post Message
16 Messages - Page   of 1   
Bookmark and Share Search the Forum

Author Message
Scraggle

User


Joined: Thu Jul 10th 2003
Location: Teesside University
Posted: 17th Mar 2006 03:15     Edited: 17th Mar 2006 03:20     | link | toggle

This is the second installment of my bitmap fonts. Like the first they are FREE to use however you wish .... enjoy

Note
This pack was originally posted in the DarkBASIC Professional forum but it slipped off the page before many people got to see it. So, I have reposted it here, which is where it should have been in the first place!


Pack 1 used 32 x 32 fonts.
Pack 2 uses 64 x 64 fonts.

Load Bitmap and cut images - keeping transparency:
+ Code Snippet
`*********************************
`       LOAD BITMAP FONT
`*********************************
Function LoadBMfont(FileName as string,FontImageNumber)
	
	load image FileName,FontImageNumber,1
	Font = 32
	For y = 0 to 9
		for x = 0 to 9
			GetImage( FontImageNumber, Font + FontImageNumber, x*64, y*64, 64, 64 )
			inc Font
		next x
	next y
`	Delete Image FontImageNumber
	
endfunction


`*********************************
`   GET IMAGE WITH TRANSPARENCY
`*********************************
function GetImage(Image1,NewImage,Xstart,Ystart,Xsize as dword,Ysize as dword)
	
	`Find unused memblocks
	Memblock1 = 1
	repeat
		inc Memblock1
	until memblock exist(Memblock1) = 0
	NewMemblock = 2
	repeat
		inc NewMemblock
	until memblock exist(NewMemblock) = 0
	
	`Set up variables
	Local Width as Dword
	Local Height as Dword
	Local Depth as Dword
	Local Red as Byte
	Local Green as Byte
	Local Blue as Byte
	Local Alpha as Byte
	
	`Do it!
	make memblock from image Memblock1,Image1
	Width = memblock dword(Memblock1,0)
	Height = memblock dword(Memblock1,4)
	Depth = memblock dword(Memblock1,8)
	make memblock NewMemblock,(Width*Height)+12
	
	Write memblock Dword NewMemblock,0,Xsize
	Write memblock Dword NewMemblock,4,Ysize
	Write memblock Dword NewMemblock,8,Depth
	
	Position = (Width  * (Ystart)*4) + (Xstart*4) + 12
	NewPosition = 12
	
	for y = 1 to Ysize
		for x = 1 to Xsize 
	   
	      Blue = memblock byte(Memblock1,Position)
	      Green = memblock byte(Memblock1,Position+1)
	      Red = memblock byte(Memblock1,Position+2)
	      Alpha = memblock byte(Memblock1, Position+3)
	      
	      write memblock byte NewMemblock,NewPosition,Blue
	      write memblock byte NewMemblock,NewPosition+1,Green
	      write memblock byte NewMemblock,NewPosition+2,Red
	      write memblock byte NewMemblock,NewPosition+3,Alpha
	      
	      inc Position,4
	      Inc NewPosition,4
	      
		next x
		inc Position , (width*4) - (Xsize*4)
	next y
	
	make image from memblock NewImage,NewMemblock
	delete memblock Memblock1
	delete memblock NewMemblock
	
endfunction


Trim the transparent edges away from the fonts:
+ Code Snippet
`Put the 2 DIM commands at the top of you code
Dim BMleft(127)
Dim BMwidth(127)
'*********************************
`       TRIM BITMAP FONT
`*********************************

Function TrimBMFont(FontNo)

	Local BlankColumn as boolean
	Local Alpha as byte
	Local Chr as integer
        Local FontWidth as integer = 64
        Local FontHeight as integer = 64
		
	For Chr = 33 to 126
		Make Memblock From Image 1 , FontNo + Chr
		for x = 1 to FontWidth
			BlankColumn = Yes
			for y = 1 to FontHeight - 1
				
				if BMleft(Chr) = 0
					Position = (y * FontWidth * 4) + (x * 4) + 15
					Alpha = memblock byte(1 , Position)

					if Alpha > 0
						BlankColumn = No
						y = FontHeight - 1
					endif
				endif
				
			next y
			
			if BlankColumn = No
				BMleft(Chr) = x
				x = FontWidth
			endif
			
		next x
		
		for x = FontWidth - 1 to 1 step - 1
			BlankColumn = Yes
			for y = 1 to FontHeight - 1
				
				if BMwidth(Chr) = 0
					Position = (y * FontWidth * 4) + (x * 4) + 15
					Alpha = memblock byte(1 , Position)

					if Alpha > 0
						BlankColumn = No
						y = FontHeight
					endif
				endif
				
			next y
			
			if BlankColumn = No
				BMwidth(Chr) = x - BMleft(Chr)
				x = 1
			endif
			
		next x
		delete memblock 1
		
	next Chr

	BMleft(32) = 0
	BMwidth(32) = FontWidth / 2
	
endfunction



Display the font:
+ Code Snippet
`*********************************
`      DISPLAY BITMAP FONT
`*********************************

Function BMFont(X,Y,S as string,ImageNo,SpriteNo,Kern)
	
	
	for k = 1 to len(S)
		Chr = asc(mid$(S,k))
		
		if k > 1
			sprite SpriteNo + k ,NewX - BMleft(Chr) ,Y ,ImageNo + Chr
			NewX = (NewX) + BMwidth(Chr) + Kern
		else
			sprite SpriteNo + k ,X - BMleft(Chr) ,Y ,ImageNo + Chr
			NewX = X + BMwidth(Chr) + Kern
		endif

	next k

endfunction



Click the download button to download the PNG files with transparent backgrounds.


WireFrame


Sketched


Big Cheese


Dark Castle


Under Water


Rustic Logs


PacMania


Old Rope


Football Crazy


Fire 2


Evil


BloodBath 2


Bamboo



Back to top
http://www.codebrewers.com
Download: bitmap_fonts_2.rar Size: 1903129 bytesReport this message as abusive
Miguel Melo

User


Joined: Mon Aug 8th 2005
Location: Lisbon, Portugal
Posted: 17th Mar 2006 15:20           | link | toggle

Scraggle, it's people like you that make the Internet worthwile! Many thanks!

I have vague plans for World Domination
Back to top
Silicon Notation
Report this message as abusive
tha_rami

User


Joined: Sat Mar 25th 2006
Location: Netherlands
Posted: 2nd Apr 2006 01:08           | link | toggle

Lol, these rule! Thanks, I like the sketched one!

tha_rami - the best way to predict the future is to invent it
Back to top
My Portfolio Find user on ICQ
Report this message as abusive
BMacZero

User


Joined: Fri Dec 30th 2005
Location: E:/N_America/USA/ California/South
Posted: 3rd Apr 2006 18:13           | link | toggle

Hmm the "Big Cheese" could be interesting for a Star-Wars style introduction if it was flipped a little ...

Bmaczero
Back to top
Report this message as abusive
poke a fish

User


Joined: Wed Feb 8th 2006
Location: Utah
Posted: 4th Apr 2006 22:33           | link | toggle

Nice, that blue Sketched one is way cool, i might want to use that for somthing. I also like the Dark Castle, and Evil ones. Nice Work

Back to top
Report this message as abusive
Narf The Mouse

User


Joined: Fri Jul 16th 2004
Location: Cyberspace
Posted: 19th Apr 2006 13:12           | link | toggle

These are cool! And universally usefull, too.

Cheese!

Expert Bug-Finder, Horrible at Identifying Them.
Back to top
Report this message as abusive
Cash Curtis II

User


Joined: Fri Apr 8th 2005
Location: Ramstein, Germany
Posted: 1st May 2006 02:37           | link | toggle

Awesome! A very nice spread of EVIL in this pack. Thanks!!


Come see the WIP!
Back to top
CashCurtis.com
Report this message as abusive
Nicholas Thompson

User


Joined: Mon Sep 6th 2004
Location: London, UK
Posted: 24th Jul 2006 16:38           | link | toggle

Scraggle - I love you. Can I have you babies? These are fantastic! Are there any licensing implications?

Back to top
Thingy ma Jig
Report this message as abusive
Google Ad
Back to top
 
Oddmind

User


Joined: Sun Jun 20th 2004
Location: Atlanta, Georgia
Posted: 25th Jul 2006 01:43           | link | toggle

too fun for my project :\ oho wells.

I never make anything vibrant . they are nice fonts though! really great work

formerly KrazyJimmy

Prayers for rain...
Back to top
Report this message as abusive
Scraggle

User


Joined: Thu Jul 10th 2003
Location: Teesside University
Posted: 25th Jul 2006 12:16     Edited: 10th Aug 2006 12:16     | link | toggle

@NT Absolutely not! Thank you and no.

or, the long version ... I have three cats, that's all the babies I need thanks. I'm glad you like them There are no licensing implications at all. Do with them whatever the hell you like. If you want to mention me that would be cool, if you don't want to then that's fine too.

Did you see my other free stuff?
Scraggle's Bitmap Fonts Pack 1
Scraggle's Bitmap Fonts Pack 2
Scraggle's Bitmap Fonts Pack 3
Scraggle's Planets
Scraggle's Nebulae
Scraggle's Stars/Suns


Back to top
http://www.codebrewers.com
Report this message as abusive
EddieB

User


Joined: Wed Sep 29th 2004
Location: United Kingdom
Posted: 25th Jul 2006 16:11           | link | toggle

Looks awesome man!

Does anyone have the functions above in C++ for DGSDK? I do not have time to convert, but Id love to use them.
Back to top
Bizarreon
Report this message as abusive
Xenocythe

User


Joined: Thu May 26th 2005
Location: You Essay.
Posted: 10th Aug 2006 12:11     Edited: 10th Aug 2006 12:21     | link | toggle

Awesomeness

Whats the kern for?


EDIT: How do I make the font smaller?

Applyby has Flies in his Eyes.
Back to top
XenMedia.org
Report this message as abusive
Scraggle

User


Joined: Thu Jul 10th 2003
Location: Teesside University
Posted: 10th Aug 2006 12:18           | link | toggle

The Kern value is the gap between characters. It is often neccessary to have this as a negative value if you want the letters very close together.


Back to top
http://www.codebrewers.com
Report this message as abusive
Scraggle

User


Joined: Thu Jul 10th 2003
Location: Teesside University
Posted: 10th Aug 2006 12:54     Edited: 10th Aug 2006 12:55     | link | toggle

[Update]

I've updated the 'Football Crazy' font by making the football white instead of transparent, I think it looks better but the original is still in the main download if you prefer it like that.

Click Download to get the file as a .PNG file with a transparent background.




Back to top
http://www.codebrewers.com
Download: football crazy.rar Size: 330747 bytesReport this message as abusive
Xenocythe

User


Joined: Thu May 26th 2005
Location: You Essay.
Posted: 10th Aug 2006 13:26           | link | toggle

P.S. (again) how do I make your fonts smaller? Just scale the image down?

Applyby has Flies in his Eyes.
Back to top
XenMedia.org
Report this message as abusive
Scraggle

User


Joined: Thu Jul 10th 2003
Location: Teesside University
Posted: 10th Aug 2006 13:58           | link | toggle

That would do it.
You would have to change the variables in the cut image function to match though.


Back to top
http://www.codebrewers.com
Report this message as abusive

Go to the first page of this board Return to the Forum Menu Post Message
16 Messages - Page   of 1   
Search the Forum

Sorry, but it has been so long since anyone replied to this Thread that it has been automatically locked.
You may read it but not reply.

Forum Search

Enter a word or phrase to search our Forum for:

Thread Subject Search
Search Phrase:
Search Scope: Entire forum
Just this board
 
Google Forum Search
Search Phrase:
 
Apollo v2.02


Dark Game Studio
Privacy Policy AUP Top of Page