Altering DrawText character spacing

BlitzMax Forums/BlitzMax Programming/Altering DrawText character spacing

DrawText uses the font's default character spacing (is that called Kerning?). Anyway is there are way to alter the spacing by say 10%? Perhaps a setting in the DrawText module?

Otherwise I'll have to do this manuall i.e. draw a character then use TextLength to get the width of the char and add a % to it and then draw the next char. Could be a bit slow...

Thanks!

Look at the imagefont.draw method in imagefont.mod. It simply does what you're suggesting by looping through the text array and drawing each character at x+n

Like this? ;)
Function DrawTextSpaced( t$,x#,y#, space:Int)

	Function Draw( font:TImageFont, text$,x#,y#,ix#,iy#,jx#,jy#, space:Int )
		For Local i:Int=0 Until text.length
		
			Local n:Int=font.CharToGlyph( text[i] )
			If n<0 Continue
			
			Local glyph:TImageGlyph=font.LoadGlyph(n)
			Local image:TImage=glyph._image
			
			If image
				Local frame:TImageFrame=image.Frame(0)
				If frame
					Local tx#=glyph._x*ix+glyph._y*iy+(i*space)
					Local ty#=glyph._x*jx+glyph._y*jy			
					frame.Draw 0,0,image.width,image.height,x+tx,y+ty
				EndIf
			EndIf
			
			x:+glyph._advance*ix
			y:+glyph._advance*jx
		Next		
	EndFunction
	
	Local gc:TMax2DGraphics = TMax2DGraphics.Current()	

	Draw GetImageFont(), t,..
	x+gc.origin_x+gc.handle_x*gc.tform_ix+gc.handle_y*gc.tform_iy,..
	y+gc.origin_y+gc.handle_x*gc.tform_jx+gc.handle_y*gc.tform_jy,..
	gc.tform_ix,gc.tform_iy,gc.tform_jx,gc.tform_jy, space
EndFunction

(Code ripped from BRL.ImageFont and BRL.Max2D)

yeah like that ;-) thx. But I may not need it now. See my other post...

Permission to add to framework with your name as a credit please?

Thanks TonyG, you are correct as usual but I have a secret "fear" of looking in the largely uncommented mod files.

Grable: Well I've used it anyway. thanks!