Two bugs: CreatePixmap, LoadGlyph

BlitzMax Forums/BlitzMax Programming/Two bugs: CreatePixmap, LoadGlyph

There is no law saying glyphs have to have images, as it is very unlikely for any characters <=32 (space) to be printable in a character set.

You will need to add your own checks such as:
Function PixmapReDim(src:TPixmap Var, w%, h%)

	If Not src Return
	
	Local pm:TPixmap = src.Copy()
	src = CreatePixmap(w , h , src.format)
	
	'fill with 0
	Local c:Int = $000000FF
	Local p:Int Ptr = Int Ptr(src.PixelPtr(0,0))
	Local l = w*h
	For Local i=0 Until l
		p[i]=c
	Next
	
	src.Paste( pm , 0 , 0 )
	'DebugStop
End Function

Function AddChar( dst:TPixmap Var, font:TImageFont, char% )
	Local glyph:TImageGlyph = font.LoadGlyph( char )
	Local x% = dst.width
	Local h% = dst.height
	If (glyph._h + glyph._y) > h Then h = glyph._h + glyph._y
	PixmapReDim( dst, x + glyph._w, h )
	If glyph._image dst.Paste( glyph._image.pixmaps[0], x, glyph._y )
	
	'DrawOnImage( dst, glyph._image, x, glyph._y )
End Function


Function GetFontsPath$()
	Return "C:\windows\fonts"
End Function

'==============================================================================

Local fontFile$ = GetFontsPath() + "verdana.ttf"
Local font:TImageFont = LoadImageFont( fontFile, 12 )

Local bmp:TPixmap
Local i% = 0
Local mi% = i+255
'------------------------------------------------------------------------------

Local glyph:TImageGlyph = font.LoadGlyph(i)
bmp = CreatePixmap( glyph._w, glyph._h+glyph._y,  PF_RGBA8888, 4 )
If glyph._image bmp.Paste( glyph._image.pixmaps[0], 0,glyph._y )

For i=i+1 To mi
	AddChar( bmp, font, i )
Next