Fonttext for max ?

BlitzMax Forums/BlitzMax Programming/Fonttext for max ?

Paul "Taiphoz"(Posted 2011) [#1]
I managed to get fonttext from an old USB pen and the got tue update but noticed that it's not got max support . Is there any other max bmpfonts about ?.

Iv started to write my own bit of code to load the fonttxt ini files to use in my own project so the code won't be pretty but if anyone is interested when I have a working prototype I will shove the code up.


GfK(Posted 2011) [#2]
Fontmachine. its free with blide.


Paul "Taiphoz"(Posted 2011) [#3]
Not free the is it when you need to buy blide to get it.


GfK(Posted 2011) [#4]
Not free the (sic) is it when you need to buy blide to get it.
I was just reading about your game you have in development which you plan to release first on PC, then on iOS and Android platforms. With the latter needing some capital investment one would presume from reading between the lines, that there will be a fee for playing the PC version of your game.

My question is this - why do you think everything should be handed to you on a plate? The creators of that software need to live as well - not just you. The last time I posted in a thread of yours you complained that you couldn't buy anything because you have no job. I don't want to be Captain Obvious but why don't you go and find one?


Paul "Taiphoz"(Posted 2011) [#5]
I am offended by your assumption that I expect anything for free, in fact that's an insult, I expect nothing for free, I simply appreciate it when it is, because I simply cant afford it.

Do you have a problem with me ? or just all people with very little spare money in their pockets!.

My situation, to answer your question, is that I have limited funds, and I really do mean limited, I first need to save so I can buy monkey with luck in a few months, hence starting my project now in max to save time, once I buy monkey I then need to save again as you very rightly put it, to buy the licence needed to become an iOS Developer, 99$ per year.

At which point I will again be out of cash, until again I can save some up to get something else.

The Simple fact of the matter is, that in the grand scheme of things, Blide while a nice looking development environment for those with money burning a hole in their pockets, for the other's out there like me, father of two at home looking after the kids while the wife works, blide quite frankly is not even on my radar, and probably never will be.

Nor are a lot of other things here , like the cool 3D engine leadwerks, or the amazing looking physics engines which I would love to mess with but simply cant.

SO NO!. I do not expect anything for free, and I have no objection to paying for things either as is evident above, and will I charge for trizzel PC, I in all honesty have no clue, it will all depend on one vital thing, at the end do I enjoy playing it, if the answer is yes I might ask for a donation and let the buyer decide how much they think its worth.

As for the iOS or mobile version I will definitely be charging something for it, because simply getting it out there to the player will cost me, and I will want to try and recoup some of that.


Paul "Taiphoz"(Posted 2011) [#6]
Oh and back on topic, I have a working version of my code now, it can load more than one font at the same time and text out that font to your chosen screen location.

As for speed an optimization well, messy would be an apt word probably it's serving the function I need of it at the moment.

if anyone wants it just give me a shout I'll be more than happy to upload/post it.


ziggy(Posted 2011) [#7]
Yavin: If it is of interest to you, the FontMachine module is free and open source. Not the editor, but the module could have some code of your interest if you're going to make your own bitmap font system.


GfK(Posted 2011) [#8]
Yavin - OK I take it back.

By way of meagre apology, here's my FONText code for Blitzmax, which I used in Magicville: http://www.blitzbasic.com/codearcs/codearcs.php?code=2840

It was only ever written for personal use so it ain't necessarily pretty, but it does the job well enough. Could always modify it to add more features, but this was all I needed it to do.

I used FONText 1.65. It might work with other versions as is, but I can't guarantee it.


Paul "Taiphoz"(Posted 2011) [#9]
here is mine.

Here is mine, same sorta deal messy as hell just coded for my own use.

I'm fairly sure mine wont be the fastest ever seen but it works, and can handle as many fonts as you care to use, although I suspect the more fonts you use the slower it gets.


Example of use.
  myFont.draw(10 , 10 , "This is a small text." , "green")
  Local Text:String
  text = "this is a very long line of test and with a little luck it should wrap around into a few lines instead of just one."
		
  myFont.drawArea(10 , 30 , 300 , 15 , text , "small")




cFont.bmx
Type cChar
	Field x:Int ' x value for the letter
	Field y:Int ' y for the letter	
	Field width:Int ' width and height for the letter
	Field height:Int
	Field Char:String ' "A"	
	Field image:TImage
	Field fontid:String ' this will hold the name of the font taken from its path.	
End Type

Global cCharList:TList = CreateList()

Type cFont
	Field image:TImage
	Field fontid : String
	Field width:Int ' the width of the area for the text to go.
	
	
	Method New()
		ListAddLast cFontList,Self
	End Method
	
	Method loadfont(path:String)
		Self.fontid = path
		
		Local fullpath:String = AppDir + "/" + path + ".ini"
		
		Local filein:TStream = OpenFile(fullpath , True , False)
		Local data:String
		Local Height:Int = 0
		
	
		Self.image = LoadImage (AppDir + "/" + path + ".png")
		
		Local fontimage:TImage = Self.image	
		
		Repeat
			data = ReadLine(filein)
			
			'Get the blocksize.
			If height=0
				If Instr(data , "blocksize=")=1
					height=Int(Right(data,Len(data)-10))
				End If
			End If
			
			'Fill the list with charcters.
			
			If Instr(data , "[charset]") = 1
				Repeat
					'debugstop
					data = ReadLine(filein)
					Local dpos:Int = 0
					Local fe:Int , fc:Int , sc:Int , tc:Int				
					fe = Instr(data , "=")
					fc = Instr(data , "," , fe)
					sc = Instr(data , "," , fc+1)
					
					Local Letter:cChar = New cChar
										
					letter.height = height
					
					letter.char = Left$(data ,fe-1  )
					
					'Local tt:Int = Len(letter.char)
					
					letter.x = (Mid$(data , fe+1 , fc-fe).toint())
					letter.y = (Mid$(data,fc+1,sc-fc).toint())
					letter.width = (Mid$(data , sc + 1 , Len(data) ).toint() )
					letter.image = fontimage
					letter.fontid=path
					ListAddLast(cCharList,letter)
					
				Until Eof(filein)
				
			End If
			
		Until Eof(filein)
		CloseFile filein
		
		
		
	End Method

	Method DrawArea(x:Int , y:Int,w:Int,h:Int, text:String,font:String)
		'Draw text to an area, and wrap it around it it does not fit.
		' at the moment it's wrapping as soon as it finds a space
		' so that it does not break up a word, this means it's
		' going over its border depending on word length.
		' could get around this by going through the text twice
		' first run we dont draw anything just find all the break points
		' then on the second loop through we use the first pass break points
		' to make sure our text does not go out of bounds.
		
		Local iter:Int = 0
		Local position:Int = 0
		Local tWidth:Int = 0
		Local newline:Int = 0
		'Local words:Int=0
			
		
		
		For Local looper:Int = 1 To Len(text)			
			
			Local Character:String
			Character = Mid$(text , looper , 1)
			
			For Local charset:cChar = EachIn cCharlist
				If Character = charset.char
					If Character <> " "
					
						If charset.fontid=font
							DrawSubImageRect(charset.image , x+position , y+newline , charset.width , charset.height , charset.x , charset.y , charset.width , charset.height)
							position:+ charset.width
							Exit
						End If
					Else
						If charset.fontid=font							
							position:+ charset.width
							If position + charset.width > w
								position = x-charset.width
								newline:+h
							End If
							Exit
						End If
					End If										
					
				End If
			Next
		Next

		
	End Method
	
	Method Draw(x:Int , y:Int , text:String,font:String)
		'Basic stuff, just grab each individual letter , and draw an image for it.
		Local iter:Int = 0
		Local position:Int = 0
		'debugstop		
		For Local looper:Int = 1 To Len(text)			
			
			Local Character:String
			Character = Mid$(text , looper , 1)
			
			For Local charset:cChar = EachIn cCharlist
				If Character = charset.char
					If Character <> " "
					
						If charset.fontid=font
							DrawSubImageRect(charset.image , x+position , y , charset.width , charset.height , charset.x , charset.y , charset.width , charset.height)
							position:+ charset.width
							Exit
						End If
					Else
						If charset.fontid=font							
							position:+ charset.width
							Exit
						End If
					End If										
					
				End If
			Next
		Next

		
	End Method
End Type
Global cFontList:TList = CreateList()